/re-arch:re-arch-domainsfrom re-arch
Identifies business domains (bounded-context candidates) in existing applications by analyzing code structure, data model, routes, DI wiring, and git history. Produces a domain map with dependencies, external systems, shared parts, and confidence levels.
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.
Goal: a map of the application's business areas that a developer and a manager can both read. It will not always lead to a clean architecture per domain; its first job is to make the application visible, and every later step (diagnosis, options, plan) is organised by it.
Folder structure lies in vibe-coded apps: files land where the AI put them. Each signal sees something different:
/api/invoices, InvoiceService).No single signal is enough. A domain proposed by two or three of them is credible; one supported by only one is a hypothesis.
Cluster (deterministic):
python3 <this-skill-dir>/scripts/cluster.py <repo-root>/.re-arch [--resolution 1.0]
Read .re-arch/domains-candidates.md. Too coarse (one cluster with most of the code): rerun with --resolution 1.5; too fragmented: 0.7. Note the modularity: below about 0.3 the code has weak boundaries, which is itself a finding for the diagnosis.
Framework-convention layouts (Laravel, Rails, Django, Symfony, Spring MVC with controller/service/repository packages, NestJS by layer): files are grouped by technical type and wired by the framework, so the import graph mostly shows layers and clusters come out mixed. There, use routes and entities as the primary signal: start from the "HTTP routes" section of the scan summary (or scan.json routes), group routes by resource, and attach to each group its controller, requests/validators, transformers/serializers, policies and models. Use the clusters only to confirm. Files reported as "used by 0 files" in such layouts (middleware, providers) are usually wired by the framework, not dead.
Read the code to name and correct. For each cluster, open its entry points (routes, controllers, pages, commands, handlers) and its main entities. Decide:
core (what makes the product different, rules worth investing in), supporting (needed, specific, simpler), generic (auth, billing provider, email: buy or keep simple), technical (not a business domain: db client, logging, UI kit).
The kind drives the options later: rich patterns are worth their cost in core domains much more than in generic ones.Dependencies between domains. From cluster dependencies, runtime edges, cross co-change and shared entities, list who depends on whom and why, in one short note each ("orders reads user email to send the confirmation"). A dependency in both directions is worth flagging: it is often the first thing to break. Use kind: runtime for dependencies that exist only through the DI container.
External systems. From the scan's "External systems" section, keep the systems that matter to the business (database, payment, email, queues, identity, LLM APIs, third-party SaaS, hard-coded HTTP hosts) and attach each to the domains that use it. This becomes the C4 context view of the report. Merge duplicates (two database drivers are one database unless there really are two).
Fuzzy zones. List what does not fit cleanly: an entity used by four domains (User almost always), a rule computed in two domains, a "utils" file holding business logic, files with no link at all. These are often the most valuable findings; do not hide them to make the map look clean.
Confidence. Per domain: high when supported by structure, data and history; medium with two signals; low with one, or when inferred mostly from names. Give the reason in one line. Never present a low-confidence domain as established.
Write .re-arch/domains.json following the schema below.
Validate with people. If someone is in the conversation, show the map as a short list (name, kind, confidence, main dependencies) and ask for corrections before going on: the team knows its product better than the graph does. Record validated_by_team: true only when someone confirmed.
.re-arch/domains.json{
"method": "imports + DI + co-change + data model + routes, clustered (modularity 0.42) then reviewed in the code",
"validated_by_team": false,
"domains": [
{
"id": "orders", "name": "Orders", "kind": "core",
"description": "Cart validation, pricing, discounts, order creation, payment",
"confidence": "high", "confidence_reason": "own entities, cohesive cluster, co-change inside",
"files": ["src/app/api/orders/route.ts", "src/app/checkout/page.tsx"],
"entities": ["Order", "OrderItem", "Coupon"], "loc": 120,
"depends_on": [{"id": "users", "kind": "imports", "strength": 2, "note": "reads user email for the confirmation"}]
}
],
"external_systems": [{"name": "Stripe", "kind": "payment", "used_by": ["orders"]}],
"shared": [{"path": "src/lib/db.ts", "role": "Prisma client used by every domain"}],
"fuzzy_zones": [{"title": "Discount rules", "detail": "computed in the checkout page and in the orders API", "files": ["src/app/checkout/page.tsx", "src/app/api/orders/route.ts"]}]
}
kind in core | supporting | generic | technical; depends_on.kind in imports | shared-entity | cochange | runtime. Strings in the deliverable language (.re-arch/meta.json lang, else the person's language). List all files per domain (the report truncates for display). Run python3 <re-arch-report-dir>/scripts/validate.py <repo>/.re-arch after writing: it checks ids and that every listed file exists.
Also give the person the map in the conversation (one line per domain, then notable dependencies, external systems and fuzzy zones), and offer to render it with re-arch-report, which draws the domain map and the context view, and exports both as Mermaid in .re-arch/architecture.md for the repository's docs.
What SKILL.md sets; muted values are Claude Code's defaults
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-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./re-arch-pitchWrites the management-facing case for a refactoring or architecture effort, without jargon - current risks tied to evidence, options including doing nothing, recommendation, investment in T-shirt sizes and team capacity with explicit assumptions, milestones, success indicators and the decision requested. Use when someone must convince a CTO, CEO, board, product management or a steering committee to fund technical-debt reduction or a refactoring, needs an executive summary of an architecture audit, or asks how to explain a refactoring to non-technical people. Part of the re-arch suite; reads .re-arch/findings.json, options.json and plan.json.Other plugins' skills for the same job