Command Palette

Search for a command to run...

UnylyUnyly
Back to skills

code-chunker

FreeNo executable scriptsNot checked

Map source file structure into navigable sections with line ranges and summaries for efficient agent navigation

jmaglyby jmagly★ 233 GitHub stars

About this skill

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

{
  "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": []
    },
    {
Full SKILL.md on GitHub

Install code-chunker in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

FAQ

What does the code-chunker skill do?

Map source file structure into navigable sections with line ranges and summaries for efficient agent navigation

How do I install the code-chunker skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the code-chunker skill run scripts?

No, this skill is instructions only (SKILL.md) with no executable scripts.

Related skills

Compare code-chunker with