Overview
Reads files with smart filtering based on language detection. Strips comments, empty lines, and optionally function bodies for aggressive token reduction.Syntax
Arguments
File to read, or
- for stdinOptions
Filter level:
none- No filtering, raw outputminimal- Remove comments and blank lines (40-60% reduction)aggressive- Remove comments, blanks, and function bodies (70-80% reduction)
Maximum lines to show. Smart truncation preserves critical code sections.
Show line numbers in output
Language Detection
Automatic detection by file extension:- Rust (.rs) - Comments, attributes, test modules
- Python (.py) - Docstrings, comments, type hints
- JavaScript/TypeScript (.js, .ts, .tsx, .jsx) - JSDoc, comments, imports
- Java (.java) - Javadoc, comments, annotations
- Go (.go) - Comments, build tags
- C/C++ (.c, .cpp, .h, .hpp) - Comments, preprocessor
- Unknown - Generic text filtering
Filter Levels
Minimal (Default)
- Removes single-line comments (
//,#) - Removes multi-line comments (
/* */,''',""") - Removes empty lines
- Preserves all code and type signatures
- 40-60% token reduction
Aggressive
- Everything from
minimal - Removes function bodies (keeps signatures)
- Removes test code blocks
- Preserves interfaces, types, constants
- 70-80% token reduction
- Use when you only need API signatures
Token Savings
60% reduction (minimal) - preserves code structure 80% reduction (aggressive) - API overview onlyOutput Format
With--line-numbers:
Exit Codes
0- Success1- File not found or permission denied
Related Commands
rtk grep- Search file contentsrtk ls- List directory contentsrtk json- View JSON structure
