Structured architecture analysis evaluating layer boundaries, dependency direction, circular imports, and public API surface.
From workflow-orchestrationnpx claudepluginhub mikecubed/agent-orchestration --plugin workflow-orchestrationThis skill uses the workspace's default tool permissions.
Designs and optimizes AI agent action spaces, tool definitions, observation formats, error recovery, and context for higher task completion rates.
Implements structured self-debugging workflow for AI agent failures: capture errors, diagnose patterns like loops or context overflow, apply contained recoveries, and generate introspection reports.
Compares coding agents like Claude Code and Aider on custom YAML-defined codebase tasks using git worktrees, measuring pass rate, cost, time, and consistency.
Use this skill when a developer or agent needs a systematic evaluation of a codebase's architectural health. It applies the ARCH-1 through ARCH-6 analytical framework to detect layer violations, circular imports, missing abstractions, and dependency direction problems. When the map-codebase skill has already run, this skill consumes its factual context brief to avoid redundant discovery.
Persistent team, squad, or fleet-style long-lived orchestration is out of scope for this skill. Use a separate orchestration layer if persistent coordination is needed.
Activate when the developer asks for things like:
Also activate when:
/workflow-orchestration:map-codebase has run and the developer wants deeper analysis;Before you start, identify:
.agent/architecture-report.md);arch-check skill (from clean-code-codex) is available in the current session;If any critical inputs are missing, ask the developer before proceeding.
Use separate roles for:
The scout produces a factual context brief of the architectural structure. The reviewer applies judgment against the ARCH-1 through ARCH-6 framework. Keep fact-gathering and evaluation separate.
Resolve the active model for each role using this priority chain:
Project config — look for the runtime-specific config file in the current project root:
.copilot/models.yaml.claude/models.yamlThese are plain YAML files (no markdown, no fenced blocks). Read the implementer, reviewer, and scout keys directly. If a key is absent, fall back to the baked-in default for that role — do not re-prompt for a key that is missing.
Session cache — if models were already confirmed earlier in this session, reuse them without asking again.
Baked-in defaults — if neither config file nor session cache exists, show the defaults below, ask the user to confirm or override them once, then cache the answer for the rest of the session.
| Runtime | Role | Default model |
|---|---|---|
| Copilot CLI | Implementer | claude-opus-4.6 |
| Copilot CLI | Reviewer | gpt-5.4 |
| Copilot CLI | Scout | claude-haiku-4.5 |
| Claude Code | Implementer | claude-opus-4.6 |
| Claude Code | Reviewer | claude-opus-4.6 |
| Claude Code | Scout | claude-haiku-4.5 |
Before launching discovery, check SESSION.md ## Decisions for a brief-path entry from a prior map-codebase run.
brief-path exists and the file at that path is readable → load it as the factual context brief and skip Step 2.If no usable brief exists, run a single scout pass to gather the minimum context needed for architecture evaluation:
This is a narrower pass than full map-codebase — it gathers only what the ARCH rules need.
Apply each rule against the gathered context. For each rule, the reviewer produces a verdict and supporting evidence.
ARCH-1 — Layer violations
Check whether any module bypasses its expected layer boundary. For example:
Verdict: PASS if no violations found, FAIL with specific file and import locations.
ARCH-2 — Circular imports / dependency cycles
Detect circular import chains. Use static analysis tools if available (e.g., madge, deptree, go vet), or trace import graphs manually for smaller codebases.
Verdict: PASS if no cycles found, FAIL with the cycle chain (A → B → C → A).
ARCH-3 — Missing public API declarations
Check whether internal modules are accessed directly by external consumers instead of through a declared public API (e.g., index files, __init__.py, mod.rs, or explicit exports).
Verdict: PASS if all cross-boundary access goes through public APIs, FAIL with specific violations.
ARCH-4 — Dependency direction violations
Verify that dependencies flow in the expected direction (upper layers depend on lower layers, not the reverse). For example:
Verdict: PASS if dependency direction is consistent, FAIL with specific inversions.
ARCH-5 — God modules
Identify modules with too many responsibilities. Heuristics:
Verdict: PASS if no god modules found, FAIL with specific modules and evidence.
ARCH-6 — Missing or incomplete abstraction boundaries
Check for cases where abstraction boundaries are implied but not enforced:
Verdict: PASS if abstraction boundaries are present and enforced, FAIL with specific gaps.
If the arch-check skill from clean-code-codex is available in the current session:
arch-check;arch-check was used.If arch-check is not available, note its absence in the report and rely on the manual evaluation only.
Merge all evaluation results into a single report:
arch-check was integrated;Write the report to the confirmed output path. If the write fails, try the fallback path docs/architecture-report.md.
Write .agent/SESSION.md using the full schema defined in docs/session-md-schema.md:
current-task: "Architecture review against ARCH-1 through ARCH-6"
current-phase: "architecture-reviewed"
next-action: "address violations or proceed to implementation"
workspace: "<repository root or subtree>"
last-updated: "<ISO-8601 datetime>"
Required sections:
## Decisions — record report-path: <actual output path>, context source, and arch-check availability## Files Touched — the report file path## Open Questions — any ARCH rules that could not be fully evaluated## Blockers — blocking violations that must be addressed before implementation## Failed Hypotheses — analysis approaches that did not yield resultsIf the SESSION.md write fails: log a warning and continue. Do not block workflow completion.
All 6 ARCH rules must be evaluated. A rule that cannot be fully evaluated (e.g., no import graph available for ARCH-2) counts as evaluated but must be recorded with an "inconclusive" verdict and the reason.
The durable architecture report must be written to disk. If both the primary and fallback paths fail, the gate fails.
If the arch-check skill was available, its output must be included in the report. If it was not available, the report must note its absence.
Before declaring the review complete, confirm ALL of the following. Any failing item blocks the "review complete" declaration.
If any item is FAIL: report the failing item(s) by name, state what must be done to resolve each, and do not advance past the gate.
map-codebase first to narrow scope.When stopping, ensure any partial results are preserved as a durable artifact so work is not lost.
Developer: review the architecture of this project before we start the refactor
# Architecture Review — my-app
**Repository:** /home/user/projects/my-app
**Timestamp:** 2025-07-20T15:00:00Z
**Scope:** full repository
**Context source:** map-codebase brief (.agent/codebase-brief.md)
**arch-check:** integrated
## Summary
| Rules evaluated | Pass | Fail | Blocking |
|-----------------|------|------|----------|
| 6 | 4 | 2 | 1 |
## ARCH-1 — Layer violations
**Verdict:** FAIL (blocking)
- `src/api/routes/users.ts:14` imports `src/db/prisma.ts` directly (bypasses service layer)
- `src/api/middleware/auth.ts:8` reads from `src/db/sessions.ts` directly
**Action:** Route database access through the service layer.
## ARCH-2 — Circular imports
**Verdict:** PASS
No circular import chains detected (verified with madge).
## ARCH-3 — Missing public API declarations
**Verdict:** PASS
All cross-boundary imports go through index.ts barrel files.
## ARCH-4 — Dependency direction violations
**Verdict:** FAIL (warning)
- `src/utils/logger.ts:22` imports `src/services/config.ts` (utility depending on service)
**Action:** Extract config reading into a shared config utility.
## ARCH-5 — God modules
**Verdict:** PASS
No modules exceed the responsibility threshold.
## ARCH-6 — Missing abstraction boundaries
**Verdict:** PASS
Database access is consistently abstracted through the repository layer.