claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Feature Request: Record (custom) slash command usage as telemetry events

Open JohnnyMorganz opened this issue 4 months ago • 4 comments

As an organization, we would like to see what slash commands are providing the most value to our developers, e.g. to determine ROI based on automation of mechanical tasks.

We've implemented OpenTelemetry monitoring based off https://docs.anthropic.com/en/docs/claude-code/monitoring-usage, however it seems that no telemetry event is emitted when a slash command is invoked. One thought is maybe claude_code.user_prompt event would be emitted with the prompt contents starting with the /[command] text (when OTEL_LOG_USER_PROMPTS is enabled), however this is also not the case.

It would be great if there was an event tracking slash command usage. I think the key attributes would be:

  • the slash command name
  • the scope of the command (project vs. personal). Ideally with some way to determine what the project was as well? (but maybe that's a separate feature request).
  • Maybe also the arguments to the slash command (but only with OTEL_LOG_USER_PROMPTS enabled?)

JohnnyMorganz avatar Sep 02 '25 13:09 JohnnyMorganz

+1, this is a great feature request.

Like you, I noticed that slash commands don't trigger the claude_code.user_prompt event, even with OTEL_LOG_USER_PROMPTS enabled. It seems like the telemetry hook for prompts only fires on natural language inputs, not commands.

As a potential workaround until there's official support, you might be able to use Claude Code Hooks.

The documentation mentions a UserPromptSubmit hook that runs before Claude processes any user input. This hook receives a JSON object on stdin containing the full prompt text.

You could write a simple script that:

  1. Acts as the UserPromptSubmit hook.
  2. Parses the incoming JSON to get the prompt string.
  3. Checks if the prompt starts with a /.
  4. If it's a slash command, you can parse the command name and arguments. You could even determine the scope by checking if a command file with that name exists in ./.claude/commands/ (project) vs. ~/.claude/commands/ (personal).
  5. From that script, you could then log the data to a file or emit your own custom OpenTelemetry event.

It's definitely more work than having a built-in event, but it might get you the data you need in the meantime. You can find the details in the Hooks Guide documentation.

Still, hoping the team considers adding a dedicated claude_code.slash_command.invoked event with these attributes built-in

coygeek avatar Sep 02 '25 17:09 coygeek

Hi team. Is there any update on this request?

Our org is running into the same scenario. We were using hooks but decided to move to otel to leverage the built-in functionalities instead of maintaining hooks.

kevin-vanta avatar Nov 18 '25 17:11 kevin-vanta

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] avatar Dec 19 '25 10:12 github-actions[bot]

Still a useful feature request to have built-in, without needing to create custom hooks and telemetry uploading functionality

JohnnyMorganz avatar Dec 19 '25 17:12 JohnnyMorganz