Bugfix
End-to-end workflow for investigating, diagnosing, and fixing bugs. Orchestrates environment analysis (analyze-local skill or analyze-prod skill), evidence collection, bug report preparation, fix planning, and implementation by the appropriate engineering role.
1. Receive Bug Report
Gather the bug description from the user:
- What is the expected behavior?
- What is the actual behavior? (error message, wrong output, crash, performance issue)
- Steps to reproduce (if known)
- Environment: local (Docker) or production (cloud K8s)?
- When did it start? (after deploy, config change, or unknown)
- Severity: P1 (outage), P2 (degraded), P3 (minor), P4 (cosmetic)
If the user provides partial information, extract what you can and fill gaps during analysis. For P1/P2 — skip detailed intake and proceed immediately to Step 2.
2. Analyze Environment
Based on the environment, delegate to the appropriate analysis follow-up skill:
| Environment |
follow-up skill |
When to use |
| Local Docker / Docker Compose |
analyze-local skill |
Bug observed in local dev environment |
| Cloud production (GKE/AKS/EKS, managed DB) |
analyze-prod skill |
Bug observed in production or staging |
| Code-only (no infra) |
Skip to Step 3 |
Bug is in application logic, no environment analysis needed |
Run the follow-up skill. It will:
- Apply the appropriate diagnostic role (
sre-engineer role or devops-engineer role)
- Collect environment snapshot (container/pod status, logs, metrics, networking)
- Identify infrastructure-level issues
- Present diagnosis
If the follow-up skill resolves the issue (e.g., container restart, config fix) — skip to Step 8.
If the root cause is in application code — continue to Step 3 with the collected evidence.
3. Detect Stack and Apply Engineer Role
Determine the affected service's tech stack and apply the appropriate engineering role:
- Read project's
AGENTS.md — tech stack declaration
- Scan project files —
package.json, pom.xml, requirements.txt, go.mod, etc.
- Check evidence from Step 2 — which service's logs show the error? What language is the stack trace in?
Role assignment:
| Stack Signal |
Role |
Next.js, React, TypeScript, .tsx files |
frontend-engineer role |
Spring Boot, Java, .java files |
java-engineer role |
FastAPI, Python, .py files |
python-engineer role |
| Terraform, Dockerfile, Helm, CI/CD |
devops-engineer role |
| ML model, training pipeline, inference |
ml-engineer role |
| Multiple stacks affected |
Apply all relevant roles |
| Unknown / general |
software-engineer role |
Announce the applied role(s) to the user.
4. Collect Evidence
Gather all evidence into a structured collection. Combine data from Step 2 (environment analysis) with code-level investigation:
Use the applied role's debugging methodology to trace the bug:
- Read error stack traces to identify the failing code path
- Search codebase for related functions, error handlers, and data flows
- Check recent changes (
git log -n 20 --oneline) for potential regressions
- Identify the minimal reproduction case
5. Prepare Bug Report
Compile findings into a structured bug report. Present to the user for review:
## Bug Report
### Summary
[One sentence: what is broken]
### Severity: [P1 | P2 | P3 | P4]
### Environment
- **Type**: [local | production]
- **Service**: [name]
- **Stack**: [detected] | **Role**: [applied]
### Expected Behavior
[What should happen]
### Actual Behavior
[What actually happens — include error messages]
### Steps to Reproduce
1. [step]
2. [step]
3. [observed error]
### Evidence
- **Stack trace**: [snippet or reference]
- **Logs**: [relevant entries]
- **Metrics**: [if applicable]
- **Affected code**: [file:line references]
### Root Cause Analysis
[Technical explanation of why the bug occurs]
### Affected Components
- [file/module 1] — [how it's affected]
- [file/module 2] — [how it's affected]
Wait for user confirmation before proceeding to fix.
6. Plan the Fix
Create an ordered fix plan following the applied role's guidelines:
- Root cause fix — address the actual cause, not symptoms
- Complete fix — fix everything described in the bug report. Do not leave cosmetic issues, lint warnings, or minor problems unfixed. Do not create follow-up tickets for things you can fix now
- Regression test — test that would have caught this bug
- Related fixes — any adjacent issues discovered during investigation. Fix them in the same changeset — do not increase tech debt
Present the plan:
## Fix Plan
### Root Cause
[What caused the bug — one sentence]
### Changes
1. [file] — [what to change and why]
2. [file] — [what to change and why]
...
### Tests
1. [test file] — [test that reproduces and verifies the fix]
2. [test file] — [regression test for edge cases]
### Risk Assessment
- **Blast radius**: [which features could be affected by this change]
- **Rollback**: [how to revert if the fix causes issues]
Wait for user approval before implementing.
7. Implement the Fix
Execute the approved plan step by step.
For each change:
- State what you are about to do (file, change summary)
- Implement the fix following the applied role's code quality standards
- Verify the code compiles/parses without errors
Then write tests:
- Regression test: Reproduces the original bug — must fail without fix, pass with fix
- Edge case tests: Cover related scenarios discovered during investigation
- Run the full test suite to catch regressions
Rules:
- Fix the root cause, not the symptom
- Fix EVERYTHING reported in the bug — do not leave non-blocking or cosmetic issues unfixed
- Fix all lint errors, style violations, and warnings introduced or exposed by the change
- Follow existing code patterns and conventions
- No new warnings or linter errors — and fix pre-existing ones in the affected files if trivial
- Do not defer fixes to "follow-up" tasks — complete the fix in this changeset
- Do not increase tech debt — if you touch it, leave it better than you found it
- If the fix is more complex than expected — stop and discuss with the user
- If you need more information about the environment, run specialized follow-up skills (
analyze-local skill or analyze-prod skill) to collect it
8. Self-Review the Fix
Before declaring the bug fixed, perform a thorough self-review. Do NOT skip this step.
Code review checklist:
If the self-review reveals any remaining issues — fix them before proceeding. Do not declare the bug fixed with known remaining problems.
9. Verify the Fix
Verify the bug is resolved in the appropriate environment:
For local bugs:
- Run the reproduction steps — confirm the bug no longer occurs
- Run the full test suite — all tests pass (new + existing)
- If Docker-based: rebuild and verify with
analyze-local skill (optional)
- If you need more data, run specialized follow-up skills for
analyze-local skill to collect environment state
For production bugs:
- Verify the fix locally first
- Deploy through normal CI/CD pipeline (do NOT hotfix production directly)
- After deploy: re-run relevant checks from
analyze-prod skill to confirm resolution
- Monitor error rates and SLIs for regression
Verification checklist:
If any check fails — fix and re-verify. Do NOT declare the bug fixed until every checkbox passes.
10. Summary
Present the completed bugfix:
- Bug: one-sentence summary
- Severity: P1–P4
- Environment: local / production
- Role(s) applied: which roles were used
- Root cause: technical explanation
- Fix: what was changed (files, brief description)
- Tests added: count and description
- Self-review: passed — all items verified
- Verification: how it was confirmed fixed
- Remaining issues: NONE (if any remain, go back and fix them before reporting)
- Prevention: recommendations to avoid similar bugs (e.g., add validation, improve error handling, add monitoring)
Integration
- follow-up skills:
analyze-local skill, analyze-prod skill (environment diagnostics — launch as specialized skills when more data is needed)
- Follow-up:
run-tests skill (verify fix), pre-commit skill (quality gate), create-pr skill (submit fix)
- Skills:
code-review skill (review fix), test-strategy skill (test strategy), worktree-isolation skill (branch isolation)
1---2name: bugfix-23description: End-to-end bugfix workflow — analyze environment (local Docker or cloud production), collect evidence, prepare bug report, plan fix, apply appropriate engineer role, implement and verify the fix.4---56# Bugfix78End-to-end workflow for investigating, diagnosing, and fixing bugs. Orchestrates environment analysis (`analyze-local` skill or `analyze-prod` skill), evidence collection, bug report preparation, fix planning, and implementation by the appropriate engineering role.910## 1. Receive Bug Report1112Gather the bug description from the user:1314- **What is the expected behavior?**15- **What is the actual behavior?** (error message, wrong output, crash, performance issue)16- **Steps to reproduce** (if known)17- **Environment**: local (Docker) or production (cloud K8s)?18- **When did it start?** (after deploy, config change, or unknown)19- **Severity**: P1 (outage), P2 (degraded), P3 (minor), P4 (cosmetic)2021If the user provides partial information, extract what you can and fill gaps during analysis. For P1/P2 — skip detailed intake and proceed immediately to Step 2.2223## 2. Analyze Environment2425Based on the environment, delegate to the appropriate analysis follow-up skill:2627| Environment | follow-up skill | When to use |28|---|---|---|29| Local Docker / Docker Compose | `analyze-local` skill | Bug observed in local dev environment |30| Cloud production (GKE/AKS/EKS, managed DB) | `analyze-prod` skill | Bug observed in production or staging |31| Code-only (no infra) | Skip to Step 3 | Bug is in application logic, no environment analysis needed |3233Run the follow-up skill. It will:34- Apply the appropriate diagnostic role (`sre-engineer` role or `devops-engineer` role)35- Collect environment snapshot (container/pod status, logs, metrics, networking)36- Identify infrastructure-level issues37- Present diagnosis3839**If the follow-up skill resolves the issue** (e.g., container restart, config fix) — skip to Step 8.4041**If the root cause is in application code** — continue to Step 3 with the collected evidence.4243## 3. Detect Stack and Apply Engineer Role4445Determine the affected service's tech stack and apply the appropriate engineering role:46471. **Read project's `AGENTS.md`** — tech stack declaration482. **Scan project files** — `package.json`, `pom.xml`, `requirements.txt`, `go.mod`, etc.493. **Check evidence from Step 2** — which service's logs show the error? What language is the stack trace in?5051**Role assignment:**5253| Stack Signal | Role |54|---|---|55| Next.js, React, TypeScript, `.tsx` files | `frontend-engineer` role |56| Spring Boot, Java, `.java` files | `java-engineer` role |57| FastAPI, Python, `.py` files | `python-engineer` role |58| Terraform, Dockerfile, Helm, CI/CD | `devops-engineer` role |59| ML model, training pipeline, inference | `ml-engineer` role |60| Multiple stacks affected | Apply all relevant roles |61| Unknown / general | `software-engineer` role |6263Announce the applied role(s) to the user.6465## 4. Collect Evidence6667Gather all evidence into a structured collection. Combine data from Step 2 (environment analysis) with code-level investigation:6869<evidence_checklist>70- **Error output**: Full error message, stack trace, exit code71- **Logs**: Relevant log entries (timestamped) from the affected service72- **Reproduction**: Can you reproduce locally? Consistent or intermittent?73- **Scope**: Which endpoints / features / components are affected?74- **Timeline**: When did it start? What changed? (recent commits, deploys, config)75- **Data**: Specific inputs that trigger the bug (request payload, user ID, dataset)76- **Metrics** (if from prod): Error rate, latency change, affected user count77- **Related code**: Files, functions, lines most likely involved78</evidence_checklist>7980Use the applied role's debugging methodology to trace the bug:81- Read error stack traces to identify the failing code path82- Search codebase for related functions, error handlers, and data flows83- Check recent changes (`git log -n 20 --oneline`) for potential regressions84- Identify the **minimal reproduction case**8586## 5. Prepare Bug Report8788Compile findings into a structured bug report. Present to the user for review:8990```91## Bug Report9293### Summary94[One sentence: what is broken]9596### Severity: [P1 | P2 | P3 | P4]9798### Environment99- **Type**: [local | production]100- **Service**: [name]101- **Stack**: [detected] | **Role**: [applied]102103### Expected Behavior104[What should happen]105106### Actual Behavior107[What actually happens — include error messages]108109### Steps to Reproduce1101. [step]1112. [step]1123. [observed error]113114### Evidence115- **Stack trace**: [snippet or reference]116- **Logs**: [relevant entries]117- **Metrics**: [if applicable]118- **Affected code**: [file:line references]119120### Root Cause Analysis121[Technical explanation of why the bug occurs]122123### Affected Components124- [file/module 1] — [how it's affected]125- [file/module 2] — [how it's affected]126```127128Wait for user confirmation before proceeding to fix.129130## 6. Plan the Fix131132Create an ordered fix plan following the applied role's guidelines:1331341. **Root cause fix** — address the actual cause, not symptoms1352. **Complete fix** — fix everything described in the bug report. Do not leave cosmetic issues, lint warnings, or minor problems unfixed. Do not create follow-up tickets for things you can fix now1363. **Regression test** — test that would have caught this bug1374. **Related fixes** — any adjacent issues discovered during investigation. Fix them in the same changeset — do not increase tech debt138139Present the plan:140141```142## Fix Plan143144### Root Cause145[What caused the bug — one sentence]146147### Changes1481. [file] — [what to change and why]1492. [file] — [what to change and why]150...151152### Tests1531. [test file] — [test that reproduces and verifies the fix]1542. [test file] — [regression test for edge cases]155156### Risk Assessment157- **Blast radius**: [which features could be affected by this change]158- **Rollback**: [how to revert if the fix causes issues]159```160161Wait for user approval before implementing.162163## 7. Implement the Fix164165Execute the approved plan step by step.166167**For each change:**1681. State what you are about to do (file, change summary)1692. Implement the fix following the applied role's code quality standards1703. Verify the code compiles/parses without errors171172**Then write tests:**1731. **Regression test**: Reproduces the original bug — must fail without fix, pass with fix1742. **Edge case tests**: Cover related scenarios discovered during investigation1753. Run the full test suite to catch regressions176177**Rules:**178- Fix the root cause, not the symptom179- Fix EVERYTHING reported in the bug — do not leave non-blocking or cosmetic issues unfixed180- Fix all lint errors, style violations, and warnings introduced or exposed by the change181- Follow existing code patterns and conventions182- No new warnings or linter errors — and fix pre-existing ones in the affected files if trivial183- Do not defer fixes to "follow-up" tasks — complete the fix in this changeset184- Do not increase tech debt — if you touch it, leave it better than you found it185- If the fix is more complex than expected — stop and discuss with the user186- If you need more information about the environment, run specialized follow-up skills (`analyze-local` skill or `analyze-prod` skill) to collect it187188## 8. Self-Review the Fix189190Before declaring the bug fixed, perform a thorough self-review. Do NOT skip this step.191192**Code review checklist:**193- [ ] Re-read every changed file diff — verify correctness and completeness194- [ ] Every item from the bug report or user description is addressed — nothing left unfixed195- [ ] No cosmetic issues, lint warnings, or style violations remain in changed files196- [ ] No TODO, FIXME, or "will fix later" comments introduced197- [ ] No tech debt created — the code is clean and production-ready198- [ ] Run linter on all changed files — zero warnings199- [ ] Run formatter on all changed files — zero diffs200201If the self-review reveals any remaining issues — fix them before proceeding. Do not declare the bug fixed with known remaining problems.202203## 9. Verify the Fix204205Verify the bug is resolved in the appropriate environment:206207**For local bugs:**208- Run the reproduction steps — confirm the bug no longer occurs209- Run the full test suite — all tests pass (new + existing)210- If Docker-based: rebuild and verify with `analyze-local` skill (optional)211- If you need more data, run specialized follow-up skills for `analyze-local` skill to collect environment state212213**For production bugs:**214- Verify the fix locally first215- Deploy through normal CI/CD pipeline (do NOT hotfix production directly)216- After deploy: re-run relevant checks from `analyze-prod` skill to confirm resolution217- Monitor error rates and SLIs for regression218219**Verification checklist:**220- [ ] Original bug no longer reproduces221- [ ] ALL items from the bug report are fixed — not just the primary symptom222- [ ] Regression test passes223- [ ] Full test suite passes (no new failures)224- [ ] Linter passes with zero warnings on changed files225- [ ] No unrelated files modified226- [ ] Code follows project conventions and role guidelines227- [ ] No deferred work — everything is done in this changeset228229If any check fails — fix and re-verify. Do NOT declare the bug fixed until every checkbox passes.230231## 10. Summary232233Present the completed bugfix:234235- **Bug**: one-sentence summary236- **Severity**: P1–P4237- **Environment**: local / production238- **Role(s) applied**: which roles were used239- **Root cause**: technical explanation240- **Fix**: what was changed (files, brief description)241- **Tests added**: count and description242- **Self-review**: passed — all items verified243- **Verification**: how it was confirmed fixed244- **Remaining issues**: NONE (if any remain, go back and fix them before reporting)245- **Prevention**: recommendations to avoid similar bugs (e.g., add validation, improve error handling, add monitoring)246247## Integration248249- **follow-up skills**: `analyze-local` skill, `analyze-prod` skill (environment diagnostics — launch as specialized skills when more data is needed)250- **Follow-up**: `run-tests` skill (verify fix), `pre-commit` skill (quality gate), `create-pr` skill (submit fix)251- **Skills**: `code-review` skill (review fix), `test-strategy` skill (test strategy), `worktree-isolation` skill (branch isolation)