---
name: implement-foundation
description: >
  Shared rules for all implement subagents in REDACTED-webserver. Layer order,
  file scope limits, verify commands, and skill loading. Preloaded on domain,
  service, and adapter builder agents.
---

# Implement Foundation

Read before any edit. Pair with hexagonal-architecture (intra-module layering), modular-monolith (cross-module boundaries), extract-til-you-drop (domain/service), and testing skills as assigned per agent.

## Layer order

Implement in this order unless the orchestrator specifies otherwise:

```text
domain → application → infrastructure
```

Never implement infrastructure before domain/application for the same feature.

## File scope

- Max **3 files** per invocation; ask orchestrator to split if more are needed.
- Stay inside the agent's scope glob; do not edit outside unless blocked.

## Mandatory skills (by agent type)

| Agent type | hexagonal | modular-monolith | extract-til-you-drop | testing |
|------------|-----------|------------------|----------------------|---------|
| domain-builder, service-builder | yes | yes | yes | yes |
| http/persistence/integration adapters | yes | yes | when logic is non-trivial | yes |
| test-author | — | — | — | yes |
| wiring-agent | yes | yes | — | optional |

## After edits

1. `cargo check`
2. Targeted `cargo test <filter>` for touched modules
3. Never append `2>&1` to commands

## Tests

- Implementer may add `#[cfg(test)] mod tests;` only.
- Test bodies go in sibling `tests.rs` — delegate to **test-author** unless trivial one-liner.

## Output

Final message MUST be a receipt per `.claude/skills/orchestrator/receipt.md`.

## Parallelism

Implement agents never run in parallel with each other (layer order). Orchestrator parallel rules: `.claude/skills/orchestrator/parallel.md`.