fix-bug
Systematic bug investigation, resolution, and documentation. Use when fixing bugs that need thorough analysis, test coverage, and a formal bugfix report. Applies systematic debugging methodology, creates regression tests, and generates a standardized report in specs/bugfixes/<bug-name>/. For complex bugs, spawns competing implementation agents (including alternative harnesses like Kiro) and selects the best solution. Triggers on requests like "fix this bug", "debug and document this issue", or when a bug needs both resolution and documentation.
What this skill does
# Bug Fix Workflow
Fix bugs systematically while ensuring proper test coverage and documentation. Simple bugs are fixed directly; complex bugs get multiple competing implementations to find the best solution.
## Transit Integration
If a `T-[number]` ticket is mentioned (e.g., `T-42`), track it throughout the workflow:
- Extract the display ID from the reference
- Automatically create a branch named `T-{number}/bugfix-{bug-name}` (no user prompt needed)
- Move the ticket to `in-progress` status after branch creation. Add a comment: "Starting bugfix — investigating on branch T-{number}/bugfix-{bug-name}"
- Move the ticket to `ready-for-review` status after the PR is created. Add a comment: "Fix ready for review — PR #{pr-number}"
Use `mcp__transit__update_task_status` with the display ID to update status. Always include a comment when changing status.
If no Transit ticket is mentioned, skip all Transit-related steps.
## Workflow
### 1. Bug Name
Determine a concise, descriptive bug name (kebab-case) for the report directory. Derive from the issue description or ask the user if unclear.
### 2. Branch Creation
**When a Transit ticket is present:** If the current branch already matches `T-{number}/bugfix-*` (e.g., in a worktree), skip branch creation. Otherwise, automatically create a branch named `T-{number}/bugfix-{bug-name}` and switch to it. Do not ask for permission. Move the ticket to `in-progress` status.
**When no Transit ticket is present:** Use AskUserQuestion to offer branch naming options:
- `bugfix/{bug-name}` - Standard bugfix branch
- Skip branch creation
### 3. Systematic Investigation
Invoke the `systematic-debugger` skill to perform structured root cause analysis:
- Phase 1: Initial Overview (problem statement)
- Phase 2: Systematic Inspection (identify defects)
- Phase 3: Root Cause Analysis (Five Whys)
- Phase 4: Solution & Verification (proposed fixes)
Capture findings for the bugfix report.
### 4. Create Regression Tests
Before implementing the fix, write tests that prove the bug exists:
1. Write one or more failing tests that reproduce the bug
2. Run the tests to confirm they fail as expected — this is the "red" in red/green TDD
3. These tests become the acceptance criteria: the bug is fixed when they pass
The tests should:
- Be minimal and focused on the specific bug
- Include a descriptive name referencing the bug
- Document the expected vs actual behaviour in comments
Do not implement the fix yet. The tests must fail at this point.
### 5. Generate Initial Bugfix Report
Create `specs/bugfixes/<bug-name>/report.md` using the template in `references/report-template.md`. At this stage the "Resolution" section will be empty — it gets filled in after the fix is implemented.
### 6. Commit Investigation Checkpoint
Commit everything so far (failing tests + report + any investigation artifacts) using the `/commit` skill. This creates a clean baseline that competing implementations can branch from.
The commit message should indicate this is the investigation phase, e.g.: `T-42: Add investigation report and failing regression tests for {bug-name}`
### 7. Assess Difficulty
Evaluate the bug's complexity based on the investigation findings. Consider:
- **Number of files affected** — single file vs cross-cutting changes
- **Root cause clarity** — straightforward logic error vs subtle interaction
- **Risk of side effects** — isolated change vs changes near critical paths
- **Multiple valid approaches** — one obvious fix vs several plausible strategies
**Simple bugs** (single clear fix, low risk, few files): proceed to Step 8A.
**Complex bugs** (multiple possible approaches, higher risk, cross-cutting, or subtle root cause): proceed to Step 8B.
When in doubt, prefer the complex path — the overhead is small and you get better solutions compared to the risk of a naive fix for something subtle.
### 8A. Simple Fix (Direct Implementation)
For straightforward bugs:
1. Implement the fix
2. Run the regression tests to confirm they now pass (the "green")
3. Run the full test suite to ensure no breakage
4. Run linters/validators as per project conventions
5. Skip to Step 10.
### 8B. Complex Fix (Competing Implementations)
For complex bugs, spawn multiple agents that independently implement the fix. Each agent works in an isolated worktree branched from the current commit (which has the failing tests).
#### 8B.1 Prepare Implementation Brief
Write a concise implementation brief that all agents receive. Include:
- The root cause from the investigation (Phase 3 findings)
- The proposed solution(s) from Phase 4
- Paths to the failing test files so agents can verify their fix
- The project's test/lint commands (from Makefile or project conventions)
- Any constraints or areas to avoid
#### 8B.2 Spawn Competing Agents
Launch 3 agents in parallel, each in its own worktree. Use the exact tools specified below — do not substitute different tools or MCP agents for Agents 1 and 2.
**Agent 1 — Primary approach:** Call the **Agent tool** (not an MCP tool) with `isolation: "worktree"` and `subagent_type: "general-purpose"`. This spawns a Claude subagent in an isolated git worktree. Prompt it to implement the fix following the primary approach from the investigation's Phase 4.
**Agent 2 — Alternative approach:** Call the **Agent tool** (not an MCP tool) with `isolation: "worktree"` and `subagent_type: "general-purpose"`. This spawns a Claude subagent in an isolated git worktree. Prompt it to implement the fix using an alternative strategy — if Phase 4 identified alternatives, use one; otherwise instruct it to find its own approach that differs from Agent 1's.
**Agent 3 — Kiro (independent perspective):** This is the only agent that uses an MCP tool. Call `mcp__devtools__kiro-agent` with `agent: "kiro"` and `yolo-mode: true`. The `agent: "kiro"` parameter gives Kiro access to all its skills rather than just the default agent. Since Kiro operates in the current working directory, first create a worktree manually for it:
```bash
git worktree add ../{repo-name}-worktrees/fix-{bug-name}-kiro -b fix-{bug-name}-kiro HEAD
```
Then pass a prompt that includes the implementation brief and instructs Kiro to work in the worktree directory, implement the fix, run the regression tests, and run the full test suite.
To be explicit: Agents 1 and 2 use the Agent tool (subagent_type: "general-purpose", isolation: "worktree"). Only Agent 3 uses mcp__devtools__kiro-agent. Do not use mcp__devtools__codex-agent, mcp__devtools__gemini-agent, or any other MCP agent tool for Agents 1 and 2.
Each agent's prompt should follow this structure:
```
You are implementing a fix for a bug. Work in {worktree_path}.
## Bug Summary
{root cause from investigation}
## Your Approach
{specific approach for this agent}
## Failing Tests
The following tests reproduce the bug and must pass after your fix:
{test file paths and how to run them}
## Requirements
1. Implement the fix
2. Run the regression tests — they must pass
3. Run the full test suite — no regressions allowed
4. Run linters/validators: {lint commands}
5. Commit your changes with a descriptive message
```
#### 8B.3 Compare Solutions
After all agents complete, evaluate each solution. Read the diffs and test results from each worktree.
**Evaluation criteria** (in priority order):
1. **Correctness** — do the regression tests pass? Does the full test suite pass?
2. **Minimality** — fewer changed lines and files is better, all else being equal
3. **Code quality** — readable, follows project conventions, no hacks or workarounds
4. **Safety** — low risk of side effects, no changes to unrelated code
5. **Maintainability** — would a future developer understand this change easily?
Disqualify any solution where:
- The regression tests don't pass
- The full test suite has new failures
- Linting errors were introduced
If all solutions are disqualified, fall back to Step 8A (implement directly using the best partial sRelated in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.