Architecture review of a change: does it leave the repo easier or harder to change next time? Four non-overlapping dimensions — boundary (what changes together lives together), structure (decisions cheap to verify), evolution (contracts never break in place), legibility (the structure tells a reader where things are and what they do) — each judged by a clean reviewer, every finding traced to whether this change introduced it. Health, not correctness. `audit` for the whole repo, `audit <path /...
$npx -y skills add Surething-io/cockpit --skill ar --agent claude-code
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Ar?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/surething-io-cockpit-50eb1825)
---
name: ar
description: "Architecture review of a change: does it leave the repo easier or harder to change next time? Four non-overlapping dimensions — boundary (what changes together lives together), structure (decisions cheap to verify), evolution (contracts never break in place), legibility (the structure tells a reader where things are and what they do) — each judged by a clean reviewer, every finding traced to whether this change introduced it. Health, not correctness. `audit` for the whole repo, `audit <path / feature>` for one area as it stands."
argument-hint: "[PR · branch · commit | audit [<path / feature>] | new]"
---
# ar — Architecture Review
Architecture debt never turns a test red, so line-by-line review and tools both miss it. It
lives in four things that rot slowly: **where boundaries are drawn, where code is placed, how
contracts are changed, whether a newcomer can still read the structure**. ar asks one question — **is the next change cheaper or more
expensive?** Whether the code is *correct* is not ar's question.
## Four dimensions
| Dimension | Invariant |
|---|---|
| **Boundary** | what changes together lives together |
| **Structure** | decisions are cheap to verify |
| **Evolution** | contracts never break in place |
| **Legibility** | the structure tells a reader where things are and what they do |
They are the four orthogonal axes of change cost — space, verification, coordination,
understanding. The
first principle, the admission gate and every judgement live in `reviewer.md`; this file is the
main session's: it picks the mode, dispatches, gates and assembles, and never judges.
## Principles (reason from these when no rule fits)
- **P1 The clean reviewer is the ordinary maintainer** — every judgement runs in a clean
subagent that sees only the brief and these files. Where it struggles to read, the real
maintainer will be bitten. The author's rationale ("this place is special") never reaches it;
the main session never judges, filters, or steers.
- **P2 Lossless relay** — the main session owns the frame; everything inside a finding is the
reviewer's own words.
- **P3 Evidence over intuition** — boundaries on co-change and the import graph, contracts on
consumers actually found, probability on measured churn. "Looks coupled", "nobody uses
that", "changes often" are leads.
- **P4 Answer the mode's question** — a change review says which way *this change* moved the
architecture and never bills it for debt it didn't touch; an audit says how healthy the
scope is as it stands (§1).
## Files
| File (under `{{COCKPIT_DIR}}/skills/ar/`) | Holds | Who opens it |
|---|---|---|
| `SKILL.md` | principles, modes, orchestration, report gate, fix plan | the main session only |
| `reviewer.md` | first principle, admission gate, instantiation, sources (cg / git / grep), finding semantics, map, output format, format gate | every reviewer; the main session for "Output" and "Format gate" when gating |
| `boundary.md` · `structure.md` · `evolution.md` · `legibility.md` | one dimension's method | the reviewer of that dimension; an `all` reviewer opens each fired one |
A reviewer that skips its dimension file reviews with no method and its findings fail the
gate. Running a file from memory of this table is not running it — open it.
**Where a rule goes.** Anything a reviewer emits or is checked against — method, finding
semantics, output format, the format gate, what to do with a malformed brief — lives in the
reviewer files. `SKILL.md` holds only what the main session does: pick the mode, dispatch,
assemble, plan fixes. A reviewer rule placed here is a rule no reviewer reads.
Reviewers are pointed at `reviewer.md`, never at this file: its templates (especially the fix
plan) are the main session's, and a reviewer that reads them emits them.
> **A reviewer who landed here anyway:** close this file, open `reviewer.md` and your dimension
> file(s). Don't spawn further subagents.
---
## 1. Modes — the only place they differ
Every rule below that depends on the mode reads this table; nothing else branches on it.
| | **change** (default) | **area audit** `audit <path / feature>` | **repo audit** `audit` |
|---|---|---|---|
| Question | which way did this change move it | how healthy is this area | how healthy is the repo |
| Range | `git diff <merge-base>` + untracked | the area's paths (findings live here); what they import and what imports them is evidence only | the whole working tree |
| Triage (§2.1) | yes | no — all four fire | no — all four fire |
| Reviewers | per fired dimension; clearly tiny → 1 × all fired | 4 | 4 |
| Rounds (§2.2) | per task | per area | per repo |
| Origin | introduced / worsened / pre-existing | `audit` | `audit` |
| Outside list | pre-existing debt the change didn't touch | debt located outside the area's paths, neighbours included | none |
| Registered list (brief) | known residuals of this task | none | none |
| Verdict counts | introduced + worsened + intent-blocking | all findings | all findings |
| Co-change | changed files' partners not in the change | the area's hot files' partners outside it | whole-repo matrix |
| Map | modules the change touches, `+` on new edges | the area's layers, its in / out edges | declared layer stack, violating edges |
| Fix placement (§4) | this change only if all three conditions hold | separate PRs | separate PRs |
A feature name resolves to paths. This is scoping, not judgement — the main session proposes,
states the paths in the heading, and the user corrects them:
```python
def audit_area(arg):
if is_path(arg): return paths(arg) # one or more paths / globs
leads = dirs_named(arg) + files_named(arg) + rg_files(arg) + cg_search(arg) # cg search
# is noisy for short names: leads only
roots = the code directories, routes, CLI and skill the leads agree on, smallest first
if two readings remain: ask_user("which of these is <arg>?", candidates) # one question
return roots # heading: "audit <arg> (<roots>)"
```
The area's paths are a fact about scope, stated in the brief and the heading — not a hint about
what is wrong.
---
## 2. Main session
```text
user args ─► mode (§1) ─► triage (change only) ─► brief (§2.3) ─► clean reviewers ∥
─► format_gate, bounce to the same reviewer ─► relay by section ─► report (§3) ─► fix plan (§4)
```
```python
def run_ar(target, user_args):
mode = MODES.pick(user_args) # §1
scope = mode.range(target) # diff / area paths / repo
intent = frozen_intent(target, mode) # change: PR text / requirement / commit
# message, never the dev session's rationale;
# audit: "audit of <area or repo>"
task = (mode.task_key(target), intent)
prev = last_review_heading(conversation, same_task=task)
round = 1 if prev is None or user_says_new(user_args) else prev.round + 1
registered = mode.registered() # §1 row; change: the residuals this task
# registered (fix-plan outside items, PR
# residual list), one line each, no rationale
fired = triage(scope) if mode.triage else ALL
if not fired:
return f"## Architecture review: {task} (round {round})\nNo architectural impact: <why>"
reviewers = mode.reviewers(fired, scope) # §1 row "Reviewers"
brief = BRIEF.fill(mode, scope, round, intent, registered)
assert dispatch_check(brief, round)
mapper = first fired of (boundary, structure, evolution, legibility) # draws the map
reports = parallel(spawn_clean(brief.with_scope(r, draws_map=(mapper in r.dimensions)))
for r in reviewers)
for r in reports:
while (errors := format_gate(r)): # reviewer.md "Format gate"
r = ask_same_reviewer(r, "fit your own findings to the format", errors)
# a bounce changes form only; a content change (a number, a rating) must be
# stated in the re-emitted report, never slipped in
return assemble(reports, mode)
def assemble(reports, mode):
# Reviewer text is relayed VERBATIM, one section per dimension, in the order boundary,
# structure, evolution, legibility (an `all` reviewer's report is split at its own dimension
# lines). Findings are already numbered by their reviewer — B1.., S1.., E1.., L1.. — so nothing is merged,
# renumbered, de-duplicated, trimmed or re-worded. One spot seen on several axes stays as
# several findings: each axis says something different about it, and the fix plan (§4) is
# where one root cause becomes one group.
# The main session writes only, each marked "(main)":
# - the heading + verdict (§3), with the index when there are > 5 findings;
# - one cross-reference line: ids whose first Evidence ranges overlap, mechanically —
# "(main) same spot: B2 ↔ S1, E3 ↔ B4" (omitted when none);
# - a section heading before each relayed report ("### Boundary", ...);
# - one total line after the last section;
# - the fix plan (§4).
# MAY also: bounce a report through the gate; ask a reviewer for ITS OWN missing detail.
# MUST NOT: relay findings between reviewers; point a reviewer at a path; downgrade, drop,
# reclassify; explain a finding away with the dev session's context.
# Dispute → a FRESH clean subagent re-checks it.
sections = [Section(dim, r.part(dim)) for dim in (BOUNDARY, STRUCTURE, EVOLUTION, LEGIBILITY)
for r in reports if dim in r.dimensions]
xref = overlaps(f for sec in sections for f in sec.findings) # by first Evidence range
return render(heading_and_verdict(sections, mode), xref, sections,
"(main) " + recount(sections, mode))
```
### 2.1 Triage — change mode, mechanical, from the diff alone
The main session decides only *which reviewers to spawn*, from facts a script could check.
| Fires | When the diff… |
|---|---|
| **Boundary** | touches ≥ 2 top-level modules, adds an import across modules, adds a module or a file at a module root, or adds a type / constant to a shared file |
| **Structure** | adds or changes branching in code with `await` / callbacks / threads / I/O, or adds code to a persistence / transport layer |
| **Evolution** | touches a contract surface: migrations / schema, event or queue payloads, cross-process types, public API routes, persisted enums / ids / config keys, telemetry definitions |
| **Legibility** | adds, moves or renames a module, directory, file or export; changes a public signature; adds a layer of indirection (factory, registry, re-export, event hop); touches architecture docs |
None fires (copy, rename proven complete by grep, tests or docs only) → "no architectural
impact". Unsure → it fires.
### 2.2 Rounds
Every round reviews the whole range, not the increment — one pass misses a different few each
time. Same task (§1 row "Rounds", same intent, work since the last review fixes its findings) →
next round; another task, a changed intent, or `new` → round 1. Unsure → ask one question. The
heading carries both: `## Architecture review: <task> (round N)`.
### 2.3 Brief — fill in verbatim, add nothing
```text
Read and follow {{COCKPIT_DIR}}/skills/ar/reviewer.md and, for each dimension in your scope,
{{COCKPIT_DIR}}/skills/ar/<dimension>.md. You are the clean reviewer.
Your scope: <boundary | structure | evolution | legibility | all: <fired dimensions>>.
Map: <you draw it | you don't draw one>.
Mode: <change | area audit | repo audit> — origin: <§1 row>; outside: <§1 row>;
co-change: <§1 row>; map: <§1 row>
Write the report in <user's language>; identifiers and file:line unchanged.
## Under review
Repo: <abs path> Branch: <name> PR: <url or "none"> Round <N>
Range: <§1 row "Range", filled in — for an area, its paths>
## Intent (round 1 text, unchanged)
<PR text / requirement / commit message, or "audit of <area or repo>">
## Already registered — report only if this change makes one worse
<one line per residual, no rationale; "none">
## Constraints
Read-only: no edits, commits, pushes, checkouts, stashes, worktrees, installs, PR comments or
external writes. <environment limits the user stated (e.g. a cg endpoint unavailable), or omit>
```
Nothing else goes in: no focus areas, no "the author did X because Y", no earlier findings or
fixes, no paths beyond the range, no restated format. Each hands the reviewer the author's view
— the one thing it exists to lack (P1). If it seems to need more, the intent is incomplete:
tell the user instead.
```python
def dispatch_check(brief, round):
return all([brief.sections == BRIEF.sections, # nothing added or dropped
brief.intent == round_1_intent(task), # verbatim
f"Round {round}" in brief,
brief.range == mode.range_text(scope)]) # §1, never narrower
```
---
## 3. Report and gate
```python
REPORT = [ # exactly these parts, in this order, nothing else
"heading+verdict", # "## Architecture review: <task> (round N)" +
# "<N> findings (🔴a 🟡b ⚪c). Worst: <Consequence verbatim> (<id>)"
# ties (Worst and index): B, S, E, L in that order, then by number
# N counts what §1 row "Verdict counts" says, across all sections;
# > 5 findings → an index, a Markdown list sorted by severity:
# "- S1 🔴 <Consequence>" (change mode adds the origin after the rating)
"cross-reference", # "(main) same spot: B2 ↔ S1" — omitted when no ranges overlap
"sections", # "### Boundary" / "### Structure" / "### Evolution" / "### Legibility", each followed by
# that reviewer's report verbatim: map (mapper only), findings,
# outside, coverage — reviewer.md "Output"
"total", # "(main) <the §1 'Verdict counts' line>" after the last section
]
# blank line before the heading and before and after every code block
# no impact × probability chart: severity already is that product, findings are sorted by it
# and churn is on every first line — a chart would restate them
# format_gate: reviewer.md "Format gate" — one definition, run by the reviewer before it
# emits and by the main session on every report.
```
---
## 4. Fix plan — appended by the main session
The sections are relayed untouched (P2). Then the main session **always appends a fix plan**
under its own heading, built only from the findings' Evidence / Fix lines — no new analysis, no
re-rating. This is where findings merge: one root cause seen by several reviewers (often what
the cross-reference already pairs) becomes one group listing every id:
````
---
## Fix plan (main session — not a review finding)
```text
① <root cause, one line> B2 S1 E3
fix <target shape> · ~<lines, or ? when no finding line gives a size> · touches: <modules>
when this PR | separate PR (why)
```
★ Recommended: <what goes where, in what order; what is only registered>
Reply with a plain yes in your language to apply it, or name groups (①②) / findings (S1).
````
```python
def plan_fixes(report, mode):
for item in report.outside: register(item) # fixed here only if the user names it
for g in group_by_root_cause(all findings of all sections): # main's own analysis, so
# labelled as the main's
if mode != "change": g.when = "separate PR"; continue # §1 row "Fix placement"
# in THIS change only if all hold — architecture fixes tend to grow:
# 1. the cost lives in code this change wrote, not old shared code
# 2. no new mechanism (descriptor table, hook, module, event version) and no module
# the diff didn't touch
# 3. cheaper now than later (a contract not yet released, a copy not yet spread)
g.when = "this PR" if all_three(g) else "separate PR" # the user decides
if mode == "change" and no introduced/worsened 🔴 remains:
recommend("architecture does not block merging; separate PRs are follow-ups")
if mode != "change":
recommend("order the separate PRs by severity, then churn; a 🔴 in a hot file first")
```
A PR's architecture review always finds more than the PR should carry. What is cheapest now
belongs in it; a new table or a split module is its own change, reviewed on its own.