investigate
Six-phase root-cause debugging for crashes, build failures, or "why is this broken" reports. Iron Law - no fixes without root cause. Auto-engages /freeze.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Six-phase root-cause debugging for crashes, build failures, or "why is this broken" reports. Iron Law - no fixes without root cause. Auto-engages /freeze.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Audit context window consumption across LOTRAOM agents, skills, rules, MCP servers, and CLAUDE.md. Report token estimates, flag bloat, recommend trims.
Hard-block Edit/Write outside a chosen directory. Use to scope-lock edits during a focused fix or refactor. Pair with /unfreeze to release.
Release the directory edit lock set by /freeze. Edit and Write are unrestricted again. No-op if /freeze was never set.
Dispatch an independent Codex verification job for the current changes
Inspect all changed files, group by logical concern, and guide atomic per-concern commits
Check mod compatibility against a new Bannerlord version by reviewing patch targets and GameModel overrides
基于 SOC 职业分类
| name | investigate |
| description | Six-phase root-cause debugging for crashes, build failures, or "why is this broken" reports. Iron Law - no fixes without root cause. Auto-engages /freeze. |
| allowed-tools | ["Bash","Read","Grep","Glob","Edit","Write","WebSearch","AskUserQuestion"] |
| hooks | {"PreToolUse":[{"matcher":"Edit","hooks":[{"type":"command","command":"bash ${CLAUDE_PROJECT_DIR}/.claude/skills/freeze/check-freeze.sh"}]},{"matcher":"Write","hooks":[{"type":"command","command":"bash ${CLAUDE_PROJECT_DIR}/.claude/skills/freeze/check-freeze.sh"}]}]} |
Adapted from garrytan/gstack/investigate via TAOM 2026-05-17. Reuses our existing /freeze hook so debug scope is auto-locked.
NO FIXES WITHOUT ROOT-CAUSE INVESTIGATION FIRST.
Fixing symptoms creates whack-a-mole debugging. Every fix that doesn't address root cause makes the next bug harder to find. Find the root cause, then fix it. This is a BLOCKING GATE, not optional.
Gather context before forming any hypothesis.
Collect symptoms. Read error messages, stack traces, save-load logs, Bannerlord crash dumps. If the user hasn't given enough context, ask ONE question at a time via AskUserQuestion.
Read the code. Trace from symptom back. Use Grep/find_symbol (Serena MCP) to find references; Read to understand logic.
Check recent changes.
git log --oneline -20 -- <affected-files>
Was this working before? What's in the diff?
Reproduce. Can you trigger the bug deterministically? Bannerlord-specific:
Check the simpler-fix-first list. Before investigating engine internals, check whether the bug is in:
skins.xml / monsters.xml / action_sets.xml (race + animation issues)LOTRAOM_*.xml data files (XML schema or value problems).claude/rules/xslt.md)Main/IoC.cs registration order (service-locator hot path)Verify TaleWorlds API signatures. LOTRAOM targets Bannerlord v1.2.12. Before assuming a method exists or has a particular signature, run ilspycmd against the installed DLLs at E:\Steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\. Use the /research skill if the surface is large.
Output: "Root-cause hypothesis: ..." — a specific, testable claim about what is wrong and why.
Once you have a hypothesis, lock edit scope to the affected directory. This skill's own PreToolUse hooks (declared in this SKILL.md's frontmatter) ARE active while /investigate is running, so writing the state file here will fire them — that's why this skill can auto-engage freeze without separately invoking /freeze.
SCOPE="<e.g. Main/Features/HeroRace/>"
STATE_DIR="${CLAUDE_PROJECT_DIR}/.claude/tmp/freeze"
mkdir -p "$STATE_DIR"
echo "$SCOPE" > "$STATE_DIR/freeze-dir.txt"
echo "Debug scope locked to: $SCOPE"
Tell the user: "Edits restricted to <scope> for this debug session. Outside-scope edits will be hard-blocked. Run /unfreeze to release."
If the bug genuinely spans the whole repo (e.g., a shared adapter contract change), skip the lock and note why.
Important: Other agents/skills that don't have their own hooks: frontmatter cannot auto-engage freeze by writing the state file alone — the file is inert outside an active hook-bearing skill. They must explicitly invoke /freeze instead. /investigate is special because it declares its own copy of the freeze hook in this SKILL.md.
Check whether the bug matches a known LOTRAOM/Bannerlord failure pattern before writing any fix:
| Pattern | Signature | Where to look |
|---|---|---|
| Harmony patch type-load | TypeLoadException at startup, mod fails before main menu | Patch target signature mismatch — verify with ilspycmd against v1.2.12 |
| Harmony patch silent skip | Patch loads, but behavior doesn't change in-game | Wrong target method, prefix returning false unexpectedly, manual patch matching wrong overload. BHA0001 warning at build = broken patch. |
| GameModel cast | InvalidCastException in vanilla model call | New override returning wrong type, or base call missing. Check Main/Core/Services/ModelRegistry.cs |
| Service-locator at startup | IoC.Resolve returns null, NullReferenceException in patch | Service registered after CampaignBehavior runs — registration order bug in Main/IoC.cs |
| VM string crash | {=key}Text shows literal in UI, or NRE on property access | Missing TextObject().ToString() or stale localization file |
| Sprite missing / atlas corruption | Items render in underwear, sprite renders blank/black | Wrong sprite ID in XML, or missing equipment ID. The Rhûn weapon work (see MEMORY.md) had repeated cases of this. |
| Save-load state loss | Buff or feature works once, lost after save+load | Missing SyncData, or storing non-savable type. Project rule: "Save All Hero Sets" + "String IDs for Saves" |
| Race / culture XML wiring | Custom culture characters appear vanilla | XSLT didn't pass through new attribute (see .claude/rules/xslt.md), or XML missing required field |
Culture lookup using .Name.ToString() | Localized strings mismatch culture lookups | Project rule violation: use ICultureMapper.GetLotrCultureName(culture.StringId) |
| Engine-scale property | AgentDrivenProperties change has no effect or wrong magnitude | Missed downstream consumer / clamp / multiplier — decompile and trace |
Also check:
git log --all --oneline -- <file> for prior fixes in the same area — recurring bugs in the same files are an architectural smell, not coincidencedocs/reviews/ for prior Codex/deep-review findings on this codedocs/features/<feature>.md for known limitations / design notesIf WebSearch is needed for a Bannerlord modding pattern, sanitize the error first — strip path prefixes (E:\Steam\steamapps\..., c:\Users\mikew\...), customer identifiers, mod-internal IDs, and stack hostnames. Search the generic error category, not the raw message.
Before writing ANY fix, verify your hypothesis.
Confirm. Add a temporary log line, assertion, or debug output at the suspected root cause. Reproduce. Does evidence match?
If wrong: return to Phase 1. Do NOT guess your way to a fix. The cost of a second investigation is minutes; the cost of a wrong fix is hours.
3-strike rule. If three hypotheses fail in sequence, STOP and use AskUserQuestion:
3 hypotheses tested, none match. This may be architectural rather than a simple bug.
A) Continue — I have a new hypothesis: [describe]
B) Escalate — this needs human eyes
C) Instrument and wait — add logging, defer fix to next repro
Red flags — slow down if you see any of these:
Once root cause is confirmed:
Fix the root cause, not the symptom. Smallest change that eliminates the actual problem.
Minimal diff. Fewest files, fewest lines. Resist refactoring adjacent code while debugging — log it for a follow-up.
Write a regression test. Per .claude/rules/tests.md (TDD-mandatory):
Build + tests.
./build.ps1 -RunTests -MinCoverage 80
No build errors. No test regressions. Paste the output.
Blast-radius gate. If the fix touches >5 files, AskUserQuestion:
This fix touches N files. Large blast radius for a bug fix.
A) Proceed — root cause genuinely spans these files
B) Split — fix the critical path now, defer the rest
C) Rethink — maybe a more targeted approach exists
Reproduce the original bug scenario and confirm it's fixed. Not optional. For Bannerlord, this often means launching the game manually — say so explicitly if you can't test in-game.
Run the test suite. Paste the output.
Output a structured debug report:
DEBUG REPORT
=========================================
Symptom: [what the user observed]
Root cause: [what was actually wrong, in LOTRAOM terms]
Phase that found it: [Phase 3 pattern match | Phase 4 hypothesis | etc.]
Fix: [what changed, file:line references]
Evidence: [test output, in-game repro result if applicable]
Regression test: [LOTRAOM.Tests/.../FooTests.cs:line]
Files touched: [N]
Status: DONE | DONE_WITH_CONCERNS | BLOCKED
=========================================
After verification passes, ask the user whether to release the scope lock or keep it for the next change. If keeping, leave the freeze state in place; if releasing, run /unfreeze.
/freeze hook to its own session. It works whether or not the user explicitly ran /freeze first./investigate once per feature in sequence, releasing freeze between runs./codex-verify after fix lands, before merge — gets an adversarial second opinion on the root-cause analysis.