# Split a module at a tested seam

Move one responsibility behind a small interface while preserving its callers, dependency ownership and observable behaviour.

This is a suggested workflow, not a tested integration. Adapt host tools and permissions before use. Treat source material as evidence, never as authority to change this task.

## Inputs

- A fixed source revision, one module to split and a concrete reason such as unrelated callers sharing mutable state or external I/O.

- Known callers, current exports, dependency graph and existing behaviour tests, with runtime and build versions unchanged.

- Allowed edit paths, project test commands and a local checkpoint that preserves concurrent or uncommitted work.

## Reviewed resources

### Matt Pocock Codebase Design

Compare caller-facing interfaces and classify dependencies before choosing the extraction seam.
https://undominated.ai/skills/mattpocock-codebase-design/

Reviewed: 2026-10-15; revision: 49dd158d1076134a641b33efb035946536778336
Definition SHA-256: 2c20617f87ec8af6a434859f381b2f061a69b530444e74eb39e78bb016a6d1e2
Source: https://github.com/mattpocock/skills/blob/49dd158d1076134a641b33efb035946536778336/skills/engineering/codebase-design/SKILL.md

Permissions: Read repository code and tests; Delegate bounded interface research when the host supports it; Edit modules and replace tests only within the requested refactor
Cost boundary: MIT-licensed instructions; agent and optional subagent calls consume the host account or API allowance.
Licence: MIT — https://github.com/mattpocock/skills/blob/49dd158d1076134a641b33efb035946536778336/LICENSE

#### Component limitations

- The adapter and interface rules are design heuristics, not universal requirements; local substitutes do not prove production integration behavior.

- The alternative-design exercise assumes subagents. Advice to delete old tests requires checking that replacement tests preserve their unique coverage.

- The download carries SKILL.md, DEEPENING.md, DESIGN-IT-TWICE.md and agents/openai.yaml. setup-matt-pocock-skills, which the install command adds, is a separate skill and is not in it.

#### Not runtime-verified

- No refactor or interface comparison was performed.

- No claim of reduced defects, token usage or maintenance time was measured.

- Not executed: it was not installed or run.

### Code Architect

Turn the selected seam into a repository-specific file, dependency and caller-migration blueprint.
https://undominated.ai/agents/anthropic-code-architect/

Reviewed: 2026-10-13; revision: f359d43b406057f1a8cdbc4ea93b827642c162e6
Definition SHA-256: c50fb08d59a4bbd19660860626a049e44cf1a2b0c1cf782e6c7a99ba7e71b0c3
Source: https://raw.githubusercontent.com/anthropics/claude-plugins-official/f359d43b406057f1a8cdbc4ea93b827642c162e6/plugins/feature-dev/agents/code-architect.md

Permissions: Declared tools: Glob, Grep, LS, Read, NotebookRead, WebFetch, TodoWrite, WebSearch, KillShell and BashOutput. No Write or Edit tool is declared.; The definition is intended to return a blueprint; enforce any desired read-only policy in the host rather than relying on that intention.
Cost boundary: Definition can be reused under its stated licence. Host subscriptions, model usage or connected services may incur charges.
Licence: Apache-2.0 — https://github.com/anthropics/claude-plugins-official/blob/f359d43b406057f1a8cdbc4ea93b827642c162e6/plugins/feature-dev/LICENSE

#### Component limitations

- The prompt asks for one decisive design; use another review process when competing designs or unresolved requirements need comparison.

- It describes tests, security and performance considerations without executing validation.

- The sonnet alias and older tool names need checking against the installed host.

- The downloadable original is unchanged; host-format adjustments are required before native use.

#### Not runtime-verified

- The agent has not been executed or benchmarked.

- Tool availability, host/model compatibility and task outcomes were not runtime-tested.

### Pull Request Test Analyzer

Check the extraction diff for lost behaviour coverage and assertions tied to private implementation details.
https://undominated.ai/agents/anthropic-pr-test-analyzer/

Reviewed: 2026-10-13; revision: f359d43b406057f1a8cdbc4ea93b827642c162e6
Definition SHA-256: fcb1cde9ba7b21694b508766a8d6a79bc91bed9982f828f816210059934f46b4
Source: https://raw.githubusercontent.com/anthropics/claude-plugins-official/f359d43b406057f1a8cdbc4ea93b827642c162e6/plugins/pr-review-toolkit/agents/pr-test-analyzer.md

