Claude Code

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:

  1. Cache hits require an exactly matching request prefix.
  2. A 5-minute or 1-hour TTL determines expiry after inactivity, not the matching rules.
  3. 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

Scenario5-minute TTL1-hour TTL
Continuous follow-upsEach hit refreshes the 5-minute timerEach hit refreshes the 1-hour timer
Return after a 10-minute breakUsually reprocesses the prefixUsually still reads the old prefix
Change model or effortStill a missStill a miss
First turn enabling fast modeStill a miss; uncached input uses fast mode pricingStill a miss, but later turns tolerate longer gaps
After /compactSummary request usually reads old cache, then new summarized history rebuildsSame behavior, with longer-lived old cache

#CLI startup commands

CommandCache effect5m / 1h interpretation
claudeNew interactive session loads system prompt, directory, git status, and CLAUDE.mdSessions started in the same directory close together may share a prefix; 1h helps after a break
claude "query"Interactive session plus an initial messageDifferent 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 promptFrequent script calls stay warm within 5m; consider 1h for spaced tasks
claude -cContinues the latest session in the current directoryHistory can hit if the CLI has not changed and TTL has not expired
claude -c -p "query"Continues the latest session with another requestSame behavior; useful for automated follow-ups
claude -r "<session>"Resumes a specified sessionA long session reprocesses substantial history on the first turn after TTL expiry
claude --model <model>Selects the model at startupModel is a cache key; different models do not share cache
claude --effort <level>Selects effort at startupEffort is a cache key; different effort levels do not share cache
claude --fallback-model a,bTries fallback models only when the primary is unavailableA fallback turn acts as a model change and builds a separate cache
claude --safe-modeSkips CLAUDE.md, skills, plugins, hooks, MCP, output styles, and other customizationsPrefix 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 requestsEach spawned teammate has its own cache; display mode itself does not consume 5m/1h cache
claude update / claude install stableNext startup may change system prompt or tool definitionsFirst turn after an upgrade usually fully misses; 1h does not guarantee cross-version hits
claude doctorDiagnostic command, normally without a model callNo prompt cache involvement
claude agentsOpens Agent View or lists background sessionsManagement interface only; newly dispatched agents have independent caches
claude attach <id>Attaches to a background sessionContinues its history; hits are more likely within TTL
claude logs <id>Views background logsNo model call
claude stop/rm/respawn <id>Manages background sessionsAfter respawn, process or version changes may rebuild cache next turn
claude mcp login/logout <name>Handles MCP OAuth onlyOAuth does not change the prompt; connection changes can affect cache after restart or a server change
claude remote-controlStarts Remote Control server modeRemote messages enter the same history; see Web and Remote Control for authentication and Base URL limits
claude project purgeDeletes local project stateAfter transcripts are deleted, /resume cannot continue that history
claude gatewayStarts the Claude apps gateway for administratorsNo direct effect on current CLI cache, but gateway behavior affects all forwarded cache traffic

#In-session commands

CommandCache effect5m / 1h interpretation
/add-dir <path>Adds a readable directory, usually as an appended session messageDoes 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 cacheEach advisor call rereads the entire transcript without sharing cache across advisor calls
/agentsNewer versions show instructions for managing subagentsDoes 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 PRCloud session has its own environment and cache; local history only gains the dispatch record
/background [prompt] / /bgMoves the session to the background, optionally with another instructionContinues the same session; reconnections follow that session's own TTL
/batch <instruction>Bundled skill splitting work into 5–30 worktree/subagent unitsParent adds a plan; background subagents each build their own cache, usually with 5m TTL
/branch [name]Copies a session branch from the current pointInherits the old prefix; first turn is more likely to hit within TTL
/btw <question>Side question outside the main conversationKeeps the main cache clean; useful for a quick aside
/cd <path>Moves the session to another directory; official behavior attempts to preserve conversation cacheAppends the new CLAUDE.md as a message; old history can hit within 5m/1h
/chromeConfigures Claude in ChromeSetup itself does not affect model cache; browser output increases context once added to history
/claude-api ...Bundled skill loading API references or migration guidanceSkill instructions append as messages; extensive references increase subsequent input
/clear [name]Clears context and starts a sessionOld session is resumable, but the new one rebuilds project context
/code-review ...Bundled skill for local or cloud multi-agent reviewLocal review appends instructions and tool results; ultra cloud review has independent cache
/colorChanges the prompt bar colorUI state only; no prompt cache effect
/compact [instructions]Summary request reads old cache, then replaces history with a shorter summaryNext turn rebuilds the shorter history cache; use at natural breaks
/config [key=value]Most settings reload live; model, outputStyle, and thinking varyOutput style usually does not apply or invalidate cache immediately; model changes miss
/context [all]Shows context usageRead-only observation; does not change the prefix
/copy [N]Copies a response or code blockLocal operation without a model call
/cost / /stats / /usageShows usage, limits, and activityDoes not change the prompt; useful for checking cache reads/writes
/dataviz [request]Bundled skill for chart and dashboard designAppends instructions without changing the system prompt
/debug [description]Enables debug logs and assists diagnosisLogging itself does not change the prompt; asking Claude to analyze logs adds context
/deep-research <question>Bundled workflow with parallel search and source cross-checkingSubtasks cache separately; the parent receives result summaries
/diffShows the current diffMay read and append git diff to history; large diffs increase future tokens
/doctorDiagnoses configuration and loginMostly local checks; asking Claude to explain results adds context
/exportExports the sessionLocal operation; no cache effect
/fastFirst activation misses because of headers and possible model switchingOfficial notes say v2.1.86+ subsequent toggles/rate-limit fallback no longer repeatedly invalidate the same session cache
/feedbackSubmits feedbackNot a cost optimization tool; usually no main model cache effect
/forkDelegates current context to a background subtaskChild inherits the parent prefix and can more easily read its cache within TTL
/goalSets a sustained completion conditionGoal is session state; automatic follow-up turns append normally and refresh TTL
/hooksShows hook configuration and executionObservation command; effects of edits depend on settings reload and the next trigger
Ask Claude to spawn teammatesAgent Teams starts independent Claude Code instancesEach teammate has its own context/cache; tokens grow roughly with active teammate count
/initGenerates or improves CLAUDE.mdFile writes are not retroactive; the current session usually retains startup-loaded CLAUDE.md
/loopSets repeated checks or scheduled promptsEach trigger is a new request; intervals over 5m can cool 5m cache, while 1h is more resilient
/mcpViews, authenticates, and manages MCP serversConnection changes may alter tool definitions; tool search/deferred tools are more cache-friendly
/memoryEdits memory filesRoot-level CLAUDE.md content usually does not apply immediately; loaded after /clear or restart
/modelChanges the modelFull miss next turn; choose the model before a long task
/permissionsManages allow/ask/denyScoped allow/ask usually preserves tool definitions; denying an entire tool changes the system prompt layer
/planEnters plan modeOrdinary plan mode appends state; with opusplan, entering/leaving plan mode changes the model
/plugin listLists pluginsNo model call
/recapGenerates a display summary without replacing historyCache-friendly but does not free context
/reload-pluginsApplies plugin changesSkills/hooks/agents/themes mostly append; plugin MCP follows MCP tool rules
/rename <name>Names the sessionMetadata only; no prompt cache effect
/resumeResumes historyCan hit with unchanged version/model/effort within TTL; first turn after a long gap costs more
/rewindRewinds conversation and file checkpointsReturns to an old prefix; usually more likely to read old cache than /compact
/scheduleSets one-time or recurring tasksScheduled requests hit according to spacing; intervals over 5m benefit more from 1h TTL
/security-reviewPerforms deeper security reviewMulti-agent/skill work appends substantial context; subtasks cache separately
/setup-bedrock / /setup-vertexProvider setup wizardRestarting or switching provider changes request routing and cache location
/simplify [target]Cleanup-only review with optional fixesSimilar to /code-review; may append diffs and check results
/skillsLists, filters, and toggles skill visibilityListing does not change the prefix; invoking a skill appends a message
/statusShows statusRead-only observation
/statuslineConfigures the status line scriptRefreshes run locally without model calls
/stopStops the current background sessionDoes not affect other sessions' caches
/tasks / /bashesLists background tasksLocal/session management; no model prefix change
/team-onboardingGenerates onboarding docs from recent usageReads local history and appends analysis, potentially substantial
/teleport / /tpBrings a web session into the local terminalContinues web/cloud history locally; cache location and provider can change
/terminal-setupConfigures terminal shortcutsLocal configuration; no model effect
/themeSets terminal themeUI configuration; no model effect
/tui [default|fullscreen]Switches terminal rendererUI renderer only; no prompt effect
/ultraplan <prompt>Performs deep cloud planningCloud session caches independently; local session receives the plan
/ultrareview [PR]Deep cloud review; /code-review ultra is now recommendedCloud agents each cache independently
/usage-creditsConfigures credits beyond plan allowanceUsing credits can reduce Claude subscription TTL from 1h to 5m
/verifyBundled skill to build, run, and observe the appTool output can be long; verification appends like ordinary session work
/voiceVoice inputTranscription requires claude.ai identity; resulting text is an ordinary session message
/web-setupConnects GitHub to Claude Code on the webSetup command; cloud sessions cache independently
/workflowsShows dynamic workflow progressManagement interface; subtasks cache independently
Incoming channel eventsMCP channels append external events to a running sessionClosely 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.

