$npx -y skills add tody-agent/codymaster --skill cm-codeintellUnified code intelligence — Skeleton Index (zero-dep, <4s) + AST knowledge graph (CodeGraph) + architecture diagrams (Mermaid) + smart context builder. Pre-indexes code structure so AI agents understand any codebase instantly. 95% token compression for onboarding. 30% fewer token
| 1 | # Code Intelligence — Structural Understanding for AI Agents |
| 2 | |
| 3 | ## TL;DR |
| 4 | - **Use to** index codebase for fast structural understanding |
| 5 | - **Outputs**: skeleton index, AST graph, Mermaid diagrams |
| 6 | - **Token saving**: ~95% for onboarding, ~30% for deep analysis |
| 7 | - **Next**: cm-planning or cm-debugging |
| 8 | |
| 9 | > **Stop scanning. Start querying.** Skeleton Index (<4s, zero deps) + AST graph + architecture diagrams = instant code understanding. |
| 10 | > Inspired by [CodeGraph](https://github.com/colbymchenry/codegraph) + [GitDiagram](https://github.com/ahmedkhaleel2004/gitdiagram). |
| 11 | > TRIZ-optimized: 10 inventive principles applied. |
| 12 | |
| 13 | ## When to Use |
| 14 | |
| 15 | **ALWAYS for medium-to-large projects.** This is infrastructure, not an action skill. |
| 16 | |
| 17 | - **Auto-triggered by:** `cm-start` Step 0.7 (project init) — **ALWAYS runs Layer 0** |
| 18 | - **Manually triggered for:** "understand this codebase", "what calls X?", "what breaks if I change Y?" |
| 19 | - **Skip when:** NEVER — Layer 0 (Skeleton) works on any project size |
| 20 | |
| 21 | ### Detection Thresholds (Auto-Trigger) |
| 22 | |
| 23 | ``` |
| 24 | TRIGGER if ANY of these are true: |
| 25 | → Project has >50 source files |
| 26 | → User wants to refactor or re-code an existing project |
| 27 | → User says "understand the codebase" / "what does this do?" |
| 28 | → cm-execution encounters >3 grep/glob calls for one task |
| 29 | → cm-debugging needs callers/callees to trace a bug |
| 30 | ``` |
| 31 | |
| 32 | --- |
| 33 | |
| 34 | ## Architecture: 4 Layers |
| 35 | |
| 36 | ``` |
| 37 | ┌──────────────────────────────────────────────────────────────────────────┐ |
| 38 | │ cm-codeintell │ |
| 39 | ├──────────────────┬──────────────────┬──────────────────┬────────────────┤ |
| 40 | │ LAYER 0 │ LAYER 1 │ LAYER 2 │ LAYER 3 │ |
| 41 | │ Skeleton Index │ Code Graph │ Architecture │ Smart Context │ |
| 42 | │ (Instant) │ (Structure) │ Diagram (Visual)│ (Synthesis) │ |
| 43 | ├──────────────────┼──────────────────┼──────────────────┼────────────────┤ |
| 44 | │ grep/find/awk │ tree-sitter AST │ File tree + LLM │ All layers + │ |
| 45 | │ → skeleton.md │ → SQLite graph │ → Mermaid.js │ qmd → focused │ |
| 46 | │ (~5K tokens) │ → MCP server │ → .cm/ storage │ context packet │ |
| 47 | ├──────────────────┼──────────────────┼──────────────────┼────────────────┤ |
| 48 | │ ZERO deps │ codegraph_* │ Auto-generated │ Feeds: exec, │ |
| 49 | │ <4 seconds │ MCP tools │ at project init │ plan, debug │ |
| 50 | │ ANY project size │ 50+ files │ 20+ files │ All consumers │ |
| 51 | └──────────────────┴──────────────────┴──────────────────┴────────────────┘ |
| 52 | ``` |
| 53 | |
| 54 | ### TRIZ Principles Applied |
| 55 | |
| 56 | | # | Principle | How Applied | |
| 57 | |---|-----------|-------------| |
| 58 | | **#1** Segmentation | 4 independent layers — each usable alone | |
| 59 | | **#2** Taking Out | Extract only signatures, discard function bodies | |
| 60 | | **#5** Merging | CodeGraph + GitDiagram + Skeleton → one unified skill | |
| 61 | | **#10** Prior Action | Pre-index at project init, not at query time | |
| 62 | | **#13** Inversion | Code summarizes ITSELF to agent (push, not pull) | |
| 63 | | **#15** Dynamicity | Adaptive: skeleton (<20) vs graph (>50) vs full (>200) | |
| 64 | | **#25** Self-Service | Auto-detect project size → auto-select intelligence level | |
| 65 | | **#28** Mechanics Substitution | Replace file reading (slow) with pattern matching (fast) | |
| 66 | | **#35** Parameter Changes | Unit: file content → function signature → 95% compression | |
| 67 | | **#40** Composite | One skill = skeleton + graph + diagrams + context builder | |
| 68 | |
| 69 | --- |
| 70 | |
| 71 | ## Layer 0: Skeleton Index (Instant — Zero Dependencies) |
| 72 | |
| 73 | > **Purpose:** Lightning-fast grep-based extraction of function signatures, class definitions, exports, and module boundaries. Produces a compact `.cm/skeleton.md` that gives the agent instant understanding of any codebase. |
| 74 | |
| 75 | ### How It Works |
| 76 | |
| 77 | ``` |
| 78 | 1. SCAN → find all source files (14 languages supported) |
| 79 | 2. EXTRACT → grep for function/class/export signatures only |
| 80 | 3. GROUP → organize by directory (module boundaries) |
| 81 | 4. CAP → limit per-dir (15 files) + total (600 lines) |
| 82 | 5. OUTPUT → .cm/skeleton.md (~5K tokens for 600-file project) |
| 83 | ``` |
| 84 | |
| 85 | ### Usage |
| 86 | |
| 87 | ```bash |
| 88 | # Run from project root |
| 89 | bash scripts/index-codebase.sh |
| 90 | |
| 91 | # Custom paths |
| 92 | bash scripts/index-codebase.sh /path/to/project /path/to/output.md |
| 93 | ``` |
| 94 | |
| 95 | ### What It Extracts (Per Language) |
| 96 | |
| 97 | | Language | Patterns Extracted | |
| 98 | |----------|-------------------| |
| 99 | | TypeScript/JavaScript | `export`, `function`, `class`, `interface`, `type`, `enum`, `const =`, routes | |
| 100 | | Python | `def`, `async def`, `class`, `@app.route`, `from...import` | |
| 101 | | Go | `func`, `type...struct`, `type...interface`, `package` | |
| 102 | | Rust | `pub fn`, `struct`, `enum`, `impl`, `trait`, `mod` | |
| 103 | | Java/Kotlin | |