Skip to content

feat: rtk session — Show RTK adoption across Claude Code sessions #487

Closed

Description

@FlorianBruniaux

Use case

rtk session shows my last 10 Claude Code sessions with the RTK vs raw command ratio, so I can see if my hook is working.

Scope MVP (v1)

Single command, zero flags. Displays the 10 most recent sessions.

Technical approach: reuse provider.rs directly

ClaudeProvider already exposes:

  • discover_sessions(project_filter, since_days) -> Vec<PathBuf> — finds JSONL session files
  • extract_commands(path) -> Vec<ExtractedCommand> — parses JSONL, returns command + output_len

What session_cmd.rs does:

  1. ClaudeProvider.discover_sessions(None, Some(30)) → all sessions last 30 days
  2. For each session: extract_commands(path) → Vec<ExtractedCommand>
  3. Count: total = cmds.len(), rtk_count = cmds.iter().filter(|c| c.command.starts_with("rtk ")).count()
  4. Calculate adoption %, format output_len
  5. Sort by mtime desc, take top 10
  6. Display table

Zero JSONL parsing duplication — reuses the trait as-is.

Target output

RTK Session Overview (last 10)
------------------------------------------------------------------
Session            Date        Cmds   RTK   Adoption  Output
------------------------------------------------------------------
abc123de           Mar 10      42     38    90% @@@@.   24K
fed987cb           Mar 09      18     12    67% @@@..    8K
------------------------------------------------------------------
Average adoption: 83%
Tip: Run `rtk discover` to find missed RTK opportunities

(ASCII progress bar with simple blocks for terminal compatibility)

Files to create/modify

File Action
src/session_cmd.rs Create (~250 lines, shorter thanks to provider reuse)
src/main.rs Add mod session_cmd, Commands::Session, routing
scripts/test-all.sh Add smoke test assertion

Reuse existing

  • discover::provider::{ClaudeProvider, SessionProvider, ExtractedCommand}
  • tracking::estimate_tokens()
  • Table pattern from gain.rs
  • dirs::home_dir()

Error handling

  • ~/.claude/projects/ absent → "No Claude Code sessions found."
  • Corrupted JSONL → handled by provider (skip line)
  • Session with no Bash commands → skip
  • Implicit limit: 10 sessions max (perf guard)

Tests

  • Inline tests with JSONL fixtures in tempdir
  • Test RTK vs raw count on mock ExtractedCommand
  • Test progress bar rendering (0%, 50%, 100%)
  • Test empty session → skip

Verification

cargo fmt --all && cargo clippy --all-targets && cargo test
./target/debug/rtk session   # on real setup
hyperfine 'rtk session'      # target <500ms (I/O bound, JSONL parsing)

Out of scope (v2, defer)

  • --project filter by current project
  • --days N temporal filter
  • --format json
  • --verbose per-session command detail

Acceptance criteria

  • rtk session displays last 10 sessions with adoption %
  • Reuses provider.rs without JSONL parsing duplication
  • Sessions with no Bash commands are skipped
  • cargo test passes, clippy clean
  • CHANGELOG.md + README updated

Activity

  1. added
    enhancement
    on Mar 10, 2026
  2. added a commit that references this issue on Mar 14, 2026
    8c57f03
  3. added a commit that references this issue on May 14, 2026
    3daa140
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions