code-chunker
Map source file structure into navigable sections with line ranges and summaries for efficient agent navigation
What this skill does
# code-chunker
Analyze a source file's structure and produce a navigable map with logical sections, line ranges, and summaries for efficient agent navigation.
## Triggers
Alternate expressions and non-obvious activations (primary phrases are matched automatically from the skill description):
- "map this file" → structural chunking for navigation
- "chunk for navigation" → file structure mapping
## Purpose
Agents encounter large files they cannot immediately refactor — third-party code, generated code, legacy files awaiting decomposition. Without a structural map, agents must read the entire file to find relevant sections, wasting context window space.
The code-chunker produces a "table of contents" for source files, enabling agents to read only the sections they need. The doc-splitter does this for documentation; code-chunker does it for source code.
This skill complements `/decompose-file` — chunker maps files for navigation, decomposer splits them permanently.
## Behavior
When triggered, this skill:
1. **Parse file structure**:
- Detect language from file extension
- Identify top-level declarations (functions, classes, interfaces, types, constants)
- Group related declarations into logical sections
- Calculate line ranges for each section
2. **Generate section summaries**:
- For each section, produce a one-line description of its purpose
- Count key elements (imports, exports, methods, functions)
- Note dependencies between sections
3. **Produce navigable map**:
- Output structured map with section names, line ranges, and summaries
- Include quick-reference commands for reading specific sections
- Provide grep suggestions for common navigation needs
4. **Cache map** (optional):
- Store generated map in `.aiwg/working/code-maps/` for reuse during the session
- Invalidate cache when file modification time changes
## File Map Format
```
File Map: src/extensions/registry.ts (847 lines)
Sections:
1. Imports and type definitions (lines 1-45)
— 12 imports, 3 type aliases, 1 interface
2. ExtensionRegistry class (lines 47-320)
2a. constructor() — initializes registry with providers (lines 47-85)
2b. register() — registers an extension by type and name (lines 87-145)
2c. lookup() — finds extension by name or capability (lines 147-210)
2d. listByType() — returns all extensions of a given type (lines 212-260)
2e. unregister() — removes an extension from registry (lines 262-320)
3. Validation functions (lines 322-480)
3a. validateExtension() — checks required fields and types (lines 322-390)
3b. validateManifest() — validates manifest.json schema (lines 392-440)
3c. checkDependencies() — resolves and validates dependency tree (lines 442-480)
4. Discovery helpers (lines 482-620)
4a. discoverExtensions() — scans directories for extensions (lines 482-540)
4b. globForType() — finds files matching extension type patterns (lines 542-590)
4c. resolveExtensionPath() — resolves relative paths to absolute (lines 592-620)
5. Deployment logic (lines 622-847)
5a. deployToProvider() — deploys extension to a platform provider (lines 622-720)
5b. buildProviderConfig() — generates provider-specific config (lines 722-790)
5c. writeDeploymentFiles() — writes files to provider directories (lines 792-847)
Quick Commands:
Read lines 87-145 → register() method
Read lines 322-390 → validateExtension()
Read lines 622-720 → deployToProvider()
Grep "register" → 14 matches across sections 2, 3
Grep "deploy" → 8 matches in section 5
```
## Arguments
| Argument | Required | Default | Description |
|----------|----------|---------|-------------|
| `<file-path>` | Yes | — | File to map |
| `--depth <level>` | No | function | Granularity: `function`, `class`, `block` |
| `--format <type>` | No | map | Output: `map`, `json`, `tree` |
| `--section <n>` | No | — | Read a specific section immediately |
| `--cache` | No | true | Cache map for session reuse |
## Depth Levels
### Function (default)
Maps individual functions and methods:
```
2b. register() — registers an extension (lines 87-145)
```
### Class
Maps at class/module level only:
```
2. ExtensionRegistry class (lines 47-320) — 5 methods, 274 lines
```
### Block
Maps at code block level (most granular):
```
2b-i. register() parameter validation (lines 87-95)
2b-ii. register() type checking (lines 96-120)
2b-iii. register() storage and indexing (lines 121-145)
```
## Output Formats
### Map (default)
Human-readable section listing with line ranges and summaries. See File Map Format above.
### JSON
```json
{
"file": "src/extensions/registry.ts",
"loc": 847,
"language": "typescript",
"sections": [
{
"id": "1",
"name": "Imports and type definitions",
"start": 1,
"end": 45,
"summary": "12 imports, 3 type aliases, 1 interface",
"children": []
},
{
"id": "2",
"name": "ExtensionRegistry class",
"start": 47,
"end": 320,
"summary": "Main registry class with 5 methods",
"children": [
{
"id": "2a",
"name": "constructor()",
"start": 47,
"end": 85,
"summary": "Initializes registry with providers"
}
]
}
]
}
```
### Tree
```
src/extensions/registry.ts (847 lines)
├── Imports and types (1-45)
├── ExtensionRegistry (47-320)
│ ├── constructor() (47-85)
│ ├── register() (87-145)
│ ├── lookup() (147-210)
│ ├── listByType() (212-260)
│ └── unregister() (262-320)
├── Validation (322-480)
│ ├── validateExtension() (322-390)
│ ├── validateManifest() (392-440)
│ └── checkDependencies() (442-480)
├── Discovery (482-620)
│ ├── discoverExtensions() (482-540)
│ ├── globForType() (542-590)
│ └── resolveExtensionPath() (592-620)
└── Deployment (622-847)
├── deployToProvider() (622-720)
├── buildProviderConfig() (722-790)
└── writeDeploymentFiles() (792-847)
```
## Language Detection
| Extension | Language | Parsing Strategy |
|-----------|----------|-----------------|
| `.ts`, `.tsx` | TypeScript | `export`, `class`, `function`, `interface`, `type`, `const` declarations |
| `.js`, `.jsx`, `.mjs` | JavaScript | `export`, `class`, `function`, `const` declarations |
| `.py` | Python | `class`, `def`, top-level assignments, decorators |
| `.go` | Go | `func`, `type`, `var`, `const` blocks |
| `.rs` | Rust | `fn`, `struct`, `impl`, `mod`, `enum`, `trait` |
| `.java` | Java | `class`, `interface`, `enum`, method declarations |
| Other | Heuristic | Blank lines, comment blocks, indentation patterns |
## Usage Examples
### Basic File Map
```
User: "map src/extensions/registry.ts"
Skill produces the navigable map showing 5 sections with line ranges.
Agent can then read only the section needed:
"Read lines 87-145 of src/extensions/registry.ts"
```
### Section Navigation
```
User: "/code-chunker src/extensions/registry.ts --section 3"
Skill:
1. Generates map (or uses cached version)
2. Immediately reads and displays section 3 (Validation functions, lines 322-480)
Output: Full content of lines 322-480 with the map as header context.
```
### JSON for Agent Consumption
```
User: "/code-chunker src/large-file.py --format json"
Skill produces JSON map that another agent or script can consume
to programmatically navigate the file.
```
### Auto-Trigger on Large File Read
When an agent attempts to read a file over 300 lines, the code-chunker can be
invoked automatically to provide a map first:
```
Agent reads src/legacy/monolith.ts (920 lines)
→ Auto-chunk: "File is 920 lines. Here's the structure map.
Which section do you need?"
```
## Integration
This skill uses:
- `agent-friendly-code` rule: Threshold for when to suggest chunking
- `rlm-context-management` rule: Aligns with Rule 2 (programmatic access over full-context loading)
- `/decompose-file` skill: ChunkeRelated in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.