agentleFS
wachawowachawo/claude-skills/skills/improve-arch/SKILL.md

improve-arch

Skill0 starsChanged 6 months agoMITView on GitHub

Find opportunities to deepen modules in the codebase, drawing on the domain language from CONTEXT.md and decisions recorded in docs/adr/.

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    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. Distinctive:

    Use these terms in every sentence exactly as defined.

    line 13
  2. Distinctive:

    Conflicts with ADRs: if a candidate contradicts an existing ADR, raise it only when the friction is actually serious enough to justify …

    line 59
  3. Distinctive:

    Don't enumerate every theoretical refactor an ADR forbids.

    line 60
  4. Distinctive:

    Do NOT propose interfaces yet.

    line 62
  5. Very specific:

    Sharpening a fuzzy term during the conversation?: Update CONTEXT.md right there.

    line 71

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

Improve Codebase Architecture

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

Glossary

Use these terms in every sentence exactly as defined. Consistent language is the point; don't slide into "component", "service", "API", or "boundary". Full definitions are in LANGUAGE.md.

  • Module — anything that has an interface and an implementation (function, class, package, slice).
  • Interface — everything the caller must know to use the module: types, invariants, error modes, call ordering, configuration. Not just the type signature.
  • Implementation — the code inside.
  • Depth — leverage at the interface: lots of behavior behind a small interface. Deep = high leverage. Shallow = the interface is almost as complex as the implementation.
  • Seam — the place where the interface lives; the point at which behavior can be changed without editing it in place. (Use this word, not "boundary".)
  • Adapter — a concrete entity that satisfies the interface at a seam.
  • Leverage — what callers gain from depth.
  • Locality — what maintainers gain: changes, bugs, and knowledge concentrate in one place.

Key principles (full list in LANGUAGE.md):

  • The deletion test: imagine you deleted the module. If the complexity disappears, it was a pass-through. If complexity surfaces at N callers, it was earning its keep.
  • The interface is the test surface.
  • One adapter = a hypothetical seam. Two adapters = a real seam.

This skill is informed by the project's domain model. The domain language supplies names for good seams; ADRs record decisions that the skill should not rediscover.

Process

1. Exploration

First read the project's domain glossary and any ADRs in the area you are touching.

Then use the Agent tool with subagent_type=Explore to walk the codebase. Don't follow rigid heuristics — explore organically and note places where friction is felt:

  • Where does understanding a single concept require jumping across many small modules?
  • Where are modules shallow — interface almost as complex as implementation?
  • Where have pure functions been extracted for testability, but real bugs hide in how they are called (no locality)?
  • Where do tightly coupled modules leak across their seams?
  • Which parts of the codebase are untested or poorly testable through the current interface?

Apply the deletion test to anything you suspect is shallow: does removing it concentrate complexity or just move it around? "Yes, it concentrates" is the signal you want.

2. Presenting candidates

Show a numbered list of deepening opportunities. For each candidate:

  • Files — which files/modules are affected
  • Problem — why the current architecture creates friction
  • Solution — a description of the change in plain language
  • Benefits — explanation in terms of locality and leverage, and how tests will improve

Use the CONTEXT.md vocabulary for the domain and the LANGUAGE.md vocabulary for architecture. If CONTEXT.md defines "Order", say "the Order intake module" — not "the FooBarHandler" and not "the Order service".

Conflicts with ADRs: if a candidate contradicts an existing ADR, raise it only when the friction is actually serious enough to justify revisiting the ADR. Flag it explicitly (e.g. "contradicts ADR-0007 — but worth reopening because…"). Don't enumerate every theoretical refactor an ADR forbids.

Do NOT propose interfaces yet. Ask the user: "Which of these would you like to explore?"

3. The grilling loop

Once the user picks a candidate, move into a grilling conversation. Walk the design tree with them — constraints, dependencies, the shape of the deepened module, what sits behind the seam, which tests survive.

Side effects happen in stride, as decisions crystallize:

  • Naming the deepened module after a concept that isn't in CONTEXT.md? Add the term to CONTEXT.md — same discipline as /grill-with-docs (see CONTEXT-FORMAT.md). Create the file lazily if it doesn't exist.
  • Sharpening a fuzzy term during the conversation? Update CONTEXT.md right there.
  • The user rejected a candidate with a substantive reason? Offer an ADR with the wording: "Want me to record this as an ADR so future architecture reviews don't re-suggest it?" Only offer when the reason will actually be useful to a future explorer to avoid re-proposing the same thing — skip ephemeral reasons ("not worth it right now") and self-evident ones. See ADR-FORMAT.md.
  • Want to consider alternative interfaces for the deepened module? See INTERFACE-DESIGN.md.

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.