Script path fallback: qq scripts are invoked as bare commands (e.g. unity-test.sh). If "command not found", use ${CLAUDE_PLUGIN_ROOT}/bin/<command> instead.
Respond in the user's preferred language (detect from their recent messages, or fall back to the language setting in CLAUDE.md).
Add or update Unity tests for the current change. This skill is for writing tests, not for running them. After authoring coverage, hand off to /qq:test.
Querying live scene/component state while authoring tests: if you need to inspect the current Unity scene to understand what to assert (component layouts, serialized values, runtime state), see shared/tykit-reference.md. Tools like unity_query, unity_object, get-field, call-method, get-array let you probe the live editor instead of guessing from source code.
Arguments: $ARGUMENTS
- A file path, symbol, bug description, or plan step that needs coverage
editmode / edit: force EditMode coverage
playmode / play: force PlayMode coverage
regression: force the smallest regression-focused test
--assembly "Asm.Tests": prefer a specific test assembly
--auto: skip prompts and continue into /qq:test --auto after tests are written
0. Read qq project state first when available
If qq-project-state.py is available, read it before choosing scope:
qq-project-state.py --pretty
Use it for:
work_mode and policy_profile to understand expected verification pressure
changed_runtime_files to identify the code under test when the user did not specify a target
last_test_status to understand whether coverage is missing vs. failing
Rules:
- Explicit user scope always wins
- Prefer the smallest meaningful coverage for the current task
- Do not turn this into a whole-project test rewrite
1. Determine the target
Pick scope in this order:
- Explicit user input (file path, bug description, plan step, or test type)
- A known failing bug / regression path from the current conversation
- The active implementation plan step and its done criteria
- Current uncommitted runtime changes
- Ask the user one concise question if the target is still ambiguous
When the input is broad, narrow it:
- one system over the whole feature
- one regression path over a full suite rewrite
- one test assembly over new scattered files
2. Inspect the existing test layout
Before writing tests:
- read existing test files near the code under test
- inspect any nearby test
.asmdef files
- reuse existing helpers, fixtures, scene setup, and naming patterns
- prefer extending an existing test file when it keeps the suite coherent
If no tests exist yet, create the smallest conventional home that fits the repo:
Assets/Tests/EditMode/ for pure logic or editor-side behavior
Assets/Tests/PlayMode/ for scene/lifecycle/integration behavior
3. Choose the right test kind
- EditMode: pure logic, data transforms, orchestration, deterministic calculations, and code that does not need scene frames to prove correctness
- PlayMode: MonoBehaviour lifecycle, scene wiring, frame progression, physics, animation, or behavior that only makes sense in play
- Regression: the smallest test that proves a bug stays fixed; prefer this for
fix mode when feasible
If the user did not force a mode, choose the lightest mode that still proves the behavior.
4. Write the tests
Author the smallest useful coverage:
- cover the intended behavior, not every branch in the file
- add the highest-risk edge case or regression assertion
- avoid tests that merely duplicate production implementation line by line
- keep setup minimal; extract helpers only when repetition is real
- if adding a new test assembly, keep references minimal and consistent with repo conventions
When this work is tied to a bug fix:
- prefer writing the regression first when the repro is clear
- if the current architecture makes the repro impossible to express cleanly, state that explicitly and write the next-best narrow guardrail
5. Stop at authored coverage
By default, this skill stops after the test files are written.
- Summarize which files changed
- State which behavior is now covered
- Recommend the exact
/qq:test command to run next, using editmode, playmode, --assembly, or --filter when that would keep validation narrow
--auto mode: after writing the tests, continue directly to /qq:test --auto with the narrowest appropriate scope.
Handoff
- Tests authored cleanly → "Coverage is in place. Want to run
/qq:test now?"
- Tests authored in
--auto mode → continue to /qq:test --auto
- Blocked by ambiguous expected behavior → ask one short question before writing more code
Notes
- Keep
/qq:add-tests separate from /qq:test; one authors coverage, the other executes it
- Prefer modifying existing test files over spawning a brand-new structure for every change
- If a plan already contains a Tests step, implement that step here instead of inventing a different coverage target
1---2name: add-tests3description: Author Unity EditMode, PlayMode, or regression tests for the current change without conflating that with test execution.4---56> **Script path fallback**: qq scripts are invoked as bare commands (e.g. `unity-test.sh`). If "command not found", use `${CLAUDE_PLUGIN_ROOT}/bin/<command>` instead.78Respond in the user's preferred language (detect from their recent messages, or fall back to the language setting in CLAUDE.md).910Add or update Unity tests for the current change. This skill is for **writing tests**, not for running them. After authoring coverage, hand off to `/qq:test`.1112> **Querying live scene/component state while authoring tests**: if you need to inspect the current Unity scene to understand what to assert (component layouts, serialized values, runtime state), see [`shared/tykit-reference.md`](../../shared/tykit-reference.md). Tools like `unity_query`, `unity_object`, `get-field`, `call-method`, `get-array` let you probe the live editor instead of guessing from source code.1314Arguments: $ARGUMENTS15- A file path, symbol, bug description, or plan step that needs coverage16- `editmode` / `edit`: force EditMode coverage17- `playmode` / `play`: force PlayMode coverage18- `regression`: force the smallest regression-focused test19- `--assembly "Asm.Tests"`: prefer a specific test assembly20- `--auto`: skip prompts and continue into `/qq:test --auto` after tests are written2122## 0. Read qq project state first when available2324If `qq-project-state.py` is available, read it before choosing scope:2526```bash27qq-project-state.py --pretty28```2930Use it for:3132- `work_mode` and `policy_profile` to understand expected verification pressure33- `changed_runtime_files` to identify the code under test when the user did not specify a target34- `last_test_status` to understand whether coverage is missing vs. failing3536Rules:3738- Explicit user scope always wins39- Prefer the smallest meaningful coverage for the current task40- Do not turn this into a whole-project test rewrite4142## 1. Determine the target4344Pick scope in this order:45461. Explicit user input (file path, bug description, plan step, or test type)472. A known failing bug / regression path from the current conversation483. The active implementation plan step and its done criteria494. Current uncommitted runtime changes505. Ask the user one concise question if the target is still ambiguous5152When the input is broad, narrow it:5354- one system over the whole feature55- one regression path over a full suite rewrite56- one test assembly over new scattered files5758## 2. Inspect the existing test layout5960Before writing tests:6162- read existing test files near the code under test63- inspect any nearby test `.asmdef` files64- reuse existing helpers, fixtures, scene setup, and naming patterns65- prefer extending an existing test file when it keeps the suite coherent6667If no tests exist yet, create the smallest conventional home that fits the repo:6869- `Assets/Tests/EditMode/` for pure logic or editor-side behavior70- `Assets/Tests/PlayMode/` for scene/lifecycle/integration behavior7172## 3. Choose the right test kind7374- **EditMode**: pure logic, data transforms, orchestration, deterministic calculations, and code that does not need scene frames to prove correctness75- **PlayMode**: MonoBehaviour lifecycle, scene wiring, frame progression, physics, animation, or behavior that only makes sense in play76- **Regression**: the smallest test that proves a bug stays fixed; prefer this for `fix` mode when feasible7778If the user did not force a mode, choose the lightest mode that still proves the behavior.7980## 4. Write the tests8182Author the smallest useful coverage:8384- cover the intended behavior, not every branch in the file85- add the highest-risk edge case or regression assertion86- avoid tests that merely duplicate production implementation line by line87- keep setup minimal; extract helpers only when repetition is real88- if adding a new test assembly, keep references minimal and consistent with repo conventions8990When this work is tied to a bug fix:9192- prefer writing the regression first when the repro is clear93- if the current architecture makes the repro impossible to express cleanly, state that explicitly and write the next-best narrow guardrail9495## 5. Stop at authored coverage9697By default, this skill stops after the test files are written.9899- Summarize which files changed100- State which behavior is now covered101- Recommend the exact `/qq:test` command to run next, using `editmode`, `playmode`, `--assembly`, or `--filter` when that would keep validation narrow102103**`--auto` mode:** after writing the tests, continue directly to `/qq:test --auto` with the narrowest appropriate scope.104105## Handoff106107- **Tests authored cleanly** → "Coverage is in place. Want to run `/qq:test` now?"108- **Tests authored in `--auto` mode** → continue to `/qq:test --auto`109- **Blocked by ambiguous expected behavior** → ask one short question before writing more code110111## Notes112113- Keep `/qq:add-tests` separate from `/qq:test`; one authors coverage, the other executes it114- Prefer modifying existing test files over spawning a brand-new structure for every change115- If a plan already contains a Tests step, implement that step here instead of inventing a different coverage target