test-driven-development
The test-driven-development Claude Code skill enforces strict Test-Driven Development practices for feature implementation and bug fixes, requiring failing tests before production code and minimal code to pass tests in red-green-refactor cycles. Use this skill when TDD is explicitly requested, when working on medium-to-high complexity atomic tasks, or when addressing shared modules, contract changes, or core logic with regression risk.
git clone --depth 1 https://github.com/GanyuanRan/Aegis /tmp/test-driven-development && cp -r /tmp/test-driven-development/skills/test-driven-development ~/.claude/skills/test-driven-developmentSKILL.md
# Execute → False-positive entry on a native-direct-skill host? → **Exit immediately unless the user explicitly asked for TDD or the conversation already contains `TDD Route: strict`.** In `off` mode, do not start RED / GREEN / REFACTOR from generic bugfix, contract, shared-module, or risky-code wording alone. Hand control back to `using-aegis`, `systematic-debugging`, `writing-plans`, or the fast path with verification. → Implementing a feature or bugfix under TDD Route `strict`? → **No production code without a failing test first.** Gate: medium/high complexity? → route to brainstorming or writing-plans first. Mode: `auto` chooses strict/light/skipped by risk; `off` disables automatic TDD, not completion verification. Cycle: RED (write test → watch it fail) → GREEN (minimal code → watch it pass) → REFACTOR (clean up → keep green) Regression: shared module → related tests. contract change → producer + consumer. core logic → old + new tests. Ripple signal hit → cover producer+consumer or real user path before claiming green. GREEN proves the currently expressed behavior slice only. GREEN does not by itself prove parent-task acceptance, business-value completion, or final completion. → Done when: chosen TDD Route is recorded, strict-route tests pass, TDD preflight gate passed when applicable, pre-edit complexity risk was checked for non-trivial source edits, and `verification-before-completion` has fresh evidence. # Test-Driven Development (TDD) ## Overview Write the test first. Watch it fail. Write minimal code to pass. If you didn't watch the test fail, you don't know if it tests the right thing. TDD Mode has two values: `auto` and `off`. `auto` lets Aegis choose a `TDD Route`; `off` disables automatic TDD routing but never disables `verification-before-completion`. On native-direct-skill hosts, automatic entry must stay anchored to literal conversation markers such as `TDD Route: strict`, `strict TDD`, `test-first`, or `RED / GREEN / REFACTOR`, not generic risky-implementation wording. ## When to Use Only enter this skill after one of these explicit entry signals exists: - the user explicitly asks for strict TDD, test-first development, or RED / GREEN / REFACTOR - the current conversation already contains `TDD Route: strict` from another Aegis workflow Typical strict-route shapes once entry is already justified: new features, bug fixes, refactoring, behavior or logic changes, interface/data contract changes, cross-module or shared-module changes, and core logic refactors. Exceptions (ask your human partner): throwaway prototypes, generated code, config files, pure docs cleanup, read-only diagnosis, comment-only changes. ## TDD Mode and Route Before source edits, decide: ```text TDD Route: - Mode: auto | off - Decision: strict | light | skipped - Reason: - Verification: ``` In `auto`, use `strict` for behavior, bugfix, contract, shared/core, producer / consumer, persistence, permission, migration, or meaningful regression risk. Use `light` for tiny low-risk edits with an obvious readback or command check. Use `skipped` for read-only, docs-only, generated, throwaway, comment-only, or environment-bound work where TDD does not fit. In `off`, do not automatically require TDD. Explicit user/project TDD requests still apply, and risky work may still justify recommending strict TDD. `verification-before-completion` still applies before any completion claim. If this skill was loaded anyway without an explicit TDD request or a visible `TDD Route: strict` marker, exit instead of improvising an automatic strict route from risk words alone. ## Preflight Gate TDD is the implementation discipline for an approved behavior or atomic task. It is not a substitute for task routing, product clarification, or planning. Before writing tests or production code, stop and route to brainstorming or writing-plans if the current request has any medium- or high-complexity signal: - multiple files, modules, pages, screens, services, or owners - user-visible flows such as navigation, onboarding, checkout, lifecycle, or recovery paths - state transitions, routing rules, API or data contracts, compatibility boundaries, migrations, permissions, or persistence - more than one acceptance path or manual/visual verification requirement - unclear product behavior, competing constraints, or long-running execution For these tasks, require a baseline read-set, plan, and atomic tasks before TDD. High-complexity or ambiguous tasks also need a spec/design review before planning. Only proceed directly with TDD for low-complexity work whose intent, owner, compatibility boundary, verification path, and slice goal / success evidence are already clear. ## Complexity Budget Before strict TDD on non-trivial work, record the planned complexity budget so RED/GREEN does not silently normalize a wrong or overloaded owner. ```text Complexity Budget: - Artifact class: - Current pressure: - Projected post-change pressure: - Planned governance: ``` Use `using-aegis/references/complexity-governance.md` for shared artifact classes, pressure signals, and the meaning of planned governance. ## Pre-Edit Complexity Check Before production code edits, check whether the intended source edit would add logic to an overloaded or wrong owner. Tiny edits can keep this to one line. Use `using-aegis/references/complexity-governance.md` for shared pressure signals and the meaning of `over-budget`. ```text Pre-Edit Complexity Check: - Target edit file: - Existing pressure signal: - Owner fit: - Safer edit boundary: - Decision: edit-in-place | extract helper | add owner file | split task | pause for plan update ``` If the decision is `pause for plan update`, stop TDD and return to `writing-plans` or `brainstorming` with the evidence. If the predicted result is that this slice would push a maintained artifact over budget and the slice does not also govern that overrun, do not continue with RED/GREEN as if the t
|
Deprecated - use the aegis:brainstorming skill instead
Deprecated - use the aegis:executing-plans skill instead
Deprecated - use the aegis:writing-plans skill instead
Use when retiring old logic, collapsing duplicate owners, removing fallbacks, or touching schema, persistence, or source-of-truth boundaries while deciding whether to delete old paths, retain compatibility, or stop for confirmation.
Use when defining new features, product behavior, UI/component design, architecture choices, contract changes, or ambiguous medium/high-complexity work before implementation.
Use when the user asks for caveman mode, fewer tokens, brief responses, compressed communication, or otherwise explicitly requests a much shorter answer.
Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies