agentleFS
luizomfluizomf/omskills/skills/engineering/codebase-design/SKILL.md

codebase-design

Skill3 starsChanged 2 months agoMITView on GitHub

Design or improve deep modules. Use when shaping a module interface, deepening modules, placing a seam, reducing coupling, designing for testability, or when another skill requires the deep-module vocabulary.

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 10 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

2 rules. 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 181 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

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

    Use these architecture terms as defined here.

    line 12
  2. Distinctive:

    When comparing interface designs, check:

    line 56

“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: modules whose callers can exercise multiple required behaviors through a smaller interface at a defined seam. Apply the terms and rules below when designing or restructuring code. The target outcomes are leverage across callers, locality of changes and defects, and tests that use the same interface as production callers.

Glossary

Use these architecture terms as defined here. Do not substitute component, service, API, or boundary, because those words identify different or narrower concepts.

Module — any unit with exactly one interface and an implementation, including a function, class, package, or tier-spanning slice. This term does not imply scale. Avoid unit, component, and service for this concept.

Interface — every fact a caller must know to use a module correctly: type signatures, invariants, ordering constraints, error modes, required configuration, and performance characteristics. API and signature name only part of this surface.

Implementation — code inside a module. Use adapter instead when discussing the role a concrete implementation fills at a seam. Implementation size and adapter size are independent; for example, a Postgres repository can be a small adapter with a large implementation, while an in-memory fake can be a large adapter with a small implementation.

Depth — behavior a caller or test can exercise relative to the interface facts it must learn. A module is deeper than an alternative when it preserves required behavior while exposing fewer methods, parameters, invariants, ordering constraints, error modes, configuration requirements, or performance obligations. It is shallow when callers must supply or coordinate the implementation's intermediate states and steps.

Seam (Michael Feathers) — a location where behavior can be altered without editing code at that location. Seam placement and the behavior behind the seam are separate decisions. A seam may be internal to a module. Avoid boundary, which also refers to a DDD bounded context.

Test seam — a seam exposed through the caller-visible interface that production callers and behavior tests share. Tests may use a different adapter at that seam, but do not bypass the interface to reach an internal seam.

Adapter — a concrete module that satisfies an interface at a seam. The term identifies the role, not the implementation technology.

Leverage — reuse of behavior behind one interface across multiple callers or tests. A change behind the interface applies without reproducing the rule at each caller.

Locality — concentration of a behavior's code, required knowledge, defects, changes, and verification in one module rather than its callers.

Deep and shallow modules

A deep module exposes a smaller interface than the behavior it contains:

┌─────────────────────┐
│   Small Interface   │  ← fewer caller-visible facts
├─────────────────────┤
│                     │
│  Deep Implementation│  ← behavior hidden from callers
│                     │
└─────────────────────┘

A shallow module exposes an interface that repeats most implementation decisions:

┌─────────────────────────────────┐
│       Large Interface           │  ← many caller-visible facts
├─────────────────────────────────┤
│  Thin Implementation            │  ← forwards or rearranges inputs
└─────────────────────────────────┘

When comparing interface designs, check:

  • whether multiple methods can become one operation without losing required behavior;
  • whether the module can derive or own any current parameters;
  • whether invariants, ordering, configuration, errors, or performance obligations can move behind the interface; and
  • whether the reduced surface still supports every required caller and test behavior.

Principles

  • Depth is a property of a module relative to its interface. Internal composition does not make an external interface shallow. A module may use internal seams available only to its implementation and implementation-level tests while exposing one external seam to callers.
  • Deletion test. Model deleting the module while preserving required behavior. If no caller must absorb rules or knowledge, the module was a pass-through. If rules or knowledge must be copied or coordinated across callers, the module provides locality or leverage. This is design evidence, not an automatic deletion rule: preserve required behavior and safety constraints, and judge total complexity and caller usability.
  • The interface is the test surface. Production callers and behavior tests use the same test seam. A test that must bypass the interface is evidence that the interface does not expose required behavior or that the tested behavior belongs to another module.
  • Two justified adapters warrant a port. Introduce a port only when at least two adapters are justified (typically production + test).

Designing for testability

Accept dependencies instead of constructing them inside the behavior

// Dependency can vary at the seam.
function processOrder(order, paymentGateway) {}

// Dependency selection is coupled to this implementation.
function processOrder(order) {
  const gateway = new StripeGateway();
}

Return results instead of producing side effects

// The result is observable without inspecting mutation.
function calculateDiscount(cart): Discount {}

// Verification requires observing mutation and hidden discount state.
function applyDiscount(cart): void {
  cart.total -= discount;
}

Minimize the caller-visible surface

A smaller caller-visible surface generally requires fewer tests and simpler setup.

Rejected framings

  • Implementation-lines divided by interface-lines: this metric can increase by adding implementation code without adding behavior. Evaluate depth by caller-visible facts and exercised behavior instead.

Progressive references

  • For deepening a cluster with known dependencies, read DEEPENING.md for dependency categories, seam discipline, and replace-don't-layer testing.
  • For comparing alternative interfaces, read DESIGN-IT-TWICE.md for the optional one-designer comparison process. Use it only when the invoking workflow authorizes that designer role and the current caller can dispatch a non-delegating leaf within its inherited depth. A non-delegating leaf resolves accepted sources directly or returns a blocker to its caller.
  • To scan an entire repository for candidates, use improve-codebase-architecture. First run cd '<loaded-skill-directory>' && pwd -P with this loaded file's directory and resolve the link from that physical base. Read the target even when absent from discovery.

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.