agentleFS
yugasunyugasun/aiops/skills/improve-codebase-architecture/SKILL.md

improve-codebase-architecture

Skill4 starsChanged 3 months agoApache-2.0View on GitHub

Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick. Use when the user says architecture review, codebase health, deepening, refactor suggestions, or complains about architectural friction.

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

Adopted by

Most recently taken up by

Used with

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

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

  • simo97Skill

    request-refactor-plan

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

    Also in 45 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 79 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 54 projects that use this

  • +2 more from simo97

The file

We split this skill into the rules it gives an agent

6 rules. 1 is common, 1 is distinctive, and 4 are very specific to this project.

  • 1

    Common

    Most of the 187 edited versions we read keep these.

  • 1

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

    If graphify-out/graph.json exists, tell the user: "代码图谱已就绪(N 个模块),将基于图谱做增强分析。" Then query /code-graph query god-nodes and /code-graph query …

    line 24
  2. Very specific:

    If no graph exists, tell the user: "未检测到代码图谱,使用有机探索模式。如需更精确的分析,可先运行 /code-graph build(需要先安装 graphify)。" Then fall back to organic …

    line 25
  3. Distinctive:

    Run 6 perspective agents in parallel using the Agent tool.

    line 29
  4. Common:

    Do NOT propose interfaces yet.

    line 75
  5. Very specific:

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

    line 84
  6. Very specific:

    If the user declines /code-graph build, fall back to a single Explore agent for organic exploration — the original behavior.

    line 89

“Common” is measured: kept by at least 6 in 10 of the 187 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 command is informed by the project's domain model and design-vocabulary.md — use those terms exactly in every suggestion.

The domain language in CONTEXT.md gives names to good seams; ADRs in docs/adr/ record decisions this command should not re-litigate.

Process

1. Graph check (optional)

architecture_health flows run a graph_build phase first (phases.py). If you arrive here without a graph, check for graphify-out/graph.json:

  • If graphify-out/graph.json exists, tell the user: "代码图谱已就绪(N 个模块),将基于图谱做增强分析。" Then query /code-graph query god-nodes and /code-graph query communities to get the global view. Query specific modules as needed via /code-graph query.
  • If no graph exists, tell the user: "未检测到代码图谱,使用有机探索模式。如需更精确的分析,可先运行 /code-graph build(需要先安装 graphify)。" Then fall back to organic exploration.

2. Multi-modal sweep

Run 6 perspective agents in parallel using the Agent tool. Each agent queries the code graph from a different angle. See sweep-patterns.md for agent prompt templates.

Structure agent — Identify shallow modules (god-nodes where interface ≈ implementation)

Data-flow agent — Trace cross-module data flow and seam leakage

Change agent — Identify friction from hotspots: high-coupling + high-churn modules

Test agent — Map untested critical seams (high in-degree, zero test coverage)

Security agent — Identify trust boundary violations and auth/business logic mixing

Performance agent — Structural performance risks: broad-state queries, missing cache seams, deep sync chains

3. Cross-validate

Spawn a synthesis agent that receives all 6 perspectives:

  • De-duplicate findings (same module flagged by multiple agents = higher confidence)
  • Rank by convergence: findings confirmed by 2+ agents rank highest
  • Apply the deletion test to the top findings
  • Produce a final candidate list (5-10 items)

4. Present candidates as an HTML report

Write a self-contained HTML file to the OS temp directory so nothing lands in the repo. Resolve the temp dir from $TMPDIR, falling back to /tmp (or %TEMP% on Windows), and write to <tmpdir>/architecture-review-<timestamp>.html so each run gets a fresh file. Open it for the user — xdg-open <path> on Linux, open <path> on macOS, start <path> on Windows — and tell them the absolute path.

The report uses Tailwind via CDN for layout and styling, and Mermaid via CDN for diagrams where a graph/flow/sequence reliably communicates the structure. Mix Mermaid with hand-crafted CSS/SVG visuals — use Mermaid when relationships are graph-shaped (call graphs, dependencies, sequences), and hand-built divs/SVG when you want something more editorial (mass diagrams, cross-sections, collapse animations). Each candidate gets a before/after visualisation. Be visual.

For each candidate, render a card with:

  • Files — which files/modules are involved
  • Problem — why the current architecture is causing friction
  • Solution — plain English description of what would change
  • Benefits — explained in terms of locality and leverage, and how tests would improve
  • Before / After diagram — side-by-side, custom-drawn, illustrating the shallowness and the deepening
  • Recommendation strength — one of Strong, Worth exploring, Speculative, rendered as a badge
  • Sweep evidence — which perspective agents flagged this (badge per agent)

End the report with a Top recommendation section: which candidate you'd tackle first and why.

Use CONTEXT.md vocabulary for the domain, and design-vocabulary.md for structure. If CONTEXT.md defines "Order," talk about "the Order intake module" — not "the FooBarHandler," and not "the Order service."

ADR conflicts: if a candidate contradicts an existing ADR, only surface it when the friction is real enough to warrant revisiting the ADR. Mark it clearly in the card (e.g. a warning callout: "contradicts ADR-0007 — but worth reopening because…"). Don't list every theoretical refactor an ADR forbids.

See HTML-REPORT.md for the full HTML scaffold, diagram patterns, and styling guidance.

Do NOT propose interfaces yet. After the file is written, ask the user: "Which of these would you like to explore?"

5. Grilling loop

Once the user picks a candidate, run the /grilling skill to walk the design tree with them — constraints, dependencies, the shape of the deepened module, what sits behind the seam, what tests survive.

Side effects happen inline as decisions crystallise — run the /domain-modeling skill to keep the domain model current as you go:

  • Naming a deepened module after a concept not in CONTEXT.md? Add the term to CONTEXT.md. Create the file lazily if it doesn't exist.
  • Sharpening a fuzzy term during the conversation? Update CONTEXT.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.

Legacy mode (no code graph)

If the user declines /code-graph build, fall back to a single Explore agent for organic exploration — the original behavior. The HTML report should note that findings are based on exploration only, not structured graph data, and may be less comprehensive.

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.