architecture-compass
Architecture Compass scans an existing repository to assess its architectural state, conducts a structured interview to align on current design and desired direction, and generates a shareable insights document. Use it when evaluating codebase architecture, identifying drift from intended design, planning architectural improvements, or understanding structural weaknesses in a single repository, module, or folder.
git clone --depth 1 https://github.com/techygarg/lattice /tmp/architecture-compass && cp -r /tmp/architecture-compass/skills/molecules/architecture-compass ~/.claude/skills/architecture-compassSKILL.md
# Architecture Compass
## Required Skills
Read, apply:
1. `framework:knowledge-priming` -- Load codebase context: language, framework, structure, conventions (always)
2. `framework:architecture` -- Architectural audit lens and recommended direction guardrails (always)
3. `framework:domain-driven-design` -- Strategic DDD only: bounded contexts, domain seams (conditional: only when domain complexity warrants it)
4. `framework:collaborative-judgment` -- Surface judgment calls during co-design rounds (always)
## Workflow
### Step 1: Load Existing Context
**Check for an existing insights document first.** If `.lattice/insights/architecture.md` already exists:
- Read it. Check the Session Status table using these three states:
- `pending` — row exists, no content written yet
- `in-progress` — content exists in the section but no agreed date recorded
- `✅ agreed` — content exists and date is recorded
- Resume from the earliest `pending` or `in-progress` phase. For `in-progress` phases: present the existing content for re-confirmation rather than regenerating it.
- **In-progress without content:** If Current Architecture is `in-progress` but the document has no Current Architecture content (the previous session's scan context was lost), re-run Step 2 scan before presenting.
- **Staleness check:** If the most recent `✅ agreed` date in the Session Status table is older than 30 days, run a lightweight re-scan (Steps 2.1 and 2.6 only — tree + imports). If material structural changes are detected, present them and ask whether Current Architecture needs revision before proceeding.
- Do not re-scan if Current Architecture is already `✅ agreed` and the staleness check passes.
- Tell the user what was found and which phase the session resumes from.
If no existing document: proceed from Step 2.
Check for `.lattice/config.yaml`. Load `knowledge-base.md` and `architecture.md` from `.lattice/standards/` if they exist — these shape both the audit lens and the recommended direction proposal.
If no `.lattice/` config exists, offer to run `lattice-init` first. If declined, infer defaults from the scan.
Use `framework:knowledge-priming` to establish codebase identity before analysis.
---
### Step 2: Silent Scan — Architectural Signal Extraction
Do not ask any questions yet. Scan first, form a hypothesis, then ask only what code cannot reveal.
**Confirm scope before scanning.** If the working directory is a monorepo or contains multiple independent services/modules, ask: *"Which service or module should this assessment focus on?"* Do not scan the full monorepo root — assess one bounded scope at a time. If the user requests the full monorepo: explain that a single insights document cannot meaningfully capture many independent architectures. Offer: (1) assess the shared infrastructure/platform layer as one scope, (2) produce a lightweight index of all services with one-line architecture classification, then deep-assess the 2–3 most painful ones. If the user still insists, proceed with a service-by-service scan at reduced depth (Steps 2.1 + 2.6 per service).
This is signal extraction, not a full read. **Target: 15–25 file reads** (view/open operations). Grep, glob, and directory listings do not count against this budget — they are structural reconnaissance, not deep reads. Stop reading a module once its responsibility, dependencies, and layer fit are clear.
**Scanning protocol — execute in order:**
1. **Directory tree** (3 levels deep) — intended organization, layer structure, naming conventions. Do this before opening any file.
2. **Dependency manifests** — `package.json`, `pom.xml`, `go.mod`, `requirements.txt`. Language, framework, key external dependencies.
3. **Architecture documents** — `README.md`, `ARCHITECTURE.md`, `docs/`, ADR directories. The intended architecture often lives here — the gap between intention and reality is itself a finding.
4. **Archaeology** — before analysing flows, reduce scope:
- Dead code (no callers) — candidates for deletion, but verify no side effects first: static initializers, scheduled tasks, event listeners, and framework hooks are invisible to call-graph analysis
- Duplicate functionality — two implementations of the same concept, must reconcile before any change
- Implicit coupling — shared mutable state, globals, ambient context, thread-locals
- Hidden integration points — outbound calls to external systems in unexpected places
5. **Seam identification and viability** — natural boundaries where one side can change without the other knowing:
- Domain seams (distinct business concepts), technical seams (I/O vs. business logic), team seams, temporal seams
- For each seam: assess viability — how many callers cross it? Cheap seams become first moves.
6. **Import and dependency patterns** — grep import statements across all source files. Do not open full bodies. Reveals dependency direction, load-bearing modules, layer violations cheaply.
7. **Entry points** — 3–5 files: routes, controllers, CLI handlers, event consumers. Reveals outermost layer.
8. **Interface and contract files** — interfaces, abstract classes, ports. Reveals intended boundaries, whether followed or not.
9. **One representative file per top-level module** — confirm responsibility, catch what import grep missed.
10. **Stop. Form the hypothesis:**
- What the architecture actually is vs. what it was intended to be
- **Drift or mismatch?** Drift = sound intention, gradual decay → restore. Mismatch = wrong pattern for domain → replace. This shapes the recommended direction.
- Which seams are viable (low exploitation cost)
- Most significant violations, with specific named evidence
- Dead code and duplicates that can be cleaned up before any structural work
If a module remains unclear after Step 9, read one additional file from it. This is the only scan extension permitted.
**If the scan produces no meaningful architectural signal** — fewAudit and fix all Lattice documentation, README, docs/, GitHub issue templates, and CLAUDE.md to ensure they are fully aligned with the current skill inventory. Documentation drift is the most common source of user confusion in Lattice — a skill exists in the codebase but not in the docs, or a renamed skill leaves a stale reference in the bug report template. If you've made any change to skills/ and haven't run this, run it now. Use when the user says 'align docs', 'audit docs', 'update documentation', 'skill align', 'check docs are in sync', 'audit skill inventory', 'ensure docs are aligned', 'are the docs up to date', or 'what needs updating'. Standalone — does not call other skills.
Create a new Lattice skill — atom, molecule, or refiner — following all framework conventions. Writing skill files manually almost always produces convention violations: wrong section order, missing confirmation gates, defaults.md without the right structure. This skill knows all of that and guides you through it. Use whenever adding any new atom, molecule, or refiner to Lattice, or when the user says 'create a new skill', 'add an atom', 'add a molecule', 'add a refiner', 'build X for Lattice', 'new lattice skill', or 'skill forge'. Does not validate, align docs, or deploy — those are separate skills you run after.
Deep behavioral audit of a Lattice skill — proposes 3 review personas relevant to the skill, runs independent scenario analysis from each persona's perspective, then merges only the high-confidence, practical findings into a severity-ordered gap report with proposed fixes. Structural validation (conventions, cross-references) is skill-validate's job — this skill finds gaps that would realistically surface when someone actually uses the skill: missing scenario handling, ambiguous instructions, silent failure cases, and behavioral inconsistencies. Filters out theoretical edge cases, low-likelihood speculation, and findings owned by other skills. Use after writing or significantly changing any skill, or when the user says 'review this skill', 'deep review', 'does this skill work', 'find gaps in this skill', 'stress test this skill', 'review from different angles', or 'skill review'. Standalone — does not call other skills.
Validate any Lattice SKILL.md against all tier conventions — atoms, molecules, and refiners. Catches structural errors, broken cross-references, and convention violations before they reach the repo. If you just wrote or modified a Lattice skill file and haven't run this yet, run it now — manual review consistently misses the same categories of errors this skill is specifically designed to catch. Use when the user says 'validate this skill', 'check this skill', 'does this follow conventions', 'review this skill file', 'check my SKILL.md', or 'skill validate'. Reports PASS/FAIL with specific file-and-section findings and actionable fixes. Standalone — does not call other skills.
Facilitate a structured conversation to define architecture principles for a repository. Supports multiple architecture styles: clean architecture (default), hexagonal / ports & adapters, modular monolith, or custom. Produces a formal architecture document that the corresponding atom will use. Use when setting up a new project, defining architecture standards, or when the user says 'setup architecture', 'define layers', 'architecture principles', 'help me define my architecture', 'hexagonal architecture', 'modular monolith', 'ports and adapters', or 'define my architecture style'.
Enforce architectural rules when generating or modifying code. Defaults to clean architecture; supports any architecture style via the architecture-refiner. Validates layer responsibilities, dependency direction, and structural constraints using the loaded architecture rules. Use when generating code, reviewing architecture, creating new files, or when the user mentions 'architecture', 'layers', 'structure', 'dependency rules', 'hexagonal architecture', 'ports and adapters', 'modular monolith', or 'onion architecture'. Also use when reviewing generated code for structural compliance.
Investigate, reproduce, and safely fix a bug with regression protection. Composes context, diagnosis, architecture, code quality, and testing guardrails into a reproduce-first repair workflow. Use when the user says 'fix this bug', 'debug this', 'investigate this failure', 'patch this regression', 'repair this issue', or 'why is this broken'.
Facilitate a structured conversation to define clean code principles for a repository. Produces a formal clean-code.md document that the clean-code atom will use as its override. Use when setting up coding standards, defining code quality rules, or when the user says 'setup clean code', 'define coding standards', 'code quality principles', 'coding guidelines', or 'help me define my code standards'.