Commands and cache effects
How Claude Code CLI and slash commands, model changes, background agents, Web/Remote Control, and 5-minute/1-hour prompt caching interact.
This page focuses on whether a command makes the next turn slower or more expensive. Three rules matter:
- Cache hits require an exactly matching request prefix.
- A 5-minute or 1-hour TTL determines expiry after inactivity, not the matching rules.
- Changes to the model, effort, fast mode header, system prompt, or tool definitions usually rebuild the cache next turn.
Claude subscriptions generally use a 1-hour TTL within plan allowances. API keys, Bedrock, Vertex, Foundry, Claude Platform on AWS, and third-party providers default to 5 minutes. Whether a third-party gateway produces real hits depends on complete forwarding of cache, tool, and beta fields.
To apply caching strategies to daily development, see Best practices and workflows.
#Reading TTL behavior
| Scenario | 5-minute TTL | 1-hour TTL |
|---|---|---|
| Continuous follow-ups | Each hit refreshes the 5-minute timer | Each hit refreshes the 1-hour timer |
| Return after a 10-minute break | Usually reprocesses the prefix | Usually still reads the old prefix |
| Change model or effort | Still a miss | Still a miss |
| First turn enabling fast mode | Still a miss; uncached input uses fast mode pricing | Still a miss, but later turns tolerate longer gaps |
After /compact | Summary request usually reads old cache, then new summarized history rebuilds | Same behavior, with longer-lived old cache |
#CLI startup commands
| Command | Cache effect | 5m / 1h interpretation |
|---|---|---|
claude | New interactive session loads system prompt, directory, git status, and CLAUDE.md | Sessions started in the same directory close together may share a prefix; 1h helps after a break |
claude "query" | Interactive session plus an initial message | Different prompts change only the end; preceding project context may still hit |
claude -p "query" | One-shot non-interactive request, still using the Claude Code system prompt | Frequent script calls stay warm within 5m; consider 1h for spaced tasks |
claude -c | Continues the latest session in the current directory | History can hit if the CLI has not changed and TTL has not expired |
claude -c -p "query" | Continues the latest session with another request | Same behavior; useful for automated follow-ups |
claude -r "<session>" | Resumes a specified session | A long session reprocesses substantial history on the first turn after TTL expiry |
claude --model <model> | Selects the model at startup | Model is a cache key; different models do not share cache |
claude --effort <level> | Selects effort at startup | Effort is a cache key; different effort levels do not share cache |
claude --fallback-model a,b | Tries fallback models only when the primary is unavailable | A fallback turn acts as a model change and builds a separate cache |
claude --safe-mode | Skips CLAUDE.md, skills, plugins, hooks, MCP, output styles, and other customizations | Prefix differs from normal startup; use for diagnosis, not normal cache-rate measurement |
claude --teammate-mode <mode> | Sets Agent Teams display mode without directly changing model requests | Each spawned teammate has its own cache; display mode itself does not consume 5m/1h cache |
claude update / claude install stable | Next startup may change system prompt or tool definitions | First turn after an upgrade usually fully misses; 1h does not guarantee cross-version hits |
claude doctor | Diagnostic command, normally without a model call | No prompt cache involvement |
claude agents | Opens Agent View or lists background sessions | Management interface only; newly dispatched agents have independent caches |
claude attach <id> | Attaches to a background session | Continues its history; hits are more likely within TTL |
claude logs <id> | Views background logs | No model call |
claude stop/rm/respawn <id> | Manages background sessions | After respawn, process or version changes may rebuild cache next turn |
claude mcp login/logout <name> | Handles MCP OAuth only | OAuth does not change the prompt; connection changes can affect cache after restart or a server change |
claude remote-control | Starts Remote Control server mode | Remote messages enter the same history; see Web and Remote Control for authentication and Base URL limits |
claude project purge | Deletes local project state | After transcripts are deleted, /resume cannot continue that history |
claude gateway | Starts the Claude apps gateway for administrators | No direct effect on current CLI cache, but gateway behavior affects all forwarded cache traffic |
#In-session commands
| Command | Cache effect | 5m / 1h interpretation |
|---|---|---|
/add-dir <path> | Adds a readable directory, usually as an appended session message | Does not load the new directory's .claude/ configuration; the main prefix stays warm within TTL |
/advisor [model|off] | Advisor tool definition follows the cache breakpoint, so toggling usually preserves the main cache | Each advisor call rereads the entire transcript without sharing cache across advisor calls |
/agents | Newer versions show instructions for managing subagents | Does not change the prompt; the old creation UI was also mainly an interactive operation |
/autofix-pr [prompt] | Dispatches Claude Code on the web to monitor a PR | Cloud session has its own environment and cache; local history only gains the dispatch record |
/background [prompt] / /bg | Moves the session to the background, optionally with another instruction | Continues the same session; reconnections follow that session's own TTL |
/batch <instruction> | Bundled skill splitting work into 5–30 worktree/subagent units | Parent adds a plan; background subagents each build their own cache, usually with 5m TTL |
/branch [name] | Copies a session branch from the current point | Inherits the old prefix; first turn is more likely to hit within TTL |
/btw <question> | Side question outside the main conversation | Keeps the main cache clean; useful for a quick aside |
/cd <path> | Moves the session to another directory; official behavior attempts to preserve conversation cache | Appends the new CLAUDE.md as a message; old history can hit within 5m/1h |
/chrome | Configures Claude in Chrome | Setup itself does not affect model cache; browser output increases context once added to history |
/claude-api ... | Bundled skill loading API references or migration guidance | Skill instructions append as messages; extensive references increase subsequent input |
/clear [name] | Clears context and starts a session | Old session is resumable, but the new one rebuilds project context |
/code-review ... | Bundled skill for local or cloud multi-agent review | Local review appends instructions and tool results; ultra cloud review has independent cache |
/color | Changes the prompt bar color | UI state only; no prompt cache effect |
/compact [instructions] | Summary request reads old cache, then replaces history with a shorter summary | Next turn rebuilds the shorter history cache; use at natural breaks |
/config [key=value] | Most settings reload live; model, outputStyle, and thinking vary | Output style usually does not apply or invalidate cache immediately; model changes miss |
/context [all] | Shows context usage | Read-only observation; does not change the prefix |
/copy [N] | Copies a response or code block | Local operation without a model call |
/cost / /stats / /usage | Shows usage, limits, and activity | Does not change the prompt; useful for checking cache reads/writes |
/dataviz [request] | Bundled skill for chart and dashboard design | Appends instructions without changing the system prompt |
/debug [description] | Enables debug logs and assists diagnosis | Logging itself does not change the prompt; asking Claude to analyze logs adds context |
/deep-research <question> | Bundled workflow with parallel search and source cross-checking | Subtasks cache separately; the parent receives result summaries |
/diff | Shows the current diff | May read and append git diff to history; large diffs increase future tokens |
/doctor | Diagnoses configuration and login | Mostly local checks; asking Claude to explain results adds context |
/export | Exports the session | Local operation; no cache effect |
/fast | First activation misses because of headers and possible model switching | Official notes say v2.1.86+ subsequent toggles/rate-limit fallback no longer repeatedly invalidate the same session cache |
/feedback | Submits feedback | Not a cost optimization tool; usually no main model cache effect |
/fork | Delegates current context to a background subtask | Child inherits the parent prefix and can more easily read its cache within TTL |
/goal | Sets a sustained completion condition | Goal is session state; automatic follow-up turns append normally and refresh TTL |
/hooks | Shows hook configuration and execution | Observation command; effects of edits depend on settings reload and the next trigger |
| Ask Claude to spawn teammates | Agent Teams starts independent Claude Code instances | Each teammate has its own context/cache; tokens grow roughly with active teammate count |
/init | Generates or improves CLAUDE.md | File writes are not retroactive; the current session usually retains startup-loaded CLAUDE.md |
/loop | Sets repeated checks or scheduled prompts | Each trigger is a new request; intervals over 5m can cool 5m cache, while 1h is more resilient |
/mcp | Views, authenticates, and manages MCP servers | Connection changes may alter tool definitions; tool search/deferred tools are more cache-friendly |
/memory | Edits memory files | Root-level CLAUDE.md content usually does not apply immediately; loaded after /clear or restart |
/model | Changes the model | Full miss next turn; choose the model before a long task |
/permissions | Manages allow/ask/deny | Scoped allow/ask usually preserves tool definitions; denying an entire tool changes the system prompt layer |
/plan | Enters plan mode | Ordinary plan mode appends state; with opusplan, entering/leaving plan mode changes the model |
/plugin list | Lists plugins | No model call |
/recap | Generates a display summary without replacing history | Cache-friendly but does not free context |
/reload-plugins | Applies plugin changes | Skills/hooks/agents/themes mostly append; plugin MCP follows MCP tool rules |
/rename <name> | Names the session | Metadata only; no prompt cache effect |
/resume | Resumes history | Can hit with unchanged version/model/effort within TTL; first turn after a long gap costs more |
/rewind | Rewinds conversation and file checkpoints | Returns to an old prefix; usually more likely to read old cache than /compact |
/schedule | Sets one-time or recurring tasks | Scheduled requests hit according to spacing; intervals over 5m benefit more from 1h TTL |
/security-review | Performs deeper security review | Multi-agent/skill work appends substantial context; subtasks cache separately |
/setup-bedrock / /setup-vertex | Provider setup wizard | Restarting or switching provider changes request routing and cache location |
/simplify [target] | Cleanup-only review with optional fixes | Similar to /code-review; may append diffs and check results |
/skills | Lists, filters, and toggles skill visibility | Listing does not change the prefix; invoking a skill appends a message |
/status | Shows status | Read-only observation |
/statusline | Configures the status line script | Refreshes run locally without model calls |
/stop | Stops the current background session | Does not affect other sessions' caches |
/tasks / /bashes | Lists background tasks | Local/session management; no model prefix change |
/team-onboarding | Generates onboarding docs from recent usage | Reads local history and appends analysis, potentially substantial |
/teleport / /tp | Brings a web session into the local terminal | Continues web/cloud history locally; cache location and provider can change |
/terminal-setup | Configures terminal shortcuts | Local configuration; no model effect |
/theme | Sets terminal theme | UI configuration; no model effect |
/tui [default|fullscreen] | Switches terminal renderer | UI renderer only; no prompt effect |
/ultraplan <prompt> | Performs deep cloud planning | Cloud session caches independently; local session receives the plan |
/ultrareview [PR] | Deep cloud review; /code-review ultra is now recommended | Cloud agents each cache independently |
/usage-credits | Configures credits beyond plan allowance | Using credits can reduce Claude subscription TTL from 1h to 5m |
/verify | Bundled skill to build, run, and observe the app | Tool output can be long; verification appends like ordinary session work |
/voice | Voice input | Transcription requires claude.ai identity; resulting text is an ordinary session message |
/web-setup | Connects GitHub to Claude Code on the web | Setup command; cloud sessions cache independently |
/workflows | Shows dynamic workflow progress | Management interface; subtasks cache independently |
| Incoming channel events | MCP channels append external events to a running session | Closely spaced events refresh session TTL; long logs raise subsequent input costs |
#Cache effects of environment-dependent commands
These commands commonly appear with official accounts, Desktop, Web, IDEs, GitHub/Slack, or particular providers. Most do not directly ask the model a question, but can indirectly affect caching through account state, tool sets, providers, or subsequent session structure.
| Command | Cache effect | 5m / 1h interpretation |
|---|---|---|
/help | Reads current command help, normally preserving the prefix | Check command availability without invalidating 5m/1h cache |
/login | Authentication normally stays outside the main prompt | Provider, account capabilities, or tools can change after login; observe the next new session |
/logout | Clears account state, changing later official capabilities | Does not directly consume prompt cache, but changes later identity/tool boundaries |
/ide | Manages IDE connection state | No direct cache change; injected files/diagnostics add context once in history |
/desktop, /app | Hands the session to Desktop | Surface, provider, or storage may change; evaluate the new session boundary |
/mobile, /qr | Generates a mobile connection entry point | No main model call; subsequent mobile messages use the connected session's TTL |
/remote-env | Changes the default environment for future cloud agents | Preserves the current local prefix; future cloud sessions rebuild with the new environment |
/install-github-app | OAuth/installation, normally outside the main model | GitHub App/Actions/secrets setup leads to independently cached cloud automation |
/install-slack-app | OAuth/installation, normally outside the main model | Slack-triggered work caches by Slack/cloud session |
/design-login | Design system authorization without direct prompt changes | Subsequent /design-sync introduces component data and tool output |
/design-sync [hint] | Bundled skill and upload tools may produce long flows | First sync reads many React components; stable later syncs can reuse matching prefixes |
/powerup | Tutorial content, usually separate from production tasks | Avoid inserting tutorials into long production sessions to keep context focused |
/fewer-permission-prompts | Reads history and writes a permission allowlist | Permission changes can alter next-turn tool paths; observe the next cost |
/focus | Toggles a UI view | No prompt cache effect |
/scroll-speed | Configures fullscreen scrolling | No prompt cache effect |
/keybindings | Shows/configures keybindings | No model cache effect; input behavior may change |
/exit | Exits the UI or detaches from a background session | Pausing interaction does not refresh TTL; compare the return interval with 5m/1h |
/run | Tool flow to start, observe, and drive an app | Logs, screenshots, and errors increase future tokens; stable recipes improve reuse |
/run-skill-generator | Writes a project run skill | Skill changes alter loadable context after /reload-skills or a new session |
/sandbox | Changes sandbox/permission boundaries | Tool availability/results may change; observe the first turn under the new boundaries |
/release-notes | Shows release notes | No main cache effect; helps explain first-turn misses after upgrades |
/reload-skills | Reloads skills | Description/visibility changes affect later skill calls; reload at natural breaks when needed |
/remote-control | Pairs claude.ai or the Claude app with a local session | Remote messages enter the same history; custom gateway credentials may make it unavailable |
/review | Read-only GitHub PR review | PR data/comments enter cloud or local review; cache follows that session |
/insights | Analyzes usage and friction | May read history and produce a long report; best after completing the task |
/heapdump | Local diagnostic heap snapshot | No main cache effect unless Claude analyzes the snapshot or logs |
/privacy-settings | Account settings UI | No prompt cache effect |
/passes | Account allowance entry point | No current prompt change, but allowance policy affects future models/provider routing |
/pr-comments | Accesses PR comments | Comments add task context; filter the target first for large PRs |
/setup-bedrock, /setup-vertex | Provider setup wizards | Provider changes can change cache location and supported beta/tool fields; next turn usually rebuilds |
/team-onboarding | Generates docs from recent usage history | Output may be long; use at task completion, outside a long session being optimized for caching |
/upgrade | Opens an upgrade entry point or plan page | Account/plan action itself preserves the prompt; TTL, models, and allowances may change afterward |
/stickers, /radio | Non-core account/entertainment features | Not development cache signals |
/vim | Removed | No cache involvement; use Editor mode in /config |
#Provider and gateway notes
| Symptom | Explanation |
|---|---|
| Cache fields remain 0 with Passion8 | Prefix may be too short, model/effort may change, MCP tools may be upfront, or the gateway may not forward cache fields |
Gateway models absent from /model picker | Gateway must support /v1/models; set CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 |
| Cache misses immediately after connecting MCP | If tool search is unavailable with custom ANTHROPIC_BASE_URL, tool definitions may enter the system prompt prefix |
| Remote Control unavailable | Official docs require claude.ai identity and may disable it with gateway credentials or a non-Anthropic Base URL |
| Expensive first turn after enabling fast mode | Headers and a possible Opus switch affect the cache key; decide at the start of a long session |
For 429, 529, timeouts, oversized requests, or unavailable models, first see Error reference. Where possible, retry without changing model or effort to preserve the existing cache key.
A 5-minute or 1-hour TTL describes only the prompt-prefix cache window. It is not the retention period for local transcripts, gateway logs, or server-side data. See Data usage and privacy.
#Official references
Support
Need help?
For setup, billing, or model issues, email us. Check the status page for uptime.
WeChat / QQ support is available at the bottom right.