CommandCache effect5m / 1h interpretation
/helpReads current command help, normally preserving the prefixCheck command availability without invalidating 5m/1h cache
/loginAuthentication normally stays outside the main promptProvider, account capabilities, or tools can change after login; observe the next new session
/logoutClears account state, changing later official capabilitiesDoes not directly consume prompt cache, but changes later identity/tool boundaries
/ideManages IDE connection stateNo direct cache change; injected files/diagnostics add context once in history
/desktop, /appHands the session to DesktopSurface, provider, or storage may change; evaluate the new session boundary
/mobile, /qrGenerates a mobile connection entry pointNo main model call; subsequent mobile messages use the connected session's TTL
/remote-envChanges the default environment for future cloud agentsPreserves the current local prefix; future cloud sessions rebuild with the new environment
/install-github-appOAuth/installation, normally outside the main modelGitHub App/Actions/secrets setup leads to independently cached cloud automation
/install-slack-appOAuth/installation, normally outside the main modelSlack-triggered work caches by Slack/cloud session
/design-loginDesign system authorization without direct prompt changesSubsequent /design-sync introduces component data and tool output
/design-sync [hint]Bundled skill and upload tools may produce long flowsFirst sync reads many React components; stable later syncs can reuse matching prefixes
/powerupTutorial content, usually separate from production tasksAvoid inserting tutorials into long production sessions to keep context focused
/fewer-permission-promptsReads history and writes a permission allowlistPermission changes can alter next-turn tool paths; observe the next cost
/focusToggles a UI viewNo prompt cache effect
/scroll-speedConfigures fullscreen scrollingNo prompt cache effect
/keybindingsShows/configures keybindingsNo model cache effect; input behavior may change
/exitExits the UI or detaches from a background sessionPausing interaction does not refresh TTL; compare the return interval with 5m/1h
/runTool flow to start, observe, and drive an appLogs, screenshots, and errors increase future tokens; stable recipes improve reuse
/run-skill-generatorWrites a project run skillSkill changes alter loadable context after /reload-skills or a new session
/sandboxChanges sandbox/permission boundariesTool availability/results may change; observe the first turn under the new boundaries
/release-notesShows release notesNo main cache effect; helps explain first-turn misses after upgrades
/reload-skillsReloads skillsDescription/visibility changes affect later skill calls; reload at natural breaks when needed
/remote-controlPairs claude.ai or the Claude app with a local sessionRemote messages enter the same history; custom gateway credentials may make it unavailable
/reviewRead-only GitHub PR reviewPR data/comments enter cloud or local review; cache follows that session
/insightsAnalyzes usage and frictionMay read history and produce a long report; best after completing the task
/heapdumpLocal diagnostic heap snapshotNo main cache effect unless Claude analyzes the snapshot or logs
/privacy-settingsAccount settings UINo prompt cache effect
/passesAccount allowance entry pointNo current prompt change, but allowance policy affects future models/provider routing
/pr-commentsAccesses PR commentsComments add task context; filter the target first for large PRs
/setup-bedrock, /setup-vertexProvider setup wizardsProvider changes can change cache location and supported beta/tool fields; next turn usually rebuilds
/team-onboardingGenerates docs from recent usage historyOutput may be long; use at task completion, outside a long session being optimized for caching
/upgradeOpens an upgrade entry point or plan pageAccount/plan action itself preserves the prompt; TTL, models, and allowances may change afterward
/stickers, /radioNon-core account/entertainment featuresNot development cache signals
/vimRemovedNo cache involvement; use Editor mode in /config

#Provider and gateway notes

SymptomExplanation
Cache fields remain 0 with Passion8Prefix 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 pickerGateway must support /v1/models; set CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1
Cache misses immediately after connecting MCPIf tool search is unavailable with custom ANTHROPIC_BASE_URL, tool definitions may enter the system prompt prefix
Remote Control unavailableOfficial docs require claude.ai identity and may disable it with gateway credentials or a non-Anthropic Base URL
Expensive first turn after enabling fast modeHeaders 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.