/skraft:outside-in-tddfrom skraft
Drives outside-in / double-loop TDD: turns an approved scenario into working software via an acceptance test first, trustworthy RED before implementation, and domain logic emerging from failing behaviour. Finishes with wiring verification and mutation gates.
Ships in skraft. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Turns an approved scenario into working software. Start from observable behavior at the application boundary, get trustworthy failure first, then let design emerge from failing tests.
Core rule: real domain objects, mocked external boundaries, fast in-memory tests. Hard rule: no implementation code before RED is a clean behavior failure.
This skill never decides what the expected result should be.
Before entering any phase below, confirm the behaviour has an approved observable outcome — a Gherkin scenario, a worked example, an agreed expected value. When it does not:
bdd-methodology owns that conversation. Re-enter here once it has an answer.An unapproved outcome driven out through a clean cycle still yields a suite that proves only that the code matches a guess.
It owns SEQUENCE: what must be true before the next phase may start, and what evidence proves it, and which production layer a business rule's code lands in. Everything else is delegated — load the owner rather than re-deriving its rules here.
| Question | Owner |
|---|---|
| What the observable behaviour IS, and whether it is approved | bdd-methodology |
| Which test project, which test layer, which double | clean-architecture-testing |
| Whether a domain test is authorized; coverage matrix; walking-skeleton strategy A–D | test-design-mandates |
Survivor classification after a developer's /skraft-mutation run | mutation-testing |
| Commit-time self-check | craft-discipline |
| Cleaning up test code that already passes | test-refactoring-catalog |
| Phase order, entry evidence, the outer→inner handoff, and which production layer a rule's code lands in | this skill |
A loading agent descriptor owns MODE — interactivity, thresholds, and what its dispatch payload carries. Where the two disagree, the descriptor wins on mode and this skill wins on sequence. A rule here that names a mode (pause and ask, a mutation percentage, how big one increment is) describes the common case; it does not override the descriptor that loads it.
Outer drives WHAT to build, inner drives HOW. Never build a class not required by an active scenario.
The inner cycle is 2 steps, not 3: RED (behavior failure) → SYNTHESIZE GREEN (clean synthesis). There is no dirty-then-refactor step.
Identify the input boundary (use case / interactor the test enters through) and the output boundaries (gateways the test observes: repositories, presenters, external services). Target exactly ONE scenario.
Boundary-to-Boundary Testing below defines what counts as a boundary at each test level, and what
must never be tested directly. clean-architecture-testing maps each level to its project and
doubles.
Write the failing test. Run it.
Programming by Wishful Thinking: when your test won't compile, you're discovering the API you need. Stub just enough to compile, then confirm the test fails on behavior.
Any assertion designed to fail unconditionally makes the test compile and fail, but asserts
nothing about the API under test. It produces false RED evidence, in every language.
craft-discipline C5 enumerates them; throw new NotImplementedException() is the one that
matters here, because it is the most tempting way to satisfy step 2 below.
A proper wishful-thinking test calls the function you WISH existed and lets the build or runtime surface the failure naturally:
NEVER insert a placeholder assertion, including as the stub in step 2. craft-discipline C5 owns
the list and enforces it at commit time.
Hard rule: this checkpoint is not skippable. Do not proceed to SYNTHESIZE GREEN without it.
The invariant: the failing test is inspected — by someone other than whoever is about to write the implementation — before any production code exists. What is inspected is the RED output itself, never a promise that it exists.
Who inspects, and how, is MODE.
test commit
before any production code of that scenario exists; no RED run is captured. Each inner unit
test's red is run and read. Continue to SYNTHESIZE GREEN in the same dispatch — never stop after
RED to wait for an inspection. The DELIVER reviewer's test-integrity lens inspects every test
commit against the test plan.In every mode, no implementation is written until the inspection — or, in SKRAFT DELIVER, the
scenario's test commit — exists.
Orient design before synthesis: which pattern (specification, factory, builder), which layer owns the logic, immutability and return values vs mutations.
Name the owner in writing, once per rule, before its implementation is written. State the type that will hold the rule and the layer it lives in, then check that answer against When to Write Which below. "The use case computes it" is valid only for orchestration or a simple rule.
Implement the smallest slice the failing test demands — and implement it clean the first time.
"Clean synthesis" constrains the QUALITY of the first draft, not its SCOPE. Complete means complete for THIS test: no speculative branches, no unrequested error handling, no abstraction the test does not force. Gold-plating here contradicts the Walking Skeleton rule and is what a descriptor means by "minimal production code".
No iteration after SYNTHESIZE GREEN unless RED was wrong or architectural guidance changed. Refining code instead of revising RED means you are back in 3-step TDD — stop and restart.
test-design-mandates Mandate 4 opens
a gate for, or a case no example of the scenario reaches.craft-discipline C11). Rows of two rules never share a RED.git diff --name-only (step 1 of
Post-GREEN Wiring Verification); its other steps and the Object Calisthenics rules
(craft-discipline C10) run once on the scenario's whole diff, before its commit.| Stack | One test | Its project or module | Quiet, failures only |
|---|---|---|---|
| .NET | dotnet test <test project> --filter "FullyQualifiedName~<Class>.<Method>" | dotnet test <test project> | --verbosity quiet |
| Java, Maven | mvn -q test -Dtest=<Class>#<method> (-pl <module> in a multi-module build) | mvn -q test -pl <module> | -q |
| Java, Gradle | gradle test --tests "<Class>.<method>" (:<module>:test) | gradle :<module>:test | -q |
| TypeScript, Vitest | npx vitest run <file> -t "<name>" | npx vitest run <folder> | --reporter=dot |
| Python, pytest | pytest <file>::<test> | pytest <folder> | -q |
Pending excluded — every test but the acceptance tests of scenarios not delivered yet, by the
scenario id that starts each acceptance test's name (S5_…, test_s5_…): .NET
--filter "FullyQualifiedName!~S5_&FullyQualifiedName!~S6_"; Maven -Dtest='!*S5_*,!*S6_*';
Vitest -t "^(?!.*\b[Ss](5|6)_)"; pytest -k "not s5_ and not s6_". A runner that only
includes (Gradle --tests) lists the delivered scenarios' ids and the unit tests instead.
The stack's test command from the stack-commands file stays the command of record: add only the filter and the verbosity to it, never replace it with another runner.
craft-discipline C9. A red is never chained to a commit; the
only red commit is the story's test commit.What a run commits, by pass. The test command's output tells a failing assertion from a build error only when read: a red is never chained to a commit; a green is.
| Pass | Commits |
|---|---|
| Acceptance tests of the story (skraft DISTILL) | One test commit: every scenario's acceptance test and the skeleton they call, after one run whose output shows each failing on a business assertion, formatted and linted before the commit |
| Scenario in progress (skraft DELIVER) | The inner cycles commit nothing. One feat or fix commit once the scenario passes, its unit tests and every format or lint fix included, chained so it commits only when the run passes: <test command, pending scenarios excluded> && git add <each file> && git commit -s -m "<subject>" -m "Refs: #N" |
| No scenario: gates or review sent the story back, a session without skraft | Each cycle: feat or fix with its test and the code, once green; refactor for a change under green |
| Review asks for a stronger test, no behavior change | One test commit, never a RED→GREEN cycle: it adds assertions or cases to existing tests and never removes or rewrites a line. A stricter assertion that must replace an existing one carries PLAN_DEVIATION: <old assertion> → <new assertion> in the commit body, one line per replacement |
The acceptance tests of a scenario are its oracle: the green never changes them. A wrong one is named and sent back to whoever wrote it.
| Phase | What | Success Criteria |
|---|---|---|
| PREPARE | Name the input and output boundaries, pick ONE scenario | The scenario under test is unambiguous |
| RED | Write test, stub until it compiles, run | Test fails on behavior (assertion), not compilation |
| Guidance (MANDATORY) | Orient the approach, name the type and layer that will own the rule, + the failing test is inspected | Owning type and layer stated before the implementation is written, the RED output has been seen by someone other than its implementer |
| SYNTHESIZE GREEN | Synthesize the smallest slice the test demands, clean the first time | Tests green, architecture respected, nothing built the test did not force |
| COMMIT & VERIFY | Wiring verification, mutation gate, commit | Production files in the diff, mutation gate run and its survivors resolved, red only in a scenario's test commit |
| Excuse | Reality |
|---|---|
| "Compilation error IS red" | No. Compilation = wishful thinking. RED = behavior failure. |
| "I'll write dirty code then refactor" | That's 3-step TDD. SYNTHESIZE GREEN produces clean code. |
| "I can skip RED, I know it'll fail" | Run it. RED proves your test catches real failures. |
| "The placeholder fails, so it's RED" | No. A placeholder asserts nothing about the API (craft-discipline C5). Write the real call; let the missing symbol cause a compile error, then stub past it. |
| "All the tests pass, so the design is fine" | Green proves behavior, never placement. A tier table living in the handler passes every test and is still in the wrong layer. |
Any of these mean: Delete the code, start over with a proper RED.
NEVER modify a failing test to make it pass — fix the implementation. If stuck after 3 attempts: revert to last green, escalate.
A test modified to turn green is theater: it no longer witnesses behavior.
Every test enters through an input boundary (use case / interactor) and asserts at output boundaries (gateways) or on the return value. Internal classes (entities, value objects, domain services) are exercised indirectly — never instantiated directly in test code.
| Test level | Input boundary | Output observation |
|---|---|---|
| Acceptance | Use case / interactor (application handler) | Gateway mocked (repository, email…) or use-case output DTO |
| Unit (domain function) | The public function signature (its contract IS the boundary) | Return value |
| Integration (gateway adapter) | Gateway contract | Real infrastructure (DB, filesystem, subprocess) |
Unit tests are NOT "isolated object tests." They are boundary-to-boundary at a smaller scope. Testing a pure domain function by calling it directly IS boundary-to-boundary — the function's public signature is the contract under test.
Do not test directly: basic constructors (unless they enforce complex invariants), simple getters/setters, or DTOs and passive data structures. Simple value objects are covered by their use in policies and orchestrators.
Every row answers two questions. Answering only the test question is how a rule ends up living in an orchestrator.
| Signal | Code lives in | Test that covers it |
|---|---|---|
| Orchestration (load/save/publish, no rule) | Application use case / handler | Use Case test (Acceptance) |
| Simple rule: one condition, no edge-case matrix | Application use case / handler | Already covered by primary Use Case test |
| Rule over an aggregate's own state | Method on the Domain entity / aggregate | Use Case test (Acceptance) |
| Complex invariants, large edge-case matrices, or reused rules | A NEW named type in the Domain project (architecture-patterns picks Policy vs Domain Service vs Specification) | Use Case test (Acceptance); add a Domain test only if test-design-mandates Mandate 4 opens a gate |
"Complex" is not a judgement call: tiers or bands, a cap or a floor, rounding, or three or more worked examples of one calculation put you on the last row. Classify the whole approved rule as the feature states it, not the delta of the slice you are on.
Whichever row you land on, the handler holds no arithmetic and no branch of the rule beyond the simple-rule row: it passes the inputs to the Domain type and returns what comes back. A Domain type that carries the tier rate while the handler keeps the bands and the cap is the same failure, half done. Placement never depends on whether a Domain test is authorized: an unauthorized Domain test means the Use Case test covers the type, never that the rule moves back into the handler.
Default: Start with a Use Case test. Add Domain tests only if extracting a complex rule makes testing simpler.
Placement is not permission to design upfront: the Domain type still appears only when a failing test demands it (Step 2). When a rule has meaningful edge-case combinations, cover those combinations explicitly in Domain tests.
Prerequisite: Gherkin scenarios written and approved before this skill applies — for new
features, bug fixes, and behavior-changing refactoring. bdd-methodology defines WHAT the
observable behavior is; this skill turns it into working software.
Translate the scenario to a top-level acceptance-style test entering at the Application boundary. Mock only external boundaries; use real domain objects.
STOP. Do NOT create any domain class, value object, entity, policy, or enum before your first test fails to compile. Design MUST emerge from red — not from upfront thinking. Even if you already know the domain from context, create nothing until the test's compilation failure confirms what's needed. This includes adding 'just a new variant' of something that already exists: a new vehicle type, a new rejection reason, a new value object field, or a new boundary value — even if similar ones already exist in the codebase. Wait for the test's compilation failure before creating the new type.
The bar is a failing test, not a failing test that already names the type. For a last-row rule in When to Write Which, the RED you already have is the one that authorizes the Domain type.
Placeholder test bodies are the same failure mode — see Placeholder assertions are NOT wishful thinking above.
Step 1 after every GREEN; steps 2 to 4 once per scenario, after the whole suite turns green and BEFORE its commit:
git diff --name-only. Every production file the behavior required MUST appear in the diff.git diff --name-only. If an Application file gained a rate, threshold, cap,
or rounding computation and no Domain file was added or changed, the policy is in the orchestrator.
BLOCK the commit and move it. Moving misplaced code is not the forbidden post-GREEN iteration: the
acceptance test does not change and stays green throughout.This skill owns when the gate runs and what evidence closes it. skraft-quality-bar owns
the numbers, and no setting lowers them.
Code you cannot cover is code no approved behavior asked for — delete it rather than lower the bar.
The coverage run happens once, after the story's last work commit, and only it closes the gate. If the gate has not run, the work is not complete — that is sequence, and it holds for every change.
Mutation never runs in the delivery, inside a cycle or after it: G6 is recorded not_run, and
the developer runs /skraft-mutation.
ONE walking skeleton at a time. A feature has several — test-design-mandates sizes them at
2–5, one per major flow variant, and picks each one's strategy (A/B/C/D) — but you drive one to GREEN
before starting the next. Two skeletons RED at once is the Concentric Circle ordering rule broken at
the skeleton level: two incomplete end-to-end paths, neither of them evidence.
This skill decides in what order you take them and what "done" means for one:
The double loop (acceptance + domain unit tests) is the inner circle. Once it is GREEN for a behavior slice, expand outward — one circle at a time.
| Phase | What to write | Prerequisite |
|---|---|---|
| 1 — Inner (double loop) | Acceptance test at the application boundary + domain unit tests | none — always first |
| 2 — API circle | Integration test at the transport boundary (in-process host, real entry point) | Phase 1 GREEN |
| 3 — Infrastructure circle | Integration test at the persistence / broker / external adapter boundary | Phase 2 GREEN |
Ordering rule: never start Phase N+1 while Phase N is RED. Expanding outward while the inner loop is still RED hides the root cause under outer-circle complexity and produces untraceable failures.
For test project placement and folder naming conventions, see clean-architecture-testing.
The story's scenarios are written as executable acceptance tests together, committed red in one
test commit, then made green one scenario at a time. No [Skip], no [Ignore], nothing disabled
(craft-discipline C5): a pending scenario stays an active, failing test.
.feature (skraft: the acceptance-designer, in
DISTILL; the software-engineer never writes one), values copied verbatim, each test's name starting with its scenario id and an underscore
(S4_WelcomeFiveTakesFiveEuros, test_s4_welcome_five…) — a name every runner filters on, with the skeleton signatures they compile against and no behavior.test commit. One command: the run and the
commit never wait on each other's turn when the output was already read.&& git add … && git commit -m "feat(feature): <rule> S4–S7".Every green commit leaves the delivered scenarios and every other test green; only the acceptance tests of scenarios not delivered yet are red.
Scope: an orchestrator that dispatches individual TDD slices. The SKRAFT orchestrator dispatches a
whole story to the software engineer, whose RED inspection is the scenario's test commit (see
Between RED and GREEN); it never splits RED and GREEN into two dispatches.
If you dispatch subagents to carry out a TDD slice — whatever the orchestration mechanism:
NEVER put RED and SYNTHESIZE GREEN in the same subagent prompt.
Split every TDD task into two separate dispatches:
The inspection checkpoint is the orchestrator's responsibility. It cannot be delegated to the subagent that will implement the result — that is the entire point of splitting the dispatch.
You are violating this rule if your subagent prompt contains both "write the failing test" AND
"implement the solution", or you wrote PAUSE in a plan comment but included all steps in one
prompt, or you assumed the developer would confirm via the plan document. Plans are documentation;
dispatch boundaries are enforcement. Subagents execute what they receive — split the prompt. And
efficiency that skips developer validation is not efficiency: one-shot dispatch is not a shortcut
worth taking.
| Mistake | Fix |
|---|---|
| Mocking domain objects in acceptance tests | Use real domain objects, mock only external boundaries |
| Designing domain objects upfront | Let domain emerge from test failures — don't design before testing |
| Treating compilation errors as RED | Stub to compile, then confirm failure on a business assertion |
| Placeholder assertion standing in for a real one | Call the API you wish existed; let the missing symbol fail the build |
| Committing when only test files changed | Post-GREEN verification via git diff --name-only |
| Modifying a failing test to pass | Iron Rule violation — fix the implementation or revert |
| Skipping the architectural guidance checkpoint | The failing test is inspected before any implementation is written |
| Writing every acceptance test up front and skipping all but one | Author one acceptance test per slice — a skipped test is a false green |
| Skipping Gherkin ("too small") | Even small features benefit from behavior-first thinking |
| Polluting Gherkin with class/endpoint names | Keep scenarios in business language only |
| Testing data structures directly by default | Test policies/rules; data types are covered by usage |
bdd-methodology defines WHAT → this skill drives RED → inspection → SYNTHESIZE-GREEN →
craft-discipline is the commit-time self-check; mutation-testing serves the developer's
/skraft-mutation runs. See What this skill owns for the full delegation map, and pair with domain-specific
testing skills for patterns and examples.
assets/CommandHandlerTestTemplate.cs (opens in a new tab)assets/QueryHandlerTestTemplate.cs (opens in a new tab)references/cqrs-patterns.md (opens in a new tab)references/outer-loop.md (opens in a new tab)references/test-examples.md (opens in a new tab)references/testing-strategy.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
tdd, outside-in, double-loop, acceptance-test, behavior-driven
npx claudepluginhub sebastiendegodez/skraft-plugin --plugin skraft44 skills in this plugin
/acceptance-review-criteriaUse when reviewing DISTILL artefacts (Gherkin scenarios, test plans, implementation plans) for quality, completeness, and alignment. Contains the gate definitions and scoring rubric for the acceptance-designer-reviewer lenses./adr-eligibility-gateUse when deciding WHETHER a candidate architectural choice deserves an architecture decision record, before any record is drafted: a story enters DESIGN with a list of candidate choices, a reviewer flags ADR inflation, or someone asks "should I write an ADR for X?", "how many ADRs does this story need?", "is this ADR-worthy?", "this feels like too many ADRs", "disambiguate baseline from decision". Runs a baseline-vs-decision gate over each candidate and returns ELIGIBLE or NOT ELIGIBLE with the baseline, convention or architecture test that already covers it. Do NOT use when the decision is already settled and the user asks for the record to be written, when the request is about the ADR template, status transitions, superseding or lifecycle, or when the question is which pattern to adopt — those belong to architecture-decisions and architecture-patterns.
/adversarial-review-lensesUse when reviewing a phase artifact — a discovery brief, a plan, a design, an acceptance specification, or a slice reported as delivered — and the review has to end in a defensible pass-or-block verdict rather than a list of remarks. Covers judging whether the artifact covers everything that fed into it, whether it matches the business intent, whether it holds together internally, and what it puts at risk downstream, then weighing those into a single call. Not for routine code review of an ordinary change.Other plugins' skills for the same job