c4-architect
Skill1 starsChanged 5 months agoMITView on GitHub
Generates and maintains C4 architecture diagrams (Context, Container, Component) as Mermaid in docs/architecture/. Triggers on /c4, or when significant structural changes are committed (new services, changed dependencies, new DB tables, new API routes). Auto-detects project from cwd.
Files
C4 Architect
Generate C4 model diagrams for the current project. Output: Mermaid .md files in docs/architecture/.
What to generate
| Level | File | When to generate | What it shows |
| C1 Context | c4-context.md | New project, new external dependency, new actor | System boundary, external systems, users |
| C2 Container | c4-container.md | New service/app/DB/queue added | Apps, databases, message queues, their relationships |
| C3 Component | c4-component-[name].md | New module/service layer, significant refactor | Internal components of a single container, their dependencies |
Invocation modes
| Argument | Behavior |
context | Regenerate C1 only |
container | Regenerate C2 only |
component [name] | Regenerate C3 for named container |
all | Regenerate all levels |
refresh | Diff current code against existing diagrams, update only what changed |
| (none) | Smart mode — detect what changed since last generation, update those |
Workflow
- Read existing diagrams in
docs/architecture/(if any) - Scan the project to build the architecture model:
- Package.json / Gemfile / pyproject.toml → tech stack
- Directory structure → containers and components
- API routes, DB schemas, external service calls → relationships
- Environment variables → external dependencies
- Existing CLAUDE.md / README → documented architecture
- Diff against existing diagrams — only regenerate what changed
- Generate Mermaid using C4 notation (see reference/mermaid-c4.md)
- Write files to
docs/architecture/ - Report what changed and why — flag any arrows that were added/removed
Diagram format
Each file follows this template:
# C[N] [Level Name] — [Project Name]
> Auto-generated by c4-architect. Last updated: YYYY-MM-DD
> Manual edits will be overwritten on next refresh.
```mermaid
C4Context
title System Context — [Project]
...
`` `
## What changed
- [bullet list of changes since last generation, or "Initial generation"]Rules
- Never remove a node without confirming it's actually gone from the codebase
- Preserve manual annotations — if a diagram has
%% MANUAL:comments, keep them - Flag uncertainty — if you can't determine a relationship direction, add
%% UNCERTAIN:comment - One component diagram per container — don't combine multiple containers in one C3
- Keep diagrams readable — max ~15 nodes per diagram. Split if larger.
- Use
docs/architecture/relative to project root. Create if missing. - Include a
docs/architecture/README.mdindex linking all diagrams
Post-commit hook behavior
When triggered automatically after a commit (via hook):
- Check if the commit touches structural files (new dirs, schema files, route files, package deps, docker/infra)
- If yes → run
refreshmode silently - If the refresh produces changes → commit them as
docs: update C4 diagrams - If no structural changes → skip silently
Reference
See reference/mermaid-c4.md for Mermaid C4 syntax and examples.
In this repository54 other files it gives its agents.
- AGENTS.mdAGENTS.md
- skills/deep-recon/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- adversarial-researchSkill
- algorithmic-artSkill
- api-integrationSkill
- breakdownSkill
- canvas-designSkill
- coding-agentsSkill
- compound-engineeringSkill
- context-budgetSkill
- counterfactualSkill
- critiqueSkill
- d3js-visualizationSkill
- data-analyst-agentSkill
- database-migrationsSkill
- deep-reconSkill
- design-tasteSkill
- doc-coauthoringSkill
- e2b-sandboxSkill
- ecosystem-auditSkill
- excalidraw-diagramSkill
- executing-plansSkill
- frontend-designSkill
- fullstack-agentSkill
- grillSkill
- kickoffSkill
- mcp-builderSkill
- model-migrationSkill
- naming-the-machineSkill
- full-output-enforcementSkill
- package-researchSkill
- pdf-generationSkill
- pp2pSkill
- pp3pSkill
- prompt-engineerSkill
- prompt-groundingSkill
- redesignSkill
- requesting-code-reviewSkill
- reverse-engineer-to-learnSkill
- review-changesSkill
- scratchpadSkill
- shipSkill
- slack-gif-creatorSkill
- sprint-architectSkill
- techdebtSkill
- test-and-fixSkill
- threat-modelSkill
- verification-before-completionSkill
- visual-verdictSkill
- webapp-testingSkill
- web-asset-generatorSkill
- whatdidimissSkill
- writing-plansSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

