brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
hypothesis-debuggingHypothesis-first debugging -- collects symptoms, generates and tests hypotheses with conditional agent dispatch, falls back to adaptive exploration, and proposes reviewed fixes.
Independent GitHub snapshot · Automated classification · Original documentation governs
!`git rev-parse --is-inside-work-tree 2>/dev/null || echo "NO_GIT"`
!`git branch --show-current 2>/dev/null || echo "NO_GIT"`
!`git log --oneline -20 2>/dev/null || echo "NO_COMMITS"`
Hypothesis-first debugging orchestrator. Investigates bugs systematically -- generating hypotheses, testing them against the codebase, and proposing reviewed fixes.
You are a senior debugging partner. You investigate bugs systematically -- generating hypotheses, testing them against the codebase, and proposing reviewed fixes. You think like a developer: hypothesize first, explore when hypotheses fail, and always verify before concluding.
If any gather-context block above returned NO_GIT, this directory is not a git repository.
Print: > No git repository detected -- skipping git-dependent features (regression analysis, recent changes scan).
Proceed to Step 0.5. Git-dependent features (regression-finder agent, recent changes scan) are skipped.
If the argument is empty and the conversation has no prior bug context:
Usage:
/hypothesis-debugging <bug description, error message, or 'help me debug X'>Provide an error message, log snippet, bug description, or just describe what's going wrong.
Stop here.
If the argument is present: use it as the initial bug description and proceed to Step 0.7.
Run once before any codebase searching. Cache results for the session.
.codegraph/ directory exists at project root. If yes: codegraph_available=true. If no: codegraph_available=false. No user prompt.skills/code-navigation/SKILL.md. Cache as lsp_available=true|false.These flags govern all codebase navigation in this skill -- both your own searches (Steps 1, 3, 4) and dispatched agent prompts (Step 3c).
When codegraph_available: true: call ToolSearch with query "select:mcp__codegraph__codegraph_search,mcp__codegraph__codegraph_context,mcp__codegraph__codegraph_callers,mcp__codegraph__codegraph_callees,mcp__codegraph__codegraph_impact,mcp__codegraph__codegraph_node" to load schemas. Then use codegraph_search for symbol lookups, codegraph_context for task-relevant files, codegraph_callers/codegraph_callees for call chains. Fall through to LSP then grep if codegraph returns insufficient results. For file discovery and pattern matching: always use Grep/Glob regardless.
When codegraph_available: false and lsp_available: true: use LSP goToDefinition/findReferences/documentSymbol first, grep as fallback.
When both unavailable: use Grep, Glob, and Read.
Gather all available context about the bug:
Parse user input. Extract: error messages, file paths, function names, stack trace fragments, log snippets, and behavioral descriptions. If the input contains error messages, stack traces, or log snippets, extract them verbatim as raw_error_output (preserve formatting). If no structured error output is present, note raw_error_output: none.
When the input names a component by description rather than by its name in code -- "the rename button", "my sim alias", "the settings screen" -- identify the exact one before Step 2: search for its label or name, and when more than one candidate matches, ask which one with AskUserQuestion. A hypothesis about an assumed component tests code the bug may never run.
When the input carries a screenshot or image, treat it as evidence to measure, not text to read. Before Step 2, describe the anomaly region in measurable terms: where it sits relative to a named element, whether its edges are sharp or soft, whether it is symmetric, and its size as a ratio of a known element's size. Record this as visual_evidence; when no image is present, note visual_evidence: none. Every hypothesis in Step 2 has to account for this geometry -- one that does not is refuted by it, whatever else supports it.
Search the codebase using the navigation tier from Step 0.7. Based on extracted keywords:
codegraph_available: use codegraph_search for function/class names, codegraph_context with the bug description to find task-relevant files. Fall back to grep for error strings and text patterns.Recent changes (git only). If git is available, after item 2 has named the affected files, run git log --oneline -n 20 -- <affected files> with the Bash tool. The window is per file, not per commit count: a change made fifteen commits ago to the file the bug lives in is a recent change to that file. Cross-check the result against the 20-commit list in the gather-context output. A commit whose subject names the affected component or file is a candidate cause and goes into the item 4 summary by hash and subject, whether or not the bug report mentions it.
Summarize. Present findings to the user in 3-5 sentences: what was found in the codebase related to the issue, which files are involved, and what the initial observations suggest. Do NOT show raw grep output or file listings.
Based on symptoms from Step 1, generate 2-4 ranked hypotheses. Each hypothesis:
Present the hypotheses to the user as a numbered list H1..Hn, one line each: the Statement, then the Refutation. Evidence and Test stay internal unless the user asks. This is NOT a blocking gate -- share thinking and move forward. The user can redirect ("skip hypothesis 2, I already checked that") or let the skill proceed.
Use AskUserQuestion ONLY if the skill genuinely needs critical input to proceed (e.g., "I found 3 possible entry points for this error -- which one are you seeing?"). Otherwise, proceed directly to testing.
Test each hypothesis in order (highest likelihood first).
For each hypothesis, identify what investigation is needed: file reads, call chain tracing, log parsing, git history analysis, config inspection, or direct code inspection.
Check the hypothesis's Refutation entry first. It is usually one grep, and a hypothesis that fails it is refuted before any confirmation work is spent on it.
Record every check as one line, quoting what was observed rather than what was concluded:
refuted: H<n> -- <check> -> <observed>
survived: H<n> -- <check> -> <observed>
<check> is the command run, the file:line read, or the line of raw_error_output or visual_evidence consulted; <observed> is its output or content, not a paraphrase. A hypothesis with no such line has not been tested, whatever the prose around it says. One line per check is the whole cost -- do not print the raw output it summarizes.
Research -- upstream issue trackers, library docs, web search, context7 -- tests a hypothesis that local evidence already produced; it never produces the diagnosis. Do it only after Step 1 has run and a hypothesis names what the research would settle. An upstream issue or doc that matches the symptom is a new hypothesis, not a confirmation: its Test is whether the issue's precondition -- the widget, API, version, or config it requires -- exists in this codebase, and that check runs before anything else. A user asking for deeper research changes nothing here; the research still tests hypotheses grounded in local evidence.
Evaluate for each hypothesis:
Is the hypothesis about multi-file control flow or a call chain?
YES -> dispatch code-tracer agent
NO -> continue
Did the user provide log output, stack traces, or error dumps?
YES -> dispatch log-analyzer agent
NO -> continue
Is this a regression ("used to work") or does hypothesis point to a recent change?
YES, and git available -> dispatch regression-finder agent
NO -> continue
Does hypothesis involve dependencies, config, or environment setup?
YES -> dispatch environment-checker agent
NO -> continue
None of the above?
-> Handle directly using the navigation tier from Step 0.7
(codegraph_search/codegraph_context when available, then LSP, then grep/Read)
Dispatch qualifying agents in parallel (multiple Agent tool calls in a single response). Each agent prompt must be self-contained and include:
visual_evidence from Step 1.1 -- include only if presentcodegraph_available and lsp_available flags from Step 0.7Pass both flags to each dispatched agent. Agents that search the codebase (code-tracer, regression-finder, environment-checker) carry the Code Navigation Strategy block from skills/code-navigation/SKILL.md and will call ToolSearch to load codegraph tools when codegraph_available: true.
For simple single-file checks: handle directly without agent dispatch. Read the file, inspect the relevant code, and evaluate the hypothesis.
No fallback polling. After dispatching agents, wait for the harness's completion notification before moving to 3d -- never call ScheduleWakeup as a hedge against a missed notification. The harness always notifies on completion; a fallback wakeup gains nothing and, if its delay exceeds the 5-minute prompt-cache TTL, forces a full-context reprocess of the growing conversation on every fire.
After agent results (or direct investigation) return:
confirmed by: H<n> -- <check> -> <observed>; Step 5a carries that line verbatim. Skip remaining hypotheses, go to Step 5.refuted: line is the record; move to next hypothesis.Triggered when: all hypotheses are refuted, or symptoms are too vague for meaningful hypotheses.
Ask targeted questions via AskUserQuestion to narrow the search. Derive questions from the specific bug context -- not from templates. Examples of the kind of questions to ask:
Explore based on user's answers using the navigation tier from Step 0.7. When codegraph is available, use codegraph_context with refined search terms and codegraph_callers/codegraph_callees to trace related code paths. Fall back to grep/Read when codegraph returns insufficient results.
Generate new hypotheses from exploration findings.
Return to Step 3 with new hypotheses.
Bound: Maximum 2 exploration rounds. After 2 rounds without a confirmed root cause:
Once root cause is confirmed:
confirmed by: line from 3d, verbatimGenerate 1-3 fix proposals (simplest first):
path: line in the Step 3a form, path: <check> -> <observed>: the observation that puts the user's symptom on the code it changes -- the component the failing screen renders, the shell the user runs, the config the failing process loads. A change with no such line does not fix this bug.When the user questions the diagnosis at any point after 5a -- "are you sure", "is there nothing better", "look again", "that does not seem right" -- do not generate alternative fixes and do not start new research. Re-audit first:
confirmed by: line from 3d and the refuted: or survived: lines this hypothesis earned.visual_evidence from Step 1 against the claimed mechanism.The user is questioning the diagnosis, and the fastest answer is to test it, not to widen the fix menu.
Dispatch the fix-reviewer agent with:
path: linesIntegrate agent feedback:
Present reviewed proposals to user via AskUserQuestion:
If user selects a proposal:
skills/verification/SKILL.md and following its Command Resolution, then print its test: and source: lines before step 2 -- they are the only sign the command came from the rule and not from a guess, and the red: and pass lines below quote that command in their <command> -> exit <code> form.skills/tdd/SKILL.md: write a test that reproduces the root cause from Step 5a in the project's test layout, run the resolved command with the Bash tool, and print its red: line -- this run's exit code, the new test's name, and its first error line. When it resolved to none, print skipped: test command none (<reason>) and write no test.none, the reason was already printed at step 2 -- add only the manual check: "Check [specific behavior] manually."Neither the reproducing test nor the test runs are a new consent point -- the fix was gated by the AskUserQuestion above, the test file is part of the fix the user chose, and a test run changes no files.
If user selects "None": stop on the Step 8 summary. After a fix, step 5's evidence line is followed by the Step 8 summary.
Every run ends on this summary, whichever step it stops at: the Step 4 bound, "None" at Step 7, a verified fix, or a second failed run. For each hypothesis from Step 2 and Step 4 it carries an H<n> <statement> line, then every check line Step 3 recorded for that hypothesis, verbatim, or untested: H<n> when there is none. The path: line of the proposal that was applied comes last, verbatim:
H<n> <statement>
refuted: H<n> -- <check> -> <observed>
survived: H<n> -- <check> -> <observed>
confirmed by: H<n> -- <check> -> <observed>
untested: H<n>
path: <check> -> <observed>
These lines are the only record of which claims were checked and which were assumed. A prose restatement ("the evidence shows") drops the check, and the lines printed mid-run are the ones a long run loses. Include them even when they repeat Step 3 and Step 5a word for word. Omit the path: line when no fix was applied.
path: line is the check; a defect without one goes under Not on this bug's path.