Agent Skillscbrock84/headcount › test-driven-development

test-driven-development

GitHub

指导通过先写失败测试再实现代码的TDD流程,用于功能开发、修复回归及重构,强调边界测试与最小化变更。

plugins/technology/skills/test-driven-development/SKILL.md cbrock84/headcount

Trigger Scenarios

新功能或bug修复前编写测试 需要添加回归测试时 现有代码难以安全修改时

Install

npx skills add cbrock84/headcount --skill test-driven-development -g -y
More Options

Non-standard path

npx skills add https://github.com/cbrock84/headcount/tree/main/plugins/technology/skills/test-driven-development -g -y

Use without installing

npx skills use cbrock84/headcount@test-driven-development

指定 Agent (Claude Code)

npx skills add cbrock84/headcount --skill test-driven-development -a claude-code -g -y

安装 repo 全部 skill

npx skills add cbrock84/headcount --all -g -y

预览 repo 内 skill

npx skills add cbrock84/headcount --list

SKILL.md

Frontmatter
{
    "name": "test-driven-development",
    "description": "Drives implementation by writing a failing test first, then the smallest code that passes it. Use this before writing implementation code for any feature or bugfix, when a bug needs a regression test, when existing code is hard to change safely, or when someone asks whether a change is covered. Also use to decide what is worth testing and what is not."
}

Test-driven development

The loop

  1. Red — write one test that fails for the right reason. Run it. A test that passes immediately is testing nothing; a test that errors instead of failing is testing the wrong thing.
  2. Green — the smallest change that makes it pass. Ugly is fine here.
  3. Refactor — clean up with the test green. If it goes red, you changed behavior, not structure.

Never skip step 1. Writing the test after the code produces a test shaped to the implementation, which is the one shape that cannot catch the implementation being wrong.

What to test

Test behavior at the boundary a caller actually depends on. For each unit ask: if this broke silently, who notices and how? If the answer is nobody, delete the code rather than test it.

  • Test: branching logic, boundary conditions, error paths, anything with a past bug, contracts between modules.
  • Do not test: getters, framework behavior, private helpers reachable only through a public path already covered, exact wording of log lines.

Bugs

Every bug gets a failing test before the fix, reproducing it at the smallest scope that shows it. That test is the proof the bug existed and the guard that it stays fixed. A fix without one is a claim.

Rules

  • One behavior per test. A test asserting five things tells you almost nothing when it fails.
  • The test name states the behavior, not the method: rejects_expired_token, not test_auth.
  • Never weaken an assertion to get green. If a test is inconvenient, the design is telling you something.
  • Never mock what you own — mock the network and the clock, not your own modules. Mocking your own code tests the mock.

Never

  • Write the test after the code and call it test-driven. You will test what you built rather than what was required.
  • Skip watching the test fail. A test that has never failed proves nothing.
  • Delete or skip a failing test to unblock a release. Fix it, or revert what broke it.
  • Treat a coverage number as the goal. It counts lines executed, not behavior pinned down.

Return contract

Report the tests added, what each pins down, what is deliberately untested and why, and the actual command you ran with its output. "Tests pass" without the command output is not a result.

Version History

  • d58a7ee Current 2026-09-02 21:11

Same Skill Collection

plugins/corporate-strategy/skills/chief-strategy-officer/SKILL.md
plugins/corporate-strategy/skills/market-entry/SKILL.md
plugins/corporate-strategy/skills/mergers-and-acquisitions/SKILL.md
plugins/corporate-strategy/skills/portfolio-strategy/SKILL.md
plugins/corporate-strategy/skills/scenario-planning/SKILL.md
plugins/corporate-strategy/skills/strategic-alliances/SKILL.md
plugins/customer-experience/skills/chief-customer-officer/SKILL.md
plugins/customer-experience/skills/customer-onboarding-and-implementation/SKILL.md
plugins/customer-experience/skills/customer-success-management/SKILL.md
plugins/customer-experience/skills/escalation-management/SKILL.md
plugins/customer-experience/skills/self-service-and-knowledge/SKILL.md
plugins/customer-experience/skills/support-operations/SKILL.md
plugins/customer-experience/skills/voice-of-customer/SKILL.md
plugins/data-analytics/skills/ai-ml-governance/SKILL.md
plugins/data-analytics/skills/business-intelligence/SKILL.md
plugins/data-analytics/skills/chief-data-officer/SKILL.md
plugins/data-analytics/skills/data-engineering/SKILL.md
plugins/data-analytics/skills/data-governance/SKILL.md
plugins/data-analytics/skills/data-modeling/SKILL.md
plugins/demand-generation/skills/ai-search-optimization/SKILL.md
plugins/demand-generation/skills/app-store-optimization/SKILL.md
plugins/demand-generation/skills/experimentation/SKILL.md
plugins/demand-generation/skills/landing-page-cro-expert/SKILL.md
plugins/demand-generation/skills/lead-capture/SKILL.md
plugins/demand-generation/skills/lifecycle-messaging/SKILL.md
plugins/demand-generation/skills/listing-distribution/SKILL.md
plugins/demand-generation/skills/marketing-analytics/SKILL.md
plugins/demand-generation/skills/paid-advertising/SKILL.md
plugins/demand-generation/skills/programmatic-seo/SKILL.md
plugins/demand-generation/skills/seo-strategy/SKILL.md
plugins/executive/skills/ai-research-analyst/SKILL.md
plugins/executive/skills/business-growth-consultant/SKILL.md
plugins/executive/skills/chief-executive/SKILL.md
plugins/executive/skills/fundraising-and-investor-relations/SKILL.md
plugins/executive/skills/saas-idea-validator/SKILL.md
plugins/finance/skills/budgeting-and-forecasting/SKILL.md
plugins/finance/skills/capital-allocation/SKILL.md
plugins/finance/skills/capital-structure-and-covenants/SKILL.md
plugins/finance/skills/cost-accounting/SKILL.md
plugins/finance/skills/financial-modeling/SKILL.md
plugins/finance/skills/financial-reporting-and-close/SKILL.md
plugins/finance/skills/financial-statement-analysis/SKILL.md
plugins/finance/skills/internal-controls-and-audit/SKILL.md
plugins/finance/skills/revenue-recognition/SKILL.md
plugins/finance/skills/tax/SKILL.md
plugins/finance/skills/treasury-and-liquidity/SKILL.md
plugins/finance/skills/unit-economics/SKILL.md
plugins/it-operations/skills/backup-and-recovery/SKILL.md
plugins/it-operations/skills/chief-information-officer/SKILL.md
plugins/it-operations/skills/cloud-administration/SKILL.md

Metadata

Files
0
Version
d58a7ee
Hash
11c5bb96
Indexed
2026-09-02 21:11

trang chủ - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-04 14:58
浙ICP备14020137号-1 $bản đồ khách truy cập$