Default Database Location
RTK stores token savings tracking data in a SQLite database at the platform-specific default location:| Platform | Default Path |
|---|---|
| Linux | ~/.local/share/rtk/history.db |
| macOS | ~/Library/Application Support/rtk/history.db |
| Windows | %APPDATA%\rtk\history.db |
The database stores 90 days of command history with automatic cleanup. Each record includes: command, timestamps, input/output tokens, savings percentage, and execution time.
Why Customize Database Path?
Common use cases for custom database locations:1. Shared Team Tracking
Track token savings across multiple developers:2. CI/CD Integration
Persist tracking data in CI pipelines:3. Multi-User Systems
Separate tracking per user on shared machines:4. Project-Specific Tracking
Track different projects independently:5. Disk Space Management
Move database to larger partition:Configuration Methods
Method 1: Environment Variable (Highest Priority)
Method 2: Config File
Edit~/.config/rtk/config.toml:
Priority Order
RTK resolves the database path using this priority (highest to lowest):RTK_DB_PATHenvironment variable — Overrides everythingconfig.tomlsetting — Used if env var not set- Platform default — Fallback if neither is configured
Use Cases with Examples
Shared Team Tracking
Scenario: 5 developers working on the same project, want to measure team-wide token savings. Setup:CI/CD Pipeline Tracking
Scenario: Track token savings in GitHub Actions across all CI runs.Per-Project Tracking
Scenario: Developer works on multiple projects, wants separate tracking per project.Multi-User Isolation
Scenario: Shared Linux server with multiple users, each needs independent tracking.Verification
Check which database path RTK is using:Migration Between Databases
Move tracking data from old database to new location:RTK databases are standard SQLite files. You can merge databases using
sqlite3 CLI tools if needed.Troubleshooting
Database Not Found
Symptom:rtk gain shows zero commands despite usage history.
Solution: Check if path points to wrong location.
Permission Denied
Symptom:Error: Permission denied (os error 13) when running RTK commands.
Solution: Ensure RTK can write to the database directory.
Config File Ignored
Symptom: Database path inconfig.toml not respected.
Solution: Check if environment variable is set (it takes precedence).
Database Schema
SQLite Schema Details
SQLite Schema Details
The RTK database contains two main tables:
commands table:id: Integer primary keytimestamp: RFC3339 UTC timestamp (indexed)original_cmd: Standard command (e.g., “git status”)rtk_cmd: RTK command used (e.g., “rtk git status”)input_tokens: Estimated tokens from standard outputoutput_tokens: Actual tokens from RTK outputsaved_tokens: Calculated savings (input - output)savings_pct: Savings percentage ((saved / input) * 100)exec_time_ms: Execution time in millisecondsproject_path: Working directory path (for project-scoped queries)
parse_failures table:id: Integer primary keytimestamp: RFC3339 UTC timestamp (indexed)raw_command: Unparsed command stringerror_message: Parse error descriptionfallback_succeeded: Whether fallback execution succeeded (0/1)
See Also
- Tee Recovery — Full output recovery on command failures
- Proxy Mode — Bypass RTK filtering while tracking metrics
