/re-arch:re-arch-scanfrom re-arch
Deterministic structural scan of JavaScript/TypeScript, PHP, .NET, Java/Kotlin, C/C++, Go, or Rust codebases for architecture analysis. Generates dependency graphs, coupling metrics, cycles, hotspots, data models, HTTP routes, and more. First step for any architecture audit or refactoring plan.
Ships in re-arch. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Produce facts before anyone forms an opinion. The scan is a set of scripts (Python standard library, plus the language's own tools when present) so it gives the same answer every time and does not depend on the model reading thousands of files.
python3 <this-skill-dir>/scripts/scan.py <repo-root> [--out <repo-root>/.re-arch] [--exclude 'legacy/**'] [--since '12 months ago']
Options that change what the scan may do:
--precise auto (default): use compiler-grade sources when available (table below). --precise off forces the regex layer, useful only to compare.--fetch-tools: allows downloading analysis tools from the package registry (today: the typescript package for the JS/TS resolver, cached in ~/.cache/re-arch-scan). It never runs repository code. Use it when the repo has no node_modules and the network allows it.--allow-build: allows steps that execute the project's build scripts (CMake configure to produce compile_commands.json, Maven/Gradle compile for jdeps). Ask the person before using it: build scripts are code from the repository. Without it, the scan uses what is already built or falls back.--module-depth auto (default) uses build units (projects, crates, Maven/Gradle modules, workspace packages) as the first level of modules when they exist, otherwise the first folder below the source root, and splits any module holding more than 35% of the code.--exclude for generated code, vendored libraries or legacy folders the team explicitly leaves out. Ask before excluding anything the team did not mention.--no-git and say that churn, hotspots by change frequency, co-change and knowledge distribution are missing. With a shallow clone, suggest git fetch --unshallow first. An inactive repository (no commit in the window) automatically falls back to its last 500 commits.--out (for example .re-arch/billing).Python 3.8+ is the only hard requirement.
The summary starts with a "Graph sources" section. Read it first: it says how much to trust each language's graph.
| Ecosystem | Precise source (used automatically when available) | Fallback |
|---|---|---|
| C/C++ | compile_commands.json (real -I/-D per file) + preprocessor include tree (clang++/g++ -E -H: macro-computed includes, conditional compilation) | include dirs parsed from CMakeLists, then conventional roots |
| Go | go list -e -json (exact import paths, build tags, std excluded; GOPROXY=off, no download) | module path from go.mod |
| Rust | cargo metadata --no-deps --offline (crate graph, crate roots, cross-crate use) | Cargo.toml parsed directly |
| Java/Kotlin | jdeps on compiled classes (class-level, sees inline qualified names, Kotlin) | imports + same-package names |
| .NET | .csproj ProjectReference graph (exact, no build): cross-project edges not declared are dropped as resolution errors | namespaces + type names |
| JS/TS | TypeScript's own resolver (tsconfig per file with extends, paths, exports, workspaces) from the repo's typescript or --fetch-tools | tsconfig paths + workspace names parsed by the scanner |
| PHP | PHP tokenizer: every class reference resolved with namespace and use rules (same-namespace, ::class, inline names) | use statements + same namespace |
When a precise source was not available, the summary says why in "note:" lines and how to get it (install dependencies, generate compile_commands.json, build the Java project). Pass that on to the person when the graph matters for the conclusions.
Read .re-arch/scan-summary.md first, it is short on purpose. scan.json holds every file with its imports, runtime imports, signals, churn and metrics; query it with a few lines of Python for details rather than loading it whole.
| Section | Use it to |
|---|---|
| Graph sources, notes | know how far to trust each graph |
| Build units | the compiler-enforced structure (projects, crates, modules, packages); phantom workspace dependencies |
| Dependency injection | bindings found (an empty section is normal when the framework generates implementations, as Spring Data repositories, or when constructors are wired explicitly) (explicit registrations, facades, single implementations) and runtime edges consumer -> implementation. Runtime edges are kept apart from imports: layering rules use imports, coupling and domains use both |
| Modules (Ca, Ce, I) and dependencies | modules everything depends on, modules depending on everything; "at runtime (DI)" lines show hidden coupling |
| Cycles | module cycles block layering and extraction; file cycles are often the first refactoring step |
| Mixed responsibilities | candidates for business logic in controllers/components: open each file, the signals are regexes |
| Hotspots | complex code that changes often: where refactoring pays first |
| Fix commits, most fixed files | the most concrete evidence of cost for both audiences |
| Knowledge distribution | knowledge islands in hotspots, code whose authors left, modules owned by one person (pseudonymised, see below) |
| Duplicated blocks | copy-paste, frequent in generated code |
| Data model | raw material for domain discovery |
| Co-change pairs | hidden coupling; commits sharing a ticket id (JIRA-123, #456) are grouped as one change |
| Dependency hygiene | several libraries for one job, packages imported but not declared (phantom or hallucinated), declared but never imported |
| External systems | databases, payment, email, queues, LLM APIs, hard-coded HTTP hosts: the C4 context view |
| HTTP routes | routes and handler files; the main domain signal in framework-convention layouts |
| Possible secrets | a security finding; never copy the value anywhere, cite the location only |
Knowledge distribution is about people. The scan pseudonymises authors (A1 is the largest contributor) in scan.json and every deliverable; the mapping goes to .re-arch/authors-map.json, with a .gitignore next to it, for the tech lead only. Never put real names or emails in findings, report or pitch, and present knowledge concentration as an organisational risk, never as individual performance. With fewer than 3 authors, concentration is normal and is not reported as islands.
The summary ends with the limits that apply to this run. The main ones:
db, http, ui, external_io, env_config, global_state) are pattern matches: open the cited line before turning one into a finding;Nothing to write beyond the script output. Tell the orchestrator (or the person, when run alone) in a few lines: size, test ratio, graph sources and their precision, number of module cycles, mixed-responsibility files, the top three hotspots, the share of fix commits, and anything the person should do to get a precise graph.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub gregorybabonaux/re-arch --plugin re-arch10 skills in this plugin
/re-arch-academyProduces training material to upskill a development team on the architecture and practices of a refactoring - a learning path ordered by the refactoring plan, modules anchored in the team's own code (before/after taken from their repository, katas extracted from real files, exercises, review checklists), curated references, for juniors and seniors. Use when a team must learn clean architecture, hexagonal, DDD, layering, testing legacy code or refactoring techniques, when a tech lead wants onboarding or workshop material about their codebase's target architecture, when developers who vibe-code need to learn craftsmanship basics, or as the training step of an architecture audit. Part of the re-arch suite; reads .re-arch/findings.json, options.json and plan.json./re-arch-auditUse this skill whenever someone questions the overall structure or health of an existing codebase and wants a verdict and a way forward, not a single code fix. This covers "is our repo/workspace/solution well structured?", layer or dependency leaks (domain code depending on the DB or framework), and projects, crates or modules nobody can untangle. It also covers an inherited legacy monolith or a vibe-coded/AI-generated app that is getting hard to change, rewrite vs incremental cleanup, tech debt assessment, refactoring roadmaps, and justifying the investment to a CTO, management or board. Also use it for team architecture rules and re-audits. Produces an evidence-based audit (domain map, weaknesses with file references, sized options from light fixes to modular monolith, hexagonal or CQRS, phased plan, management pitch, CI and AI guardrails, HTML report). JS/TS, PHP/Laravel/Symfony, .NET, Java/Kotlin, C/C++, Go, Rust. Not for one PR review, one-function refactor, security audit or cloud diagram./re-arch-diagnoseDiagnoses the architectural weaknesses of an existing codebase with evidence (file and line) for every finding, rated by severity and fix size, explained in technical and business impact, with the strengths to keep and what looks bad but is fine. Covers layering, business logic in controllers or UI, coupling and cycles, duplicated rules, domain boundaries, data model, testability, state, error handling, configuration and secrets, dependency hygiene, knowledge concentration, and the tells of vibe-coded or AI-generated code. Use for architecture-level code reviews, technical debt assessments, "what is wrong with this codebase", before a refactoring plan, or as the diagnosis step of an architecture audit. Part of the re-arch suite; reads .re-arch/scan.json and domains.json./re-arch-domainsIdentifies the business domains of an existing application (bounded-context candidates) from its code, data model, routes, dependency-injection wiring and git history, and draws a domain map with dependencies, external systems (C4 context view), shared technical parts, fuzzy zones and a confidence level per domain. Use when someone wants to understand what an application is made of, visualise its functional areas, prepare a modular monolith or microservice split, organise a refactoring per domain, or as the domain-mapping step of an architecture audit. Works even when folder names mean nothing, as in vibe-coded apps. Part of the re-arch suite; needs .re-arch/scan.json from re-arch-scan./re-arch-guardrailsGenerates the guardrails that keep a codebase in its chosen architecture - rules for AI coding agents (root and per-domain AGENTS.md, CLAUDE.md, Cursor rules), a project skill telling agents where new code goes, agent hooks that run the architecture check during the agent's own turn, fitness functions for CI with a frozen baseline (dependency-cruiser, deptrac, Pest arch, NetArchTest, ArchUnit, Spring Modulith, go-arch-lint, depguard, Cargo workspaces, cargo-deny, CMake targets, plus a language-agnostic checker), an ADR (MADR) and a review checklist. Use after choosing a target architecture, when AI agents keep putting code in the wrong place, to enforce layering or module boundaries, set up architecture tests, or frame vibe coding. Part of the re-arch suite./re-arch-optionsProposes and compares 2 to 4 target architectures for an existing codebase, each sized by human understanding cost and implementation size (S, M, L, XL), scored against the business's quality scenarios, justified by signals in the code and possibly different per domain. Covers targeted refactoring, transaction script, layered service/repository, feature folders, vertical slices, modular monolith, clean/hexagonal/onion, rich domain model, CQRS, event sourcing, domain events, anti-corruption layers and feature-sliced design, with reasons for rejected styles. Never defaults to hexagonal. Use when choosing which architecture to move to, comparing clean vs hexagonal vs simpler options, deciding whether event sourcing or CQRS is worth it, or as the options step of an architecture audit. Part of the re-arch suite.Other plugins' skills for the same job