// Provides reusable templates for generating comprehensive codebase knowledge bases including architecture diagrams, concept maps, and module documentation. Supports both single-project and monorepo structures. Use when creating project documentation, knowledge bases, or when user mentions KB templates, codebase documentation, or project documentation structure.
| name | knowledge-base-templates |
| description | Provides reusable templates for generating comprehensive codebase knowledge bases including architecture diagrams, concept maps, and module documentation. Supports both single-project and monorepo structures. Use when creating project documentation, knowledge bases, or when user mentions KB templates, codebase documentation, or project documentation structure. |
This skill provides professional templates for creating comprehensive codebase knowledge bases. These templates help document codebases systematically, making them easier to understand and navigate for developers.
Documentation Templates:
Two Structure Types:
Use this skill when:
For standard single-project repositories:
# Target structure
{RP1_ROOT}/context/
โโโ index.md # Project overview
โโโ concept_map.md # Domain concepts
โโโ architecture.md # System architecture
โโโ modules.md # Module breakdown
โโโ patterns.md # Implementation patterns
โโโ state.json # Metadata
Using Templates:
templates/single-project/index.md{RP1_ROOT}/context/index.mdTemplate Placeholders:
[Project Name]: Replace with actual project name[Language]: Replace with programming language(s)[Date]: Replace with current date[repo-url], [commands], etc.: Replace with actual valuesFor repositories with multiple projects:
# Target structure
{RP1_ROOT}/context/
โโโ index.md # Repository overview
โโโ concept_map.md # Cross-project concepts
โโโ architecture.md # System-wide architecture
โโโ modules.md # Modules across projects
โโโ dependencies.md # Inter-project relationships
โโโ technology-matrix.md # Tech stack matrix
โโโ projects/ # Per-project documentation
โ โโโ service-a/
โ โ โโโ overview.md
โ โ โโโ concept_map.md
โ โ โโโ architecture.md
โ โ โโโ modules.md
โ โโโ frontend/
โ โโโ ...
โโโ state.json # Repository metadata
Using Templates:
templates/monorepo/ templates for repository-level docstemplates/single-project/ templates for per-project docsStep 1: Determine Project Type
if is_monorepo():
base_templates = "templates/monorepo/"
needs_project_level = True
else:
base_templates = "templates/single-project/"
needs_project_level = False
Step 2: Load and Fill Templates
# Read template
template = read_file(f"{skill_path}/{base_templates}/index.md")
# Fill with analyzed data
filled = template.replace("[Project Name]", project_name)
filled = filled.replace("[Date]", current_date)
# ... more replacements
# Write to target location
write_file(f"{RP1_ROOT}/context/index.md", filled)
Step 3: Generate Diagrams Templates include Mermaid diagram placeholders. When filling templates:
Purpose: Entry point and navigation hub for progressive KB loading
Key Sections:
When to Use: Always - this is the mandatory entry point for all KB-aware agents
Progressive Loading Pattern: Index.md is designed as a "jump off" point. Agents should:
Purpose: Domain concepts and terminology
Key Sections:
When to Use: Projects with domain-specific terminology or complex business logic
Purpose: System architecture and design
Key Sections:
When to Use: Always - helps understand system design
Diagram Integration: Uses Mermaid for:
Purpose: Detailed module and component breakdown
Key Sections:
When to Use: Codebases with clear module structure
Diagram Integration: Uses Mermaid ER diagrams and dependency graphs
Purpose: Implementation patterns and coding idioms
Key Sections:
When to Use: Always - helps AI and developers follow established conventions
Budget: Hard limit of 150 lines for scannability
Purpose: Inter-project dependencies and relationships
Key Sections:
When to Use: Monorepos with multiple projects
Purpose: Technology stack by project
Key Sections:
When to Use: Monorepos with multiple technology stacks
Purpose: Metadata and tracking information
Key Fields:
repo_type: "single-project" or "monorepo"analysis_date: When analysis was performedbuild_strategy: Which strategy was usedlanguages_detected: Code statisticscoverage_metrics: Documentation coveragevalidation_context: Validation issues trackingincremental_updates: Change trackingWhen to Use: Always - tracks knowledge base state
This skill's templates include Mermaid diagrams. Use the mermaid skill to:
Example workflow:
1. Load architecture.md template
2. Generate Mermaid diagram for project
3. Use mermaid skill to validate diagram
4. Fill template with validated diagram
5. Write completed documentation
These templates are designed to work with knowledge building workflows:
/knowledge-build: Uses these templates to generate documentation/knowledge-load: Loads generated knowledge bases (deprecated - agents load KB directly)/project-birds-eye-view: May use similar structureImportant: Index.md is generated directly by the /knowledge-build orchestrator, NOT by a sub-agent. This is because the orchestrator has visibility into all 4 sub-agent outputs and can aggregate key facts into a "jump off" entry point.
Extract data from each sub-agent's JSON output:
| Data | Source Agent | JSON Path |
|---|---|---|
| Project summary | concept-extractor | data.concepts[0].description or domain overview |
| Entry points | architecture-mapper | data.entry_points[] |
| Key pattern | pattern-extractor | data.patterns[0].name |
| Tech stack | module-analyzer | data.project.frameworks[] + data.project.primary_language |
| Project name | spatial-analyzer | project.name or package.json |
| Languages | module-analyzer | data.metadata.languages[] |
After writing concept_map.md, architecture.md, modules.md, patterns.md, calculate line counts:
wc -l {{RP1_ROOT}}/context/concept_map.md
wc -l {{RP1_ROOT}}/context/architecture.md
wc -l {{RP1_ROOT}}/context/modules.md
wc -l {{RP1_ROOT}}/context/patterns.md
# For monorepo, also:
wc -l {{RP1_ROOT}}/context/dependencies.md
wc -l {{RP1_ROOT}}/context/technology-matrix.md
Use template from templates/{single-project|monorepo}/index.md:
| Placeholder | Data Source |
|---|---|
[Project Name] | spatial-analyzer or package.json name |
[Primary languages] | module-analyzer languages |
[Version] | package.json version or git describe |
[Date] | Current date (ISO format) |
[2-3 sentences...] | Aggregated from concept-extractor domain description |
[main file/command] | architecture-mapper entry_points[0] |
[primary architectural pattern] | pattern-extractor patterns[0].name |
[core technologies] | module-analyzer frameworks |
~[N] (line counts) | wc -l results from file manifest step |
[key directories] | spatial-analyzer structure or architecture-mapper |
[project-a], [project-b] | spatial-analyzer monorepo_projects (monorepo only) |
See EXAMPLES.md for complete filled-in knowledge base examples.
See REFERENCE.md for:
All templates are in the templates/ directory:
templates/
โโโ single-project/
โ โโโ index.md
โ โโโ concept_map.md
โ โโโ architecture.md
โ โโโ modules.md
โ โโโ patterns.md
โโโ monorepo/
โ โโโ index.md
โ โโโ concept_map.md
โ โโโ architecture.md
โ โโโ modules.md
โ โโโ patterns.md
โ โโโ dependencies.md
โ โโโ technology-matrix.md
โโโ state.json
Access templates using Read tool with full path from skill base directory.