Product

Code Outline

Code Outline turns source files into a structured outline that humans can read and LLMs can parse.

v3.0.0

Install

pnpm

pnpm add -g @sammons/code-outline-cli

npm

npm install -g @sammons/code-outline-cli

Use

One output format per use case: a tree for a terminal, structured data for a pipeline, or a compressed format sized for an LLM's context window.

ASCII

$ code-outline "src/**/*.ts" -f ascii

📁 example.ts
├─ export_statement: User [1:1] :1
  └─ interface_declaration: User [1:8] :1
    └─ interface_body [1:23]
├─ export_statement: UserService [6:1] :6
  └─ class_declaration: UserService [6:8] :6
    └─ class_body [6:26]
      ├─ method_definition: constructor [7:3] :7
      ├─ method_definition: getUser [9:3] :9
      └─ method_definition: createUser [13:3] :13
├─ export_statement: validateEmail [18:1] :18
└─ export_statement: const DEFAULT_TIMEOUT_MS [22:1] :22
JSON

$ code-outline "src/**/*.ts" -f json

[
 {
  "file": "example.ts",
  "hasError": false,
  "outline": {
   "type": "program",
   "children": [
    {
     "type": "export_statement",
     "name": "User",
     "children": [
      { "type": "interface_declaration", "name": "User" }
     ]
    }
   ]
  }
 }
]
YAML

$ code-outline "src/**/*.ts" -f yaml

- file: example.ts
  hasError: false
  outline:
   type: program
   children:
    - type: export_statement
      name: User
      children:
       - type: interface_declaration
         name: User
LLMText

$ code-outline "src/**/*.ts" -f llmtext

<Outline format="llmtext-v2">
example.ts (22L)
1-4 export interface User
 2 field id
 3 field email
6-16 export class UserService
 7 method constructor
 9-11 method getUser
 13-15 method createUser
18-20 export fn validateEmail
22 export const DEFAULT_TIMEOUT_MS
</Outline>

MCP Server

The MCP server wraps the CLI as two tools an agent can call directly, without shelling out.

Install

pnpm add -g @sammons/code-outline-mcp

Register with Claude Code

claude mcp add code-outline -- code-outline-mcp

Generic stdio config

{
  "mcpServers": {
    "code-outline": {
      "command": "code-outline-mcp",
      "args": []
    }
  }
}

Tool

outline

Runs the CLI once per glob pattern and concatenates the results in the requested format.

Tool

code_outline_version

Returns the installed code-outline CLI version.

What's New

Major Changes

  • llmtext now prints one semantic line per symbol (<line>[-<endLine>] [export] <kind> <name>) under real file paths; the old format moves to --format llmtext-v1.
  • --depth counts symbol levels in llmtext, so --depth 2 shows class members (#53).
  • Grammar plumbing (statement_block, class_body, non-function object pairs, duplicate lexical_declaration/variable_declarator lines) and function locals no longer print (#54).
  • Imports and re-exports print their source text on one line, eliding the middle beyond 200 characters so the module path survives (#55, #61).
  • Every symbol carries its end line (#56).

Minor Changes

  • Add Markdown, JSON, and YAML plugins (@sammons/code-outline-markdown, @sammons/code-outline-json, @sammons/code-outline-yaml).
  • Add --match, --kind, and --at for finding definitions the way rg finds text.
  • --match <regex> keeps llmtext symbols whose name matches, with their enclosing symbols, and drops files without a match unless they have syntax errors. Smart case: a pattern with no literal uppercase letter ignores case; escapes, \p{…} classes, and group names do not count.
  • --kind fn,method keeps symbols of the listed kinds; it combines with --match.
  • --at <path:line> (repeatable, or --at - to read rg -n output from stdin) prints the symbols enclosing each line, outermost first.
  • Wildcard patterns skip files with unsupported extensions instead of failing the run.

Patch Changes

  • Updated dependencies [3ec804d]
  • Updated dependencies [61f9eb4]
  • Updated dependencies [a380ebd]
  • Updated dependencies [4ce3f5a]
  • Updated dependencies [3c7f0a4]
  • @sammons/code-outline-parser@3.0.0
  • @sammons/code-outline-markdown@3.0.0
  • @sammons/code-outline-json@3.0.0
  • @sammons/code-outline-yaml@3.0.0
  • @sammons/code-outline-formatter@3.0.0
  • @sammons/code-outline-csharp@3.0.0
  • @sammons/code-outline-java@3.0.0
  • @sammons/code-outline-python@3.0.0
  • @sammons/code-outline-rust@3.0.0
  • @sammons/code-outline-typedmind@3.0.0