skills/align-architecture/SKILL.md
Verify architecture and design documents against code implementation; produce an Architecture Compliance Report when implementation diverges from ADR or design decisions.
npx skillsauth add nesnilnehc/ai-cortex align-architectureInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
验证代码实现是否与 ADR、设计文档或架构规范中记录的架构和设计决策保持一致。当实施偏离记录的决策时,生成架构合规性报告。
治理目标:生成一份可操作的架构合规性报告,将文档化的架构/设计决策与当前实施进行比较,并列出合规性差距以及影响和补救建议。
成功标准(必须满足所有要求):
设计-解决方案;当需要结构审查时,建议“审查架构”验收测试:队友能否阅读报告并立即了解哪些架构决策被违反、代码中的何处以及下一步该做什么?
本技能负责:
本技能不负责:
转交点:报告后,如果设计必须改变,则移交给“设计-解决方案”,或者如果没有设计比较,则移交给“审查-架构”以进行结构代码审查。
|场景|推荐顺序|
| --- | --- |
|日常任务完成 | align-planning(轻量级)|
|里程碑或释放门| align-planning(完整)→ 然后align-architecture |
|实施后检查| 对齐架构 |
|规划和建筑都存在问题|首先进行“对齐规划”;如果报告表明设计代码漂移 → align-architecture |
当规划层对齐不确定时,在“align-architecture”之前运行“align-planning”;否则,独立运行“align-architecture”进行设计与代码验证。
按 specs/artifact-contract.md §8 Runtime Norms Resolution Protocol 的 §8.2 / §8.3 / §8.5 实现:读项目规范若声明了 architecture-compliance artifact_type 的 path_pattern,则使用项目值;否则 fall through 到技能默认(docs/calibration/architecture-compliance.md)。本技能为固定路径治理产出,只用 path_pattern 覆盖机制。
You are responsible for architecture compliance verification.
Compare documented architecture and design decisions (ADRs, design docs) against
the codebase and produce an Architecture Compliance Report when divergence exists.
1、解决设计源码路径(项目规范或默认:docs/architecture/、docs/design-decisions/、docs/process-management/decisions/)
2.解析代码范围:
在比较之前评估设计覆盖范围:
规则:
部分 | ‘违反’ | 未知update_设计:执行权威; 应更新设计以匹配(建议“设计-解决方案”)update_code:设计保持权威;代码应该重构以匹配设计-解决方案;当需要仅结构审查时,进行“审查架构”将报告写至:
docs/ARTIFACT_NORMS.md 或 .ai-cortex/artifact-norms.yaml)docs/calibration/architecture-compliance.md(除非明确请求快照,否则覆盖)报告必须包含机器可读的合规性块(YAML 或 JSON)。
# Architecture Compliance Report
**Date:** YYYY-MM-DD
**Design Sources:**
**Code Scope:**
**Status:** compliant | partial | violated
**Evidence Readiness:** strong | weak | missing (when partial verification used)
**Confidence:** high | medium | low
## Summary
- Total decisions checked:
- Compliant:
- Partial:
- Violated:
## Compliance Gaps
### Gap 1
- **Type:** boundary violation | missing component | divergent pattern | outdated design
- **Design Source:**
- **Code Location:**
- **Impact Scope:**
- **Root Cause:**
- **Recommended Action:** update_code | update_design | both
- **Remediation:**
## Covered / Uncovered Scope (when partial verification)
- Covered:
- Uncovered:
- Reason:
## Recommended Next Actions
1.
2.
## Machine-Readable Compliance
evidence:
readiness: "strong" # strong | weak | missing
confidence: "high" # high | medium | low
gaps:
- type: "boundary violation"
designSource: "docs/architecture/adr-001.md"
codeLocation: "pkg/infra/db.go"
impactScope: "Domain layer imports infrastructure"
rootCause: "Repository interface not used; direct DB import"
recommendedAction: "update_code" # update_code | update_design | both
remediation: "Implement repository pattern per ADR-001"
不要做这些(其他技能可以处理它们):
审查架构设计解决方案align-planning何时停止并交接:
团队成员是否可以在没有额外说明的情况下针对前 1-3 个合规差距采取行动?
如果否:完善证据并明确补救措施。
如果是:报告完成;进行转交或补救。
上下文:ADR-001 规定域不得导入基础设施。代码显示域包导入数据库驱动程序。
输出:
docs/process-management/decisions/20240101-adr-001-layered-architecture.mdpkg/domain/order.go(导入pkg/infra/db)背景:项目没有 ADR 或设计文档。
输出:
上下文:只有 pkg/auth 有 ADR; pkg/orders 和 pkg/inventory 没有设计文档。
输出:
pkg/auth(根据 ADR-002 进行验证)pkg/orders、pkg/inventory(无设计来源;标记为未知)上下文:ADR-003 指定同步 API;实现使用异步事件驱动流程,利益相关者更喜欢它。
输出:
本技能产出 Architecture Compliance Report。除人类可读叙述外,机器可读片段须满足下表结构:
| 元素 | 格式 | 必填字段 | 路径模式 |
| :--- | :--- | :--- | :--- |
| 报告主体 | Markdown | front-matter(artifact_type/created_by/created_at/lifecycle);正文章节:摘要 / 设计来源 / 比对范围 / 差距列表 / 移交建议 | docs/calibration/architecture-compliance.md(默认;如需快照另起 -snapshot 副本) |
| 差距条目 | 列表项 | type(boundary_violation / outdated_design / undocumented / partial_validation)/ design_source / code_location / impact / fix(或 recommended_action) | 报告正文「差距列表」节 |
| 证据准备度 | 标量 | readiness(strong / moderate / weak)/ confidence / covered_scope / uncovered_scope | 报告正文「比对范围」节 |
| 机器可读块 | YAML fenced yaml compliance_gaps: | gaps[] 每项含 id/type/design_source/code_location/severity/fix_kind | 报告正文末尾,供 plan-next/auto-iterate 消费 |
development
Generate an LLM agent test suite (golden cases, mock-LLM unit tests, evaluator harness) from an agent implementation and its agent-test contract. Use when an agent has no tests, or a contract exists but the test code is missing.
development
After code changes, auto-detect the project's build system and local deployment method for a given directory, then build the project and restart its locally-deployed environment (Docker Compose / systemd / process manager). Never assumes — asks only when detection is ambiguous. Caches detected commands per project in .cortex/redeploy-local.yaml; re-invocations on the same project skip re-scanning until signal files change, the cache expires (30 days), or the skill version bumps.
tools
Publish a NATS message conforming to a cross-team contract, using NATS MCP tools. Authors the contract on first use if missing. Reads project-level cache (.cortex/nats.yaml) to avoid re-prompting basics across sessions.
tools
Drain pending NATS messages from a producer contract via NATS MCP tools (default batch / drain-style). Applies Tolerant Reader semantics and per-message ack/nak/term, returning aggregated stats. Reads project-level cache (.cortex/nats.yaml) to avoid re-prompting.