speckit-c4-validate
Check architecture diagrams for Mermaid syntax, C4 rule and consistency problems without changing files
- License 许可
- MIT
- 最近更新
- 2026-10-11
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- speckit-c4-validate
- metadata
- { "author": "github-spec-kit", "source": "c4:commands/speckit.c4.validate.md" }
- description
- Check architecture diagrams for Mermaid syntax, C4 rule and consistency problems without changing files
- compatibility
- Requires spec-kit project structure with .specify/ directory
03 SKILL.md 正文
Validate Architecture Diagrams
Check the current feature's architecture document and the project-level views against the C4 conventions and against the documents they are derived from.
This command is read-only. Do not create or modify any project file. Report findings and let the user decide what to fix.
User Input
$ARGUMENTS
You MUST consider the user input before proceeding (if not empty). It may limit the check to the feature or to the project-level views.
Configuration
Read .specify/extensions/c4/c4-config.yml if it exists. Use these defaults for any
key that is missing or when the file is absent:
architecture_dir:.specify/extensions/c4/docs/architecturefeature_file:architecture.mdmermaid_cli:mmdc
Steps
-
Read the rules. Read
.specify/extensions/c4/templates/c4-conventions.mdin full. -
Locate the documents. Run the prerequisites script from the repository root and parse
FEATURE_DIR,FEATURE_SPECandIMPL_PLAN:- Bash:
.specify/scripts/bash/check-prerequisites.sh --json --paths-only - PowerShell:
.specify/scripts/powershell/check-prerequisites.ps1 -Json -PathsOnly
The documents to check are
FEATURE_DIR/<feature_file>andcontext.md,containers.mdanderd.mdunderarchitecture_dir. Check the ones that exist. If none exist, report that there is nothing to validate, name the command that creates each (/speckit-c4-feature,/speckit-c4-system), and stop. - Bash:
-
Syntax. For every Mermaid block in those documents:
- If the
mermaid_clicommand is available, extract each block to a temporary file outside the repository and run<mermaid_cli> -i <file> -o <file>.svg. A non-zero exit is a syntax finding; quote the parser message. - Otherwise review the block by hand: it starts with a valid diagram type, every macro and arrow is in the allowed subset from the conventions, brackets and quotes balance, and every alias used in a relationship is declared. State in the report that syntax was reviewed manually, not parsed.
- If the
-
Rendered readability. When the C4 diagrams were rendered in step 3, measure them with
python3 .specify/extensions/c4/scripts/python/c4_layout.py score <file>.svg ...and inspect the renderings as well as the source. Report an INFO finding, quoting the counts, when a relationship crosses an unrelated element or label, labels overlap, relationship lines cross or coincide, or routes are unnecessarily long. Label overlap counts are estimates: confirm every finding in the rendering. Syntax validity alone does not establish readability. If rendering or Python is unavailable, say that layout was not measured or not visually checked. This step only reads and writes temporary files outside the repository. -
C4 rules. Check each C4 diagram against the conventions:
- one level per diagram, and one container per component diagram;
- every container and component has a technology and a description;
- every relationship has a label, and a protocol between containers;
- no element without a relationship;
- no leftover template placeholders (
[SYSTEM NAME],[Component 1]) or template example content.
-
Consistency across views.
- People and external systems in
containers.mdmatchcontext.md. - Every container boundary in a feature component diagram is a container in
containers.md, or is listed asAddin the feature's Architecture Impact table. - An element has the same alias, label and technology everywhere it appears.
- Every database container has a section in
erd.md.
- People and external systems in
-
Consistency with the feature documents.
- Every sequence participant is an element in a C4 view.
- Every user story in
FEATURE_SPEChas at least one sequence diagram, and each diagram names the story it covers. - Sequence message labels correspond to operations in
contracts/. - The feature ER diagram contains every entity in
data-model.md, with matching attributes and relationships, and nothing thatdata-model.mdlacks. - Every
FKattribute has a relationship line and the reverse. - Technologies match
IMPL_PLANTechnical Context. - The Architecture Impact table accounts for every difference between the feature diagrams and the project-level views.
-
Links.
FEATURE_SPECandIMPL_PLANlink to the architecture documents, the feature architecture document links back to them, and every relative link resolves to a file that exists.
Report
Output a findings table, most severe first:
| ID | Severity | Document | Diagram or section | Finding | Suggested fix |
|---|
Severity levels:
- ERROR: the diagram will not render, or it contradicts the spec, plan, data model or contracts.
- WARNING: a C4 convention is broken or two views disagree.
- INFO: readability or completeness suggestion.
Follow the table with the count per severity, the documents checked, and whether
syntax was parsed with the Mermaid CLI or reviewed manually, and whether layout was
measured. If there are no findings, say
so plainly. If there are findings, offer to fix them with
/speckit-c4-feature or /speckit-c4-system; do not apply
fixes from this command.
04 同仓库更多 Skills
ship
Run this repo's checks, then commit and push to the branch the user names
speckit-c4-system
Create or update the project-level C4 context view, container view and ER diagram
speckit-c4-feature
Generate a feature's C4 component diagrams, sequence diagrams and ER diagram in architecture.md
ship
Run this repo's checks, then commit and push to the branch the user names
speckit-taskstoissues
Convert existing tasks into actionable, dependency-ordered GitHub issues for the feature based on available design artifacts.
speckit-tasks
Generate an actionable, dependency-ordered tasks.md for the feature based on available design artifacts, with every task labelled against the Verification Plan and test tasks ordered first.