Implement a Service
The failure mode this prevents is a large, plausible, unreviewable diff. Code arrives in layers,
each validated against the principles before it is shown, each small enough that a human can
actually read it.
Required Skills
Read and apply:
clean-architecture — layer placement and dependency direction for every file. (always)
test-strategy — every component ships with tests at the right level. (always)
collaborative-judgment — deviations and trade-offs are surfaced, not absorbed. (always)
domain-modelling — aggregates, entities, value objects, where behaviour lives. (conditional:
domain types)
data-access — repositories, queries, transactions, migrations, caches. (conditional:
persistence)
cqrs-and-consistency — read models and projections. (conditional: a separate read path)
infrastructure-adapters — ports, clients, consumers, publishers, SDK wrappers. (conditional:
the adapter layer)
resilience-patterns — timeouts, retries, breakers, outbox. (conditional: any call leaving the
process, any message handler)
idempotency-and-immutability — retry safety and shared state. (conditional: retryable
operations, message handlers, value types)
secure-service — authorisation, validation, secrets, output hygiene. (conditional: any trust
boundary — handlers, clients, queries, anything touching credentials or personal data)
api-contracts — the shape of anything crossing a boundary. (conditional: endpoints, schemas,
published events)
api-protocols — protocol-specific craft. (conditional: GraphQL, gRPC, WebSocket or SSE)
config-and-dependencies — settings, flags, new libraries. (conditional: config or dependency
changes)
contract-testing — cross-service agreement. (conditional: an integration with another service)
Workflow
Step 1 — Establish the ground
- Read
.msskills/stack.md. Absent → say once that stack-profile would make the generated code
match the project's idiom, then infer conventions from the repository and proceed.
- Read
.msskills/decisions.md — recorded decisions are binding.
- Find the blueprint in
.msskills/designs/ for this feature.
Design gate. Check the blueprint's frontmatter:
status: approved → proceed with an approved design.
status: complete → already implemented. If this is new scope, recommend design-service for a
fresh pass. If the user confirms, continue.
status: draft, or no blueprint → STOP: "There is no approved design for this. Run
/design-service first, or shall I proceed from what we have discussed?" On confirmation,
record it as a decision and continue without an approved design — every principle still
applies; there is simply no agreed contract to build against.
Level gate. With a blueprint, check which levels it contains. Missing L3 or L4 means the
failure behaviour or the contracts were never agreed — STOP, say which are missing, and ask
whether to proceed and fill them as you go or to design them first.
- Read the existing code before writing any. Find the patterns already in use — error
handling, naming, test structure, package layout — and match them. Code that is correct but
foreign is a review burden.
Step 2 — Plan and agree the order
Derive the component list from the blueprint's L2, or classify it yourself against
clean-architecture if there is no blueprint.
Plan inside-out: start at the innermost layer with no outward dependencies and work outward, so
each component's dependencies already exist when it is built. Typically: domain types → domain
logic → ports → application use cases → adapters → wiring and configuration.
Present the plan — the ordered component list, each one's layer, and what already exists that you
will reuse. Then ask for a review mode:
How should we review this?
- Layer by layer (recommended) — implement a full layer, pause for review, then the next.
- All at once — implement end to end, review the complete result.
- Component by component — pause after each one.
Default to layer by layer. STOP — do not write code against an unagreed plan. If the user
corrects the plan, revise and re-present it.
Step 3 — Implement, component by component
For each component, in the planned order, write code and its tests together.
Before writing:
- Prefer what exists. Does the standard library, an existing dependency, or existing code in
this repository already do this? Use it. Adding a dependency runs
config-and-dependencies
first.
- Prefer the simpler shape. No abstraction without a named force (
clean-architecture).
While writing, apply the principles that govern this component:
| Component kind |
Apply |
| Domain type or aggregate |
domain-modelling, clean-architecture, idempotency-and-immutability |
| Repository, query, or migration |
data-access, clean-architecture |
| Read model or projection |
cqrs-and-consistency, data-access |
| Use case / handler |
clean-architecture, secure-service, idempotency-and-immutability |
| Inbound adapter (HTTP, consumer) |
infrastructure-adapters, api-contracts, api-protocols, secure-service |
| Outbound adapter (client, publisher) |
infrastructure-adapters, resilience-patterns, secure-service |
| Configuration or flag |
config-and-dependencies |
| Tests |
test-strategy, plus contract-testing at a service boundary |
Post-generation verification — before showing anything:
- Run the Self-Validation Checklist of every applicable principle against every function and
type in the component. The checklists say STOP and verify; do that literally.
- Run every applicable Active Anti-Pattern Scan. Check each box honestly.
- Fix every violation found. Do not present code you know fails a check.
- Collect flagged Ambiguity Signals and present them through
collaborative-judgment before
showing the code. Never resolve a real trade-off silently to keep momentum.
- Run the tests you wrote, if the environment allows. Report the result. If you could not run
them, say so — never imply tests passed when they were only written.
- Present with a one-line compliance note when clean; be verbose only when reporting a violation
you fixed or a decision you need.
Pace by the chosen review mode. In every mode, one exception overrides it: a component needing
a significant deviation — a new dependency, a changed contract, unexpected complexity, a blueprint
decision that turns out to be unworkable — STOPS immediately for discussion, whatever the mode.
Step 4 — Verify across components
Once the components exist:
- Wire it and run it. Start the service. A set of components that has never been assembled is
not an implementation.
- Run the whole suite, not just the new tests. Report failures with their output.
- Trace one flow end to end against the blueprint's L3: does the real code follow the agreed
interactions, with the agreed timeouts and failure behaviour?
- Verify the contracts against L4 — request and response shapes, error catalogue, event
schemas. Flag every deviation; do not quietly ship a different contract from the approved one.
- Check the failure paths actually work: the timeout fires, the breaker opens, the duplicate
message is ignored, the compensation runs. These are the paths that only execute on the worst
day (
test-strategy).
Step 5 — Close out
- Update the blueprint:
status: complete, and record any decision made during implementation in
its Decisions Log.
- Append cross-cutting decisions to
.msskills/decisions.md.
- Summarise: what was built, what was reused, which tests cover what, what is deliberately not done.
- Name the follow-ups explicitly rather than leaving them implicit.
- Recommend
review-service for an independent audit before the change is merged.
Rules
- Never present code that fails a checklist. Fix it first.
- Tests are part of the component, not a later step.
- Never claim a test passed without running it.
- A deviation from the approved design stops the work. Surface it; the design is what was
agreed, and changing it is the user's call.
- Match the repository's conventions over this library's examples.
- Do not touch unrelated code. Improvements you notice go in the close-out list, not in the diff.
1---2name: implement-service3description: Turn an approved design into working code and tests, built inside-out one layer at a time, with every principle's checklist run before anything is presented. Covers implementation ordering, per-component validation against architecture, data, resilience, security and configuration rules, writing tests alongside the code at the right level, and pacing the work so review happens while it is still cheap. Use after design-service has produced an approved blueprint, or when the user says 'implement', 'build it', 'code this up', or 'write the service'. This workflow writes code — for changing existing code safely see refactor-safely, for auditing it see review-service.4license: MIT5---67# Implement a Service89The failure mode this prevents is a large, plausible, unreviewable diff. Code arrives in layers,10each validated against the principles before it is shown, each small enough that a human can11actually read it.1213## Required Skills1415Read and apply:16171. `clean-architecture` — layer placement and dependency direction for every file. (always)182. `test-strategy` — every component ships with tests at the right level. (always)193. `collaborative-judgment` — deviations and trade-offs are surfaced, not absorbed. (always)204. `domain-modelling` — aggregates, entities, value objects, where behaviour lives. (conditional:21 domain types)225. `data-access` — repositories, queries, transactions, migrations, caches. (conditional:23 persistence)246. `cqrs-and-consistency` — read models and projections. (conditional: a separate read path)257. `infrastructure-adapters` — ports, clients, consumers, publishers, SDK wrappers. (conditional:26 the adapter layer)278. `resilience-patterns` — timeouts, retries, breakers, outbox. (conditional: any call leaving the28 process, any message handler)299. `idempotency-and-immutability` — retry safety and shared state. (conditional: retryable30 operations, message handlers, value types)3110. `secure-service` — authorisation, validation, secrets, output hygiene. (conditional: any trust32 boundary — handlers, clients, queries, anything touching credentials or personal data)3311. `api-contracts` — the shape of anything crossing a boundary. (conditional: endpoints, schemas,34 published events)3512. `api-protocols` — protocol-specific craft. (conditional: GraphQL, gRPC, WebSocket or SSE)3613. `config-and-dependencies` — settings, flags, new libraries. (conditional: config or dependency37 changes)3814. `contract-testing` — cross-service agreement. (conditional: an integration with another service)3940## Workflow4142### Step 1 — Establish the ground43441. Read `.msskills/stack.md`. Absent → say once that `stack-profile` would make the generated code45 match the project's idiom, then infer conventions from the repository and proceed.462. Read `.msskills/decisions.md` — recorded decisions are binding.473. Find the blueprint in `.msskills/designs/` for this feature.4849**Design gate.** Check the blueprint's frontmatter:5051- `status: approved` → proceed **with an approved design**.52- `status: complete` → already implemented. If this is new scope, recommend `design-service` for a53 fresh pass. If the user confirms, continue.54- `status: draft`, or no blueprint → **STOP**: "There is no approved design for this. Run55 `/design-service` first, or shall I proceed from what we have discussed?" On confirmation,56 record it as a decision and continue **without an approved design** — every principle still57 applies; there is simply no agreed contract to build against.5859**Level gate.** With a blueprint, check which levels it contains. Missing L3 or L4 means the60failure behaviour or the contracts were never agreed — **STOP**, say which are missing, and ask61whether to proceed and fill them as you go or to design them first.62634. **Read the existing code** before writing any. Find the patterns already in use — error64 handling, naming, test structure, package layout — and match them. Code that is correct but65 foreign is a review burden.6667### Step 2 — Plan and agree the order6869Derive the component list from the blueprint's L2, or classify it yourself against70`clean-architecture` if there is no blueprint.7172Plan **inside-out**: start at the innermost layer with no outward dependencies and work outward, so73each component's dependencies already exist when it is built. Typically: domain types → domain74logic → ports → application use cases → adapters → wiring and configuration.7576Present the plan — the ordered component list, each one's layer, and what already exists that you77will reuse. Then ask for a review mode:7879> How should we review this?80> 1. **Layer by layer** (recommended) — implement a full layer, pause for review, then the next.81> 2. **All at once** — implement end to end, review the complete result.82> 3. **Component by component** — pause after each one.8384Default to layer by layer. **STOP** — do not write code against an unagreed plan. If the user85corrects the plan, revise and re-present it.8687### Step 3 — Implement, component by component8889For each component, in the planned order, write **code and its tests together**.9091Before writing:9293- **Prefer what exists.** Does the standard library, an existing dependency, or existing code in94 this repository already do this? Use it. Adding a dependency runs `config-and-dependencies`95 first.96- **Prefer the simpler shape.** No abstraction without a named force (`clean-architecture`).9798While writing, apply the principles that govern this component:99100| Component kind | Apply |101|---|---|102| Domain type or aggregate | `domain-modelling`, `clean-architecture`, `idempotency-and-immutability` |103| Repository, query, or migration | `data-access`, `clean-architecture` |104| Read model or projection | `cqrs-and-consistency`, `data-access` |105| Use case / handler | `clean-architecture`, `secure-service`, `idempotency-and-immutability` |106| Inbound adapter (HTTP, consumer) | `infrastructure-adapters`, `api-contracts`, `api-protocols`, `secure-service` |107| Outbound adapter (client, publisher) | `infrastructure-adapters`, `resilience-patterns`, `secure-service` |108| Configuration or flag | `config-and-dependencies` |109| Tests | `test-strategy`, plus `contract-testing` at a service boundary |110111**Post-generation verification — before showing anything:**1121131. Run the **Self-Validation Checklist** of every applicable principle against every function and114 type in the component. The checklists say STOP and verify; do that literally.1152. Run every applicable **Active Anti-Pattern Scan**. Check each box honestly.1163. Fix every violation found. Do not present code you know fails a check.1174. Collect flagged **Ambiguity Signals** and present them through `collaborative-judgment` *before*118 showing the code. Never resolve a real trade-off silently to keep momentum.1195. **Run the tests** you wrote, if the environment allows. Report the result. If you could not run120 them, say so — never imply tests passed when they were only written.1216. Present with a one-line compliance note when clean; be verbose only when reporting a violation122 you fixed or a decision you need.123124**Pace by the chosen review mode.** In every mode, one exception overrides it: a component needing125a significant deviation — a new dependency, a changed contract, unexpected complexity, a blueprint126decision that turns out to be unworkable — **STOPS** immediately for discussion, whatever the mode.127128### Step 4 — Verify across components129130Once the components exist:1311321. **Wire it and run it.** Start the service. A set of components that has never been assembled is133 not an implementation.1342. **Run the whole suite**, not just the new tests. Report failures with their output.1353. **Trace one flow end to end** against the blueprint's L3: does the real code follow the agreed136 interactions, with the agreed timeouts and failure behaviour?1374. **Verify the contracts** against L4 — request and response shapes, error catalogue, event138 schemas. Flag every deviation; do not quietly ship a different contract from the approved one.1395. **Check the failure paths actually work**: the timeout fires, the breaker opens, the duplicate140 message is ignored, the compensation runs. These are the paths that only execute on the worst141 day (`test-strategy`).142143### Step 5 — Close out144145- Update the blueprint: `status: complete`, and record any decision made during implementation in146 its Decisions Log.147- Append cross-cutting decisions to `.msskills/decisions.md`.148- Summarise: what was built, what was reused, which tests cover what, what is deliberately not done.149- Name the follow-ups explicitly rather than leaving them implicit.150- Recommend `review-service` for an independent audit before the change is merged.151152## Rules153154- **Never present code that fails a checklist.** Fix it first.155- **Tests are part of the component**, not a later step.156- **Never claim a test passed** without running it.157- **A deviation from the approved design stops the work.** Surface it; the design is what was158 agreed, and changing it is the user's call.159- **Match the repository's conventions** over this library's examples.160- **Do not touch unrelated code.** Improvements you notice go in the close-out list, not in the diff.