c4-architecture

c4-architecture is a command for coding agents from EngineerWithAI/engineerwith-agents. It costs 0 tokens per session (3,405 once invoked), scanned A, original, MIT.

A command that documents an existing codebase using the C4 architecture model. C4 describes software at four levels: the code, its components, deployable containers such as services or databases, and the wider system context.

In plain words
What is it for?
Use it to analyze a repository from detailed code upward and produce documentation for code, components, containers, system relationships, APIs, and architecture diagrams.
Why use it?
It turns a repository’s implementation details into architecture documentation that can be understood by both technical and non-technical readers.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/engineerwithai/engineerwith-agents/c4-architecture
Clone the repo
git clone --depth 1 https://github.com/EngineerWithAI/engineerwith-agents

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for c4-architecture

README.md
[![agentmods](https://agentmods.dev/badge/commands/engineerwithai/engineerwith-agents/c4-architecture.svg)](https://agentmods.dev/commands/engineerwithai/engineerwith-agents/c4-architecture)
Your own site
<a href="https://agentmods.dev/commands/engineerwithai/engineerwith-agents/c4-architecture"><img src="https://agentmods.dev/badge/commands/engineerwithai/engineerwith-agents/c4-architecture.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,405 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.03405
Opus 5 $0.00000 $0.01702
Sonnet 5 $0.00000 $0.00681
Haiku 4.5 $0.00000 $0.00341

Measured 3d ago against content hash 8adc8a1d2ed5, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

c4-architecture scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/c4-architecture/commands/c4-architecture.md · 386 lines

How it starts

The opening of the file, as written. The whole thing — 386 lines — stays where its author put it; the contents beside it link to each section on GitHub.

C4 Architecture Documentation Workflow

Generate comprehensive C4 architecture documentation for an existing repository/codebase using a bottom-up analysis approach.

[Extended thinking: This workflow implements a complete C4 architecture documentation process following the C4 model (Context, Container, Component, Code). It uses a bottom-up approach, starting from the deepest code directories and working upward, ensuring every code element is documented before synthesizing into higher-level abstractions. The workflow coordinates four specialized C4 agents (Code, Component, Container, Context) to create a complete architectural documentation set that serves both technical and non-technical stakeholders.]

Overview

This workflow creates comprehensive C4 architecture documentation following the official C4 model by:

  1. Code Level: Analyzing every subdirectory bottom-up to create code-level documentation
  2. Component Level: Synthesizing code documentation into logical components within containers
  3. Container Level: Mapping components to deployment containers with API documentation (shows high-level technology choices)
  4. Context Level: Creating high-level system context with personas and user journeys (focuses on people and software systems, not technologies)

Note: According to the C4 model, you don't need to use all 4 levels of diagram - the system context and container diagrams are sufficient for most software development teams. This workflow generates all levels for completeness, but teams can choose which levels to use.

All documentation is written to a new C4-Documentation/ directory in the repository root.

Phase 1: Code-Level Documentation (Bottom-Up Analysis)

1.1 Discover All Subdirectories

  • Use codebase search to identify all subdirectories in the repository
  • Sort directories by depth (deepest first) for bottom-up processing
  • Filter out common non-code directories (node_modules, .git, build, dist, etc.)
  • Create list of directories to process

Read the full file on GitHub · 386 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 386 lines · 0 tokens per session scan A 8adc8a1d2ed5

Subscribe to this mod's changes

c4-architecture is a command published in the GitHub repository EngineerWithAI/engineerwith-agents (4 stars, last pushed 7mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 3,405 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.