Skim
Smart code reader - streaming code transformation for AI agents.
Overview
Skim transforms source code by intelligently removing implementation details while preserving structure, signatures, and types - perfect for optimizing code for LLM context windows.
Think of it like cat, but smart about what code to show.
Installation
Try it (no install required)
Install globally (recommended for regular use)
# Via npm
# Via Cargo
Note: Use
npxfor trying it out. For regular use, install globally to avoid npx overhead (~100-500ms per invocation).
Quick Start
# Try it with npx (no install)
# Or install globally for better performance
# Read TypeScript with structure mode
# Process multiple files with glob patterns
# Show token reduction statistics
# Extract Python function signatures
# Parallel processing with custom job count
# Pipe to syntax highlighter
|
# Read from stdin
|
# Clear cache
Features
- 6 Languages: TypeScript, JavaScript, Python, Rust, Go, Java
- 4 Transformation Modes: Structure, Signatures, Types, Full
- Fast: 14.6ms for 3000-line files (3x faster than target)
- Cached: 40-50x speedup on repeated processing (enabled by default)
- Multi-file: Glob patterns with parallel processing (
skim 'src/**/*.ts') - Token Stats: Show reduction statistics with
--show-stats - Streaming: Outputs to stdout for pipe workflows
- Safe: Built-in DoS protections
Usage
Basic Usage
Options
Transformation Modes
Structure Mode (Default)
Removes function bodies while preserving signatures (70-80% reduction).
Input:
function add(a: number, b: number): number {
const result = a + b;
console.log(`Adding ${a} + ${b} = ${result}`);
return result;
}
Output:
function add(a: number, b: number): number { /* ... */ }
Signatures Mode
Extracts only function and method signatures (85-92% reduction).
Input:
=
= *
return +
Output:
Types Mode
Extracts only type definitions (90-95% reduction).
Input:
interface User {
id: number;
name: string;
}
function getUser(id: number): User {
return db.users.find(id);
}
Output:
interface User {
id: number;
name: string;
}
Full Mode
Returns original code unchanged (0% reduction).
Examples
Explore a codebase
# Get overview of all TypeScript files (NEW: glob support)
# Extract all Python function signatures with stats
# Review Rust types
|
# Parallel processing for faster multi-file operations
Prepare code for LLMs
# Reduce token count before sending to GPT
|
# Output: 150 (was 600)
# Get just the API surface
|
Pipe workflows
# Skim and highlight
|
# Skim and search
|
# Skim multiple files
|
Supported Languages
| Language | Extensions | Auto-detected |
|---|---|---|
| TypeScript | .ts, .tsx |
✅ |
| JavaScript | .js, .jsx, .mjs |
✅ |
| Python | .py |
✅ |
| Rust | .rs |
✅ |
| Go | .go |
✅ |
| Java | .java |
✅ |
Performance
- Parse + Transform: 14.6ms for 3000-line files (verified)
- Cached: 5ms on repeated processing (40-50x speedup)
- Token Reduction: 60-95% depending on mode
- Streaming: Zero intermediate files
- Parallel: Scales with CPU cores for multi-file processing
Security
Built-in protections against:
- Stack overflow attacks (max depth: 500)
- Memory exhaustion (max input: 50MB)
- UTF-8 boundary violations
- Path traversal attacks
Library
For programmatic usage, see the rskim-core library crate.
Links
License
MIT