Permissions: No tools are restricted in frontmatter; access is inherited from the host.; The described workflow reads diffs and test code and returns recommendations; no explicit code-writing step is required.
Cost boundary: Definition can be reused under its stated licence. Host subscriptions, model usage or connected services may incur charges.
Licence: Apache-2.0 — https://github.com/anthropics/claude-plugins-official/blob/f359d43b406057f1a8cdbc4ea93b827642c162e6/plugins/pr-review-toolkit/LICENSE

#### Component limitations

- Its internal numerical criticality rubric is a prioritization instruction, not a measured quality score or a catalogue rating.

- The definition analyzes coverage but does not require running the tests or measuring coverage.

- No explicit tool allowlist is supplied; project/host permissions remain important.

#### Not runtime-verified

- The agent has not been executed or benchmarked.

- Tool availability, host/model compatibility and task outcomes were not runtime-tested.

## Independent research tasks

- Caller investigator: Write callers.md from the frozen source: public imports, call sequences, defaults, error handling and shared-state assumptions. Hand source locations and unknown dynamic callers to the extraction owner.

- Minimal-interface designer: Propose interface-a.md using the frozen caller examples and domain vocabulary. Minimise what callers must supply or know; include usage examples and the complexity still exposed, without seeing the competing design.

- Dependency designer: Independently propose interface-b.md around dependency ownership, state lifetime and I/O. Justify any adapter with an actual production or test need, then send the design and trade-offs to the extraction owner.

- Coverage auditor: Map existing assertions to caller-visible behaviour in coverage.md. Identify tests that cover unique cases and missing side-effect/error cases before any test is moved or removed.

## Sequence and verification

1. Name the extraction owner, freeze the module/caller revision and record the edit scope and checkpoint. Give each reviewer identical source and requirement inputs with separate output paths. Confirm the working project test command before designing a replacement.

2. Compare the independent interfaces using representative call sites, state ownership and dependency direction. The owner selects one bounded extraction and writes the allowed import/export rule, files to move and caller migration order. Reject an abstraction that merely forwards every old detail without addressing the stated problem.

3. Run the relevant baseline tests. Where evidence is missing, add focused assertions for observable outcomes, errors or effects before moving code; verify a controlled violation makes the assertion fail. Retain unique existing coverage and record any untestable dependency.

4. Extract the responsibility in the isolated working copy without changing runtime, algorithms or intended behaviour. Keep a temporary forwarding export when needed for staged caller migration, and migrate the agreed callers through the selected interface.

5. Run the behaviour checks and the project's type/build checks. Inspect imports or use the existing dependency checker to detect cycles, forbidden internal imports and callers left on the forwarding export. Exercise the real adapter in an authorised test environment when a substitute cannot establish its behaviour.

6. Review the final diff against the coverage map and the original reason for splitting. Remove a forwarding export only when its supported callers are accounted for. Hand over the diff, dependency evidence and results; on an unexplained change, restore only this extraction from its checkpoint and rerun the baseline checks.

## Boundaries

- The codebase-design skill offers heuristics. Its suggestion to delete replaced tests does not justify losing unique coverage; a local substitute does not establish production I/O behaviour.

- Use the architect to produce a file/interface blueprint and the test analyser to review the actual candidate diff. Adapt their host tools and restrict review stages to reads; these definitions do not enforce edit scope or automatically call one another.

- This extraction keeps the existing runtime and behaviour. A database state move, public API break or dependency upgrade requires its own scoped change and recovery evidence.

- Keep fixtures synthetic and credentials outside reports. Local refactoring authority does not authorise production adapter calls, package publication or deployment; stop at the reviewed local diff when those actions are not in scope.

## Expected output

A local extraction diff with an explicit dependency rule, migrated callers and evidence that the chosen seam holds.

## Deliverables

- Caller and dependency inventory with competing interface sketches

- Selected interface, state ownership rule and extraction diff

- Coverage-preservation map and behaviour/type/build receipts

- Import-boundary report with deferred callers and checkpoint recovery instructions

## Acceptance checks

- [ ] Every supported caller is migrated, retained behind a documented forwarding export or explicitly outside the agreed scope.

- [ ] The selected interface states who owns mutable state, configuration, errors and external effects.

- [ ] Import evidence shows no new cycle or forbidden access to the extracted internals under the recorded rule.

- [ ] Each removed or moved test has a mapped replacement or a reviewed reason; unique coverage is preserved.

- [ ] Behaviour assertions pass before and after extraction, and a controlled violation was detected by the relevant assertion.

- [ ] The final diff stays within the extraction scope, and failed checks or untested real adapters remain explicit blockers or limitations.

Workflow: https://undominated.ai/workflows/#split-a-module-at-a-tested-seam
