c4-model
Describe and draw software architecture with the C4 model, in plain ASCII instead of Mermaid or PlantUML. Carries every C4 term with its sourced definition, the C4 principles, an ASCII notation with one template per diagram type, and a lint that checks that notation. Use when the user asks for a "C4 diagram", "system context diagram", "container diagram", "component diagram", "system landscape", "deployment diagram", "dynamic diagram", or "architecture diagram", asks to "describe the architecture" of a system, repo, or workspace, or asks what a C4 term such as "container" or "component" means.
- License 许可
- MIT
- 最近更新
- 2026-11-09
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- c4-model
- description
- Describe and draw software architecture with the C4 model, in plain ASCII instead of Mermaid or PlantUML. Carries every C4 term with its sourced definition, the C4 principles, an ASCII notation with one template per diagram type, and a lint that checks that notation. Use when the user asks for a "C4 diagram", "system context diagram", "container diagram", "component diagram", "system landscape", "deployment diagram", "dynamic diagram", or "architecture diagram", asks to "describe the architecture" of a system, repo, or workspace, or asks what a C4 term such as "container" or "component" means.
02 资源文件 64
- 参考文档editing.md6.7 KB
- 参考文档examples/peasant-labs.md19.3 KB
- 许可证LICENSE.txt1.4 KB
- 参考文档pptxgenjs.md12.5 KB
- 参考文档references/ascii-notation.md15.9 KB
- 参考文档references/glossary.md18.1 KB
- 参考文档references/principles.md8.9 KB
- 脚本scripts/__init__.py—
- 脚本scripts/add_slide.py6.7 KB
- 脚本scripts/c4-lint.py12.6 KB
- 脚本scripts/clean.py9.4 KB
- 脚本scripts/office/helpers/__init__.py—
- 脚本scripts/office/helpers/merge_runs.py5.4 KB
- 脚本scripts/office/helpers/simplify_redlines.py5.6 KB
- 脚本scripts/office/pack.py4.9 KB
- 脚本scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd1.9 KB
- 脚本scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd2.5 KB
- 脚本scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd2.8 KB
- 脚本scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd1.3 KB
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd73.2 KB
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd6.8 KB
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd50.1 KB
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd624 B
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd148.5 KB
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd1.2 KB
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd8.7 KB
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd14.4 KB
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd81.7 KB
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd1.2 KB
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd7.2 KB
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd6.2 KB
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd1.2 KB
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd880 B
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd2.5 KB
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd3.4 KB
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd7.3 KB
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd22.8 KB
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd1.3 KB
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd236.6 KB
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd25.5 KB
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd24.7 KB
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd535 B
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd5.6 KB
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd3.9 KB
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd167.4 KB
- 脚本scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd4.5 KB
- 脚本scripts/office/schemas/mce/mc.xsd3.1 KB
- 脚本scripts/office/schemas/microsoft/wml-2010.xsd25.9 KB
- 脚本scripts/office/schemas/microsoft/wml-2012.xsd3.7 KB
- 脚本scripts/office/schemas/microsoft/wml-2018.xsd901 B
- 脚本scripts/office/schemas/microsoft/wml-cex-2018.xsd1.7 KB
- 脚本scripts/office/schemas/microsoft/wml-cid-2016.xsd1002 B
- 脚本scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd600 B
- 脚本scripts/office/schemas/microsoft/wml-symex-2015.xsd745 B
- 脚本scripts/office/soffice.py5.2 KB
- 脚本scripts/office/unpack.py4.0 KB
- 脚本scripts/office/validate.py3.6 KB
- 脚本scripts/office/validators/__init__.py336 B
- 脚本scripts/office/validators/base.py31.9 KB
- 脚本scripts/office/validators/docx.py16.0 KB
- 脚本scripts/office/validators/pptx.py9.6 KB
- 脚本scripts/office/validators/redlining.py8.7 KB
- 脚本scripts/testdata/lint-cases.md8.5 KB
- 脚本scripts/thumbnail.py8.6 KB
03 SKILL.md 正文
Describe architecture with the C4 model, in ASCII
The C4 model (Simon Brown, c4model.com) describes a software system as a set of zoom levels: System Context, Containers, Components, and Code. Each level is a map of one element from the level above. This skill fixes three things: the vocabulary, the principles, and one ASCII notation that a script can check. With them, every diagram in the workspace reads the same way.
Draw in ASCII, not Mermaid or PlantUML. ASCII renders everywhere the workspace writes: GitHub Markdown, issue bodies, Beads records, commit messages, terminals, and agent transcripts. It never depends on a renderer version.
When to use it, and when not
Use C4 for the static structure of a software system: who uses it, what it talks to, what runs inside it, and how the code inside one runnable unit is organised. Use it for a whole polyrepo (system landscape), one repo (system context and container), or one binary or app (component).
Do not use C4 for business processes, workflows, state machines, domain models, data models, or UI layout. The C4 FAQ excludes these on purpose. Use a sequence list, a state table, an ER diagram, or a wireframe instead. Do not use C4 to document a library, framework, or SDK as a system in its own right. Show a library as a technology label on the container that imports it, or as a component inside that container.
Workflow
-
Pick the diagram type by audience and scope. Most work needs only levels 1 and 2.
Diagram Scope Shows Audience System Landscape an organisation or workspace people and software systems everyone System Context one software system the system, its users, its neighbours everyone Container one software system the runnable units inside it technical people Component one container the components inside it developers Code one component classes, functions, packages developers, generated only Dynamic one feature or story numbered runtime interactions everyone Deployment one environment where each container instance runs technical and ops -
Build the model before the picture. Write two tables first. Elements: name, type, technology, one-sentence description. Relationships: source, target, intent, technology. Ground every row in the code, the build files, or the deploy config. Do not draw an element that has no row, and do not leave a row out of the picture. The tables are the model; the diagram is a view of it. Keep the tables in the same file as the diagram when the diagram is long-lived.
-
Draw with the notation below. Load
references/ascii-notation.mdfor the full rules and one template per diagram type. Loadexamples/peasant-labs.mdto see the workspace drawn at every level. -
Lint the file. Run
python3 scripts/c4-lint.py <file.md>from this skill directory. It finds every fenced block whose info string isc4and checks the notation. Fix every finding. Runpython3 scripts/c4-lint.py --self-testonce after any change to the script; the fixture inscripts/testdata/lint-cases.mdmust stay green. -
Walk the review checklist in
references/principles.mdbefore the diagram ships. The lint checks form. The checklist checks meaning: does a reader outside the team understand every box, every arrow, and every technology choice without the author present? -
Place it. A diagram that describes a repo goes in that repo's
AGENTS.mdordocs/. A diagram that describes the workspace goes in the workspace guide. A diagram that explains one change goes in the issue or PR body. Keep the model tables next to long-lived diagrams so that the next edit updates both.
Notation, quick reference
A diagram is a fenced code block with the info string c4. Line 1 is the title. The last section
is the key. The full rules, the closed set of nine type tags, the tags each diagram type may
carry, and one template per diagram type are in references/ascii-notation.md.
Container diagram: <scope>
+--------------------------+ +--------------------------+
| <name> | | <name> |
| [Container: <technology>]|-- <intent> (<technology>) -->| [Container: <technology>]|
| <description.> | | <description.> |
+--------------------------+ +--------------------------+
|
| <intent> (<technology>)
v
+== <name> [Software System] ===================+
| ...elements inside the boundary... |
+================================================+
Key:
Solid box = element. Double-line box = boundary. [Type] = C4 abstraction.
Arrow = one relationship, read as "source, label (technology), target".
- Element box. Solid border. Line 1 the name. Line 2 the type tag. Then the description.
- Type tag. Square brackets, closed set, technology after the colon for containers and
components. Use square brackets nowhere else in the body. The key may write
[Type]to explain the tag. Relationship technology goes in parentheses. - Boundary. Double-line border with the name and the tag in the top edge. It holds the next level down.
- Relationship. One arrow, one direction, one label with the intent and the technology. Do not draw two-headed arrows. Number the labels on a dynamic diagram.
- Width. Keep to about 100 columns. This is a layout guideline, not a lint rule.
Hard rules
- One abstraction level per diagram. A container diagram shows containers, plus the people and systems that touch them. It never shows a component. The lint enforces the allowed set per diagram type.
- Every element has a name, a type tag, and a one-sentence description. Every container and component names its technology in the tag. Two kinds of element may omit the description: a supporting element repeated from a parent diagram, and a container instance on a deployment diagram.
- Every relationship is one arrow, one direction, one intent label. On container, component, and deployment diagrams the label also names the technology or protocol.
- Every diagram has a title of the form
<Type> diagram: <scope>and aKey:section. - A container is a runtime unit: an application or a data store that must be running for the system to work. It is not a Docker container. Where a container runs belongs on a deployment diagram, never on the container diagram.
- Libraries, frameworks, SDKs, and shared modules are not containers and not software systems.
In this workspace
schema,redact, andfairtradeare libraries. Show them as technology labels or as components, never as boxes on a context or container diagram. - Do not draw a code diagram by hand. Generate it from the source, or leave it out.
- Match the diagram to the code. When the two disagree, the diagram is wrong. Re-derive the element and relationship tables from the source before you redraw.
- Every C4 diagram passes
scripts/c4-lint.pybefore it ships. A lint finding is a defect in the diagram, not a reason to relax the lint. - Cite the model, not memory. When a definition matters, quote
references/glossary.md, which cites c4model.com page by page.
Additional resources
Reference files
references/glossary.mdEvery C4 term with its definition and its c4model.com source: the five abstractions, the seven diagram types, the deployment vocabulary, the notation vocabulary, and the modelling vocabulary.references/principles.mdThe C4 principles with their sources, the verbatim notation rules, the diagram review checklist, and the history of the model.references/ascii-notation.mdThe full ASCII notation: box, boundary, arrow, key, layout rules, and one template per diagram type.
Examples
examples/peasant-labs.mdThis workspace drawn as a system landscape, a system context, a container diagram, a component diagram, a dynamic diagram, and a deployment diagram, each with its model tables. Every block passes the lint.
Scripts
scripts/c4-lint.pyLints everyc4fenced block in the given Markdown files. Exit 0 when clean, 1 on findings.--self-testruns the fixture cases inscripts/testdata/lint-cases.md. It fails unless every lint code has a case that goes red, every clean case stays green, and every name in the script'sREQUIRED_CASESmanifest is present in the fixture.
04 同仓库更多 Skills
afk-implement
Run an unattended ("AFK") implementation session as the supervisor — scope small progressive iterations, push feature branches, open pull requests, drive review waves to clean, and never merge. Use when the user says they are going AFK or to bed, asks for overnight autonomous implementation, says "don't block on me", "open PRs but don't merge", "progressive adoption", or "stack changes".
protocol
Aura protocol reference documentation — 12-phase workflow, agent roles, constraints, and coding standards. Read when you need to understand the full workflow or look up conventions.
protocol
暂无简介
example
暂无简介
example
暂无简介
example
暂无简介