---
title: "Validate C4 Diagrams" component_type: script version: "1.0.0" audience: contributor status: stable summary: "CODITECT C4 Diagram Validator =============================" keywords: ['diagrams', 'generation', 'validate', 'validation'] tokens: ~500 created: 2025-12-22 updated: 2025-12-22 script_name: "validate_c4_diagrams.py" language: python executable: true usage: "python3 scripts/validate_c4_diagrams.py [options]" python_version: "3.10+" dependencies: [] modifies_files: false network_access: false requires_auth: false
CODITECT C4 Diagram Validator
STATUS: STUB - Not yet implemented VERSION: 0.1.0 (placeholder) AUTHOR: CODITECT Core Team
DESCRIPTION: Validates C4 model diagrams for structural correctness, consistency, and adherence to C4 methodology standards. Supports Structurizr DSL, PlantUML C4, and Mermaid C4 formats.
PURPOSE: - Validate C4 diagram syntax and structure - Check consistency across diagram levels (Context → Container → Component) - Verify element references and relationships - Ensure naming conventions and descriptions - Generate validation reports with actionable fixes
EXPECTED INPUTS: --paths : Paths to C4 diagram files --format : Input format (structurizr, plantuml, mermaid, auto) --level : C4 levels to validate (context, container, component, code) --output : Validation report output path --strict : Enable strict mode (fail on warnings) --fix : Attempt automatic fixes where possible
EXPECTED OUTPUTS: - c4-validation-report.json with: { "valid": true/false, "summary": { "diagrams": N, "errors": N, "warnings": N, "fixed": N }, "diagrams": [{ "file": "context.puml", "level": "context", "valid": true, "errors": [], "warnings": [], "elements": N, "relationships": N }], "cross_level_issues": [], "recommendations": [] }
DEPENDENCIES: - pyyaml - for Structurizr DSL parsing - plantuml - for PlantUML validation (optional) - jsonschema - for schema validation
IMPLEMENTATION REQUIREMENTS: 1. Parser for each C4 format (Structurizr, PlantUML, Mermaid) 2. C4 model object representation 3. Level-specific validation rules 4. Cross-level consistency checking 5. Element naming convention enforcement 6. Relationship validation (source/target exist) 7. Description completeness checking 8. Technology/tag validation 9. Auto-fix capabilities 10. Report generation
VALIDATION RULES: Context Level: - System must have name and description - External systems properly marked - Person elements defined - All relationships have descriptions
Container Level:
- Containers linked to parent system
- Technology specified for each container
- Internal/external boundary clear
Component Level:
- Components linked to parent container
- Responsibilities documented
- Interface definitions present
Code Level:
- Classes/functions linked to components
- Method signatures documented
USAGE EXAMPLES: # Validate all C4 diagrams python scripts/validate_c4_diagrams.py --paths diagrams/
# Validate specific level
python scripts/validate_c4_diagrams.py \
--paths diagrams/ \
--level container
# Strict mode with auto-fix
python scripts/validate_c4_diagrams.py \
--paths diagrams/ \
--strict \
--fix
RELATED COMMANDS: - /c4-methodology-skill : C4 methodology skill - /strategy : Architecture planning mode
SEE ALSO: - commands/c4-methodology-skill.md - docs/03-architecture/C4-METHODOLOGY-GUIDE.md
File: validate_c4_diagrams.py
Functions
main()
No description
Usage
python validate_c4_diagrams.py