agentleFS
NashEQifyNashEQify/forge/skills/improve_codebase_architecture/SKILL.md

improve-codebase-architecture

Skill2 starsChanged 3 days agoMITView on GitHub

Codebase-wide architecture improvement via the deep-modules pattern (Ousterhout / Feathers) — find tightly-coupled modules worth consolidating and deepening. Use when looking for refactor opportunities or to make the codebase more testable + AI-navigable; run periodically (every few days), not diff-centric.

We split this skill into the rules it gives an agent

10 rules. 0 are common, 5 are distinctive, and 5 are very specific to this project.

  • 0

    Common

    Most of the 184 edited versions we read keep these.

  • 5

    Distinctive

    This author's own choices. Worth a look.

  • 5

    Very specific

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

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

    Read and follow framework/work-principle.md before taking up work.

    line 22
  2. Distinctive:

    After larger feature additions when "it feels messy".

    line 88
  3. Distinctive:

    Before onboarding a new maintainer / agent — friction map as an entry tool.

    line 89
  4. Distinctive:

    When tests test implementation instead of behaviour — symptom that modules are shallow.

    line 91
  5. Very specific:

    Before exploring (Phase 1) and before writing any candidate, proposal or finding in deep-module vocabulary: read and follow …

    line 105
  6. Very specific:

    When starting the codebase walk: read and follow skills/improve_codebase_architecture/process.md (Phase 1 organic exploration with the …

    line 112
  7. Distinctive:

    No implementation of the refactors — only decision material.

    line 174
  8. Very specific:

    No diff review — code_review_board is a different domain.

    line 176
  9. Very specific:

    No cross-spec review — architecture_coherence_review is a different domain.

    line 178
  10. Distinctive:

    Abort: no friction found → the codebase is already deep + clean.

    line 203

“Common” is measured: kept by at least 6 in 10 of the 184 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

Read and follow framework/work-principle.md before taking up work. Resolve this reference against the framework root; retain the consumer CWD.

Skill: improve-codebase-architecture

Purpose

Surface architectural friction and propose deepening opportunities — refactors that turn shallow modules into deep modules. The goal is testability + AI-navigability.

Complementary to existing review skills:

  • code_review_board (L1/L2) is diff-centric — review of recent changes.
  • architecture_coherence_review is cross-spec — interface contracts between specs.
  • improve_codebase_architecture is codebase-wide + periodic — an every-few-days friction walk, not diff-centric.

Distinct: not "what's wrong with this PR?", but "where does friction accumulate across the whole codebase, and where would deepening concentrate complexity?".

Source

Matt Pocock's skills at b843cb5 (MIT License, © 2026 Matt Pocock); Forge's register of adopted methods.

Standalone

Distinct from:

  • code_review_board (L1/L2) — diff-centric, post-MCA return. This skill is codebase-wide + periodic; no diff required.
  • architecture_coherence_review — cross-spec interface contracts (≥2 specs). This skill is codebase-wide within a single repo, not cross-spec.
  • code-architecture persona (absorbed into code-review) — diff-review architecture axis. This skill finds refactor candidates, not review-of-existing-code.
  • frame — problem-analysis discipline. This skill is the codebase-walk discipline (anchored on concrete files + modules).

What only this skill delivers:

  • Strict glossary (module / interface / implementation / depth / seam / adapter / leverage / locality) — disciplinary vocabulary, not "component / service / API / boundary".
  • Deletion test as an identification tool for shallow modules.
  • One-adapter-hypothetical / two-adapters-real rule as anti-YAGNI for abstractions.
  • 3-phase loop (explore organic → present numbered candidates → grilling loop with the user).
  • Inline side effects: update CONTEXT.md / offer an ADR on rejection.

When to call

  • The user wants to improve architecture, find refactor opportunities, or make the codebase AI-navigable + testable.
  • Periodic (Pocock recommendation: every-few-days continuous refactor).
  • After larger feature additions when "it feels messy".
  • Before onboarding a new maintainer / agent — friction map as an entry tool.
  • When tests test implementation instead of behaviour — symptom that modules are shallow.

Do not call for

  • PR diff review → code_review_board L1 / L2.
  • Cross-spec interface check → architecture_coherence_review.
  • Single-module refactor with a clear plan → direct MCA delegation.
  • Performance optimization (hot path) → code-review performance axis.

Glossary (strict)

Before exploring (Phase 1) and before writing any candidate, proposal or finding in deep-module vocabulary: read and follow skills/improve_codebase_architecture/glossary.md (terms module, interface, implementation, depth, seam, adapter, leverage, locality; principles including the deletion test and the one-adapter / two-adapters rule; relationships; rejected framings).

Process

When starting the codebase walk: read and follow skills/improve_codebase_architecture/process.md (Phase 1 organic exploration with the deletion test; Phase 2 numbered candidates with files, problem, solution, benefits and ADR conflicts, then the user's pick; Phase 3 grilling loop with inline CONTEXT.md updates and the ADR offer on rejection).

Red flags

  • A proposal that uses "service" / "component" / "boundary" vocabulary instead of the strict glossary (drift).
  • A candidate without a files list (too abstract to decide on).
  • Solution description without locality + leverage argumentation.
  • A proposal that increases test coverage without changing the module (that's symptom treatment, not deep-module).
  • Proposing a new seam with only one adapter ("diamond" risk — hypothetical seam).
  • A proposal that violates its own CONTEXT.md vocabulary (domain drift).
  • A refactor plan without checking whether tests still test the right thing.

Common rationalizations

RationalizationReality
"It's just a small refactor"Several small refactors without glossary discipline accumulate as vocabulary drift.
"Component / service / API is standard language"Standard isn't precise enough for deep-modules discipline. The strict glossary prevents drift.
"We extract that into a util module"Util is a pattern break. A deep module has behaviour + locality. Util is pass-through.
"Several small modules are more testable"Test against implementation, not behaviour. A deep module with a small interface is easier to test (the interface is the test surface).
"We add the adapter prophylactically"One adapter = hypothetical seam. Two adapters = real seam. Adapter only when something actually varies across it.
"Pure function = automatically good"A pure function without locality (bug hides in HOW it's called) is shallow + leaky.
"We use DDD's bounded context""Boundary" is overloaded. Say seam + interface in this skill's vocabulary.

Contract

INPUT

  • Required: codebase access (repo locally or via Read tool).
  • Required: clear trigger (user request for an architecture improvement, or a periodic every-few-days run).
  • Optional: CONTEXT.md with a domain glossary (the skill uses it when present, lazy-creates when absent).
  • Optional: docs/decisions/ or docs/adr/ with ADRs.
  • Context: this skill (with the strict glossary), skills/_protocols/skill-guardrails.md, skills/documentation_and_adrs/SKILL.md.

OUTPUT

DELIVERS:

  • Phase 1 friction map (organic, qualitative — where does the reviewer experience friction?).
  • Phase 2 numbered candidate list (files / problem / solution / benefits) with strict-glossary vocabulary.
  • Phase 3 grilling conversation per picked candidate with a design-tree walk.
  • Inline side effects: CONTEXT.md updates / ADRs on rejection / cross-ref to api_and_interface_design when interface design is needed.

DOES NOT DELIVER:

  • No implementation of the refactors — only decision material.
  • No diff review — code_review_board is a different domain.
  • No cross-spec review — architecture_coherence_review is a different domain.

ENABLES:

  • A codebase-wide refactor roadmap.
  • Vocabulary discipline (anti-drift).
  • Clear decisions about seams / adapters / module shapes.
  • Testability improvement via the deep-module pattern.

DONE

  • Friction map documented (phase 1 output).
  • ≥3 numbered candidates presented in the complete format.
  • The user has picked which candidates to explore (phase 2 gate).
  • Grilling loop for picked candidates done with the design-tree walk (phase 3).
  • CONTEXT.md updates / ADRs / cross-refs done inline.
  • Strict glossary used consistently (no "service" / "component" / "boundary" drift).

FAIL

  • Retry: vocabulary drift detected → rewrite candidates with the strict glossary.
  • Escalate: ≥2 candidates contradict an existing ADR → user decision whether to revisit the ADRs.
  • Abort: no friction found → the codebase is already deep + clean. The skill is not needed now; defer to the next run.

See also

  • skills/_protocols/skill-guardrails.md — anti-patterns.
  • skills/api_and_interface_design/authoring.md — phase 3 grilling loop invokes contract-first when interface design is needed.
  • skills/documentation_and_adrs/SKILL.md — ADR format on rejection.
  • skills/code_review_board/SKILL.md — diff counterpart.
  • skills/architecture_coherence_review/SKILL.md — cross-spec counterpart.
  • skills/deprecation_and_migration/SKILL.md — when a refactor retires an old system.

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.

Reviews can't be read right now.

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.