Skip to content

feat: add rtk clean command to reset tracking history#694

Open
cubicj wants to merge 2 commits intortk-ai:developfrom
cubicj:feat/clean-command-v2
Open

feat: add rtk clean command to reset tracking history#694
cubicj wants to merge 2 commits intortk-ai:developfrom
cubicj:feat/clean-command-v2

Conversation

@cubicj
Copy link
Copy Markdown

@cubicj cubicj commented Mar 18, 2026

Summary

  • Add rtk clean command that clears all token savings records from the SQLite tracking database
  • Clears both commands and parse_failures tables, returns count of deleted records

Why

There is no way to reset rtk gain analytics. When users want to start fresh (e.g. after testing, changing workflow, or benchmarking), they must manually delete the SQLite file. rtk clean provides a safe, built-in reset.

Usage

$ rtk clean
Cleared 803 records from tracking history.

$ rtk gain
No tracking data yet.
Run some rtk commands to start tracking savings.

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test
  • Manual testing: rtk clean output inspected, rtk gain shows empty after clean

Replaces #684 (was based on master instead of develop, causing noisy diff).

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 20, 2026

CLA assistant check
All committers have signed the CLA.

@aeppling
Copy link
Copy Markdown
Contributor

Hey

We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes src/ from a flat layout into subfolders.

No logic changes — only file moves and import path updates.

What you need to do

Rebase your branch on develop when receiving this comment:

git fetch origin && git rebase origin/develop

Git detects renames automatically. If you get import conflicts, update the paths:

use crate::git;        // now: use crate::cmds::git::git;
use crate::tracking;   // now: use crate::core::tracking;
use crate::config;     // now: use crate::core::config;
use crate::init;       // now: use crate::hooks::init;
use crate::gain;       // now: use crate::analytics::gain;

Need help rebasing? Tag @aeppling

@cubicj cubicj force-pushed the feat/clean-command-v2 branch from c1f9ff2 to 8e15b21 Compare March 27, 2026 00:26
cubicj and others added 2 commits April 2, 2026 13:59
Clears all token savings records from the SQLite database,
allowing users to start fresh with `rtk gain` analytics.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- test_clear_all_deletes_records: verify record count and DB emptied
- test_clear_all_empty_db: zero records returns 0
- test_clear_all_clears_parse_failures: both tables cleared

All tests use isolated temp DB via RTK_DB_PATH to avoid interference.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@cubicj cubicj force-pushed the feat/clean-command-v2 branch from 8e15b21 to b74f6b9 Compare April 2, 2026 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants