Expert C4 Code-level documentation specialist. Analyzes code
Add this skill
npx mdskills install sickn33/c4-codeWell-structured C4 code documentation template with paradigm-specific diagrams and examples
1---2name: c4-code3description: Expert C4 Code-level documentation specialist. Analyzes code4 directories to create comprehensive C4 code-level documentation including5 function signatures, arguments, dependencies, and code structure. Use when6 documenting code at the lowest C4 level for individual directories and code7 modules.8metadata:9 model: haiku10---1112# C4 Code Level: [Directory Name]1314## Use this skill when1516- Working on c4 code level: [directory name] tasks or workflows17- Needing guidance, best practices, or checklists for c4 code level: [directory name]1819## Do not use this skill when2021- The task is unrelated to c4 code level: [directory name]22- You need a different domain or tool outside this scope2324## Instructions2526- Clarify goals, constraints, and required inputs.27- Apply relevant best practices and validate outcomes.28- Provide actionable steps and verification.29- If detailed examples are required, open `resources/implementation-playbook.md`.3031## Overview3233- **Name**: [Descriptive name for this code directory]34- **Description**: [Short description of what this code does]35- **Location**: [Link to actual directory path]36- **Language**: [Primary programming language(s)]37- **Purpose**: [What this code accomplishes]3839## Code Elements4041### Functions/Methods4243- `functionName(param1: Type, param2: Type): ReturnType`44 - Description: [What this function does]45 - Location: [file path:line number]46 - Dependencies: [what this function depends on]4748### Classes/Modules4950- `ClassName`51 - Description: [What this class does]52 - Location: [file path]53 - Methods: [list of methods]54 - Dependencies: [what this class depends on]5556## Dependencies5758### Internal Dependencies5960- [List of internal code dependencies]6162### External Dependencies6364- [List of external libraries, frameworks, services]6566## Relationships6768Optional 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**.6970### Object-Oriented Code (Classes, Interfaces)7172Use `classDiagram` for OOP code with classes, interfaces, and inheritance:7374```mermaid75---76title: Code Diagram for [Component Name]77---78classDiagram79 namespace ComponentName {80 class Class1 {81 +attribute1 Type82 +method1() ReturnType83 }84 class Class2 {85 -privateAttr Type86 +publicMethod() void87 }88 class Interface1 {89 <<interface>>90 +requiredMethod() ReturnType91 }92 }9394 Class1 ..|> Interface1 : implements95 Class1 --> Class2 : uses96```97````9899### Functional/Procedural Code (Modules, Functions)100101For functional or procedural code, you have two options:102103**Option A: Module Structure Diagram** - Use `classDiagram` to show modules and their exported functions:104105```mermaid106---107title: Module Structure for [Component Name]108---109classDiagram110 namespace DataProcessing {111 class validators {112 <<module>>113 +validateInput(data) Result~Data, Error~114 +validateSchema(schema, data) bool115 +sanitize(input) string116 }117 class transformers {118 <<module>>119 +parseJSON(raw) Record120 +normalize(data) NormalizedData121 +aggregate(items) Summary122 }123 class io {124 <<module>>125 +readFile(path) string126 +writeFile(path, content) void127 }128 }129130 transformers --> validators : uses131 transformers --> io : reads from132```133134**Option B: Data Flow Diagram** - Use `flowchart` to show function pipelines and data transformations:135136```mermaid137---138title: Data Pipeline for [Component Name]139---140flowchart LR141 subgraph Input142 A[readFile]143 end144 subgraph Transform145 B[parseJSON]146 C[validateInput]147 D[normalize]148 E[aggregate]149 end150 subgraph Output151 F[writeFile]152 end153154 A -->|raw string| B155 B -->|parsed data| C156 C -->|valid data| D157 D -->|normalized| E158 E -->|summary| F159```160161**Option C: Function Dependency Graph** - Use `flowchart` to show which functions call which:162163```mermaid164---165title: Function Dependencies for [Component Name]166---167flowchart TB168 subgraph Public API169 processData[processData]170 exportReport[exportReport]171 end172 subgraph Internal Functions173 validate[validate]174 transform[transform]175 format[format]176 cache[memoize]177 end178 subgraph Pure Utilities179 compose[compose]180 pipe[pipe]181 curry[curry]182 end183184 processData --> validate185 processData --> transform186 processData --> cache187 transform --> compose188 transform --> pipe189 exportReport --> format190 exportReport --> processData191```192193### Choosing the Right Diagram194195| Code Style | Primary Diagram | When to Use |196| -------------------------------- | -------------------------------- | ------------------------------------------------------- |197| OOP (classes, interfaces) | `classDiagram` | Show inheritance, composition, interface implementation |198| FP (pure functions, pipelines) | `flowchart` | Show data transformations and function composition |199| FP (modules with exports) | `classDiagram` with `<<module>>` | Show module structure and dependencies |200| Procedural (structs + functions) | `classDiagram` | Show data structures and associated functions |201| Mixed | Combination | Use multiple diagrams if needed |202203**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.204205## Notes206207[Any additional context or important information]208209```210211## Example Interactions212213### Object-Oriented Codebases214- "Analyze the src/api directory and create C4 Code-level documentation"215- "Document the service layer code with complete class hierarchies and dependencies"216- "Create C4 Code documentation showing interface implementations in the repository layer"217218### Functional/Procedural Codebases219- "Document all functions in the authentication module with their signatures and data flow"220- "Create a data pipeline diagram for the ETL transformers in src/pipeline"221- "Analyze the utils directory and document all pure functions and their composition patterns"222- "Document the Rust modules in src/handlers showing function dependencies"223- "Create C4 Code documentation for the Elixir GenServer modules"224225### Mixed Paradigm226- "Document the Go handlers package showing structs and their associated functions"227- "Analyze the TypeScript codebase that mixes classes with functional utilities"228229## Key Distinctions230- **vs C4-Component agent**: Focuses on individual code elements; Component agent synthesizes multiple code files into components231- **vs C4-Container agent**: Documents code structure; Container agent maps components to deployment units232- **vs C4-Context agent**: Provides code-level detail; Context agent creates high-level system diagrams233234## Output Examples235When analyzing code, provide:236- Complete function/method signatures with all parameters and return types237- Clear descriptions of what each code element does238- Links to actual source code locations239- Complete dependency lists (internal and external)240- Structured documentation following C4 Code-level template241- Mermaid diagrams for complex code relationships when needed242- Consistent naming and formatting across all code documentation243244```245
Full transparency — inspect the skill content before installing.