Reference
Spell — Bug
At a glance
| Field | Value |
|---|---|
| Invoke as | /spell-bug |
| Argument | Bug description (e.g., "Session detail dialog shows 404 when clicking a mock session") |
| Agent | agent |
| When to use | Use PROACTIVELY whenever diagnosing and fixing a bug, even if the user just describes broken behavior. |
Executive Summary
- This prompt handles the full bug lifecycle: document → track → diagnose → fix → verify → close.
- It records the bug in your configured tracker (external provider) or
TODO.md(internal mode) and links the fix commit to it. - Output is a working fix with tests, committed using Conventional Commits format.
- When to use: you have a concrete defect — wrong/broken behavior versus expected. If the report is actually a request for new behavior, route to
spell-suggest-featureinstead. For small non-blocking cleanups discovered along the way, capture them withspell-todo. - See Development Methodology for full Spell Loop reference.
Document, diagnose, and fix the described bug.
Use these files for context (each is optional — if a file is missing, proceed and note the assumption you fell back on):
- governance/development-methodology.md — Spell Loop methodology and tracker-provider specifics (which tracker, work-item types, commit-link syntax). If missing, default to
tracking_mode: internaland track inTODO.md. - DECISIONS.md — Existing ADRs to respect. If missing, proceed without ADR constraints.
- governance/testing-standards.md — Coverage thresholds. If missing, match the test conventions already present in the repo.
Workflow:
-
Capture the bug — gather these details from the user (ask if missing):
Field Description Summary One-line description of the bug Reproduction steps Numbered steps to reproduce Expected behavior What should happen Actual behavior What actually happens (include error messages, HTTP codes, screenshots) Severity Critical / High / Medium / Low Affected component File path, page, API route, or module Discovery context How was this found? (smoke test, user report, monitoring) -
Record the bug — file it in whatever tracker this repo uses. Resolve
tracking_modefrom.arcane.json(or the repo's feature/PRD frontmatter); if unset, ask rather than assuming.-
tracking_mode: internal(or no tracker configured) — append the bug toTODO.md(create it if absent) using the captured fields from Step 1. Use theTODO.mdentry's identifier as{WORK_ITEM_ID}. No external tooling required. -
tracking_mode: external— file a work item in the configured provider. Read governance/development-methodology.md for the provider, work-item type, and required fields; do not assume Azure DevOps. Extract the returned id as{WORK_ITEM_ID}.Azure DevOps is one such provider — if and only if
.arcane.json/ methodology names it (and theazCLI is available), file it like so. Resolve{ADO_ORG}and{ADO_PROJECT}from.arcane.json; ask if unset:az boards work-item create \ --type Bug \ --title "[Bug] {SUMMARY}" \ --description "{formatted description with repro steps}" \ --org https://dev.azure.com/{ADO_ORG} \ --project {ADO_PROJECT} \ --output jsonGitHub is another — if and only if
.arcane.jsonnamesexternal_provider: github(and theghCLI is authenticated):gh issue create \ --title "[Bug] {SUMMARY}" \ --body "{formatted description with repro steps}" \ --label buggh issue createprints the created issue's URL on success; extract the trailing number as{WORK_ITEM_ID}. Omit--labelif the repo has nobuglabel (gh label list) rather than guessing.
If the configured tooling is unavailable or the user prefers manual tracking, fall back to the
TODO.mdentry above and continue. -
-
Diagnose — trace the code path to find the root cause:
-
Read the affected component and its dependencies.
-
Identify the exact line(s) where the bug manifests.
-
Determine why the bug exists (data mismatch, missing case, race condition, etc.).
-
Document the root cause concisely.
-
"It worked before" and the code is unchanged: diff the environment before the code. When the report is a regression and the code the symptom points at has not changed since the last build that worked, the runtime around it moved. Before patching that code:
- Compare the dependency set and any platform or SDK version of the last good build against the current one, for example
git show <last-good-commit>:package.jsonagainst the current file, or the two lockfiles. - If a dependency in that diff plausibly owns the behavior, read its actual implementation (for a native module, the native source under
node_modules, not its README), and check its issue tracker and release notes for the versions in the diff. - Only then design the fix. Prefer the upstream fix plus a stopgap over a workaround in the calling code.
A run of fixes to the calling code that each address a real but narrower cause, none of which resolves the report, is the signal that this check was skipped.
- Compare the dependency set and any platform or SDK version of the last good build against the current one, for example
-
-
Implement the fix — write the minimal code change:
- Fix only the bug — no refactoring, no feature additions.
- Follow existing code patterns and conventions.
- If the fix touches a public interface, check all callers.
-
Add or update tests — ensure the bug cannot regress:
- Write a test that reproduces the bug (fails without the fix).
- Verify existing tests still pass.
- Run the full test suite:
npx vitest run(or project-specific command).
-
Verify the fix — confirm the bug is resolved:
- Run the reproduction steps from Step 1 — they should now succeed.
- Check for side effects in related functionality.
- If applicable, rebuild and restart:
npm run build.
-
Commit — stage and propose a commit message for approval:
fix({scope}): {SUMMARY} {Root cause explanation} {What was changed and why} {WORK_ITEM_LINK}Follow Conventional Commits format. For
{WORK_ITEM_LINK}, use the commit-link convention your tracker expects (per governance/development-methodology.md) — e.g.Fixes AB#{WORK_ITEM_ID}for Azure DevOps,Fixes #{WORK_ITEM_ID}for GitHub Issues, or a plainRefs TODO.mdfor internal mode. Wait for user approval before executinggit commit. -
Close out the tracker — update the work item's state to reflect the fix:
internal— mark theTODO.mdentry as resolved (check it off / move to a Done section).external— transition the work item to its resolved/done state via the provider. For Azure DevOps specifically (resolve{ADO_ORG}from.arcane.json):
For GitHub specifically:az boards work-item update \ --id {WORK_ITEM_ID} \ --state Resolved \ --org https://dev.azure.com/{ADO_ORG} \ --output json
For other providers, follow governance/development-methodology.md.gh issue close {WORK_ITEM_ID} --reason completed --comment "Fixed by {commit SHA or PR URL}"
Rules:
- Fix only the reported bug. Do not bundle unrelated improvements.
- If the report turns out to describe new or changed behavior rather than a defect, stop and route the user to
spell-suggest-feature. Capture any non-blocking follow-ups you notice viaspell-todorather than expanding this fix. - Every fix must have a test that would have caught the bug.
- Present the commit message for human approval — never auto-commit.
- If the root cause is unclear, present your diagnosis and ask for confirmation before implementing.
- If the fix is risky (touches shared infrastructure, auth, or data), flag it explicitly.