Architecture Review
A two-phase skill for reviewing and improving codebase architecture. Phase 1
generates a ranked findings document; Phase 2 addresses findings
systematically, one commit at a time.
When to activate
- User asks for an "architecture review" or "code review"
- User asks to "review the codebase" or "find architectural issues"
- User asks to "address findings" from a prior architecture review
- User references
claude-review-architecture.md
- User says "architecture-review review" or "architecture-review address"
Determine the phase
Examine the user's request to determine which phase to run:
- Phase 1 — the user wants a new review generated. Keywords: "review",
"analyse", "generate findings", "what's wrong with", "architecture-review review".
- Phase 2 — the user wants to act on existing findings. Keywords: "address",
"fix findings", "work through", "architecture-review address".
If unclear, ask: "Do you want to generate a new architecture review, or address
findings from an existing one?"
Document locations
Architecture review documents live in the project's doc/ directory (create
it if it doesn't exist yet). This is the fixed convention across this
package's skills — test-quality writes its findings to doc/ too, with no
docs/ fallback — so pick doc/ even if the project already has a docs/
directory.
The two files are:
doc/claude-review-architecture.md — open (unresolved) findings.
doc/claude-review-architecture-resolved.md — resolved findings,
with commit SHA and outcome for each.
Phase 1: Generate Review
Perform a comprehensive architecture and engineering review of the current
codebase and write open findings to doc/claude-review-architecture.md.
Review dimensions
Analyse the codebase across these eight lenses:
- Good Engineering Practices -- alignment with current language idioms
and community standards; mismatched patterns, duplicate logic, and
divergent conventions across packages or files
- Correctness -- bugs, race conditions, error handling gaps, incorrect
assumptions
- Operability -- observability (structured logging, metrics, tracing),
configuration management, graceful shutdown, health checks, failure-mode
handling, resource cleanup, and deployability
- Documentation -- package and exported-symbol docs, README/setup
instructions, runnable examples, and comments that explain non-obvious
"why" rather than restating "what"
- Security -- trust boundaries, authn/authz, secret handling, input
validation, TLS/crypto usage, and dependency exposure. This is a
codebase-wide lens distinct from the diff-scoped
security-review skill;
it does not replace running that skill on a pending change.
- Hexagonal Architecture -- separation of domain logic from
infrastructure (ports/adapters), direction of dependencies, and candidates
for restructuring toward clearer boundaries
- Low Coupling / Complexity -- coupling, cohesion, cyclomatic/cognitive
complexity, testability
- Beta-Release Readiness -- go/no-go signal for shipping to early users:
gaps in error handling, config/secrets management, test coverage,
documentation, and observability that would block or risk a beta release
Execution steps
- Read the project's entry points, core packages, and test files to build a
mental model of the system.
- Analyse each dimension in turn. For each finding, record:
- Which file(s) are affected
- Which dimension(s) it falls under
- A clear description of the problem
- A concrete recommended fix
- A priority rating: High, Medium, or Low
- Write all findings to
doc/claude-review-architecture.md using the
output format below.
- After writing, report the total finding count and top three High-priority
items to the user.
Output format
Write doc/claude-review-architecture.md with this structure:
# Architecture Review: `<module-path>`
_Reviewed: YYYY-MM-DD — branch `<branch>` (<commit-sha>)_
---
## Executive Summary
<2-4 sentences: overall health, most critical theme, recommended focus>
---
## Findings
### N. <Finding Title>
- **File(s):** <path(s)>
- **Dimension(s):** <one or more of: Good Engineering Practices, Correctness, Operability, Documentation, Security, Hexagonal Architecture, Low Coupling/Complexity, Beta-Release Readiness>
- **Priority:** High | Medium | Low
- **Status:** Open
- **Description:** <what the problem is and why it matters>
- **Recommended fix:** <concrete, actionable steps>
... (repeat for each finding)
---
## Priority Table
| # | Priority | Status | Finding | File(s) |
|---|----------|--------|---------|---------|
| 1 | High | Open | ... | ... |
| 2 | Medium | Open | ... | ... |
| 3 | Low | Open | ... | ... |
<module-path> is the repo's Go module path (from go.mod), e.g.
github.com/dioad/<repo>.
Phase 2: Address Findings
Work through findings in doc/claude-review-architecture.md one at a
time. Each finding gets exactly one conventional commit — except a finding
that requires a structural refactor (splitting a type, extracting an
interface, moving a package), which follows the phased-refactor pattern
instead (see phased-refactor.instructions.md, distributed alongside this
skill, for the full methodology): a zero-behavior-change extraction commit,
then a behavior-change commit, both addressing the same finding.
Scope
If the user specifies a priority (e.g. "High only"), process only findings
at that priority. Otherwise process all unresolved findings in priority order
(High first).
Per-finding workflow
For each finding:
Plan -- read the finding and identify the minimal correct fix.
Baseline complexity -- before touching any file, record its cognitive
complexity:
gocognit <file>
Fix -- implement the change.
Verify -- run the target repo's own pre-completion checks before
committing. Prefer make verify if the repo has that target; otherwise
follow the repo's project-checks rule (see project-checks.instructions.md,
distributed alongside this skill, if the target repo carries it). If neither
is available, run this baseline in order and require every step to pass:
go generate ./... # only if the repo uses code generation
go build ./... # go build . for a single-binary repo with only a root main
go fix ./...
go fmt ./...
go vet ./...
go test -race ./...
Do not proceed to the commit step if any check fails.
Post-fix complexity -- record cognitive complexity after the fix:
gocognit <file>
The complexity score must stay the same or decrease. If it increases,
rethink the approach -- unless the only way to avoid the increase is to
game the metric at the cost of human readability (e.g. an artificial split
that reads worse than the unsplit version). In that case, keep the
readable version: record the finding as resolved with a note that the
complexity delta was knowingly accepted and why, rather than forcing an
unreadable split.
Repo-wide target (informational, used to prioritise which complexity
findings to pick up first -- not a hard per-finding gate): no more than
1-2 functions with cyclomatic complexity over 15, and fewer than 5
functions with cognitive complexity over 15.
Commit -- one conventional commit per finding:
fix: <short description matching the finding title>
Update documents -- move the finding from the open file to the
resolved file:
- Remove it from
doc/claude-review-architecture.md and update the
Priority Table.
- Append it to
doc/claude-review-architecture-resolved.md in the
resolved format:### N. <Finding Title> ✅ Resolved
- **File(s):** <path(s)>
- **Dimension(s):** <dimension(s)>
- **Priority:** High | Medium | Low
- **Resolved in:** <commit-sha>
- **Complexity delta:** <before> -> <after>
- **Description:** <original description>
- **Outcome:** <what was changed, and why any complexity increase was accepted>
Constraints
- Do not batch multiple unrelated findings into a single commit (a phased
structural refactor for one finding is not "unrelated" -- see above).
- Do not skip the pre-completion checks step.
- Do not let complexity increase after a fix, unless avoiding the increase
would require gaming the metric at the cost of readability -- in that case,
keep the readable version and record why the complexity delta was accepted.
- Do not push to remote; committing locally is sufficient.
1---2name: architecture-review3description: Activate when the user asks for a comprehensive architecture review of the codebase, or wants to systematically address findings from a prior review. Reviews across eight lenses -- good engineering practices, correctness, operability, documentation, security, hexagonal architecture, low coupling/complexity, and beta-release readiness. Generates a ranked findings document (doc/claude-review-architecture.md) or works through existing findings one commit at a time.4---56# Architecture Review78A two-phase skill for reviewing and improving codebase architecture. Phase 19generates a ranked findings document; Phase 2 addresses findings10systematically, one commit at a time.1112## When to activate1314- User asks for an "architecture review" or "code review"15- User asks to "review the codebase" or "find architectural issues"16- User asks to "address findings" from a prior architecture review17- User references `claude-review-architecture.md`18- User says "architecture-review review" or "architecture-review address"1920## Determine the phase2122Examine the user's request to determine which phase to run:2324- **Phase 1** — the user wants a new review generated. Keywords: "review",25 "analyse", "generate findings", "what's wrong with", "architecture-review review".26- **Phase 2** — the user wants to act on existing findings. Keywords: "address",27 "fix findings", "work through", "architecture-review address".2829If unclear, ask: "Do you want to generate a new architecture review, or address30findings from an existing one?"3132## Document locations3334Architecture review documents live in the project's `doc/` directory (create35it if it doesn't exist yet). This is the fixed convention across this36package's skills — `test-quality` writes its findings to `doc/` too, with no37`docs/` fallback — so pick `doc/` even if the project already has a `docs/`38directory.3940The two files are:4142- **`doc/claude-review-architecture.md`** — open (unresolved) findings.43- **`doc/claude-review-architecture-resolved.md`** — resolved findings,44 with commit SHA and outcome for each.4546---4748## Phase 1: Generate Review4950Perform a comprehensive architecture and engineering review of the current51codebase and write open findings to `doc/claude-review-architecture.md`.5253### Review dimensions5455Analyse the codebase across these eight lenses:5657- **Good Engineering Practices** -- alignment with current language idioms58 and community standards; mismatched patterns, duplicate logic, and59 divergent conventions across packages or files60- **Correctness** -- bugs, race conditions, error handling gaps, incorrect61 assumptions62- **Operability** -- observability (structured logging, metrics, tracing),63 configuration management, graceful shutdown, health checks, failure-mode64 handling, resource cleanup, and deployability65- **Documentation** -- package and exported-symbol docs, README/setup66 instructions, runnable examples, and comments that explain non-obvious67 "why" rather than restating "what"68- **Security** -- trust boundaries, authn/authz, secret handling, input69 validation, TLS/crypto usage, and dependency exposure. This is a70 codebase-wide lens distinct from the diff-scoped `security-review` skill;71 it does not replace running that skill on a pending change.72- **Hexagonal Architecture** -- separation of domain logic from73 infrastructure (ports/adapters), direction of dependencies, and candidates74 for restructuring toward clearer boundaries75- **Low Coupling / Complexity** -- coupling, cohesion, cyclomatic/cognitive76 complexity, testability77- **Beta-Release Readiness** -- go/no-go signal for shipping to early users:78 gaps in error handling, config/secrets management, test coverage,79 documentation, and observability that would block or risk a beta release8081### Execution steps82831. Read the project's entry points, core packages, and test files to build a84 mental model of the system.852. Analyse each dimension in turn. For each finding, record:86 - Which file(s) are affected87 - Which dimension(s) it falls under88 - A clear description of the problem89 - A concrete recommended fix90 - A priority rating: **High**, **Medium**, or **Low**913. Write all findings to `doc/claude-review-architecture.md` using the92 output format below.934. After writing, report the total finding count and top three High-priority94 items to the user.9596### Output format9798Write `doc/claude-review-architecture.md` with this structure:99100```101# Architecture Review: `<module-path>`102103_Reviewed: YYYY-MM-DD — branch `<branch>` (<commit-sha>)_104105---106107## Executive Summary108<2-4 sentences: overall health, most critical theme, recommended focus>109110---111112## Findings113114### N. <Finding Title>115116- **File(s):** <path(s)>117- **Dimension(s):** <one or more of: Good Engineering Practices, Correctness, Operability, Documentation, Security, Hexagonal Architecture, Low Coupling/Complexity, Beta-Release Readiness>118- **Priority:** High | Medium | Low119- **Status:** Open120- **Description:** <what the problem is and why it matters>121- **Recommended fix:** <concrete, actionable steps>122123... (repeat for each finding)124125---126127## Priority Table128129| # | Priority | Status | Finding | File(s) |130|---|----------|--------|---------|---------|131| 1 | High | Open | ... | ... |132| 2 | Medium | Open | ... | ... |133| 3 | Low | Open | ... | ... |134```135136`<module-path>` is the repo's Go module path (from `go.mod`), e.g.137`github.com/dioad/<repo>`.138139---140141## Phase 2: Address Findings142143Work through findings in `doc/claude-review-architecture.md` one at a144time. Each finding gets exactly one conventional commit — except a finding145that requires a structural refactor (splitting a type, extracting an146interface, moving a package), which follows the phased-refactor pattern147instead (see `phased-refactor.instructions.md`, distributed alongside this148skill, for the full methodology): a zero-behavior-change extraction commit,149then a behavior-change commit, both addressing the same finding.150151### Scope152153If the user specifies a priority (e.g. "High only"), process only findings154at that priority. Otherwise process all unresolved findings in priority order155(High first).156157### Per-finding workflow158159For each finding:1601611. **Plan** -- read the finding and identify the minimal correct fix.1621632. **Baseline complexity** -- before touching any file, record its cognitive164 complexity:165 ```bash166 gocognit <file>167 ```1681693. **Fix** -- implement the change.170 - If the correct fix belongs in a sibling module that is part of the171 local `go.work` workspace and is in scope for this session, edit it in172 place -- never add a `replace` directive to `go.mod`. Verify and commit173 inside that sibling repo separately.174 - If the correct fix belongs upstream but is out of scope right now,175 create a GitHub issue instead of a local change:176 ```bash177 gh issue create --repo <owner>/<repo> --title "..." --body "..."178 ```1791804. **Verify** -- run the target repo's own pre-completion checks before181 committing. Prefer `make verify` if the repo has that target; otherwise182 follow the repo's `project-checks` rule (see `project-checks.instructions.md`,183 distributed alongside this skill, if the target repo carries it). If neither184 is available, run this baseline in order and require every step to pass:185 ```bash186 go generate ./... # only if the repo uses code generation187 go build ./... # go build . for a single-binary repo with only a root main188 go fix ./...189 go fmt ./...190 go vet ./...191 go test -race ./...192 ```193 Do not proceed to the commit step if any check fails.1941955. **Post-fix complexity** -- record cognitive complexity after the fix:196 ```bash197 gocognit <file>198 ```199 The complexity score must stay the same or decrease. If it increases,200 rethink the approach -- unless the only way to avoid the increase is to201 game the metric at the cost of human readability (e.g. an artificial split202 that reads worse than the unsplit version). In that case, keep the203 readable version: record the finding as resolved with a note that the204 complexity delta was knowingly accepted and why, rather than forcing an205 unreadable split.206207 Repo-wide target (informational, used to prioritise which complexity208 findings to pick up first -- not a hard per-finding gate): no more than209 1-2 functions with cyclomatic complexity over 15, and fewer than 5210 functions with cognitive complexity over 15.2112126. **Commit** -- one conventional commit per finding:213 ```214 fix: <short description matching the finding title>215 ```2162177. **Update documents** -- move the finding from the open file to the218 resolved file:219 - Remove it from `doc/claude-review-architecture.md` and update the220 Priority Table.221 - Append it to `doc/claude-review-architecture-resolved.md` in the222 resolved format:223 ```224 ### N. <Finding Title> ✅ Resolved225226 - **File(s):** <path(s)>227 - **Dimension(s):** <dimension(s)>228 - **Priority:** High | Medium | Low229 - **Resolved in:** <commit-sha>230 - **Complexity delta:** <before> -> <after>231 - **Description:** <original description>232 - **Outcome:** <what was changed, and why any complexity increase was accepted>233 ```234235### Constraints236237- Do not batch multiple unrelated findings into a single commit (a phased238 structural refactor for one finding is not "unrelated" -- see above).239- Do not skip the pre-completion checks step.240- Do not let complexity increase after a fix, unless avoiding the increase241 would require gaming the metric at the cost of readability -- in that case,242 keep the readable version and record why the complexity delta was accepted.243- Do not push to remote; committing locally is sufficient.