c4-code
Expert C4 Code-level documentation specialist. Analyzes code directories to create comprehensive C4 code-level documentation including function signatures, arguments, dependencies, and code structure.
About this skill
This AI agent skill acts as an expert C4 Code-level documentation specialist. It is designed to analyze specified code directories and generate comprehensive documentation adhering to the C4 model's code level (Level 4) perspective. The output includes detailed information such as function signatures, arguments, inter-function dependencies, and the overall code structure. This skill empowers AI agents to provide deep insights into software components, making it invaluable for understanding complex systems, aiding developer onboarding, and ensuring architectural clarity.
Best use case
Software architects and developers can use this skill to automatically generate detailed C4 code-level documentation, facilitate onboarding new team members to complex codebases, perform in-depth code reviews, or quickly grasp the internal workings and dependencies within a specific code module or directory. It helps in maintaining up-to-date documentation and understanding the granular details of a system's implementation.
Expert C4 Code-level documentation specialist. Analyzes code directories to create comprehensive C4 code-level documentation including function signatures, arguments, dependencies, and code structure.
A structured, text-based C4 code-level documentation report for the specified directory. This report will detail function signatures, their arguments, internal and external dependencies, and a clear breakdown of the code's structural components, following C4 documentation best practices.
Practical example
Example input
Generate C4 code-level documentation for the `src/services/user_management` directory. Highlight key functions, their parameters, and any significant internal dependencies.
Example output
```text
C4 Code Level Documentation: src/services/user_management
Directory: src/services/user_management
Module: user_service.py
Function: authenticate_user(username: str, password: str) -> bool
Arguments: username (str), password (str)
Dependencies: db_client.get_user(), bcrypt.checkpw()
Purpose: Validates user credentials against stored hashes.
Function: create_user(username: str, email: str, password_hash: str) -> dict
Arguments: username (str), email (str), password_hash (str)
Dependencies: db_client.insert_user(), email_service.send_welcome_email()
Purpose: Registers a new user in the system.
Module: db_client.py
Function: get_user(username: str) -> dict | None
Arguments: username (str)
Dependencies: database_connection.execute_query()
Purpose: Retrieves user data from the database.
Function: insert_user(user_data: dict) -> int
Arguments: user_data (dict)
Dependencies: database_connection.execute_insert()
Purpose: Inserts new user data into the database.
Key Dependencies:
- `user_service.py` depends on `db_client.py` and an external `bcrypt` library.
- `db_client.py` depends on a `database_connection` utility.
- `user_service.py` also depends on `email_service` for welcome emails.
```When to use this skill
- When you need to create or update C4 code-level documentation for a specific code directory or module.
- When seeking guidance, best practices, or a checklist for generating detailed C4 code-level documentation.
- When a comprehensive understanding of function signatures, arguments, dependencies, and internal code structure is required.
When not to use this skill
- When the task is unrelated to C4 code-level documentation (e.g., C4 System Context, Container, or Component diagrams).
- When you require documentation for a different domain, type, or using a tool outside the scope of C4 code analysis.
- When performing tasks that do not involve analyzing code directories for structural and functional details.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/c4-code/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How c4-code Compares
| Feature / Agent | c4-code | Standard Approach |
|---|---|---|
| Platform Support | Claude | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | easy | N/A |
Frequently Asked Questions
What does this skill do?
Expert C4 Code-level documentation specialist. Analyzes code directories to create comprehensive C4 code-level documentation including function signatures, arguments, dependencies, and code structure.
Which AI agents support this skill?
This skill is designed for Claude.
How difficult is it to install?
The installation complexity is rated as easy. You can find the installation instructions above.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
# C4 Code Level: [Directory Name]
## Use this skill when
- Working on c4 code level: [directory name] tasks or workflows
- Needing guidance, best practices, or checklists for c4 code level: [directory name]
## Do not use this skill when
- The task is unrelated to c4 code level: [directory name]
- You need a different domain or tool outside this scope
## Instructions
- Clarify goals, constraints, and required inputs.
- Apply relevant best practices and validate outcomes.
- Provide actionable steps and verification.
- If detailed examples are required, open `resources/implementation-playbook.md`.
## Overview
- **Name**: [Descriptive name for this code directory]
- **Description**: [Short description of what this code does]
- **Location**: [Link to actual directory path]
- **Language**: [Primary programming language(s)]
- **Purpose**: [What this code accomplishes]
## Code Elements
### Functions/Methods
- `functionName(param1: Type, param2: Type): ReturnType`
- Description: [What this function does]
- Location: [file path:line number]
- Dependencies: [what this function depends on]
### Classes/Modules
- `ClassName`
- Description: [What this class does]
- Location: [file path]
- Methods: [list of methods]
- Dependencies: [what this class depends on]
## Dependencies
### Internal Dependencies
- [List of internal code dependencies]
### External Dependencies
- [List of external libraries, frameworks, services]
## Relationships
Optional Mermaid diagrams for complex code structures. Choose the diagram type based on the programming paradigm. Code diagrams show the **internal structure of a single component**.
### Object-Oriented Code (Classes, Interfaces)
Use `classDiagram` for OOP code with classes, interfaces, and inheritance:
```mermaid
---
title: Code Diagram for [Component Name]
---
classDiagram
namespace ComponentName {
class Class1 {
+attribute1 Type
+method1() ReturnType
}
class Class2 {
-privateAttr Type
+publicMethod() void
}
class Interface1 {
<<interface>>
+requiredMethod() ReturnType
}
}
Class1 ..|> Interface1 : implements
Class1 --> Class2 : uses
```
````
### Functional/Procedural Code (Modules, Functions)
For functional or procedural code, you have two options:
**Option A: Module Structure Diagram** - Use `classDiagram` to show modules and their exported functions:
```mermaid
---
title: Module Structure for [Component Name]
---
classDiagram
namespace DataProcessing {
class validators {
<<module>>
+validateInput(data) Result~Data, Error~
+validateSchema(schema, data) bool
+sanitize(input) string
}
class transformers {
<<module>>
+parseJSON(raw) Record
+normalize(data) NormalizedData
+aggregate(items) Summary
}
class io {
<<module>>
+readFile(path) string
+writeFile(path, content) void
}
}
transformers --> validators : uses
transformers --> io : reads from
```
**Option B: Data Flow Diagram** - Use `flowchart` to show function pipelines and data transformations:
```mermaid
---
title: Data Pipeline for [Component Name]
---
flowchart LR
subgraph Input
A[readFile]
end
subgraph Transform
B[parseJSON]
C[validateInput]
D[normalize]
E[aggregate]
end
subgraph Output
F[writeFile]
end
A -->|raw string| B
B -->|parsed data| C
C -->|valid data| D
D -->|normalized| E
E -->|summary| F
```
**Option C: Function Dependency Graph** - Use `flowchart` to show which functions call which:
```mermaid
---
title: Function Dependencies for [Component Name]
---
flowchart TB
subgraph Public API
processData[processData]
exportReport[exportReport]
end
subgraph Internal Functions
validate[validate]
transform[transform]
format[format]
cache[memoize]
end
subgraph Pure Utilities
compose[compose]
pipe[pipe]
curry[curry]
end
processData --> validate
processData --> transform
processData --> cache
transform --> compose
transform --> pipe
exportReport --> format
exportReport --> processData
```
### Choosing the Right Diagram
| Code Style | Primary Diagram | When to Use |
| -------------------------------- | -------------------------------- | ------------------------------------------------------- |
| OOP (classes, interfaces) | `classDiagram` | Show inheritance, composition, interface implementation |
| FP (pure functions, pipelines) | `flowchart` | Show data transformations and function composition |
| FP (modules with exports) | `classDiagram` with `<<module>>` | Show module structure and dependencies |
| Procedural (structs + functions) | `classDiagram` | Show data structures and associated functions |
| Mixed | Combination | Use multiple diagrams if needed |
**Note**: According to the [C4 model](https://c4model.com/diagrams), code diagrams are typically only created when needed for complex components. Most teams find system context and container diagrams sufficient. Choose the diagram type that best communicates the code structure regardless of paradigm.
## Notes
[Any additional context or important information]
```
## Example Interactions
### Object-Oriented Codebases
- "Analyze the src/api directory and create C4 Code-level documentation"
- "Document the service layer code with complete class hierarchies and dependencies"
- "Create C4 Code documentation showing interface implementations in the repository layer"
### Functional/Procedural Codebases
- "Document all functions in the authentication module with their signatures and data flow"
- "Create a data pipeline diagram for the ETL transformers in src/pipeline"
- "Analyze the utils directory and document all pure functions and their composition patterns"
- "Document the Rust modules in src/handlers showing function dependencies"
- "Create C4 Code documentation for the Elixir GenServer modules"
### Mixed Paradigm
- "Document the Go handlers package showing structs and their associated functions"
- "Analyze the TypeScript codebase that mixes classes with functional utilities"
## Key Distinctions
- **vs C4-Component agent**: Focuses on individual code elements; Component agent synthesizes multiple code files into components
- **vs C4-Container agent**: Documents code structure; Container agent maps components to deployment units
- **vs C4-Context agent**: Provides code-level detail; Context agent creates high-level system diagrams
## Output Examples
When analyzing code, provide:
- Complete function/method signatures with all parameters and return types
- Clear descriptions of what each code element does
- Links to actual source code locations
- Complete dependency lists (internal and external)
- Structured documentation following C4 Code-level template
- Mermaid diagrams for complex code relationships when needed
- Consistent naming and formatting across all code documentation
```Related Skills
nft-standards
Master ERC-721 and ERC-1155 NFT standards, metadata best practices, and advanced NFT features.
nextjs-app-router-patterns
Comprehensive patterns for Next.js 14+ App Router architecture, Server Components, and modern full-stack React development.
new-rails-project
Create a new Rails project
networkx
NetworkX is a Python package for creating, manipulating, and analyzing complex networks and graphs.
network-engineer
Expert network engineer specializing in modern cloud networking, security architectures, and performance optimization.
nestjs-expert
You are an expert in Nest.js with deep knowledge of enterprise-grade Node.js application architecture, dependency injection patterns, decorators, middleware, guards, interceptors, pipes, testing strategies, database integration, and authentication systems.
nerdzao-elite
Senior Elite Software Engineer (15+) and Senior Product Designer. Full workflow with planning, architecture, TDD, clean code, and pixel-perfect UX validation.
nerdzao-elite-gemini-high
Modo Elite Coder + UX Pixel-Perfect otimizado especificamente para Gemini 3.1 Pro High. Workflow completo com foco em qualidade máxima e eficiência de tokens.
native-data-fetching
Use when implementing or debugging ANY network request, API call, or data fetching. Covers fetch API, React Query, SWR, error handling, caching, offline support, and Expo Router data loaders (useLoaderData).
n8n-workflow-patterns
Proven architectural patterns for building n8n workflows.
n8n-validation-expert
Expert guide for interpreting and fixing n8n validation errors.
n8n-node-configuration
Operation-aware node configuration guidance. Use when configuring nodes, understanding property dependencies, determining required fields, choosing between get_node detail levels, or learning common configuration patterns by node type.