graph-architecture
Architecture governance using C4 Model, ADR lifecycle, Architecture Fitness Functions, layer boundary enforcement, and drift detection
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Architecture governance using C4 Model, ADR lifecycle, Architecture Fitness Functions, layer boundary enforcement, and drift detection
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Accessibility compliance audit using WCAG 2.2 AA standards, ARIA validation, screen reader testing, keyboard navigation, color contrast analysis, and i18n readiness
Execute the ANALYZE phase of the lifecycle via the `agf` CLI — PRD creation, requirements, Definition of Ready (7 checks), cross-project learning
API governance and design audit using OpenAPI/Swagger spec generation, REST maturity model, contract validation, and breaking change detection
Human-in-the-loop PLANNING skill — investigates the project (graph + git + harness/gaps) and runs the whole ANALYZE→DESIGN→PLAN chain in one faceted loop to produce a COMPLETE PRD injected as graph backlog (epics, tasks, testable AC) for a separate agent to implement. Applies the project's planning methodologies — Impact Mapping + OKR per epic, JTBD, MoSCoW, WSJF/Cost-of-Delay, User Story Mapping, Example Mapping (Rules/Examples → Given-When-Then AC), SPIDR splitting, INVEST, Definition of Ready, Risk Matrix; the full catalogue lives in the skill body. Stops for the human after each complete PRD and iterates the next cycle from the project's own findings (dogfood). Does NOT implement. Triggers — graph-backlog-generation, gerar backlog, criar PRD, planejar feature, detalhar épico, novo ciclo, "plan the next thing", "what should we build next".
Automated bug discovery through static analysis, LSP diagnostics, pattern detection, regression hotspot analysis, and error catalog mining
Bug discovery + structured fix (5-Whys) with regression test, driven by the `agf` CLI — zero MCP
| name | graph-architecture |
| description | Architecture governance using C4 Model, ADR lifecycle, Architecture Fitness Functions, layer boundary enforcement, and drift detection |
| triggers | ["graph-architecture"] |
| version | 1.1.0 |
| author | Diego Nogueira |
| date | "2026-06-21T00:00:00.000Z" |
Architecture governance using C4 Model (Context, Container, Component, Code), ADR lifecycle management, Architecture Fitness Functions, layer boundary enforcement, and architecture drift detection. Ensures the system's documented architecture stays aligned with the actual codebase over time.
C4 context → C4 container → C4 component → ADR inventory → fitness functions → layer boundaries → drift detection → report → write_memory
Map the system's external boundaries. Identify: users (developers, AI agents), external systems (GitHub, Context7, Playwright, SQLite), and the system under audit itself. Generate the mermaid diagram with agf export --format mermaid --direction LR. Document: who uses the system, what external dependencies exist, what data flows in/out.
Map internal containers: CLI (Commander.js), MCP Server (tools), REST API (Express), Dashboard (React), SQLite Store, Knowledge Store, Code Intelligence Engine. For each container: technology, responsibility, communication protocols. Verify containers match src/ directory structure (cli/, mcp/, api/, web/, core/store/, core/code/).
For each container, map key components. Core modules: parser/, importer/, planner/, context/, rag/, search/, insights/, integrations/. Verify component boundaries: core/ never imports from cli/ or mcp/ (dependency direction rule from CLAUDE.md). Use agf code impact <file> and agf code callers <file:line> for real dependency analysis.
List the decision nodes with agf query --type decision --limit 50 --select data.nodes, and the
markdown ADRs with agf adr list. Verify each ADR has: Status (Proposed/Accepted/Deprecated/Superseded),
Context, Decision, Consequences. Check for stale ADRs (decisions no longer relevant). A missing decision
is authored with agf adr create "<title>"; the principles it must respect come from agf constitution list.
Define automated checks that verify architecture properties hold:
| Function | Tool | What It Checks |
|---|---|---|
| No circular dependencies | agf harness --violations --select data.violations | Dependency graph is acyclic |
| Layer isolation | npm run test:import-boundary | core/ doesn't import mcp/ or cli/ |
| Coupling score | agf harness --select data.breakdown.fitness | Module coupling within thresholds |
| Interface completeness | agf harness --select data.breakdown.types | Public contracts fully typed |
| Reachable from a surface | agf harness --select data.breakdown.connectivity | No capability ships dormant |
Score each fitness function pass/fail. See Fitness Function Scoring Table below for thresholds.
Verify the dependency direction rule: schemas/ <- core/ <- mcp/ <- cli/. Check for violations: grep for imports that cross layer boundaries in the wrong direction. Flag: core importing from mcp, schemas importing from core, cli containing business logic. Cross-reference with CLAUDE.md rules. See Layer Violation Remediation below when violations are found.
Compare current codebase structure with documented architecture (C4 diagrams, ADRs). Detect: new modules not in any diagram, deprecated modules still in use, component responsibilities that shifted, new external dependencies not documented. Run agf code index to refresh the symbol index, then agf gaps --kind design_drift --json for drift the graph can prove and agf gaps --kind phantom_done --json for nodes whose files never landed. Apply Architecture Drift Severity thresholds below.
Score per dimension (C4 completeness, ADR quality, fitness functions, layer compliance, drift). Generate updated C4 diagrams as mermaid. List architectural debt items. Save with agf memory write architecture-audit-<date> --content "<report>", and file each debt item as agf node add --type risk.
Numeric thresholds for each automated architecture check. [[pragmatic-programmer]] Tip 59 — test early, test automatically.
| Metric | Pass | Warn | Fail | Fix |
|---|---|---|---|---|
| Circular dependency count | 0 | — | ≥1 | Break cycle via interface or move module |
| Layer violation count | 0 | — | ≥1 | See Layer Violation Remediation |
| Module coupling score (0–1) | ≤0.3 | 0.31–0.5 | >0.5 | Extract shared abstraction; invert dependency |
| Interface completeness | 100% | 80–99% | <80% | Add missing type contracts |
| Undocumented external deps | 0 | 1 | ≥2 | Add ADR or update C4 container diagram |
| Stale ADRs (>90 days, Proposed) | 0 | 1 | ≥2 | Accept, reject, or supersede |
Overall: all pass = A, one warn = B, one fail = C, two+ fails = D/F.
Score each ADR 0–2 per criterion (max 10 points). [[pragmatic-programmer]] "There Are No Best Practices" — always record context and forces.
| Criterion | 0 | 1 | 2 |
|---|---|---|---|
| Context | Missing | Vague situation description | Clear problem statement with constraints |
| Forces | Missing | One force listed | ≥2 competing forces (cost, speed, correctness…) |
| Decision | Missing | States what but not why | States what + why this option over others |
| Alternatives | Missing | One alternative named | ≥2 alternatives with brief trade-off each |
| Consequences | Missing | Only positive outcomes | Both positive and negative consequences listed |
How many new undocumented modules or changes constitute real drift. [[humble-continuous-delivery]] — the pipeline fails fast; architecture governance should too.
| Signal | Severity | Action |
|---|---|---|
| 1 new undocumented module | Monitor | Note in next review; update C4 if it stabilizes |
| 3+ new undocumented modules | Flag | Update C4 diagrams before next feature work |
| Any layer violation | Block | Do not merge; apply Layer Violation Remediation |
| Deprecated module still imported | Flag | Schedule removal; create ADR if intentional keep |
| Component responsibility shift (no ADR) | Flag | Write ADR retroactively; re-score quality |
| New external dependency, no ADR | Block | Write ADR; add to C4 container diagram |
When a violation of the schemas/ ← core/ ← mcp/ ← cli/ rule is found, apply fixes in this order (lowest effort first):
schemas/ or a new shared/ module that both import. Best for: utility code duplicated across layers.Never leave a violation with only a comment — board it up with a tracked issue and a target date ([[pragmatic-programmer]] Broken Window Theory).
Five broken-window signals that predict architectural decay before metrics degrade. [[pragmatic-programmer]] Tip 4 — fix or board up every sign of neglect immediately.
// TODO: move this to core comments in boundary-crossing imports. Signal: engineers know the violation exists but it wasn't fixed.When any signal appears: log it, assign an owner, set a resolution date. Do not normalize it.
Economia de tokens. Os levers compartilhados por todas as skills —
--select,agf retrieve-command,agf exec chain, reuso antes de criação — vivem em_shared.md→ Token Economy. Fonte única: um parágrafo repetido em trinta arquivos é o trigésimo primeiro que envelhece sozinho.
Não precisa de flags. CLI gerencia compressão automaticamente com --ai ativo.
Consulte comandos com agf retrieve-command "<intenção>".
Ver _agf-rag.md para detalhes.