agentleFS
caidanwcaidanw/skills/architecture-md/SKILL.md

architecture-md

Skill9 starsChanged 4 months agoMITView on GitHub

Generate an ARCHITECTURE.md file for a codebase following matklad's principles. Use when asked to "write an architecture doc", "create ARCHITECTURE.md", "document the architecture", "explain the codebase structure", "write a codemap", or when onboarding contributors to a project. Based on https://matklad.github.io/2021/02/06/ARCHITECTURE.md.html and modeled after rust-analyzer's architecture doc.

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 6 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    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
  1. Very specific:

    Use tree, glob, and read tools to understand the project:

    line 31
  2. Very specific:

    Read README, package.json/Cargo.toml/pyproject.toml for the project's purpose

    line 33
  3. Very specific:

    Run tree -L 2 -d (or similar) to see directory structure

    line 34
  4. Distinctive:

    Read key files at module boundaries to understand the layers

    line 36
  5. Distinctive:

    Follow the template below.

    line 51
  6. Very specific:

    Use ### \path/to/module/\`` headers with backtick-quoted paths for the codemap

    line 128
  7. Distinctive:

    Use Boundary: and Invariant: prefixed callouts (bold label, not blockquotes)

    line 129
  8. Distinctive:

    Keep module descriptions to 1-3 sentences

    line 130
  9. Distinctive:

    Write in present tense, active voice

    line 132
  10. Distinctive:

    Prefer concrete over abstract: "parses CLI arguments" not "handles input processing"

    line 133

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 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.

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

ARCHITECTURE.md Generator

Generate high-quality ARCHITECTURE.md files that give newcomers a mental map of a codebase. Based on matklad's article: the biggest contributor bottleneck is not writing code, it's figuring out where to change it. ARCHITECTURE.md bridges that gap.

Core Principles

  1. Short and stable -- Only describe things unlikely to change frequently. Don't synchronize with code. Revisit a couple of times a year.
  2. Bird's eye first -- Start with the problem being solved, not the solution.
  3. Codemap over prose -- Answer "where's the thing that does X?" and "what does this thing do?" for every module.
  4. Name, don't link -- Name important files, modules, types. Don't hyperlink (links go stale). Encourage symbol search.
  5. Invariants are gold -- Explicitly call out what's deliberately absent. Important invariants are often expressed as absence, and are impossible to divine from reading code.
  6. Mark boundaries -- API boundaries between layers constrain all possible implementations behind them. Finding a boundary by randomly reading code is hard.
  7. Cross-cutting concerns last -- After the codemap, address things that are everywhere and nowhere (error handling, testing, config).

Workflow

Step 1: Explore the Codebase

Use tree, glob, and read tools to understand the project:

  • Read README, package.json/Cargo.toml/pyproject.toml for the project's purpose
  • Run tree -L 2 -d (or similar) to see directory structure
  • Identify entry points (main files, index files, bin directories)
  • Read key files at module boundaries to understand the layers

Step 2: Identify the Architecture

Map out:

  • The problem being solved -- What does this project do? What's the input/output?
  • Coarse-grained modules -- What does each top-level directory/package do?
  • Data flow -- How does data move through the system? Input -> ??? -> Output
  • API boundaries -- Which modules are public interfaces vs internal implementation?
  • Architectural invariants -- What rules are enforced by structure? What's deliberately absent?
  • Cross-cutting concerns -- Error handling, testing strategy, configuration, observability

Step 3: Write the ARCHITECTURE.md

Follow the template below. Keep the total document under ~300 lines for most projects.

Template

# Architecture

[One paragraph: what this project does at the highest level. What problem it solves.]

## Bird's Eye View

[How data flows through the system at the coarsest level.
Input -> Processing stages -> Output.
Keep this to 1-3 paragraphs.]

## Code Map

[Brief intro: "This section describes the high-level structure of the codebase.
Pay attention to **Boundary** and **Invariant** callouts."]

### `path/to/module-a/`

[What this module does in 1-3 sentences. Key types: `ImportantType`, `AnotherType`.]

**Boundary:** [If this is an API boundary, say so and what it means.]

**Invariant:** [What's deliberately absent or enforced. E.g., "This module never does I/O"
or "Nothing here depends on the HTTP layer."]

### `path/to/module-b/`

[Repeat for each significant module.]

### `path/to/module-c/`

[...]

## Cross-Cutting Concerns

### Error Handling

[How errors are handled across the codebase. Is it Result-based? Exceptions?
Do errors propagate or get caught at boundaries?]

### Testing

[Testing strategy. Where do tests live? What kinds of tests exist?
What are the important test boundaries?]

### [Other concerns as applicable]

[Configuration, observability/logging, code generation, build system, etc.
Only include sections that are genuinely cross-cutting.]

Rules

What to Include

  • Directory/module purposes (1-3 sentences each)
  • Names of important types, traits, interfaces, functions (for symbol search)
  • API boundaries between layers
  • Architectural invariants -- especially things that are deliberately absent
  • Data flow at the system level
  • Cross-cutting concerns that affect multiple modules

What to Omit

  • Implementation details of how individual modules work (that's inline doc)
  • Links to specific files or lines (they go stale)
  • Anything that changes with routine PRs
  • Exhaustive API documentation (that's rustdoc/typedoc/javadoc territory)
  • Setup instructions (that's README)
  • Contribution guidelines (that's CONTRIBUTING.md)

Style Rules

  • Use ### \path/to/module/`` headers with backtick-quoted paths for the codemap
  • Use Boundary: and Invariant: prefixed callouts (bold label, not blockquotes)
  • Keep module descriptions to 1-3 sentences
  • Name types in backticks: "Key types: FooBar, BazQux"
  • Write in present tense, active voice
  • Prefer concrete over abstract: "parses CLI arguments" not "handles input processing"

Quality Checklist

Before finishing, verify:

  • Can a newcomer find "the thing that does X" using only this doc?
  • Are API boundaries clearly marked?
  • Are architectural invariants (especially absences) called out?
  • Is every section stable enough to survive 6 months without update?
  • Are important types/modules named (not linked)?
  • Is there a bird's eye view before the codemap?
  • Are cross-cutting concerns addressed?
  • Does the codemap order match the data flow or dependency direction?
  • Is it under ~300 lines? (Shorter = more likely to be read and maintained)

Reference Example

See references/example.md for a complete example ARCHITECTURE.md for a hypothetical TypeScript project, demonstrating all the patterns above.

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.