Skip to content
claudemods

Claude Code Slash Command Mods

Claude Code slash command mods add commands like /tally that answer instantly in code, with no model call, or change how built-in commands behave.

Tool Call Counter running in Claude Code

Tool Call Counter

Counts Claude's tool calls per turn and session, shows the count by the spinner, and adds /tally for a breakdown.

  • spinner
  • transcript
  • status
  • Intercepts tool calls
  • Changes the UI
  • Adds commands/tools

tested with v2.1.291

Claude Code slash command mods add commands you type in the prompt, such as /tally or /diff, and answer them in code. Because the handler runs inside Claude Code, it can reply instantly from data the mod has collected, open a pane, or change a setting, with no request to the model and no tokens used.

How do Claude Code slash command mods register a command?

A mod calls $.command.register({ name, description }), usually in its session.start hook, and then handles command.run with a matcher for that name: on('command.run', { command: 'tally' }, ...). The handler returns { text } to print a reply, which renders as Markdown in the transcript, or {} to finish silently. Command names allow letters, digits, _ and -, up to 64 characters.

The same command.run event also fires for every other command, so a mod can wrap built-in commands. command.describe lets a mod change how commands appear in the command list, and $.command.run lets one mod invoke another command. The create guide walks through a /tally example.

What should you check before installing one?

A command mod shows Adds commands/tools. That badge on its own is low risk: the command only runs when you type it. What matters is what the command does when it runs, so read the rest of the badges. A command that reads mod state and prints a table needs nothing else. One that opens a pane adds Changes the UI. One that runs git, reads files or calls a server shows Runs commands, Reads files or Network.

Also check for name clashes. Two mods can try to register the same command name; prefer mods that use a specific name and say so on their page.

When to use a mod command instead of a prompt

Use a mod command when the answer is mechanical: counting, listing, toggling a setting, opening a view. Use a regular command file or a skill when you want Claude to think about the answer. Many useful mods combine both, collecting data in hooks and reporting it through one command.

FAQ

How is a mod command different from a custom command file?
A command file in .claude/commands sends a prompt to Claude. A mod command runs JavaScript in Claude Code and can answer immediately from state the mod collected, without a model request.
Can a mod change a built-in command?
Yes. The command.run hook sees every command before it runs, including built-in ones, and can answer it, change it or pass it on. command.describe changes how a command appears in the list.
Do mod commands work in claude -p?
Yes. Hooks run in print mode, so a command such as claude -p "/tally" works, although nothing is drawn on screen.