| name | diagnose |
| description | Guided runtime debugging — add Debug.Log diagnostics, test in play mode via MCP, read console, identify root cause and fix |
Runtime Bug Diagnosis
Structured workflow for diagnosing runtime bugs in Unity play mode.
Arguments
bug (required): Description of the bug or unexpected behavior
scene (optional): Scene to test in (default: currently loaded scene)
Workflow
Phase 1: Gather Context
- Read the console for existing errors:
mcp__UnityMCP__read_console(types=["error","warning"])
- Identify the suspect code paths based on the bug description
- Read the relevant source files to understand the flow
Phase 2: Add Diagnostics
CRITICAL: Use Debug.Log, NEVER Diag.Log — Diag.Log writes to an internal event log that does NOT appear in the Unity console.
For each suspect location, add a Debug.Log with:
- A unique
[ClassName] prefix for filtering
- Key variable state:
$"[Foo] MethodName: ref={ref != null} value={value}"
- Place logs BEFORE null checks and branching to see which path executes
Commit each modified file immediately (project rule).
Phase 3: Test
- Ensure the correct scene is loaded:
mcp__UnityMCP__manage_scene(action="get_active")
- Clear console:
mcp__UnityMCP__read_console(action="clear")
- Enter play mode:
mcp__UnityMCP__manage_editor(action="play")
- Wait 4-5 seconds for initialization
- If the bug requires user interaction, ask the user to perform the action
- Read console:
mcp__UnityMCP__read_console(count=30)
- Read errors specifically:
mcp__UnityMCP__read_console(types=["error","warning"])
- Stop play mode:
mcp__UnityMCP__manage_editor(action="stop")
Phase 4: Analyze
From the console output, determine:
- Which diagnostic logs fired (and which did NOT — gaps reveal the break point)
- Whether references were null at specific checkpoints
- Whether methods were called in the expected order
- Any Unity errors/warnings that appeared
Phase 5: Fix
- Implement the targeted fix based on diagnosis
- Remove diagnostic
Debug.Log calls (or leave them if they add value)
- Commit each file immediately
- Re-test using Phase 3 to verify the fix
- Check for zero errors/warnings in the console
Tips
- If a file is at the 450-line limit, REPLACE an existing
Diag.Log with Debug.Log instead of adding lines
- Check
mcp__UnityMCP__read_console(types=["error"]) after script edits to catch compile errors before testing
- For intermittent bugs, add more diagnostics rather than fewer — you can always remove them
- Filter console output with
filter_text parameter if output is noisy