agentleFS
sponge-b0bsponge-b0b/Polaris/.agents/skills/improve-codebase-architecture/SKILL.md

improve-codebase-architecture

Skill4 starsChanged 3 months agoApache-2.0View on GitHub

Surface architectural friction and propose module-deepening opportunities that improve locality, leverage, testability, and AI navigability.

195 other projects use a version of this, 14 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

Show its rules and text

We split this skill into the rules it gives an agent

34 rules. 0 are common, 16 are distinctive, and 18 are very specific to this project.

  • 0

    Common

    Most of the 184 edited versions we read keep these.

  • 16

    Distinctive

    This author's own choices. Worth a look.

  • 18

    Very specific

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

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

    Run $codebase-design for the architecture vocabulary (module, interface, depth, seam, adapter, leverage, locality) and its principles, …

    line 14
  2. Very specific:

    Use canonical domain language from CONTEXT.md.

    line 15
  3. Distinctive:

    Treat accepted ADRs and applicable current architecture as constraints, not suggestions.

    line 16
  4. Distinctive:

    If the Living Entity Wiki exists, consult relevant Strict Invariants, Rejected Approaches, Open Questions, and Planned entries before …

    line 17
  5. Very specific:

    If authoritative sources materially disagree, surface [source-conflict] rather than designing around one side.

    line 18
  6. Distinctive:

    If the user names a module, subsystem, or pain point, use that scope.

    line 26
  7. Very specific:

    Read the relevant CONTEXT.md, accepted ADRs, and current architecture docs first.

    line 29
  8. Very specific:

    If the Living Entity Wiki exists, use wiki/index.md to locate the relevant entity page(s).

    line 31
  9. Distinctive:

    Look organically for friction:

    line 35
  10. Distinctive:

    Do not recommend refactors merely to reduce file count or create speculative abstractions.

    line 46
  11. Distinctive:

    Do not casually re-litigate accepted ADRs.

    line 50
  12. Distinctive:

    If a candidate conflicts with one, normally omit it.

    line 52
  13. Distinctive:

    if the rejection still applies, do not recommend it.

    line 56
  14. Very specific:

    if its Reconsider when: condition appears satisfied, it may be surfaced for reconsideration.

    line 57
  15. Distinctive:

    Do not override accumulated architectural memory silently.

    line 60
  16. Distinctive:

    Write a self-contained HTML report to the OS temporary directory:

    line 64
  17. Very specific:

    Follow HTML-REPORT.md for established report patterns.

    line 74
  18. Very specific:

    Prefer self-contained HTML/CSS/SVG.

    line 76
  19. Very specific:

    Use CONTEXT.md terminology for the domain and $codebase-design terminology for architecture.

    line 91
  20. Distinctive:

    Do not design interfaces yet.

    line 93
  21. Very specific:

    Use $codebase-design when exploring alternative interfaces.

    line 111
  22. Very specific:

    Use $domain-modeling only when the discussion actually changes or sharpens domain meaning.

    line 113
  23. Distinctive:

    If the user rejects the candidate:

    line 117
  24. Very specific:

    if the rejection warrants an ADR, use $to-adr-doc.

    line 120
  25. Very specific:

    Add Reconsider when: only if the owner actually establishes such a condition.

    line 125
  26. Distinctive:

    If a real experiment failed for a concrete architectural reason, use:

    line 127
  27. Distinctive:

    Do not turn unsupported agent judgment into a Rejected Approach.

    line 131
  28. Distinctive:

    If the review produces a durable architectural outcome:

    line 135
  29. Very specific:

    use $to-adr-doc for an ADR-worthy decision.

    line 137
  30. Very specific:

    use $to-doc for durable current or proposed architecture that does not warrant an ADR.

    line 138
  31. Very specific:

    use $classify-doc if an existing document needs reclassification.

    line 139
  32. Very specific:

    Do not edit entity pages directly.

    line 141
  33. Distinctive:

    Do not perform topology changes during candidate discovery.

    line 147
  34. Very specific:

    If the owner approves such a change, use $wiki-sync according to wiki/_schema.md.

    line 149

“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

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

This skill is informed by the project's domain model and shared design vocabulary:

  • Run $codebase-design for the architecture vocabulary (module, interface, depth, seam, adapter, leverage, locality) and its principles, including the deletion test, "the interface is the test surface," and "one adapter = hypothetical seam, two = real." Use those terms consistently in suggestions.
  • Use canonical domain language from CONTEXT.md.
  • Treat accepted ADRs and applicable current architecture as constraints, not suggestions.
  • If the Living Entity Wiki exists, consult relevant Strict Invariants, Rejected Approaches, Open Questions, and Planned entries before proposing changes.
  • If authoritative sources materially disagree, surface [source-conflict] rather than designing around one side.

1. Explore

Scope before scanning — YAGNI.

Deepening pays off when it makes recurring future changes easier, so prioritize areas that actually matter.

  • If the user names a module, subsystem, or pain point, use that scope.
  • Otherwise inspect enough Git history to identify recurring hot spots. If changes are scattered, widen the search deliberately.

Read the relevant CONTEXT.md, accepted ADRs, and current architecture docs first.

If the Living Entity Wiki exists, use wiki/index.md to locate the relevant entity page(s). This is a read-only consultation, not a $wiki-sync invocation.

Then explore using the project's repository-analysis tools such as $repowise, $codegraph, $codebase-memory-mcp, or $graphify.

Look organically for friction:

  • Where does understanding one concept require bouncing between many modules?
  • Where are modules shallow — interface nearly as complex as implementation?
  • Where were functions extracted mainly for testability while the real bugs live in their composition?
  • Where is locality poor?
  • Where do supposedly separate modules leak knowledge across their seams?
  • Which behavior is hard to test through its real interface?

Apply the deletion test to serious candidates: would deleting the shallow module concentrate complexity behind a deeper interface, or merely move the same complexity elsewhere?

Do not recommend refactors merely to reduce file count or create speculative abstractions.

Existing decisions

Do not casually re-litigate accepted ADRs.

If a candidate conflicts with one, normally omit it. Surface it only when concrete changed circumstances make reconsideration genuinely warranted, and mark the conflict explicitly.

Apply the same rule to Rejected Approaches:

  • if the rejection still applies, do not recommend it;
  • if its Reconsider when: condition appears satisfied, it may be surfaced for reconsideration;
  • without an explicit condition, require concrete changed circumstances rather than elapsed time alone.

Do not override accumulated architectural memory silently.

2. Present Candidates as an HTML Report

Write a self-contained HTML report to the OS temporary directory:

<tmpdir>/architecture-review-<timestamp>.html

Nothing from the review should land in the repository.

Open the report for the user with the platform's normal local-file opener and report its absolute path.

Follow HTML-REPORT.md for established report patterns.

Prefer self-contained HTML/CSS/SVG. Do not make the report's core usefulness depend on network-only assets.

For each candidate include:

  • Files — principal modules involved.
  • Problem — why the architecture creates friction.
  • Solution — the deepening direction, without designing the final interface yet.
  • Benefits — locality, leverage, testability, and AI navigability.
  • Before / After — visual comparison.
  • Evidence — concrete dependency, change, call-flow, or testing evidence.
  • Constraints — relevant ADRs, invariants, rejected approaches, Planned work, or [source-conflict].
  • Recommendation strength — Strong, Worth exploring, or Speculative.

End with a Top recommendation and explain which candidate is most worth exploring first.

Use CONTEXT.md terminology for the domain and $codebase-design terminology for architecture.

Do not design interfaces yet.

Ask:

Which of these would you like to explore?

3. Grilling Loop

Once the user selects a candidate, run $grilling.

Explore:

  • constraints and dependencies;
  • what complexity belongs behind the deeper module;
  • what should remain visible through the seam;
  • what tests should survive;
  • whether alternative interfaces should be compared.

Use $codebase-design when exploring alternative interfaces.

Use $domain-modeling only when the discussion actually changes or sharpens domain meaning. A new module name alone is not automatically a new domain concept.

Rejected candidate

If the user rejects the candidate:

  • ephemeral reasons such as "not now" or "not worth it this release" are not durable architecture knowledge;
  • if the rejection warrants an ADR, use $to-adr-doc;
  • otherwise, if the rejection is load-bearing and the Living Entity Wiki exists, use $wiki-sync to record a Rejected Approach with:

source: owner-confirmed session decision, undocumented

Add Reconsider when: only if the owner actually establishes such a condition.

If a real experiment failed for a concrete architectural reason, use:

source: session experiment, undocumented

Do not turn unsupported agent judgment into a Rejected Approach.

Accepted direction

If the review produces a durable architectural outcome:

  • use $to-adr-doc for an ADR-worthy decision;
  • use $to-doc for durable current or proposed architecture that does not warrant an ADR;
  • use $classify-doc if an existing document needs reclassification.

Do not edit entity pages directly. Normal $wiki-sync triggers own derived wiki updates.

4. Entity Topology

A review may reveal that an entity should be split, merged, renamed, added, removed, or have its Boundary Rationale changed.

Do not perform topology changes during candidate discovery.

If the owner approves such a change, use $wiki-sync according to wiki/_schema.md.

A module, package, bounded context, or graph cluster is not automatically a wiki entity.

5. Implementation Handoff

This skill reviews and shapes architecture; it does not implement the selected refactor.

Production implementation must enter the normal implementation workflow and perform its own $wiki-sync pre-change audit.

The read-only wiki consultation performed during architecture review does not satisfy that later implementation check.

Handoff

Report:

  • candidates considered;
  • selected candidate, if any;
  • supporting evidence;
  • relevant ADRs/invariants/rejections;
  • any [source-conflict];
  • architectural decision reached;
  • any $domain-modeling, $to-adr-doc, $to-doc, $classify-doc, or $wiki-sync outcome;
  • whether implementation has actually occurred.

Distinguish clearly between reviewed, architecturally decided, documented, and implemented.

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.