uw-unity-debugging
Skill44 starsChanged 8 months agoMITView on GitHub
Systematic 4-phase debugging framework for Unity projects with GameDebug wrapper generation. Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes. Triggers on requests like "this doesn't work", "there's a bug", "it crashes when", "fix this error", "why is this happening", "null reference exception", "test is failing", "unexpected behavior", "something broke", or any debugging task. Four-phase framework (gather evidence, isolate, hypothesize, fix) that ensures understanding before attempting solutions.
In this repository13 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- uw-code-reviewSkill
- uw-dependency-injectionSkill
- uw-game-feel-integratorSkill
- uw-network-setupSkill
- uw-scriptable-object-archSkill
- uw-skill-creatorSkill
- uw-state-machineSkill
- uw-ui-toolkit-binderSkill
- uw-unity-editor-toolsSkill
- uw-unity-feature-scaffoldSkill
- uw-unity-project-setupSkill
- uw-unity-test-runnerSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
17 rules. About 0 are common, 6 are distinctive, and 11 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Check if GameDebug.cs already exists in the project (search for class GameDebug).
- Very specific: line 13
Read docs/ProjectConfig.yaml -> mcp.unity_mcp — if true, use read_console to read Unity console output.
- Very specific: line 14
Read docs/CODING_STANDARDS.md for async patterns — bugs in async code often involve missing CancellationToken or unhandled …
- Very specific: line 19
Read Unity console (read_console via MCP or ask user for errors).
- Distinctive: line 22
Check git log -5 for recent changes.
- Very specific: line 26
Add targeted GameDebug.Log at decision points.
- Distinctive: line 36
Write a test proving/disproving the hypothesis.
- Distinctive: line 37
If test fails -> back to Phase 2.
- Distinctive: line 42
Run full test suite for regressions.
- Very specific: line 96
Add ENABLE_LOGS to Scripting Define Symbols for Development builds only.
- Very specific: line 100
Write regression test: Use uw-unity-test-runner to add a test that catches the bug if it reappears.
- Very specific: line 101
Code review: Use uw-code-review to verify the fix doesn't introduce new issues.
- Very specific: line 102
Visualize debug data: Use uw-unity-editor-tools to add Gizmos or Handles for spatial debugging (visualize raycast paths, trigger volumes, …
- Distinctive: line 106
Always follow the 4-phase framework — never jump to a fix before gathering evidence and forming a hypothesis.
- Very specific: line 107
Use GameDebug wrapper, never raw Debug.Log / Debug.LogWarning / Debug.LogError.
- Distinctive: line 109
Write a regression test for every bug fix.
- Very specific: line 110
If ProjectConfig.yaml -> mcp.unity_mcp is true, use read_console for console output and run_tests to verify fixes.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Unity Debugging
4-phase debugging framework. Also generates the GameDebug wrapper class.
Before You Start
- Check if
GameDebug.csalready exists in the project (search forclass GameDebug). If not, generate it using the template below during project setup. - Read
docs/ProjectConfig.yaml -> mcp.unity_mcp— iftrue, useread_consoleto read Unity console output. - Read
docs/CODING_STANDARDS.mdfor async patterns — bugs in async code often involve missingCancellationTokenor unhandledOperationCanceledException.
4 Phases
Phase 1: Gather Evidence
- Read Unity console (
read_consolevia MCP or ask user for errors). - Reproduce — exact steps to trigger.
- Scope — single script, system interaction, or timing?
- Check
git log -5for recent changes.
Phase 2: Isolate
- Comment out systems to narrow the culprit.
- Add targeted
GameDebug.Logat decision points. - Check common causes:
- Execution order (
AwakevsStartvsOnEnable) - Null reference (destroyed object, unassigned field)
- Unity API called from background thread
- State not reset in
OnDisable/OnDestroy - Physics in
Updateinstead ofFixedUpdate
- Execution order (
Phase 3: Hypothesize & Test
- State: "I believe X happens because Y."
- Write a test proving/disproving the hypothesis.
- If test fails -> back to Phase 2.
Phase 4: Fix & Verify
- Implement minimal fix.
- Re-run the hypothesis test.
- Run full test suite for regressions.
- Clean up temp debug logs.
- Commit:
fix({scope}): {root cause description}
GameDebug Wrapper
Generate during project setup. Uses [Conditional("ENABLE_LOGS")] so all calls are stripped in release builds. Includes [CallerFilePath], [CallerMemberName], and [CallerLineNumber] for automatic context — no need to manually describe where a log came from.
using System.Diagnostics;
using System.Runtime.CompilerServices;
public enum LogTopic { General, Gameplay, Audio, UI, Network, Physics, AI }
public static class GameDebug
{
[Conditional("ENABLE_LOGS")]
public static void Log(
string message,
LogTopic topic = LogTopic.General,
[CallerFilePath] string file = "",
[CallerMemberName] string member = "",
[CallerLineNumber] int line = 0) =>
UnityEngine.Debug.Log(Format(topic, message, file, member, line));
[Conditional("ENABLE_LOGS")]
public static void LogWarning(
string message,
LogTopic topic = LogTopic.General,
[CallerFilePath] string file = "",
[CallerMemberName] string member = "",
[CallerLineNumber] int line = 0) =>
UnityEngine.Debug.LogWarning(Format(topic, message, file, member, line));
[Conditional("ENABLE_LOGS")]
public static void LogError(
string message,
LogTopic topic = LogTopic.General,
[CallerFilePath] string file = "",
[CallerMemberName] string member = "",
[CallerLineNumber] int line = 0) =>
UnityEngine.Debug.LogError(Format(topic, message, file, member, line));
private static string Format(
LogTopic topic, string msg, string file, string member, int line) {
var fileName = System.IO.Path.GetFileNameWithoutExtension(file);
return $"[{topic}] {fileName}.{member}:{line} — {msg}";
}
}Usage: GameDebug.Log("Player spawned", LogTopic.Gameplay);
Output: [Gameplay] PlayerController.Start:42 — Player spawned
Add ENABLE_LOGS to Scripting Define Symbols for Development builds only. Customize LogTopic enum per project.
After Debugging
- Write regression test: Use
uw-unity-test-runnerto add a test that catches the bug if it reappears. - Code review: Use
uw-code-reviewto verify the fix doesn't introduce new issues. - Visualize debug data: Use
uw-unity-editor-toolsto add Gizmos or Handles for spatial debugging (visualize raycast paths, trigger volumes, etc.).
Rules
- Always follow the 4-phase framework — never jump to a fix before gathering evidence and forming a hypothesis.
- Use
GameDebugwrapper, never rawDebug.Log/Debug.LogWarning/Debug.LogError. - Clean up all temporary debug logs after the fix is verified.
- Write a regression test for every bug fix.
- If
ProjectConfig.yaml -> mcp.unity_mcpistrue, useread_consolefor console output andrun_teststo verify fixes.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

