Skip to content

feat: accept --analytics-intent and --analytics-task-id on every command - #295

Merged
angeloashmore merged 13 commits into
mainfrom
claude/cli-intent-task-id-i1wobt
Sep 10, 2026
Merged

feat: accept --analytics-intent and --analytics-task-id on every command#295
angeloashmore merged 13 commits into
mainfrom
claude/cli-intent-task-id-i1wobt

Conversation

@angeloashmore

@angeloashmore angeloashmore commented Sep 9, 2026

Copy link
Copy Markdown
Member

Resolves:

Description

This PR adds the following options to all commands:

  • --analytics-intent
  • --analytics-task-id

These options allow an agent to provide context around the CLI call. We know when specific commands are called, but we don't why why they are called. Knowing the intent behind a command or set of commands helps us understand where to focus efforts.

These options are only exposed when an agent uses the CLI. Help text is hidden from humans, but the options are always accepted. We expect only agents to provide these options.

Companion change in the skill: prismicio/skills#9

Checklist

  • If my changes require tests, I added them.
  • If my changes affect backward compatibility, it has been discussed.
  • If my changes require an update to the CONTRIBUTING.md guide, I updated it.

Preview

$ AI_AGENT=claude-code prismic --help
...
OPTIONS
      --analytics-intent string    The user's overall task in one short sentence. ...
      --analytics-task-id string   A globally unique ID (UUID) for the user's task. ...
  -h, --help                       Show help for command

AGENTS
  Before the first command for a user request, generate one UUID, for example
  with `node -e "console.log(crypto.randomUUID())"`. Pass that exact value as
  --analytics-task-id on every command for the request, including read-only
  commands such as list and view. Never use a placeholder and never generate a
  second UUID for the same request. Pass the request in one sentence as
  --analytics-intent on the same commands. Analytics only, no effect on behavior.

How to QA 1

  1. Run prismic --help. No AGENTS section and no analytics options.
  2. Run AI_AGENT=test prismic --help. Both appear.
  3. Run any command with --analytics-intent "..." --analytics-task-id <uuid>. It succeeds, and the Amplitude event carries userIntent and taskId.

🤖 Generated with Claude Code

https://claude.ai/code/session_015pufvNWHTyTcd38NnNPyPK


Note

Low Risk
Analytics-only optional flags with broader command tracking for formerly untracked commands; no change to CLI command semantics.

Overview
Adds agent-only analytics flags --analytics-intent and --analytics-task-id on every CLI entry point (root parse, command router, and leaf commands). Values are forwarded into Segment (Prismic CLI Start/End) and Sentry (tags/context) so multi-command agent workflows can be grouped by task; the flags do not change command behavior.

When detectAgent() finds an agent environment, help surfaces the options plus an AGENTS section with UUID/intent usage guidance; options stay accepted but hidden for non-agent runs. detectAgent is now synchronous (existsSync for Devin).

Telemetry tracking at startup no longer skips login, logout, whoami, docs, and status—only sync is excluded at the top level because it self-tracks with watch: true. Tests and an eval assert agents reuse one UUID and one intent across all commands in a task.

Reviewed by Cursor Bugbot for commit 4911d12. Bugbot is set up for automated code reviews on this repo. Configure here.

Footnotes

  1. Please use these labels when submitting a review:
    ❓ #ask: Ask a question.
    💡 #idea: Suggest an idea.
    ⚠️ #issue: Strongly suggest a change.
    🎉 #nice: Share a compliment.

@angeloashmore angeloashmore changed the title feat: accept --intent and --task-id on every command for agent analytics feat: accept --analytics-intent and --analytics-task-id on every command Sep 9, 2026
@angeloashmore angeloashmore changed the title feat: accept --analytics-intent and --analytics-task-id on every command feat: accept --analytics-intent and --analytics-task-id on every command Sep 9, 2026
@angeloashmore
angeloashmore marked this pull request as ready for review September 9, 2026 14:55

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread src/index.ts Outdated
@angeloashmore
angeloashmore changed the base branch from main to claude/eval-record-argv September 9, 2026 15:42

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit acfdae7. Configure here.

Comment thread src/lib/command.ts
@angeloashmore
angeloashmore added this pull request to stack #298 September 10, 2026 12:51
Base automatically changed from claude/eval-record-argv to main September 10, 2026 14:04
Agents pass these two options so analytics can group the commands that
serve one user request. The options are always accepted. They appear in
help output only when an agent is detected.

The values are sent as userIntent and taskId on the "Prismic CLI Start"
and "Prismic CLI End" events, and attached to Sentry. Every command is
now tracked, including the ones that were previously excluded.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015pufvNWHTyTcd38NnNPyPK
Replaces the mutable global options hook. Help output decides at render
time whether to list the agent options.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015pufvNWHTyTcd38NnNPyPK
Agent detection is synchronous, so help builders stay synchronous and
the agent options are plain config with a hidden flag, like the router's
hidden commands.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015pufvNWHTyTcd38NnNPyPK
…mmand

The eval wraps the CLI bin to record the argv of every call, so it
checks the values the CLI receives rather than the shell text the agent
wrote. It pins the Prismic skill to the commit that adds the rule.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015pufvNWHTyTcd38NnNPyPK
…ics-task-id

The prefix says what the options are for. Without it, the names read as
if they change behavior.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015pufvNWHTyTcd38NnNPyPK
The section tells agents to generate one UUID per request and pass it,
with the request in one sentence, on every command. It appears only when
an agent is detected. Help text without it scored 0 of 3 eval trials;
with it and the skill rule, 3 of 3.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015pufvNWHTyTcd38NnNPyPK
Agents generated the UUID late or more than once. The section now says
to generate it before the first command, never use a placeholder, and
never generate a second one. The option descriptions name read-only
commands too.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015pufvNWHTyTcd38NnNPyPK
The pin moves to the merged skill commit in a later change.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015pufvNWHTyTcd38NnNPyPK
The harness now records argv for every call, so the eval no longer
needs its own bin wrapper.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015pufvNWHTyTcd38NnNPyPK
sync runs until SIGINT and tracks itself with watch: true, so the
entrypoint must not emit a second start event for it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015pufvNWHTyTcd38NnNPyPK
The router parsed only --help, so a string-valued analytics option
with no subcommand turned its value into a positional and the router
rejected it as an unknown command.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015pufvNWHTyTcd38NnNPyPK
@angeloashmore
angeloashmore force-pushed the claude/cli-intent-task-id-i1wobt branch from 3590dda to 4911d12 Compare September 10, 2026 14:04
@angeloashmore
angeloashmore merged commit 9e4d016 into main Sep 10, 2026
34 of 40 checks passed
@angeloashmore
angeloashmore deleted the claude/cli-intent-task-id-i1wobt branch September 10, 2026 14:18
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.

3 participants