N.E.K.O: Skill for Claude Code

.agent/skills/vanilla-js-ui-race-conditions/SKILL.md

Vanilla JS UI Race Conditions (VRM vs Live2D) is a skill for Claude Code, Codex from Project-N-E-K-O/N.E.K.O. It costs 37 tokens per session (889 once invoked), scanned A, original, Apache-2.0.

A guide to handling timing and state conflicts in plain JavaScript interfaces, especially when parts of the page are created later or when the interface updates before the server responds.

In plain words
What is it for?
Use it to bind events after lazy-loaded elements appear, coordinate optimistic interface updates with backend state, and support interfaces that combine VRM and Live2D models.
Why use it?
It addresses bugs such as missing controls, flickering open and closed panels, missed event handlers, and newer server data overwriting an in-progress user action.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

This is Project-N-E-K-O/N.E.K.O's own configuration. It tells Claude Code and Codex how to work on N.E.K.O itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything N.E.K.O configures →

About the project

N.E.K.O is a real-time AI catgirl companion designed to live with the user, initiate interaction, share media, and perform tasks through an emotional engine. It is intended for people seeking a proactive personal digital companion. The catalogue contains skills for working with it.

Project-N-E-K-O/N.E.K.O · 2,861 stars · on GitHub · store.steampowered.com

Reuse

Borrowing it

Nothing to install: this file belongs to Project-N-E-K-O/N.E.K.O. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/Project-N-E-K-O/N.E.K.O/main/.agent/skills/vanilla-js-ui-race-conditions/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/Project-N-E-K-O/N.E.K.O

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for Vanilla JS UI Race Conditions (VRM vs Live2D)

README.md
[![agentmods](https://agentmods.dev/badge/skills/project-n-e-k-o/n.e.k.o/vanilla-js-ui-race-conditions/github.svg)](https://agentmods.dev/skills/project-n-e-k-o/n.e.k.o/vanilla-js-ui-race-conditions)
Your own site
<a href="https://agentmods.dev/skills/project-n-e-k-o/n.e.k.o/vanilla-js-ui-race-conditions"><img src="https://agentmods.dev/badge/skills/project-n-e-k-o/n.e.k.o/vanilla-js-ui-race-conditions/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for Vanilla JS UI Race Conditions (VRM vs Live2D)

Your own site · 80×15
<a href="https://agentmods.dev/skills/project-n-e-k-o/n.e.k.o/vanilla-js-ui-race-conditions"><img src="https://agentmods.dev/badge/skills/project-n-e-k-o/n.e.k.o/vanilla-js-ui-race-conditions.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 37 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 889 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00037 $0.00889
Opus 5 $0.00018 $0.00445
Sonnet 5 $0.00007 $0.00178
Haiku 4.5 $0.00004 $0.00089

Measured 12d ago against content hash 0e399710f47b, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

Vanilla JS UI Race Conditions (VRM vs Live2D) scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.agent/skills/vanilla-js-ui-race-conditions/SKILL.md · 73 lines

What it actually says

应对原生 JS 中的 DOM 竞态与乐观更新陷阱

症状

  • 界面组件(如侧边栏、HUD)在页面初次加载时由于丢失状态而不显示,但手动交互后又能弹出。
  • 界面在开启和关闭之间发生闪烁,或者无法通过代码正确关闭。
  • 绑定在 DOM 元素上的事件监听器未能触发。

根本原因

原因 1: 不同模型/模块的 DOM 懒加载时机不一致

  • 问题: 在处理跨模型(如 Live2D 和 VRM)或模块化应用时,某些弹窗会在首次点击时才 createElement(懒加载)。
  • 为什么发生: 性能优化导致 DOM 并非一上来就在 HTML 里。如果使用固定的 setTimeout(..., 100) 去抓取 DOM 绑定事件,极大概率会面临扑空(DOM 还未生成)。
  • 解决方案: 使用自我终结的递归轮询替代死等。

原因 2: 乐观 UI (Optimistic UI) 与底层状态的竞态冲突

  • 问题: 用户点击开关后,前端乐观地将按钮置为开启并附带动画,同时向后端发起请求。但在后端返回真实 lag 之前,如果其他组件(如轮询的 App)根据空后端或者默认的错误 DOM 被触发检查,会产生互相覆盖的 BUG。
  • 为什么发生: 缺乏统一的单向数据流。
  • 解决方案: 在读取源头状态时,判断 UI 是否处于 disabled(加载中)。如果是,则优先信任 gent_ui_v2 缓存的 optimistic 状态或后端缓存 machineFlags,而不是盲目相信刚建立且尚未同步的 DOM 节点。

代码解决方案

1. 应对懒加载 DOM 的绑定轮询(安全可靠)

`javascript const bindEvents = () => { // 兼容多个 ID 解析 const getEl = (ids) => { for (let id of ids) { const el = document.getElementById(id); if (el) return el; } return null; };

const targetEl = getEl(['live2d-agent-keyboard', 'vrm-agent-keyboard']);

// 如果没找到,自己建立一个 500ms 后的新宏任务来重试,然后 return 本次任务。
if (!targetEl) {
    setTimeout(bindEvents, 500);
    return;
}

// 找到了,顺次执行并结束,不会留下任何定时器垃圾
targetEl.addEventListener('change', myLogic);
myLogic(); // 手动触发第一次检查

};

setTimeout(bindEvents, 100); // 发动第一下 `

2. 多源状态判定降级(防止覆盖)

`javascript const checkState = () => { const isUiInteractive = domCheckbox && !domCheckbox.disabled; let isFeatureOn = false;

if (!isUiInteractive) {
    // UI 在转圈加载,信任乐观状态或后端缓存
    isFeatureOn = optimisticState !== undefined ? optimisticState : backendFlags;
} else {
    // UI 处于可用交互态,百分百信任当前 DOM
    isFeatureOn = optimisticState !== undefined ? optimisticState : domCheckbox.checked;
}

} `

关键经验

  • 永远不要用硬编码的 setTimeout 时长来假定某个资源或 DOM 一定会加载完毕。
  • 如果没有 React 这种 Virtual DOM 框架,手动处理跨组件通讯时要随时当心当前脚本运行时的真实 DOM 快照情况。
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 12d ago First seen · 73 lines · 37 tokens per session scan A 0e399710f47b

Subscribe to this mod's changes

Vanilla JS UI Race Conditions (VRM vs Live2D) is a skill published in the GitHub repository Project-N-E-K-O/N.E.K.O (2,861 stars, last pushed today), licensed Apache-2.0. It adds 37 tokens to every session and 889 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.