Claude Code Custom Slash Commands Through the Aggregator: Which Model Receives the Expanded Prompt
Learn how to define project-level slash commands in Claude Code when using an aggregator API key, and trace how the expanded command prompt is routed to a specific backend model. Avoid accidentally sending commands like /review to the wrong model by understanding the routing chain from command definition to model selection.
How slash commands work in Claude Code
Claude Code lets you define reusable prompts as slash commands. When you type a command like /review in the CLI, Claude Code expands it into a full prompt before sending the request to the model. The expansion is based on a command definition file you provide.
- Built-in commands (e.g.,
/help,/clear) are handled locally. - Custom commands are defined by you and are expanded into a prompt that is sent to the model.
Defining a project-level slash command
Project-level commands are stored in your repository so the whole team can use them. Create a directory for commands (commonly .claude/commands at the project root) and add a Markdown file for each command.
Example .claude/commands/review.md:
Review the following code changes for correctness, style, and potential bugs:
$ARGUMENTS
Provide a concise report with suggestions.
The $ARGUMENTS placeholder is replaced with the text you type after the command. When you run /review src/utils.js, Claude Code expands the command into the prompt above with $ARGUMENTS replaced by src/utils.js.
The expansion is just a prompt
The key point: a custom slash command does not specify which model to use. It only produces a text prompt. The model selection happens later in the request pipeline. When you use an aggregator API key, that pipeline includes the aggregator's routing logic.
How the expanded prompt reaches a model via an aggregator
When Claude Code sends the expanded prompt, it does so through the API endpoint configured for your session. With an aggregator, that endpoint is the aggregator's API. The aggregator then routes the request to one of the backend models it supports.
The routing decision depends on:
- The model name you specify in Claude Code's configuration (e.g., via environment variables or settings).
- Any default model configured for your aggregator key.
- The aggregator's own routing rules (if you have set them).
If you do not explicitly set a model, Claude Code may use a default. That default might be a cheaper model, which is why a command like /review could silently hit a less capable backend.
Tracing the route for a custom command
To ensure your command goes to the intended model, trace the chain:
- Command definition – The file in
.claude/commands/only defines the prompt template. - Claude Code model setting – Check your Claude Code configuration (environment variable
ANTHROPIC_MODELor settings file) for the model name. This is what Claude Code sends to the aggregator. - Aggregator key defaults – Your aggregator account may have a default model set for the API key. This can override or supplement the model name from Claude Code if not explicitly provided.
- Aggregator routing – The aggregator maps the requested model name to a backend provider. If the model name is not recognized, it may fall back to a default.
To avoid surprises, always specify the model explicitly in Claude Code when you need a specific backend. For example, set ANTHROPIC_MODEL to the exact model identifier that the aggregator expects for the high-quality model you want.
Preventing /review from hitting the cheap model
If you have a command that requires a strong model (like code review), make sure the model is set for that session. Options include:
- Setting the model in your shell environment before launching Claude Code.
- Using a project-level settings file that specifies the model.
- Configuring the aggregator key to default to the desired model (if the aggregator supports it).
Remember that the slash command itself cannot enforce a model. The model is determined by the request configuration, not the command content.
Example: setting the model explicitly
Suppose your aggregator supports a model named claude-3-5-sonnet-20241022. You can export:
export ANTHROPIC_MODEL="claude-3-5-sonnet-20241022"
Then launch Claude Code. When you run /review, the expanded prompt will be sent with that model name to the aggregator, which routes it to the corresponding backend.
Checking which model was actually used
After running a command, you can verify the model by:
- Inspecting the aggregator's usage logs or dashboard.
- Checking Claude Code's verbose output (if available) for the model name.
- Reviewing the response metadata if the aggregator includes it.
This helps confirm that your command reached the intended model.
Billing implications
With the aggregator, you pay the official price times 1.3 for each request. The model you route to affects the base price. If a command silently uses a cheaper model, you pay less but may get lower quality. If you need a specific model, set it explicitly to avoid unexpected charges or results. Contributors who help improve the aggregator are credited at official price times 1.1 (or 1.2 for premium models) in USDC.
Summary
Custom slash commands in Claude Code are prompt templates. They do not control model selection. When using an aggregator, the model is determined by the model name you specify in Claude Code and the aggregator's routing. To ensure a command like /review hits the right backend, explicitly set the model in your environment or settings. Always verify the model used via aggregator logs to avoid silent misrouting.