← Code Outline

LLMText Format

A compressed, LLM-optimized output format for efficient token usage.

Overview

LLMText is a code-outline output format built for Large Language Model input. It compresses a file's structure into fewer tokens than JSON or YAML while keeping node types, names, and positions.

Key features

  • Compact syntax — cuts token count versus JSON on the same file.
  • Indented structure — one line per node, nesting shown by leading spaces.
  • Essential information preserved — node type, name, and a 1-based line:column position.
  • Built for AI context — sized to fit inside an LLM's context window.

Format structure

Each line after the file header is one AST node: its type (joined with its name when the node has one) and its 1-based line:col position. Indentation encodes the parent-child hierarchy.

node_type_name line:col

Usage

# Generate LLMText output
code-outline "src/**/*.ts" --format llmtext

# Save to file for LLM processing
code-outline "src/**/*.ts" --format llmtext > codebase.llmtext

# Combine with depth limiting
code-outline "src/**/*.ts" --format llmtext --depth 3

Example output

Given this TypeScript file:

// example.ts
export class UserService {
  constructor(private db: Database) {}

  async getUser(id: string): Promise<User> {
    return this.db.users.findById(id);
  }

  async createUser(data: UserData): Promise<User> {
    return this.db.users.create(data);
  }
}

export function validateEmail(email: string): boolean {
  return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
}

Running code-outline example.ts --format llmtext against it:

<Outline>
# Ultra-compressed code outline for LLM consumption
# Format: type_name line:col (indented for hierarchy)
# line:col is 1-based line and 1-based column for navigation
# Import/export names joined with underscore: imp_parseArgs
# Variables and functions show actual names after type

# Files
example.ts (17L)
export_statement_UserService 2:1
 class_declaration_UserService 2:8
  class_body 2:26
   method_definition_constructor 3:3
    statement_block 3:37
   method_definition_getUser 5:3
    statement_block 5:44
   method_definition_createUser 9:3
    statement_block 9:51
export_statement_validateEmail 14:1
 function_declaration_validateEmail 14:8
  statement_block 14:55
</Outline>

Position numbering is 1-based line and 1-based column in ascii and llmtext output. json and yaml keep tree-sitter's native 0-based row and column instead.

Comparison with other formats

Format Human readable LLM optimal
JSON Yes Verbose
YAML Yes Moderate
ASCII Yes Visual, human-facing
LLMText Compact Optimal

Use cases

  • AI code analysis — give an LLM codebase context without spending its context window on JSON punctuation.
  • Code documentation — generate a compact structure summary.
  • Automated reviews — feed structure data to an AI review pipeline.
  • Code understanding — help an agent orient in a large codebase quickly.

Integration examples

# Pipe to an LLM CLI
code-outline "src/**/*.ts" --format llmtext | your-llm-cli "Analyze this codebase structure"

# Save for later AI processing
code-outline "src/**/*.ts" --format llmtext > codebase-context.txt

# Register the MCP server instead of shelling out
claude mcp add code-outline -- code-outline-mcp
Mission Services Products Reading About