Filter Development Checklist
From CLAUDE.md (lines 548-605), here’s the complete checklist:Implementation
- Create filter module in
src/<cmd>_cmd.rs(or extend existing) - Add
lazy_static!regex patterns for parsing (compile once, reuse) - Implement fallback to raw command on error (graceful degradation)
- Preserve exit codes (
std::process::exit(code)if non-zero)
Testing
- Write snapshot test with real command output fixture (
tests/fixtures/<cmd>_raw.txt) - Verify token savings ≥60% with
count_tokens()assertion - Test cross-platform shell escaping (macOS, Linux, Windows)
- Write unit tests for edge cases (empty output, errors, unicode, ANSI codes)
Integration
- Register filter in main.rs Commands enum
- Update README.md with new command support and token savings %
- Update CHANGELOG.md with feature description
Quality Gates
- Run
cargo fmt --all && cargo clippy --all-targets && cargo test - Benchmark startup time with
hyperfine(verify <10ms) - Test manually:
rtk <cmd>and inspect output for correctness - Verify fallback: Break filter intentionally, confirm raw command executes
Documentation
- Add command to CLAUDE.md Module Responsibilities table
- Document token savings % (from tests)
- Add usage examples to README.md
Module Creation Pattern
Step 1: Create Module File
Step 2: Implement Standard Template
Step 3: Register in main.rs
Add the module tomain.rs:
Implementation Steps
1
Choose a filtering strategy
Select the appropriate strategy based on output type:
- Stats Extraction: Count/aggregate (git status, pnpm list)
- Error Only: Show stderr only (test failures)
- Grouping by Pattern: Group by rule/file (lint, tsc)
- Deduplication: Count repeated lines (logs)
- Structure Only: Keys without values (JSON)
- Code Filtering: Strip comments/bodies (read)
- Failure Focus: Show only failures (vitest, playwright)
- Tree Compression: Hierarchy view (ls)
- Progress Filtering: Strip ANSI (wget, pnpm)
- JSON/Text Dual: JSON when available (ruff, pip)
- State Machine: Track state transitions (pytest)
- NDJSON Streaming: Line-by-line JSON (go test)
2
Write the test first (TDD)
Create a fixture file with real command output:Write a failing test:Run the test (it should fail):
3
Implement the filter
Implement the filtering logic to pass the test:Run the test again (it should pass):
4
Add Package Manager Detection (JS/TS only)
For JavaScript/TypeScript tools, add package manager auto-detection:
5
Add graceful fallback
Ensure the filter fails gracefully:
6
Add edge case tests
Test error conditions:
7
Run quality gates
8
Benchmark performance
9
Manual testing
Test with real commands:
10
Update documentation
Update multiple files:README.md:CHANGELOG.md:CLAUDE.md (Module Responsibilities table):
Testing Requirements
Token Savings Verification
All filters must achieve ≥60% token savings:Exit Code Preservation
Test that exit codes are properly preserved:Fallback Testing
Verify graceful degradation:Example Walkthrough: Adding rtk mypy
Let’s walk through adding Python type checker support:
1. Create fixture
2. Write test
3. Implement filter
4. Complete the module
Add execution and tracking logic (see standard template above).5. Register in main.rs
6. Test manually
7. Update docs
Add to README.md, CHANGELOG.md, and CLAUDE.md.Common Pitfalls
Next Steps
- Testing Guide - TDD workflow and test types
- Architecture - Understand filtering strategies
- Security - Security review for PR merges
