Skip to content

Feature: Track invoking agent (Claude, Copilot, Codex, etc) in command analytics #1314

@Ranteck

Description

@Ranteck

Problem

Currently, RTK tracks command runs and token savings, but does not record which assistant agent (e.g., Claude Code, GitHub Copilot, Codex CLI, Cursor, etc.) triggered each command. This makes it impossible to analyze token savings per console or model, or to understand usage patterns by agent.

Suggested Solution

  • Add an agent or agent_type field to the commands table in the tracking database.
  • Detect at runtime which agent or tool is executing the command:
    • Option 1: Use environment variables (e.g., ANTHROPIC_CLAUDE_CODE, VSCode/Cursor session IDs, etc.)
    • Option 2: Pass agent identifier from CLI or hook (preferred for reliability)
  • Update the tracking code to store this value per command record.
  • Extend rtk gain and JSON/CSV exports to provide breakdowns by agent.
  • Optionally, add a migration for existing installations.

Motivation

  • Helps users understand their RTK savings and usage per console/model/agent.
  • Enables fine-grained product analytics, troubleshooting, and filter tuning.
  • Useful for users in multi-assistant environments and organizations sharing the same tracking DB.

Prior art

Many analytics platforms distinguish the source of actions. RTK could surface similar insights for tokens and efficiency by agent.

Example output (rtk gain)

By Agent
---------------------------------
Agent         Commands   Savings
claude-code   88         34,992
codex-cli     41         15,123
opencode      22         5,554
...

Related

  • src/core/tracking.rs (schema + record fn)
  • All CLI and hook integrations

This feature would be especially useful for teams and contributors using RTK with multiple LLM coding assistants.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions