AGENT SKILL

fix-bug

Fix a bug using test-driven development. Use when the user reports a bug, describes unexpected behavior, wants to fix a defect, or says something is broken. Enforces a strict test-first workflow where a failing test must be written and verified before any fix is attempted.

License 许可
MIT
最近更新
2026-11-03
Stars
★ 68
Forks
4

01 前言 Front Matter

name
fix-bug
description
Fix a bug using test-driven development. Use when the user reports a bug, describes unexpected behavior, wants to fix a defect, or says something is broken. Enforces a strict test-first workflow where a failing test must be written and verified before any fix is attempted.
allowed-tools
Read, Grep, Glob, Edit, Write, Bash
argument-hint
[bug description]

02 资源文件 2

03 SKILL.md 正文

<!-- agent-pmo:795a9c2 -->

Bug Fix Skill — Test-First Workflow

You MUST follow this exact workflow. Do NOT skip steps. Do NOT fix the bug before writing a failing test.

Step 1: Understand the Bug

  • Read the bug description: $ARGUMENTS
  • Investigate the codebase to understand the relevant code
  • Identify the root cause (or narrow down candidates)
  • Summarize your understanding of the bug to the user before proceeding

Step 2: Write a Failing Test

  • Write a test that directly exercises the buggy behavior
  • The test must assert the correct/expected behavior — so it FAILS against the current broken code
  • The test name should clearly describe the bug (e.g., test_orange_color_not_applied_to_head)
  • Use the project's existing test framework and conventions

Step 3: Run the Test — Confirm It FAILS

  • Run ONLY the new test (not the full suite)
  • Verify the test FAILS and that it fails because of the bug, not for some other reason (typo, import error, wrong selector, etc.)
  • If the test passes: your test does not capture the bug. Go back to Step 2
  • If the test fails for the wrong reason: fix the test, not the code. Go back to Step 2
  • Repeat until the test fails specifically because of the bug

Step 4: Show Failure to User

  • Show the user the test code and the failure output
  • Explicitly ask: "This test fails because of the bug. Can you confirm this captures the issue before I fix it?"
  • STOP and WAIT for user acknowledgment before proceeding
  • Do NOT continue to Step 5 until the user confirms

Step 5: Fix the Bug

  • Make the minimum change needed to fix the bug
  • Do not refactor, clean up, or "improve" surrounding code
  • Do not change the test

Step 6: Run the Test — Confirm It PASSES

  • Run the new test again
  • Verify it PASSES
  • If it fails: go back to Step 5 and adjust the fix
  • Repeat until the test passes

Step 7: Run the Full Test Suite

  • Run ALL tests to make sure nothing else broke
  • If other tests fail: fix the regression without breaking the new test
  • Report the final result to the user

Rules

  • NEVER fix the bug before the failing test is written and confirmed
  • NEVER skip asking the user to acknowledge the test failure
  • NEVER modify the test to make it pass — modify the source code
  • If you cannot write a test for the bug, explain why and ask the user how to proceed
  • Keep the fix minimal — one bug, one fix, one test

04 同仓库更多 Skills

Nimblesite
Nimblesite/DataProvider

website-audit

Audits a website for SEO, AI search performance, structured data, mobile usability, broken links, and social media cards. Fixes issues found. Use when the user mentions "audit website", "SEO", "fix search ranking", "AI search", "structured data", "social media cards", or "website performance".

市场营销营销推广
★ 68
Nimblesite
Nimblesite/DataProvider

upgrade-packages

Upgrade all dependencies/packages to their latest versions for the detected language(s). Use when the user says "upgrade packages", "update dependencies", "bump versions", "update packages", or "upgrade deps".

★ 68
Nimblesite
Nimblesite/DataProvider

submit-pr

Creates a pull request with a well-structured description after verifying CI passes. Use when the user asks to submit, create, or open a pull request.

★ 68
Nimblesite
Nimblesite/DataProvider

spec-check

Audit spec/plan documents against the codebase. Ensures every spec section has implementing code, tests, and matching logic. Use when the user says "check specs", "spec audit", or "verify specs".

★ 68
Nimblesite
Nimblesite/DataProvider

fix-bug

Fix a bug using test-driven development. Use when the user reports a bug, describes unexpected behavior, wants to fix a defect, or says something is broken. Enforces a strict test-first workflow where a failing test must be written and verified before any fix is attempted.

★ 68
Nimblesite
Nimblesite/DataProvider

code-dedup

Searches for duplicate code, duplicate tests, and dead code, then safely merges or removes them. Use when the user says "deduplicate", "find duplicates", "remove dead code", "DRY up", or "code dedup". Requires test coverage — refuses to touch untested code.

开发工程师
★ 68