reuse-first-design
Skill1 starsChanged 7 months agoMITView on GitHub
Use when authoring or refining any OpenSpec proposal/specs/design/tasks artifact, when making architectural decisions, or when proposing a new module/file/dependency. Enforces extend-before-compose-before-reuse-before-build-new, with a mandatory Reuse Decision Log anchored in CODEBASE_MAP.md and INTEGRATION_MAP.md. Rejects rationalizations like "cleaner as a new module" or "faster to just write it fresh.
In this repository60 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- openspec-apply-changeSkill
- openspec-archive-changeSkill
- openspec-exploreSkill
- openspec-proposeSkill
- api-design-from-frontendSkill
- architect-team-pipelineSkill
- bug-fix-pipelineSkill
- cartographer-teamSkill
- claude-design-importSkill
- claude-md-efficiencySkill
- closeoutSkill
- common-pipeline-conventionsSkill
- contract-first-parallelismSkill
- coverage-mappingSkill
- data-annotationsSkill
- data-dictionarySkill
- data-engineering-explorationSkill
- data-eng-pipelineSkill
- data-lineage-mappingSkill
- delivery-manifestSkill
- design-fidelity-mappingSkill
- dev-api-integration-testingSkill
- diagnostic-research-teamSkill
- documentation-currencySkill
- domain-research-teamSkill
- dynamic-value-discoverySkill
- editability-completenessSkill
- email-testingSkill
- endpoint-trace-mappingSkill
- expensive-verification-debuggingSkill
- frontend-route-mappingSkill
- helpdeskSkill
- intake-and-mappingSkill
- interaction-completenessSkill
- interaction-intuitionSkill
- interactive-mockup-discoverySkill
- intuition-map-lifecycleSkill
- mcp-output-contract-designSkill
- mempalace-integrationSkill
- mini-architect-team-pipelineSkill
- phenotype-absorptionSkill
- phenotypesSkill
- playwright-suite-builderSkill
- playwright-user-flowsSkill
- proposal-refinerSkill
- readme-stylingSkill
- root-cause-test-failuresSkill
- structure-optimizationSkill
- team-spawning-and-review-gatesSkill
- test-prod-safety-classifierSkill
- test-run-monitorSkill
- token-compressionSkill
- ux-test-builderSkill
- verification-planningSkill
- verified-agent-outputSkill
- visual-fidelity-reconciliationSkill
- visual-to-api-designSkill
- visual-verification-teamSkill
- warehouse-sql-miningSkill
The file
We split this skill into the rules it gives an agent
11 rules. About 0 are common, 7 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Every new module, file, component, or dependency degrades the system unless it earns its existence.
- Distinctive: line 35
Before proposing ANY new module / file / component / dependency:
- Very specific: line 37
Read <codebase>/docs/CODEBASE_MAP.md for every codebase in scope.
- Distinctive: line 42
If you have not done this audit, you do not get to propose new code.
- Very specific: line 46
Every design.md MUST contain a ## Reuse Decisions section.
- Distinctive: line 57
No entry → not allowed in the design.
- Distinctive: line 86
When authoring or refining any OpenSpec artifact:
- Very specific: line 95
If you're about to author a proposal.md / design.md / tasks.md / specs/<requirement>.md, the order is:
- Very specific: line 97
Read the relevant CODEBASE_MAP / INTEGRATION_MAP sections.
- Distinctive: line 100
Document every "build new" with a Reuse Decision.
- Distinctive: line 103
If you skip step 1, you will rationalize new code that already exists somewhere.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Reuse-First Design
Every new module, file, component, or dependency degrades the system unless it earns its existence. Reuse-first design is the discipline of proving that earning. This skill makes the proof explicit.
The Priority Ladder (non-negotiable)
- Extend an existing module — add a method, branch, or component to something that already exists.
- Compose with existing modules via their public interface.
- Reuse an existing module as-is.
- Build new — only when 1-3 are demonstrably insufficient, AND only with a documented Reuse Decision.
Climb the ladder from the top. You cannot skip rungs without naming why.
Phenotype reuse (a cross-project rung above build-new)
The four rungs above reason over the target workspace. When none of them yields an option — i.e.
you are about to build new — first check the phenotype library (phenotypes/, via
scripts/phenotypes/phenotypes.py match "<request>"). A matching phenotype is a proven, generalized
blueprint (see skills/phenotypes), so consuming one IS reuse — it ranks above build-new:
extend > compose > reuse (workspace) > reuse a phenotype (cross-project blueprint) > build new
A phenotype match is proposed to the user, never applied silently (a domain gate). When accepted,
log it in the Reuse Decision Log as decision: reuse (phenotype: <label>) and record the
still-required customizations (a phenotype is a head start, not a finished module). With no match or a
declined proposal, build-new proceeds with its normal Reuse Decision.
Mandatory pre-design audit
Before proposing ANY new module / file / component / dependency:
- Read
<codebase>/docs/CODEBASE_MAP.mdfor every codebase in scope. - Read
<workspace>/docs/INTEGRATION_MAP.md. - Enumerate every existing capability that overlaps with what you're proposing. List them by
file:symbol. - For each, ask in order: Can I extend it? Can I compose with it? Can I reuse it? If no — why not, with evidence.
If you have not done this audit, you do not get to propose new code.
The Reuse Decision Log
Every design.md MUST contain a ## Reuse Decisions section. One entry per proposed new module / file / component / dependency:
### <proposed-new-thing>
- **Existing considered:** `src/foo/bar.py:Bar` (from CODEBASE_MAP.md §2.3)
- **Extension attempted:** Add `process_with_retry()` method to `Bar`.
- **Why not sufficient:** `Bar` is a sync class. This work is async-only and would require a parallel async hierarchy on `Bar`. Extending pollutes Bar's single responsibility (sync data normalization).
- **Decision:** New module `src/foo/async_processor.py` that composes `Bar` for sync transforms and adds async I/O around it.
- **Net new files:** `src/foo/async_processor.py`, `tests/foo/test_async_processor.py`No entry → not allowed in the design. The Phase 1 validation loop will reject any new module without a corresponding Reuse Decision and any Reuse Decision that cites a nonexistent file/symbol.
Best-in-class principles (applied during authoring)
| Principle | Concrete check |
| DRY | No new file re-implements logic that exists in CODEBASE_MAP.md. If you see "this is similar to X but…", the answer is "extend X to handle 'but'." |
| YAGNI | No abstractions for "future flexibility" — only what the current requirements need. If you can't name the current caller, the abstraction is premature. |
| SRP | Each new module has one clear purpose, expressible in one sentence. |
| Smallest blast radius | Prefer changes touching the fewest files. Three small targeted edits beat one new file. |
| Honor existing contracts | Add new endpoints/methods over changing existing ones, unless requirements explicitly demand a break (cite the requirement). |
| Stack-canonical libraries | Use libraries already in pyproject.toml / package.json / etc. before introducing new ones. |
| Match existing conventions | Naming, file organization, error handling, logging, testing — pull from CODEBASE_MAP.md and quote the convention you're matching. |
| Composition over inheritance | Where the language allows, compose. Inheritance is a last resort and must be justified. |
Anti-pattern rationalizations to reject
| Rationalization | Rebuttal |
| "It's cleaner as a new module" | Cleanness is a tradeoff against duplication. Reuse-first wins unless duplication_cost > coupling_cost, which you must demonstrate. Subjective "cleaner" doesn't qualify. |
| "The existing one wasn't designed for this" | Then propose an extension. "Wasn't designed for it" ≠ "can't be extended." |
| "It's faster to just write it fresh" | Cost-to-write is one cost. Cost-to-maintain-two-implementations is permanent. The faster choice today is the slower team velocity tomorrow. |
| "I don't want to risk breaking the existing one" | Test coverage that the Phase 3 review gate already requires solves this. If the existing module lacks coverage, add it as part of your extension — that's part of the work. |
| "The existing one is in a different layer/service" | Then the integration map should show the connection. If the capability is genuinely needed in two layers, extract the common piece (still extension, just at the boundary). |
| "The existing one uses an old pattern; I want the new pattern" | Then your change is "migrate X to the new pattern" — a separate, scoped task. Do not silently fork. |
| "I'll mark this as new but it's basically the same logic" | If it's the same logic, it's the same module. Mark it correctly or restructure. |
Output discipline
When authoring or refining any OpenSpec artifact:
- Cite specific files / symbols from CODEBASE_MAP.md by
file:lineorfile:symbol. - Quote the existing convention (snippet) when you're matching it.
- Reject any new dependency that lacks a "why not the existing stack libraries" comparison. New deps go in a
## Dependency Decisionssection with the same Reuse Decision structure: what's already available, what was attempted, why insufficient. - For Phase 3 review-gate compliance: every file you create or modify must correspond to a Reuse Decision. Grep the diff for new file paths before declaring a task done.
Read this before you start designing
If you're about to author a proposal.md / design.md / tasks.md / specs/<requirement>.md, the order is:
- Read the relevant CODEBASE_MAP / INTEGRATION_MAP sections.
- Enumerate overlapping capabilities.
- Apply the ladder.
- Document every "build new" with a Reuse Decision.
- Then write the artifact.
If you skip step 1, you will rationalize new code that already exists somewhere.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

