agentleFS
dafaalzdafaalz/agent-skills/skills/codebase-design/SKILL.md

codebase-design

Skill2 starsChanged 51 days agoMITView on GitHub

Use when designing module interfaces, evaluating abstraction depth, identifying code seams, or turning shallow pass-through wrappers into deep modules. Don't use for syntax styling or minor formatting changes (use s13n), or single-line bug fixes (use systematic-debugging).

194 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use setup-ts-deep-modules, decision-mapping and 9 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • liufeng1976Skill

    setup-ts-deep-modules

    Wire dependency-cruiser into a TypeScript repo so each package is a deep module — implementation hidden in subfolders, reachable only through its entry-point files. User-invoked.

    Also in 43 projects that use this

  • FabienDehopreSkill

    decision-mapping

    Turn a loose idea into a sequenced map of investigation tickets, then drive them to resolution one at a time.

    Also in 8 projects that use this

  • RoentekSkill

    loop-me

    Grill me about specs for the workflows I want to build, within this workspace.

    Also in 55 projects that use this

  • LesaniSkill

    writing-beats

    Shape an article as a journey of beats, choose-your-own-adventure style. The user picks a starting beat from the raw material, you write only that beat, then offer options for where to pivot next, beat by beat, until the article reaches a natural end. Use when the user has raw material and wants to assemble it as a narrative rather than an argument.

    Also in 58 projects that use this

  • AWSSkill

    to-questionnaire

    Turn a decision you can't fully answer into a questionnaire for someone else to fill in.

    Also in 90 projects that use this

  • LesaniSkill

    writing-shape

    Take a markdown file of raw material and shape it into an article through a conversational session — drafting candidate openings, growing the piece paragraph by paragraph, arguing about format (lists, tables, callouts, quotes) at each step. Use when the user has a pile of notes, fragments, or a rough draft and wants help turning it into something publishable.

    Also in 58 projects that use this

  • +1 more from Lesani

The file

We split this skill into the rules it gives an agent

9 rules. 0 are common, 7 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 181 edited versions we read keep these.

  • 7

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Write-Target Boundary. Do not create, modify, or delete files under src/, app/, packages/, database/, tests/, or any production source tree.

    line 11
  2. Distinctive:

    Follow these five steps in sequence.

    line 22
  3. Distinctive:

    Read the project context and verify actual data schemas before modifying or creating modules.

    line 26
  4. Distinctive:

    Ask the user directly.

    line 41
  5. Very specific:

    If the user accepts, consult references/design-it-twice.md and dispatch sub-agents using invoke_subagent.

    line 45
  6. Distinctive:

    If the user declines, proceed directly to Step 3.

    line 46
  7. Distinctive:

    Wait for explicit user approval.

    line 76
  8. Distinctive:

    Use these architectural terms consistently:

    line 96
  9. Distinctive:

    Run this check before finishing the skill execution:

    line 115

“Common” is measured: kept by at least 6 in 10 of the 181 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Codebase design

Design deep modules with substantial behavior behind small interfaces, placed at clean seams, and testable directly through those interfaces.

<HARD-GATE> Write-Target Boundary. Do not create, modify, or delete files under `src/`, `app/`, `packages/`, `database/`, `tests/`, or any production source tree. Emit design artifacts only to `.agents/state/codebase-design/` and reference files. Any production write requires a separate `executing-plans` invocation with a user-approved plan. </HARD-GATE>

Modes

Select the design mode before Step 1:

  • Greenfield mode. Draft schemas, bounded contexts, and initial interface contracts from scratch.
  • Refactor mode. Audit existing database schemas, migration files, and routes to encapsulate existing complexity behind deep modules.

Workflow

Follow these five steps in sequence.

Step 1. Domain context and schema ingestion

Read the project context and verify actual data schemas before modifying or creating modules.

  1. Inspect AGENTS.md, CODEBASE.md, or CLAUDE.md in the project root if present. Use the domain nouns, bounded contexts, and naming conventions defined there.
  2. Audit database schemas and migration files:
    • For projects with existing databases, inspect migration directories (such as database/migrations/, prisma/schema.prisma, or src/db/).
    • Ground all entity attributes, foreign keys, and relations in verified schema files on disk. Never invent columns or assume database fields based on general model training.
    • For greenfield repositories without existing migrations, mark the status as greenfield initialization and draft the initial schema explicitly without unverified assumptions.
  3. Infer domain boundaries and seams directly from verified migrations, route declarations, and existing data models.

Completion criterion. The agent names modules, methods, and attributes using verified project domain terms and disk-backed database schemas.

Step 2. Design It Twice offer

Offer the user an exploratory multi-agent design pass before committing to a single interface.

Ask the user directly.

"Do you want to run a Design It Twice pass with parallel sub-agents to explore 2 to 3 contrasting interface designs, or proceed directly with a single design?"

  • If the user accepts, consult references/design-it-twice.md and dispatch sub-agents using invoke_subagent.
  • If the user declines, proceed directly to Step 3.

