techygarg/lattice-bug-fix
Investigate, reproduce, and safely fix a bug with regression protection. Composes context, diagnosis, architecture, code quality, and testing guardrails into a reproduce-first repair workflow. Use when the user says 'fix this bug', 'debug this', 'investigate this failure', 'patch this regression', 'repair this issue', or 'why is this broken'.
This is a copy. The original lives at techygarg/bug-fix.
npx skills add https://github.com/techygarg/lattice --skill bug-fix
Load these skills based on bug scope (see Steps 2 and 5 for when):
framework:knowledge-priming -- (always)framework:context-anchoring -- (always)framework:learning-harvest -- (always)framework:collaborative-judgment -- (always)framework:clean-code -- (always)framework:test-quality -- (always)framework:architecture -- (conditional)framework:domain-driven-design -- (conditional)framework:secure-coding -- (conditional)Start from failure, not proposed fix.
framework:learning-harvest Load behavior. Focus hint: "bug investigation — focus: reliability, quality signals".framework:context-anchoring Document Discovery to check for existing context doc for affected feature/module.End this step, summarize bug one sentence:
> "Observed X, expected Y, reproducible via Z."
STOP: If can't state bug clearly yet, gather more evidence before proposing code changes.
Primary discipline: don't present fix for bug you haven't reproduced.
Reproduce failure using strongest evidence available, this order:
Localize issue before editing:
framework:architecture to identify which architectural layer defect originates inframework:secure-codingframework:domain-driven-designframework:architectureIf multiple plausible root causes remain, use framework:collaborative-judgment to present leading hypotheses + what evidence would distinguish.
Before writing regression test, state root cause hypothesis explicitly, use framework:collaborative-judgment to surface:
> "Bug caused by [X]. When [C holds], correct outcome should be [P].
> Confirm this by writing test that red before fix, green after."
If user identifies flaw in hypothesis, revise before writing tests.
End step with explicit bug contract:
> C (bug condition): [exact input/state triggering bug]
> P (fix postcondition): [what correct behavior looks like when C holds]
> Preserved: [what must remain identical for all inputs outside C]
STOP: If can't state all three, keep localizing before writing tests.
Optional persistence check: Now that bug reproduced + localized, decide whether persist investigation:
framework:context-anchoring, use as source of truthPhase A — Bug-Condition Tests (must start RED)
framework:test-quality inlineStopping rule:
framework:clean-code inline, keep seam minimal.Phase B — Preservation Baseline (must stay GREEN)
Separate repair strategy from code change itself.
Before editing, decide:
Default to smallest safe fix restoring correct behavior without architectural backsliding.
Guardrails:
framework:architecture layering rules when choosing repair location — don't patch in outer layer when rule belongs inwardIf multiple valid repair strategies with meaningful trade-offs, present using framework:collaborative-judgment before proceeding.
Always apply:
framework:clean-code -- keep delta focused, readable, easy to reason aboutframework:test-quality -- maintain regression test + any nearby supporting testsConditionally apply based on localized root cause:
framework:architectureframework:domain-driven-designframework:secure-codingAfter implementing fix, before presenting:
Verify repair three levels:
When reporting completion, explicit about verification scope:
If fix narrow + confidence high, say so briefly. If verification partial, say so clearly.
Use framework:context-anchoring Enrich behavior to preserve important parts of repair:
If no context doc exists + fix exposed non-trivial design/domain lesson, suggest creating one.
Harvest learnings. Use framework:learning-harvest Harvest behavior. Session context: "bug investigation — root cause diagnosis and repair". Synthesize and propose cross-cutting patterns from this session — root cause categories, failure modes likely to recur elsewhere, boundary condition gaps. User confirms what enters the document. STOP: run this before recommending /review below.
After fix complete, recommend /review when change:
Take techygarg/lattice-bug-fix from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.