Smart code reader - streaming code transformation for AI agents
npm install rskimSmart code reader - streaming code transformation for AI agents.


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.
``bash`
npx rskim file.ts
`bashVia npm
npm install -g rskim
> Note: Use
npx for trying it out. For regular use, install globally to avoid npx overhead (~100-500ms per invocation).Quick Start
`bash
Try it with npx (no install)
npx rskim file.tsOr install globally for better performance
npm install -g rskimRead TypeScript with structure mode
skim file.tsProcess multiple files with glob patterns
skim 'src/*/.ts'Show token reduction statistics
skim file.ts --show-statsExtract Python function signatures
skim file.py --mode signaturesParallel processing with custom job count
skim '*.{js,ts}' --jobs 4Pipe to syntax highlighter
skim file.rs | bat -l rustRead from stdin
cat code.ts | skim - --language=typescriptClear cache
skim --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 protectionsUsage
$3
`bash
skim
`$3
`bash
Options:
-m, --mode Transformation mode [default: structure]
[possible values: structure, signatures, types, full]
-l, --language Override language detection
[possible values: typescript, javascript, python, rust, go, java]
-j, --jobs Number of parallel jobs [default: number of CPUs]
--no-header Don't print file path headers for multi-file output
--no-cache Disable caching (caching is enabled by default)
--clear-cache Clear all cached files and exit
--show-stats Show token reduction statistics
-h, --help Print help
-V, --version Print version
`Transformation Modes
$3
Removes function bodies while preserving signatures (70-80% reduction).
`bash
skim file.ts
`Input:
`typescript
function add(a: number, b: number): number {
const result = a + b;
console.log(Adding ${a} + ${b} = ${result});
return result;
}
`Output:
`typescript
function add(a: number, b: number): number { / ... / }
`$3
Extracts only function and method signatures (85-92% reduction).
`bash
skim file.py --mode signatures
`Input:
`python
def calculate_total(items: list[Item], tax_rate: float) -> Decimal:
subtotal = sum(item.price for item in items)
tax = subtotal * tax_rate
return subtotal + tax
`Output:
`python
def calculate_total(items: list[Item], tax_rate: float) -> Decimal:
`$3
Extracts only type definitions (90-95% reduction).
`bash
skim file.ts --mode types
`Input:
`typescript
interface User {
id: number;
name: string;
}function getUser(id: number): User {
return db.users.find(id);
}
`Output:
`typescript
interface User {
id: number;
name: string;
}
`$3
Returns original code unchanged (0% reduction).
`bash
skim file.rs --mode full
`Examples
$3
`bash
Get overview of all TypeScript files (NEW: glob support)
skim 'src/*/.ts' --no-headerExtract all Python function signatures with stats
skim 'lib/*/.py' --mode signatures --show-stats > api.txtReview Rust types
skim lib.rs --mode types | lessParallel processing for faster multi-file operations
skim 'src/*/.ts' --jobs 8
`$3
`bash
Reduce token count before sending to GPT
skim large_file.ts | wc -w
Output: 150 (was 600)
Get just the API surface
skim server.py --mode signatures | pbcopy
`$3
`bash
Skim and highlight
skim file.rs | bat -l rustSkim and search
skim file.ts | grep "interface"Skim multiple files
cat *.py | skim - --language=python
`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
rskim-core` library crate.- Repository
- Library Documentation
- npm Package
MIT