Skip to main content

Default Database Location

RTK stores token savings tracking data in a SQLite database at the platform-specific default location:
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:
All team members point to the same database, aggregating savings across the entire project.

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)

Environment variable overrides all other settings. If set, RTK ignores the config file database path.

Method 2: Config File

Edit ~/.config/rtk/config.toml:

Priority Order

RTK resolves the database path using this priority (highest to lowest):
  1. RTK_DB_PATH environment variable — Overrides everything
  2. config.toml setting — Used if env var not set
  3. 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 in config.toml not respected. Solution: Check if environment variable is set (it takes precedence).

Database Schema

The RTK database contains two main tables:commands table:
  • id: Integer primary key
  • timestamp: 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 output
  • output_tokens: Actual tokens from RTK output
  • saved_tokens: Calculated savings (input - output)
  • savings_pct: Savings percentage ((saved / input) * 100)
  • exec_time_ms: Execution time in milliseconds
  • project_path: Working directory path (for project-scoped queries)
parse_failures table:
  • id: Integer primary key
  • timestamp: RFC3339 UTC timestamp (indexed)
  • raw_command: Unparsed command string
  • error_message: Parse error description
  • fallback_succeeded: Whether fallback execution succeeded (0/1)
Automatic cleanup runs after each write, deleting records older than 90 days.

See Also

  • Tee Recovery — Full output recovery on command failures
  • Proxy Mode — Bypass RTK filtering while tracking metrics