Get the FREE Ultimate OpenClaw Setup Guide →

better-bug-fix

npx machina-cli add skill saadjs/agent-skills/better-bug-fix --openclaw
Files (1)
SKILL.md
2.2 KB

Better Bug Fix

Follow a test-first debugging workflow that proves the bug and validates the fix.

Workflow

  1. Triage and scope the bug.

    • Restate the symptom and expected behavior in one sentence.
    • Identify the affected area (files, module, API, UI).
  2. Write a minimal failing test first.

    • Add the smallest test that reproduces the bug.
    • Prefer existing test frameworks and patterns in the repo.
    • If no tests exist, create a minimal repro harness as close as possible to existing structure.
  3. Run tests to confirm failure.

    • Execute the narrowest test command that includes the new test.
    • Record the failing output or error signature.
  4. Delegate fixes to subagents.

    • Spawn 2-3 subagents with clear ownership of investigation/fix ideas.
    • Ask each to propose a fix and the rationale, referencing the failing test.
    • Keep their scopes non-overlapping (e.g., data flow, edge cases, API contract).
  5. Implement the best fix.

    • Apply the most plausible fix based on test and codebase conventions.
    • Keep the change minimal and focused on the bug.
  6. Prove the fix.

    • Re-run the failing test(s) and any relevant nearby tests.
    • Ensure the new test passes and no regressions are introduced.
  7. Report clearly.

    • Explain the root cause, the test added, and why the fix works.
    • Call out any remaining risks or follow-ups.

Guardrails

  • Do not attempt a fix before a reproducing test exists.
  • If a test cannot be written, explicitly explain why and propose the closest alternative (repro script or manual steps).
  • Avoid refactors unless necessary to make the test feasible.
  • Keep changes small; prefer surgical fixes.

Subagent Prompt Template

Use this template when spawning subagents:

"""

You are a subagent investigating a bug. The reproducing test is failing. Please:

  1. Identify the likely root cause in the code.
  2. Propose a minimal fix.
  3. Note any tradeoffs or additional tests to add.

Stay within your assigned scope.

"""

Source

git clone https://github.com/saadjs/agent-skills/blob/main/skills/better-bug-fix/SKILL.mdView on GitHub

Overview

Better Bug Fix provides a test-first debugging workflow for bug resolution. It starts by writing a minimal failing test that reproduces the bug, then uses 2-3 subagents to propose fixes and validates them with passing tests. The process ends with a clear report of root cause, the test added, and any follow-ups.

How This Skill Works

The workflow triages the bug and scopes the affected area, then writes the smallest failing test that reproduces it. It then delegates fixes to 2-3 non overlapping subagents who propose fixes with rationale. Finally the engineer implements the best fix and re runs the relevant tests to prove the bug is resolved.

When to Use It

  • When a user reports a bug in the system
  • When asked to fix a bug in the codebase
  • When you want a regression test added first
  • When you need input from multiple investigators via subagents
  • When you must keep changes surgical and avoid major refactors

Quick Start

  1. Step 1: Triage the reported bug and restate the symptom in one sentence
  2. Step 2: Write the smallest failing test that reproduces the bug
  3. Step 3: Run the tests, spawn 2-3 subagents to propose fixes, implement the best one, and prove the fix

Best Practices

  • Triage and restate the symptom in one sentence
  • Write the smallest failing test that reproduces the bug
  • Run the narrowest test command to observe failure
  • Delegate to 2-3 subagents with distinct scopes
  • Keep changes minimal and verify with re run tests

Example Use Cases

  • Root cause a failing API response demonstrated by a minimal failing test
  • Fix a race condition revealed by a failing test and targeted changes
  • Add a regression test for a UI bug and verify with a surgical fix
  • Resolve a broken data transformation by a focused code change
  • Address a flaky test by isolating the repro and validating with nearby tests

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers