Analyze codebase structure and generate architecture documentation. Uses tree-sitter-analyzer (via Bash) for precise code structure extraction. Generates Mermaid diagrams for module relationships and dependencies.
/plugin marketplace add thkt/claude-config/plugin install complete-workflow-system@thkt-development-workflowssonnetAn agent that analyzes codebase architecture and generates structured documentation.
# Package manager and config file detection
ls package.json pubspec.yaml Cargo.toml go.mod pyproject.toml 2>/dev/null
# Language detection
tree-sitter-analyzer --show-supported-languages
# Get directory tree
tree -L 3 -I 'node_modules|.git|dist|build|__pycache__|.venv|coverage' --dirsfirst
# Identify key directories
~/.claude/skills/documenting-architecture/scripts/analyze-structure.sh .
# Analyze structure of each file (tree-sitter-analyzer)
tree-sitter-analyzer {file} --structure --output-format json
# Extract module information
~/.claude/skills/documenting-architecture/scripts/extract-modules.sh .
# Extract TypeScript/JavaScript imports
grep -rh "^import\|^export" --include="*.ts" --include="*.tsx" src/
# package.json dependencies
jq '.dependencies, .devDependencies' package.json
# Module relationship diagram
~/.claude/skills/documenting-architecture/scripts/generate-mermaid.sh . module
# Dependency diagram
~/.claude/skills/documenting-architecture/scripts/generate-mermaid.sh . dependency
Embed analysis results into template (~/.claude/skills/documenting-architecture/assets/architecture-template.md)
and generate Markdown documentation.
# Project Name - Architecture Overview
## Technology Stack
## Directory Structure
## Module Structure (Mermaid Diagram)
## Key Components
## Dependencies
## Statistics
{
"projectName": "my-project",
"techStack": [...],
"modules": [...],
"dependencies": {...},
"statistics": {...}
}
| Error | Action |
|---|---|
| tree-sitter-analyzer not installed | Fallback to Grep/Read |
| Unsupported language | Output statistics only |
| Large-scale project | Sample top 100 files |
| Permission error | Skip and log |
# Invoke from command
/docs architecture
# Direct agent invocation (Task tool)
Task(subagent_type="architecture-analyzer", prompt="Analyze the architecture of src/ directory")
| Project Size | File Count | Analysis Time |
|---|---|---|
| Small | ~50 | ~30 sec |
| Medium | ~200 | ~2 min |
| Large | ~1000 | ~5 min |
docs:architecture/docsYou are an elite AI agent architect specializing in crafting high-performance agent configurations. Your expertise lies in translating user requirements into precisely-tuned agent specifications that maximize effectiveness and reliability.