Completion criterion. Record user preference in .agents/state/codebase-design/decision.md with explicit line design_it_twice: accepted or design_it_twice: declined.

Step 3. Deep module and seam formulation

Formulate the interface and identify module boundaries using deep module principles.

  1. Apply the deletion test. Imagine deleting the module. If complexity vanishes, the module is a shallow pass-through wrapper and should be merged or deleted. If complexity reappears across multiple callers, keep the module. Consult references/codebase-health-and-hotspots.md for git churn hotspot detection, deletion test execution, and architecture diagrams.
  2. Minimize interface surface and reject line count metrics. Measure depth by power gained per unit of interface learned, never by lines of code ratio. Reduce public methods, simplify parameters, and design functions to return pure values instead of mutating state.
  3. Classify dependencies across seams. Consult references/deepening.md to classify external touchpoints into in-process, local-substitutable, remote owned, or true external.
  4. Enforce seam discipline. Follow the rule that one adapter represents a hypothetical seam, while two adapters represent a real seam. Do not introduce interface ports unless at least two concrete adapters exist.
  5. Simplicity first and reuse hierarchy. Take the first option that fully works. Prioritize an existing codebase helper or pattern first, the standard library or platform feature second, an installed dependency third, and minimum new code last. Never add a dependency for a few lines. Never introduce abstractions, generics, or configurability layers for single-use code.
  6. Shortcut discipline and essential boundaries. When taking an intentional implementation shortcut, mark it in code using shortcut: <the limit>, <when to upgrade>. Never cut trust boundary validation, data loss error handling, security invariants, or accessibility in the name of minimalism.
  7. Align interface with test surface. Ensure callers and automated tests cross the same external seam. Do not leak internal test hooks into the public interface.
  8. Subtract before you add. When evolving or refactoring a system, remove complexity first, then build. Sequence removal before construction. Delete dead code, redundant validation checks, and unused stub references before adding new capabilities. Leave the design simpler and more capable behind the same or smaller surface than you found it.
  9. Migrate callers then delete legacy APIs. When introducing a new internal module interface, migrate all in-tree callers and purge the deprecated API in the same wave. Avoid long-lived compatibility shims, forwarding aliases, or wrapper layers for internal code. Update tests to assert the new contract, and delete tests that only protect pre-refactor implementation details.

Completion criterion. Interface specification file .agents/state/codebase-design/interface-spec.md exists on disk with headings ## Inputs, ## Outputs, ## Error states, and ## Seam placement.

Step 4. User review gate

Present the proposed interface design to the user before writing implementation code.

Cover these technical details:

  • Module responsibility and what implementation logic sits behind it.
  • Public interface signature and parameter types.
  • Seam placement and adapter classifications.
  • Automated testing strategy through the public interface.

Wait for explicit user approval. If the user requests adjustments, update the interface and repeat the review.

Completion criterion. Explicit user confirmation approving the interface design.

Step 5. Transition to implementation planning

Invoke the writing-plans skill to generate a phased implementation plan.

Pass the following envelope:

source_skill: codebase-design
source_spec_path: .agents/state/codebase-design/interface-spec.md
mode: Author

Completion criterion. The writing-plans invocation returns a plan path, and .agents/state/codebase-design/handoff.json exists on disk with plan_path matching the returned path and spec_path matching source_spec_path.

Core vocabulary

Use these architectural terms consistently:

TermDefinitionAvoid substituting
ModuleA discrete unit with an interface and an implementationComponent, service, unit
InterfaceEverything a caller must know to use the module correctly, including types, invariants, ordering constraints, error modes, configuration, and performance traitsAPI, signature
ImplementationInternal code body hidden behind the interfaceAdapter
DepthAbstraction power at the interface that provides substantial behavior behind minimal surface areaLines of code ratio
SeamThe location where behavior can be altered without editing the callerBoundary
AdapterA concrete implementation that satisfies an interface at a seamInfrastructure, driver
MultiplierTotal capability gained by callers per unit of interface learnedAbstraction power
LocalityConcentration of change, knowledge, and bugs in one placeCohesion

Boundary isolation

Design module interfaces and contracts only. Do not write functional implementation code, run database migrations, or alter production runtime files during design specification.

Quick audit checklist

Run this check before finishing the skill execution:

CheckPassing condition
Depth checkModule hides internal complexity behind a minimal parameter surface
Deletion testDeleting module causes complexity to reappear across callers
Seam disciplineNo interface port created for single-adapter dependencies
Test surfaceTests exercise the module through the same seam used by callers
Subtraction firstDead code, redundant guards, and stubs removed before adding new features
In-tree caller migrationDeprecated internal APIs and shims purged in the same wave with callers updated
Progressive disclosureDeepening and multi-agent rules loaded from references/
Reuse hierarchyPrioritizes existing helpers and platform features before new dependencies
Pipeline handoffTransition offered to writing-plans upon design approval

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.