agentleFS
sreejithramansreejithraman/SreeStack/skills/improve-codebase-architecture/SKILL.md

improve-codebase-architecture

Skill1 starsChanged 16 days agoMITView on GitHub

Find structural improvements, compare designs, and produce evidence-backed architecture recommendations or migration plans. HTML reports are optional.

195 other projects use a version of this, 155 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use migrate-to-shoehorn, writing-beats 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.
  • simo97Skill

    migrate-to-shoehorn

    Migrate test files from `as` type assertions to @total-typescript/shoehorn. Use when user mentions shoehorn, wants to replace `as` in tests, or needs partial test data.

    Also in 73 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 68 projects that use this

  • simo97Skill

    request-refactor-plan

    Use this skill when user wants to create a refactor plan.

    Also in 43 projects that use this

  • 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

  • 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 65 projects that use this

  • +2 more from simo97

The file

We split this skill into the rules it gives an agent

11 rules. 0 are common, 7 are distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 184 edited versions we read keep these.

  • 7

    Distinctive

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

    Use Redesign From First Principles when shaping a candidate, Model the Domain when ownership changes, and [Migrate Callers

    line 17
  2. Distinctive:

    Default to interactive exploration: present candidates, let the user select one, then explore its design together.

    line 27
  3. Distinctive:

    If the user named a direction (a module, a subsystem, a pain point), take it, and skip the inference below.

    line 47
  4. Very specific:

    Read the project's domain glossary (GLOSSARY.md) and any ADRs in the area you're touching first.

    line 50
  5. Distinctive:

    Default to a concise, high-level response in chat.

    line 77
  6. Very specific:

    Use the project's domain terms and the /codebase-design vocabulary.

    line 86
  7. Distinctive:

    If a candidate conflicts with an ADR, explain why the observed friction warrants revisiting that decision.

    line 90
  8. Very specific:

    Create an HTML report only when the user asks for one.

    line 93
  9. Distinctive:

    When a decision rests on an untested technical assumption, run a focused architecture experiment.

    line 112
  10. Very specific:

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

    line 121
  11. Distinctive:

    When a migration plan is requested, connect the finding to the recommended interface and owner, affected callers and compatibility paths, …

    line 132

“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

Improve Codebase Architecture

Resolve project, legacy, or custom glossary paths with glossary paths before reading or writing the domain vocabulary.

Surface architectural friction and propose deepening opportunities: refactors that turn shallow modules into deep ones. The aim is testability and AI-navigability.

Own structural improvement. Correct owns mining repeated agent mistakes and proving their prevention. Use its findings as inputs when the requested architecture work addresses an evidenced failure class.

Use Redesign From First Principles when shaping a candidate, Model the Domain when ownership changes, and Migrate Callers Then Delete Legacy APIs when moving callers. Codebase Design supplies the module vocabulary and interface techniques used below.

Choose the finish line

Default to interactive exploration: present candidates, let the user select one, then explore its design together. When the user requests an autonomous investigation or a plan backed by experiments, carry promising candidates through design and technical checks before returning the recommendation. Resolve routine technical questions from the repository and experiments. Ask only when a missing product choice, access, or scope decision changes the result. Both paths produce recommendations; a planning request does not authorize production refactoring.

This command is informed by the project's domain model and built on a shared design vocabulary:

  • Apply the skill "codebase-design" for the architecture vocabulary (module, interface, depth, seam, adapter, leverage, locality) and its principles (the deletion test, "the interface is the test surface", "one adapter = hypothetical seam, two = real"). Use these terms exactly in every suggestion, and don't drift into "component," "service," "API," or "boundary."
  • The domain language in GLOSSARY.md gives names to good seams; ADRs in docs/adr/ record decisions this command should not re-litigate.

Process

1. Explore

Scope before you scan: YAGNI. Deepening a module pays off by making future changes to it easier, so put extra weight on the parts of the codebase that have recently changed. Decide where to look before you look:

  • If the user named a direction (a module, a subsystem, a pain point), take it, and skip the inference below.
  • Otherwise, walk back a good stretch of the commit history (git log --oneline) to find the codebase's hot spots, the files and areas that keep coming up, and let those paths pull your attention first. If the changes are scattered with no clear hot spot, widen the net.

Read the project's domain glossary (GLOSSARY.md) and any ADRs in the area you're touching first.

Then use orchestration to assign a read-only exploration of that scope, with paths, domain vocabulary, ADRs, and an evidence-backed findings report as its completion criterion. Give the child these friction questions and ask it to explore organically:

  • Where does understanding one concept require bouncing between many small modules?
  • Where are modules shallow, with an interface nearly as complex as the implementation?
  • Where have pure functions been extracted just for testability, but the real bugs hide in how they're called (no locality)?
  • Where do tightly-coupled modules leak across their seams?
  • Which parts of the codebase are untested, or hard to test through their current interface?

Have the child also apply Codebase Design's ownership and enforcement checks and architecture signals to evidenced friction in this scope. Use caller traces, constructible states, and maintenance history to distinguish worthwhile candidates from layout or size preferences. The child returns recommendations without implementing them.

Include the deletion test in the brief: would deleting a suspected shallow module concentrate complexity, or just move it? A "yes, concentrates" is the signal to investigate. Accept the child's findings against the assigned scope and evidence before making recommendations.

2. Share findings and recommendations

Default to a concise, high-level response in chat. Lead with the change you recommend first and why it matters. For each worthwhile candidate, explain:

  • Finding — where the current design causes friction, with a brief example or file link that supports it.
  • Recommendation — what should change, in plain language.
  • Why — the expected benefit, key tradeoffs, and why it is worth doing.
  • Confidence — Strong, Worth exploring, or Speculative.

Use the project's domain terms and the /codebase-design vocabulary. Keep implementation detail for the follow-up discussion. If no change is worth recommending, say so and explain why.

If a candidate conflicts with an ADR, explain why the observed friction warrants revisiting that decision. Only include conflicts worth reopening.

Create an HTML report only when the user asks for one. For that path, read HTML-REPORT.md for the format and diagrams. Write it to <tmpdir>/architecture-review-<timestamp>.html, using $TMPDIR or /tmp (%TEMP% on Windows). Open it with the platform's file opener and share its absolute path. Include the high-level recommendation in chat too.

For interactive exploration, ask which candidate the user wants to explore before designing interfaces. For an autonomous investigation, select the strongest candidate or compare candidates when the evidence leaves a real tradeoff, then continue below.

3. Explore the design

For interactive exploration, apply "grilling" after the user picks a candidate: constraints, dependencies, the shape of the deepened module, what sits behind the seam, and what tests survive. For autonomous investigation, work through those questions from the code, ADRs, and evidence; bring back only questions that require the user's judgment or unavailable access.

When a decision rests on an untested technical assumption, run a focused architecture experiment. Compare actual caller requirements, migration cost, and enforceable invariants. Use the shared measurement guidance linked there for performance claims. Return commands, observations, and limits; keep unrun proposals distinct from checked designs.

During interactive design, apply "domain-modeling" as decisions crystallize:

  • Naming a deepened module after a concept not in GLOSSARY.md? Add the term to GLOSSARY.md. Create the file lazily if it doesn't exist.
  • Sharpening a fuzzy term during the conversation? Update GLOSSARY.md right there.
  • User rejects the candidate with a load-bearing reason? Offer an ADR, framed as: "Want me to record this as an ADR so future architecture reviews don't re-suggest it?" Only offer when the reason would actually be needed by a future explorer to avoid re-suggesting the same thing; skip ephemeral reasons ("not worth it right now") and self-evident ones.

For autonomous planning, record proposed glossary and ADR changes in the plan for review. When exploring alternative interfaces, use Codebase Design's design-it-twice guidance to compare structurally distinct designs through arena; check technical assumptions with experiments where proposals alone cannot distinguish the options.

4. Return a usable plan

When a migration plan is requested, connect the finding to the recommended interface and owner, affected callers and compatibility paths, migration order, enforcement, and verification. Explain tradeoffs and rejected alternatives using the evidence actually gathered. Include experiment artifacts and commands, and label checks still proposed. State any ADR or domain vocabulary changes needed.

Interactive findings are complete when worthwhile candidates have evidence, reasons, and confidence. A requested design or plan is complete when its technical uncertainties have been checked or have explicit evidence gaps and next checks, and the migration and proof are concrete enough to review. Production implementation follows only within the user's requested scope and uses the existing implementation, review, and verification workflows. Use architect when the selected design needs to guide implementation; carry forward the findings and experiments already checked.

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.