cocos-creator

cocos-creator is a skill for Claude Code, Codex from Wade-DevCode/awesome-coding-skills-cn. It costs 29 tokens per session (3,626 once invoked), scanned A, original, MIT.

A set of guidelines for writing Cocos Creator game components in TypeScript. Cocos Creator is a game engine where scenes contain nodes, components, prefabs, events, and managed resources.

In plain words
What is it for?
Use it when writing or reviewing Cocos Creator components. It covers lifecycle callbacks, node and component references, prefabs, object pooling, event cleanup, and resource management.
Why use it?
It helps prevent missing references, incorrect component startup order, repeated event listeners, resource leaks, and performance problems from repeatedly creating and destroying objects.

Skill for Claude CodeCodex

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

Good fit Use it when writing or reviewing Cocos Creator components. It covers lifecycle callbacks, node and component references, prefabs, object pooling, event cleanup, and resource management.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/wade-devcode/awesome-coding-skills-cn/cocos-creator
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add Wade-DevCode/awesome-coding-skills-cn --skill cocos-creator
Clone the repo
git clone --depth 1 https://github.com/Wade-DevCode/awesome-coding-skills-cn

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 cocos-creator

README.md
[![agentmods](https://agentmods.dev/badge/skills/wade-devcode/awesome-coding-skills-cn/cocos-creator/github.svg)](https://agentmods.dev/skills/wade-devcode/awesome-coding-skills-cn/cocos-creator)
Your own site
<a href="https://agentmods.dev/skills/wade-devcode/awesome-coding-skills-cn/cocos-creator"><img src="https://agentmods.dev/badge/skills/wade-devcode/awesome-coding-skills-cn/cocos-creator/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 cocos-creator

Your own site · 80×15
<a href="https://agentmods.dev/skills/wade-devcode/awesome-coding-skills-cn/cocos-creator"><img src="https://agentmods.dev/badge/skills/wade-devcode/awesome-coding-skills-cn/cocos-creator.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 29 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,626 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.
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.00029 $0.03626
Opus 5.5 $0.00012 $0.01450
Sonnet 5.5 $0.00006 $0.00725
Haiku 4.5 $0.00003 $0.00363

Measured 1mo ago against content hash f6209ad9f291, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

cocos-creator 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 1mo 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.

skills/cocos-creator/SKILL.md · 220 lines

How it starts

The opening of the file, as written. The whole thing — 220 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Cocos Creator 最佳实践

何时用

  • 编写任何 Cocos Creator TypeScript 组件脚本前。
  • 发现内存持续上涨、资源释放后再加载仍占用内存时。
  • 节点引用丢失、组件生命周期回调顺序不符合预期时。
  • EventTarget 事件监听器未被正确注销,导致重复触发或内存泄漏时。
  • prefab 频繁 instantiate/destroy 造成帧率抖动时。

核心规则

1. 组件化:@property 暴露,生命周期时序清楚

规则: 逻辑封装在继承自 Component 的脚本里,Inspector 可调属性用 @property 装饰器声明;onLoad 做自身初始化,start 做跨组件依赖初始化,onEnable/onDisable 管理激活态资源,onDestroy 清理一切外部引用。

为什么: AI 生成 Creator 组件时最常见的错误是在 onLoad 里调用另一个组件的方法——但另一个组件的 onLoad 还没执行,得到 undefined 或抛出"Cannot read property of undefined"。新手则把所有逻辑都堆进 start,onEnable/onDisable 完全不用,导致节点被反复激活时调度器和事件重复注册,表现为每激活一次组件,事件就多响应一次。正确的分层:onLoad = 自身组件引用缓存;start = 订阅事件、跨节点通信;onEnable = 恢复运行状态;onDisable = 暂停运行状态;onDestroy = 注销事件、释放资源。

怎么做:

  • @property(cc.Node) targetNode: cc.Node = null!; — Inspector 拖拽赋值,不在代码里 find。
  • onLoad 里只缓存 this.getComponent、this.node.getChildByName 等本节点树内的引用。
  • 跨节点通信(如 GameManager)的引用在 start 里获取,保证对方 onLoad 已完成。
  • onDestroy 里注销所有 EventTarget 监听器,停止所有 tween,清空定时器。

2. 节点引用:缓存引用,prefab 高频对象用对象池

规则: 节点或组件引用在 onLoad 里缓存成私有字段,绝不在 update 或高频函数里调用 find、getChildByName、getComponent;频繁实例化销毁的对象(子弹、特效、列表项)用 NodePool 管理,不用 instantiate + destroy。

为什么: node.getChildByName("xxx") 是线性遍历子节点树,在 update 里每帧调用、节点树稍大时就能感受到 CPU 消耗。AI 写原型代码时习惯"需要用谁就 find 谁",在单个脚本里看起来没问题,但一旦场景有几十个同类组件并发运行,性能立刻崩塌。对象池的价值:移动端 instantiate 一个复杂 prefab 耗时可达数十毫秒(涉及资源解析、组件初始化),批量生成敌人或特效时直接造成卡顿帧;NodePool 复用已有节点,激活耗时降一个数量级。新手不用对象池的另一个原因是不知道如何处理"归还时重置状态"——容易留下上次使用的残留数据。

怎么做:

  • onLoad 里:this._hpBar = this.node.getChildByName("HPBar").getComponent(cc.ProgressBar);。
  • 对象池声明:private _bulletPool: cc.NodePool = new cc.NodePool("BulletController");(参数为组件名,归还时调用该组件的 unuse 钩子重置状态)。
  • 借出:const node = this._bulletPool.size() > 0 ? this._bulletPool.get() : cc.instantiate(this.bulletPrefab);。
  • 归还:this._bulletPool.put(node);,在 BulletController 的 unuse() 里重置速度、血量、特效状态。
  • onDestroy 里:this._bulletPool.clear(); 释放池内所有节点。

3. 事件解耦:EventTarget 通信,监听必须 off

Read the full file on GitHub · 220 lines

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. 1mo ago First seen · 220 lines · 29 tokens per session scan A f6209ad9f291

Subscribe to this mod's changes

cocos-creator is a skill published in the GitHub repository Wade-DevCode/awesome-coding-skills-cn (7 stars, last pushed 4mo ago), licensed MIT. It adds 29 tokens to every session and 3,626 once invoked, about $0.0001 per session on Opus 5.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-31.

Related

Other skills, from other repositories

setup-ts-deep-modules

A TypeScript repository setup that keeps each package's internal code private behind root-level entry files. A package is a reusable unit of code, and an entry point is the file other code is meant to import.

vinvcn/mattpocock-skills-zh-CN · 49 tokens

setup-ts-deep-modules

A setup for TypeScript packages that hides their implementation behind files at the package root. Dependency-cruiser checks that outside code uses these entry points, prevents dependency cycles, and keeps internal folders private.

devcxl/mattpocock-skills-zh · 49 tokens

senior-frontend

Frontend development for React 19, Next.js 15, TypeScript, and Tailwind CSS v4 / Pengembangan frontend dengan React 19, Next.js 15, TypeScript, dan Tailwind CSS v4.

roedyrustam/vibes-plug · 50 tokens

js-backend-expert

Expert-level skill for Node.js 24+ (LTS), Bun 1.2+, and Deno 2.x backend development. Covers Express 5, Fastify 5, Hono v4, NestJS, Prisma 6, Drizzle ORM, WebSockets, BullMQ, OpenTelemetry, and microservices in English and Indonesian.

roedyrustam/vibes-plug · 77 tokens

typescript-expert

Expert guide for TypeScript 5.8+ advanced type system, strict mode, generics, utility types, branded types, inferred type predicates, isolated declarations, and type-safe architectural patterns / Panduan ahli untuk sistem tipe TypeScript 5.8+, mode strict, generics, utility types, branded types, inferred type…

roedyrustam/vibes-plug · 83 tokens

bun-runtime-expert

Expert guide for Bun 1.2+ JavaScript/TypeScript runtime — native Bun.sql Postgres client, Bun.s3 object storage, text lockfile, multi-core HTTP clusters, and bun:test / Panduan ahli runtime Bun 1.2+.

roedyrustam/vibes-plug · 57 tokens