

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
1# CLAUDE.md23This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.45## Project Overview67**rtk (Rust Token Killer)** is a high-performance CLI proxy that minimizes LLM token consumption by filtering and compressing command outputs. It reduces bash output by 60-90% on common development operations through smart filtering, grouping, truncation, and deduplication. All percentages in this repo measure bash output, not your bill. RTK ships no tokenizer (`src/core/tracking.rs` estimates tokens as `bytes / 4`), so the ratios are reliable but the absolute token counts are approximate.89This is a fork with critical fixes for git argument parsing and modern JavaScript stack support (pnpm, vitest, Next.js, TypeScript, Playwright, Prisma).1011### Name Collision Warning1213**Two different "rtk" projects exist:**14- This project: Rust Token Killer (rtk-ai/rtk)15- reachingforthejack/rtk: Rust Type Kit (DIFFERENT - generates Rust types)1617**Verify correct installation:**18```bash19rtk --version # Should show "rtk 0.28.2" (or newer)20rtk gain # Should show token savings stats (NOT "command not found")21```2223If `rtk gain` fails, you have the wrong package installed.2425## Development Commands2627> **Note**: If rtk is installed, prefer `rtk <cmd>` over raw commands for token-optimized output.28> All commands work with passthrough support even for subcommands rtk doesn't specifically handle.2930### Build & Run31```bash32cargo build # raw33rtk cargo build # preferred (token-optimized)34cargo build --release # release build (optimized)35cargo run -- <command> # run directly36cargo install --path . # install locally37```3839### Testing40```bash41cargo test # all tests42rtk cargo test # preferred (token-optimized)43cargo test <test_name> # specific test44cargo test <module_name>:: # module tests45cargo test -- --nocapture # with stdout46bash scripts/test-all.sh # smoke tests (installed binary required)47```4849### Linting & Quality50```bash51cargo check # check without building52cargo fmt # format code53cargo clippy --all-targets # all clippy lints54rtk cargo clippy --all-targets # preferred55```5657### Pre-commit Gate58```bash59cargo fmt --all && cargo clippy --all-targets && cargo test --all60```6162### Package Building63```bash64cargo deb # DEB package (needs cargo-deb)65cargo generate-rpm # RPM package (needs cargo-generate-rpm, after release build)66```6768## Architecture6970rtk uses a **command proxy architecture**: `main.rs` routes CLI commands via a Clap `Commands` enum to specialized filter modules in `src/cmds/*/`, each of which executes the underlying command and compresses its output. Token savings are tracked in SQLite via `src/core/tracking.rs`.7172For the full architecture, component details, and module development patterns, see:73- [ARCHITECTURE.md](docs/contributing/ARCHITECTURE.md) — System design, module organization, filtering strategies, error handling74- [docs/contributing/TECHNICAL.md](docs/contributing/TECHNICAL.md) — End-to-end flow, folder map, hook system, filter pipeline7576Module responsibilities are documented in each folder's `README.md` and each file's `//!` doc header. Browse `src/cmds/*/` to discover available filters.7778Supported ecosystems: git/gh/gt, cargo, go/golangci-lint, npm/pnpm/npx, ruff/pytest/pip/mypy, rspec/rubocop/rake, dotnet, playwright/vitest/jest, docker/kubectl/aws, gradlew/mvn, php/artisan/phpunit/phpstan/pest.7980### Proxy Mode8182**Purpose**: Execute commands without filtering but track usage for metrics.8384**Usage**: `rtk proxy <command> [args...]`8586**Benefits**:87- **Bypass RTK filtering**: Workaround bugs or get full unfiltered output88- **Track usage metrics**: Measure which commands Claude uses most (visible in `rtk gain --history`)89- **Guaranteed compatibility**: Always works even if RTK doesn't implement the command9091**Examples**:92```bash93rtk proxy git log --oneline -20 # Full git log output (no truncation)94rtk proxy npm install express # Raw npm output (no filtering)95rtk proxy curl https://api.example.com/data # Any command works96```9798All proxy commands appear in `rtk gain --history` with 0% bash output reduction (input = output).99100## Coding Rules101102Rust patterns, error handling, and anti-patterns are defined in `.claude/rules/rust-patterns.md` (auto-loaded into context). Key points:103104- **anyhow::Result** everywhere, always `.context("description")?`105- **No unwrap()** in production code106- **`LazyLock` statics** for all regex (never compile on every function call)107- **Fallback pattern**: if filter fails, execute raw command unchanged108- **No async**: single-threaded by design (startup <10ms)109- **Exit code propagation**: `std::process::exit(code)` on child failure110111Testing strategy and performance targets are defined in `.claude/rules/cli-testing.md` (auto-loaded). Key targets: <10ms startup, <5MB memory, 60-90% reduction in bash output bytes.112113For contribution workflow and design philosophy, see [CONTRIBUTING.md](CONTRIBUTING.md). For the step-by-step filter implementation checklist, see [src/cmds/README.md](src/cmds/README.md#adding-a-new-command-filter).114115## Build Verification (Mandatory)116117**CRITICAL**: After ANY Rust file edits, ALWAYS run the full quality check pipeline before committing:118119```bash120cargo fmt --all && cargo clippy --all-targets && cargo test --all121```122123**Rules**:124- Never commit code that hasn't passed all 3 checks125- Fix ALL clippy warnings before moving on (zero tolerance)126- If build fails, fix it immediately before continuing to next task127128**Performance verification** (for filter changes):129```bash130hyperfine 'rtk git log -10' --warmup 3 # before131cargo build --release132hyperfine 'target/release/rtk git log -10' --warmup 3 # after (should be <10ms)133```134135## Working Directory Confirmation136137**ALWAYS confirm working directory before starting any work**:138139```bash140pwd # Verify you're in the rtk project root141git branch # Verify correct branch (main, feature/*, etc.)142```143144**Never assume** which project to work in. Always verify before file operations.145146## Avoiding Rabbit Holes147148**Stay focused on the task**. Do not make excessive operations to verify external APIs, documentation, or edge cases unless explicitly asked.149150**Rule**: If verification requires more than 3-4 exploratory commands, STOP and ask the user whether to continue or trust available info.151152**Examples of rabbit holes to avoid**:153- Excessive regex pattern testing (trust snapshot tests, don't manually verify 20 edge cases)154- Deep diving into external command documentation (use fixtures, don't research git/cargo internals)155- Over-testing cross-platform behavior (test macOS + Linux, trust CI for Windows)156- Verifying API signatures across multiple crate versions (use docs.rs if needed, don't clone repos)157158**When to stop and ask**:159- "Should I research X external API behavior?" → ASK if it requires >3 commands160- "Should I test Y edge case?" → ASK if not mentioned in requirements161- "Should I verify Z across N platforms?" → ASK if N > 2162163## Plan Execution Protocol164165When user provides a numbered plan (QW1-QW4, Phase 1-5, sprint tasks, etc.):1661671. **Execute sequentially**: Follow plan order unless explicitly told otherwise1682. **Commit after each logical step**: One commit per completed phase/task1693. **Never skip or reorder**: If a step is blocked, report it and ask before proceeding1704. **Track progress**: Use task list (TaskCreate/TaskUpdate) for plans with 3+ steps1715. **Validate assumptions**: Before starting, verify all referenced file paths exist and working directory is correct172
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| rtk-ai/rtk.github/copilot-instructions.md · 76k | Copilot instructions | buildtestlint-formatstyle+2 | 97/100 | 14 days ago |
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| stacklok/toolhiveCLAUDE.md · 2.0k | CLAUDE.md | buildteststylearch+4 | 100/100 | 14 days ago | |
| Adit-Jain-srm/NightmareNetCLAUDE.md · 46 | CLAUDE.md | buildtestlint-formatstyle+6 | 100/100 | 14 days ago | |
| microsoft/playwrightCLAUDE.md · 95k | CLAUDE.md | buildtestlint-formatstyle+7 | 100/100 | 7 days ago | |
| nimbalyst/nimbalystpackages/android/CLAUDE.md · 1.5k | CLAUDE.md | setupbuildstylearch+2 | 100/100 | 14 days ago | |
| tphakala/birdnet-goCLAUDE.md · 1.6k | CLAUDE.md | buildtestlint-formatstyle+8 | 100/100 | today | |
| dotCMS/corecore-web/CLAUDE.md · 949 | CLAUDE.md | teststylearchtesting-strategy+3 | 100/100 | 14 days ago | |
| tyrchen/geektime-bootcamp-aiw7/genslides/backend/CLAUDE.md · 230 | CLAUDE.md | testlint-formatstylearch+6 | 100/100 | 9 days ago | |
| bagisto/bagistoCLAUDE.md · 28k | CLAUDE.md | setupbuildteststyle+5 | 100/100 | 7 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/rtk-ai-rtk-claude)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.