/unity-coding-skills:fix-bug [incident, failing test name, or issue URLs]from unity-coding-skills
Diagnoses and fixes bugs using a test-first workflow: reproduce with a failing test, diagnose root cause, then fix. Invoke when user reports a bug or unexpected behavior.
Ships in unity-coding-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Guide for diagnosing and fixing bugs. This skill defines a test-first debugging workflow: reproduce the bug with a failing test, diagnose the root cause, then fix it.
If the user's request is to implement a new feature, change a specification, or refactor rather than investigate or fix a bug, stop and guide the user to invoke the /implement skill instead.
Take the bug report from the incident argument: the report written directly, the name of a failing test, or the URLs of issues in an issue tracker, in any combination.
For an issue URL, fetch its body and comments (e.g., gh issue view <URL> --comments for GitHub Issues): the comments often correct the body.
Combine the argument with the bug report in the conversation, if any; when the argument is omitted, take it from the conversation alone.
Recording implementation notes: Notes for this run go in <scratchpad>/implementation-notes, where <scratchpad> is the scratchpad directory listed in your system prompt (write its absolute path literally): one note per line, in the form <category>: <note>.
Immediately before your first append in this run — and only then — delete that file if it exists (usually it will not), so this run starts from an empty one: every /fix-bug and /implement run in the session shares this file, so an earlier run abandoned before its Implementation Notes step would otherwise leak its notes into this one.
Never delete it again afterwards, including when Step 3 sends you back to Step 1 or Step 2; those loops are part of the same run and their notes must survive.
While working through Steps 1-8, whenever one of the following occurs, immediately append a line to that file — do not wait until the end to reconstruct these from memory:
Append with Bash — the Write tool cannot append:
cat >> "<scratchpad>/implementation-notes" <<'EOF'
Root cause: <one line>
EOF
When a step delegates to a subagent or another skill (the test design subagent in Step 6; /simplify and /resolve-diagnostics in Step 8), append the note yourself from what it returns — they do not write to this file.
Work from the user's report and the documents that state the specification (external specification, design docs) only — do not read code yet. Reading the implementation here biases "Expected" toward what the code does rather than what the specification says.
Extract the following from the bug report (see Input):
If any of the three cannot be determined from the bug report, use AskUserQuestion to ask the user before proceeding.
All three must be known before moving to Step 2.
Also determine the report type:
Also check the relevant documentation (external specification, design docs) for consistency with the user's bug report.
If the documentation and the report conflict, use AskUserQuestion to clarify with the user which is correct.
If the user answers that the specification itself is to change, rather than that the documentation misstates it, the request is a specification change: stop and guide the user to invoke the /implement skill instead.
If the docs contain errors or are missing relevant information, note them; Step 9 writes the corrections into the docs.
Note the test bases of this bug fix: the issue URLs of the bug report, and the files and URLs of this documentation.
List them in each test file you write or modify in this run (test-writing-guide, Test Basis).
Skip this step if Step 1 identified this as an existing test failure case. Proceed directly to Step 3.
Search the project's test code for existing tests closest to the bug scenario. These serve two purposes:
When the bug condition involves on-screen display or a user-facing UI operation, search for integration tests with UI operations or visual verification tests — the reproduction test must be at that test level, so the placement anchor and style reference must be too.
Use Explore agents to locate relevant test files and test cases.
Load the test-designing-guide skill — do not rely on automatic skill triggering — and design the reproduction test of the bug report from Step 1 (Condition / Expected / Actual) per its test design resource and its Reproduction tests resource.
Design no regression test cases: Step 6 designs them against the code the fix changes, which is unknown until Step 5.
Skip the Assessment; when the reproduction test case would be unverifiable, undefined, or ambiguous, return to Step 1 and re-clarify the bug report with the user via AskUserQuestion.
Then load the test-writing-guide and code-writing-guide skills — test code is code, so both guides apply; do not rely on automatic skill triggering — and implement the reproduction test.
Place it near the similar tests found above.
If an existing test is testing the wrong behavior (i.e., the test itself is buggy), rewrite that test to correctly reproduce the bug rather than adding a new one.
Run tests using the /run-tests skill and verify that the reproduction test fails:
If multiple tests fail and it is unclear which one corresponds to the reported bug, use AskUserQuestion to ask the user which test to focus on.
Diagnose why the test stays green, and choose the next move from the cause: e.g., the test does not reach the condition, the bug occurs only on the player (see the run-tests skill, Run Tests on the Player), it depends on timing or on data the test does not reproduce, or the bug is already fixed on this branch.
If reproduction has been attempted 3 times without success, return to Step 1 and use AskUserQuestion to re-clarify the bug report with the user.
Skip this step if Step 2 was skipped (existing test failure): the test that failed in Step 3 is the reproduction evidence, and no reproduction test was written to commit. Proceed directly to Step 5.
Present the reproduction evidence to the user via AskUserQuestion before proceeding.
Include:
Once the user confirms the reproduction is as expected:
With the reproduction confirmed, find the root cause — the line(s) or logic responsible for the bug — and formulate a fix. Before formulating it:
test-writing-guide; load it and code-writing-guide if Step 2 was skipped — do not rely on automatic skill triggering), and run it with /run-tests to verify it fails — this confirms the suspected cause before changing the production code, and pins the defect at the unit test level where the Step 2 test cannot locate it.
Take its expected result from the specification of the called code — the documentation from Step 1 — not from the code you traced to find the suspect: an expected result derived from the implementation passes whatever the implementation does; nor from its XML documentation comment, as test-designing-guide's test design resource rules for the expected results.
If it passes, the suspect is wrong: delete the test, record it under Ruled out, and look for another cause.
Skip this item when the reproduction test from Steps 2-3 is already a unit test that calls the suspected code, or when the cause lies outside code a unit test can call (e.g., scene/prefab wiring or asset settings)Before applying the fix, cover the adjacent behavior the fix could disturb:
test-designing-guide skill — do not rely on automatic skill triggering — and, per its test design resource, designs the test cases of the specifications of the members the fix formulated in Step 5 changes, e.g., the methods that own the changed lines, and tags the test cases that existing tests implement (Existing Tests).
Give it the test target of each changed member, the member's specifications from the documentation of Step 1, and the user's instructions on the test techniques, if any (e.g., error guessing); have it return the test cases verbatim.
Quote each specification verbatim with its source, e.g., the file path and heading or the URL, together with the passages it depends on, e.g., the definitions of the terms it uses, and instruct the subagent not to read the source documents or follow the links in the quoted passages: a subagent reading a whole document would fill its context with the specifications of parts the fix does not change.
Designing in a subagent keeps the method bodies you read in Step 5 out of the test design: a test case derived from the implementation passes whatever the implementation does.
A changed member without a specification gets no regression test: record it as an unclear specification instead of deriving one from the codetest-writing-guide) and run them — they must pass (they test existing correct behavior, not the bug itself).code-writing-guide skill — do not rely on automatic skill triggering/run-tests/simplify skill (Skill({skill: "simplify"}) — not a plugin skill) to apply quality improvements to the modified code/run-tests and confirm all pass/resolve-diagnostics with the files added or modified in this iteration — compute the list after /simplify finishes, so its edits are covered tooWhen the fix changed what the design docs state, e.g., a method's contract, or Step 1 found errors or missing information in the documents that state the specification, including an expected behavior confirmed with the user that no document states, write the change into those documents, so that they agree with the fixed code and its tests:
Tell the user which documents you changed.
Read <scratchpad>/implementation-notes if it exists## Implementation Notes heading — one bold sub-heading per category, each followed by a bullet list.
Always include all six categories in this order: Bug report clarifications, Root cause, Ruled out, Tradeoffs, Test changes, Open questions.
Write - None for any category with nothing recorded, and add any last-minute Open questions before finalizing.
If the file was never created, report every category as "None"Propose to the user, under a ## Preventing Recurrence heading, measures that keep bugs similar to this one from recurring.
For example, static analysis: when the root cause lies in how the code is written or how a library or framework is used, e.g., ?. on a destroyed UnityEngine.Object, an IDE inspection or a Roslyn analyzer may catch it, and the user can search for one with /find-and-setup-analysis-rule.
The proposal ends this run; leave acting on it to the user: the user reviews the report and creates the pull request of this fix first.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
12 skills in this plugin
/code-writing-guideProvides coding guidelines for Unity projects. Make sure to use this skill whenever writing, creating, editing, or modifying code files. This includes implementing new features, fixing bugs, refactoring, adding tests, or any task that results in code changes. Even for small edits or one-line fixes, load this skill to ensure project conventions are followed./design-testsDesigns tests from a specification, whatever document states it — a requirements document, design docs, or an ADR: extracts the test targets, then creates test cases for each target at the test level of its subject — e.g., integration tests for a scene or prefab, unit tests for a class's API. Use this skill whenever the specification is settled and the next step is to design the tests./npx claudepluginhub nowsprinting/unity-coding-skills --plugin unity-coding-skillsOther plugins' skills for the same job