Skip to content

feat(skill): expand needle-engine skill — cheat sheet, API ref, troubleshooting, template#1

Open
kaktus-klaus wants to merge 6 commits intoneedle-tools:mainfrom
kaktus-klaus:feat/improve-skill
Open

feat(skill): expand needle-engine skill — cheat sheet, API ref, troubleshooting, template#1
kaktus-klaus wants to merge 6 commits intoneedle-tools:mainfrom
kaktus-klaus:feat/improve-skill

Conversation

@kaktus-klaus
Copy link

Summary

Critical review + improvements to the needle-engine Claude skill, based on comparison with production skills (Trail of Bits, WebGPU/Three.js, Anthropic's own authoring guidelines).

What changed

SKILL.md — major expansion:

  • Added allowed-tools frontmatter (Anthropic best practice)
  • Added Quick Start section up top (minimal working example first)
  • Added When to Use / When NOT to Use section with concrete triggers
  • Added Unity → Needle cheat sheet table (InstantiateGameObject.instantiate, GetComponent<T>.getComponent(T), etc.) — the single most useful thing for the target audience
  • Added missing lifecycle methods: lateUpdate, fixedUpdate, all physics/trigger callbacks
  • Added Coroutines (startCoroutine, WaitForSeconds, generator pattern)
  • Added Instantiate & Destroy (GameObject.instantiate, GameObject.destroy, difference from removeComponent)
  • Added Animation API (Animator.play, crossFade, setFloat, setTrigger, etc.)
  • Added Loading assets at runtime (AssetReference, GLTFLoader)
  • Added Custom events between components (dispatchEvent / addEventListener)
  • Added experimentalDecorators + useDefineForClassFields: false TypeScript config requirement (silent footgun)
  • Expanded "Common Gotchas" from 2 → 6 items
  • Added needle_search with example queries (was buried in one line, now shows usage)
  • Added links to new reference sub-files

New: references/api.md
Full API reference: complete lifecycle table, all decorators, full this.context API, coroutines, animation, asset loading, networking RPC, XR.

New: references/troubleshooting.md
11 common issues with causes + fixes: missing @registerType, useDefineForClassFields, @syncField not syncing, physics callbacks not firing, onDestroy not called on removeComponent, animation not playing, Vite build decorator errors, performance tips.

New: templates/my-component.ts
Annotated starter component with all lifecycle sections, comments explaining each hook, and example coroutine.

Structure comparison

Before After
Single 176-line SKILL.md SKILL.md + references/ + templates/
2 gotchas 6 gotchas + full troubleshooting doc
No Quick Start Quick Start in first 15 lines
No Unity mapping Full Unity→Needle cheat sheet table
No When to Use Explicit trigger list
Missing: coroutines, instantiate, animation, asset loading All covered

🤖 Generated with Claude Code

kaktus-klaus and others added 6 commits March 2, 2026 17:37
…ooting, and template

- SKILL.md: add Quick Start, When to Use, Unity→Needle cheat sheet table,
  missing lifecycle methods (lateUpdate, fixedUpdate, collision/trigger callbacks),
  coroutines, instantiate/destroy, animation API, runtime asset loading,
  custom events, TypeScript config gotcha, expanded troubleshooting (6→11 items),
  needle_search usage examples, allowed-tools frontmatter
- Add references/api.md: full lifecycle, decorator, context, coroutine,
  animation, asset loading, networking, and XR API reference
- Add references/troubleshooting.md: 11 common issues with causes + fixes
  (missing @registerType, useDefineForClassFields, sync, physics, XR, perf)
- Add templates/my-component.ts: annotated starter component template

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Physics callbacks and coroutines: add "add inside your class" label
  (were shown outside class body, which was confusing)
- Instantiate section: remove dead `Instantiate` import (only used
  `GameObject.instantiate()` in the example)
- Animation: remove `crossFade()` and `setInteger()` which may not exist
  in Needle Engine's Animator; remove dead `AnimationClip` import
- Loading assets: replace incorrect `NeedleEngine.addContextCreatedCallback`
  (wrong use — it fires on context creation, not asset load) with correct
  `GLTFLoader.loadAsync()` pattern
- api.md: replace nonexistent `findObjectByName` with Three.js built-in
  `scene.getObjectByName()`

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add Unity/Blender workflow explanation (Blender addon, same TS workflow)
- Update "When to Use" to mention Blender addon explicitly
- Replace raw GLTFLoader.loadAsync() with AssetReference.getOrCreate() in
  both SKILL.md and references/api.md (per Needle Engine best practices)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Engine Hooks section: NeedleEngine.addContextCreatedCallback(),
  DOM events (ready, loadingfinished, loadstart) on <needle-engine>
- Frontend UI ↔ 3D section: bidirectional communication patterns
  - HTML/JS → 3D: getComponentInChildren() from page JS
  - 3D → HTML/JS: dispatchEvent() bubbling from component to DOM
  - React example: useEffect + CustomEvent listener → useState
  - Svelte example: onMount + CustomEvent listener + reactive var
- Creating a Project: expanded template list with GitHub links for
  Vite, React, Vue, SvelteKit, Next.js

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…integration.md

- Engine Hooks: replace NeedleEngine.addContextCreatedCallback with correct
  standalone hooks: onStart, onUpdate, onBeforeRender, onDestroy
- Frontend UI ↔ 3D: condense to core pattern + link to new integration.md
- Add references/integration.md: full React, Svelte, Vue, vanilla JS examples
  with bidirectional communication + hook reference table
- SKILL.md: 502 → ~430 lines (verbose framework examples moved to reference)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…e@4.15.0)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant