Now in early access, book a 30-minute demo →
← Back to blog Guide

Claude Code Commands Cheat Sheet (2026): CLI, Slash Commands, Flags, and Hooks

TL;DR
  • This Claude Code commands cheat sheet covers the 2026 surface: CLI commands and flags, every built-in slash command, permission modes, hook events, and the managed settings that override all of them.
  • Permission modes are the single most important thing to know: --permission-mode accepts default, manual, acceptEdits, plan, auto, dontAsk, and bypassPermissions, and the choice decides whether a human sees the tool call at all.
  • auto mode hands the approval decision to a permission classifier instead of a prompt. A PreToolUse hook returning ask still floors the decision at a prompt, which is why the hook, not the prompt, is where enforcement belongs.
  • Hooks are the enforcement point. PreToolUse returns allow, deny, ask, or defer before a tool runs, and exit code 2 blocks. Thirty-one hook events exist as of 2026.
  • Managed settings win over everything, including command-line flags - and allowManagedPermissionRulesOnly, allowManagedHooksOnly, and allowManagedMcpServersOnly stop a developer from loosening policy locally.
  • The flags worth alerting on: --dangerously-skip-permissions, --permission-mode bypassPermissions, --tools, --settings, --plugin-url, and --bare.

This is a working reference for the Claude Code commands surface as it stands in 2026, written for the person who has to govern it as well as use it. Every table below is the command list plus the thing a security-minded reader actually wants to know: what it changes, and whether it can quietly widen what the agent is allowed to do.

If you want the reasoning rather than the reference, the companion pieces are how Claude Code permissions actually work, the permissions and hooks hardening guide, and what shipped in 2026 and why it matters. The Codex equivalent of this page is the OpenAI Codex commands cheat sheet.

Starting and resuming sessions

CommandWhat it does
claudeStart an interactive session
claude "query"Start interactive with an initial prompt
claude -p "query"Print mode: run headless, then exit
cat file \| claude -p "query"Pipe content in and process it
claude -cContinue the most recent conversation in this directory
claude -r "<session>" "query"Resume a session by ID or name
claude --fork-sessionOn resume, create a new session ID instead of reusing the original
claude --bg "query"Start as a background agent and return immediately
claude --teleportPull a web session down into this terminal
claude --cloud "query"Create or target a web session on claude.ai

Session, agent, and daemon management

CommandWhat it does
claude agentsOpen the agent view for parallel background sessions
claude attach <id>Attach to a background session in this terminal
claude logs <id>Print recent output from a background session
claude stop <id> / claude kill <id>Stop a background session
claude respawn <id>Restart a background session with the conversation intact
claude rm <id>Remove a background session from the list
claude daemon statusPrint the background-session supervisor's state
claude daemon stop --anyStop the supervisor and hosted sessions
claude project purge [path]Delete all local Claude Code state for a project

Auth, setup, and diagnostics

CommandWhat it doesSecurity note
claude auth login / logout / statusManage the Anthropic account sessionstatus returns JSON - useful for fleet checks
claude setup-tokenGenerate a long-lived OAuth token for CI and scriptsA long-lived credential; treat it as a secret to inventory
claude doctorPrint installation and settings diagnosticsFastest way to see what config is actually live
claude update / claude install [version]Update or reinstall the binaryVersion pins matter: isolation semantics are version-dependent
claude import [codex\|gemini]Import configuration from another coding agentPulls another tool's config in; run with --dry-run first
claude remote-controlStart the Remote Control serverLets another device approve prompts for this session
claude self-hosted-runnerTurn this host into an execution environment for web, mobile, and desktop sessions (Team/Enterprise)A long-lived host accepting work initiated elsewhere
claude mcp / claude pluginManage MCP servers and pluginsBoth add artifacts you want inventoried

Permission modes: the flag that matters most

--permission-mode decides whether a human ever sees the tool call. This is the first thing to check on any endpoint, and the first thing to pin in managed settings.

ModeBehaviorGovernance posture
default / manualPrompt for approval on tool use; "Manual" is the 2026 display name with a grey badge in the footerThe safe floor for attended work
planPlan first, no edits or commands until you acceptGood default for exploring an unfamiliar repo
acceptEditsFile edits auto-accept; commands still promptReasonable for attended refactors
autoA permission classifier adjudicates instead of prompting youThe approval decision moved from a person to a model
dontAskSuppress prompts without full bypassVerify what it still blocks before allowing it
bypassPermissionsSkip permission prompts entirelyTreat as a break-glass mode; alert on it

--dangerously-skip-permissions is the equivalent of --permission-mode bypassPermissions. A separate flag, --allow-dangerously-skip-permissions, adds bypassPermissions to the Shift+Tab mode cycle without starting in it - worth knowing, because it means a session that started safely can be cycled into bypass by hand. We walk the real behavior in what dangerously-skip-permissions actually does.

Flags that change the trust boundary

FlagWhat it doesWhy it matters
--allowedTools / --disallowedToolsAllow or deny rules for tools, e.g. "Bash(git log *)"Per-session policy that a managed rule should be able to override
--toolsRestrict which built-in tools Claude can useA tightening flag - useful in CI
--add-dirAdd working directories Claude can read and editWidens the filesystem blast radius
--settingsLoad a settings JSON file or inline JSONCan carry sandbox and credential-masking config
--setting-sourcesChoose which scopes to load (user, project, local)Can drop project policy from the session
--mcp-config / --strict-mcp-configLoad MCP servers from files; ignore all others--strict-mcp-config is a hardening flag, not a risk
--plugin-dir / --plugin-urlLoad a plugin from a directory or a URL for this sessionSideloads a bundle with no marketplace review
--bareSkip auto-discovery of hooks, skills, plugins, MCP, and CLAUDE.mdAlso skips your hooks - so it skips your enforcement
--safe-modeStart with all customizations disabledTroubleshooting; same caveat as --bare
--system-prompt / --append-system-promptReplace or extend the system promptChanges agent behavior outside any policy file
--max-budget-usdStop after a dollar amount of API spendAlso halts running background subagents
--effortSet effort: low, medium, high, xhigh, max, ultracodeHigher effort means more autonomous work per turn

The sideload flags deserve a specific note. --plugin-url fetches a plugin archive from a URL for the session, and a plugin can bundle skills, subagents, hooks, and MCP server definitions in one unit. Admins can shut this class off with disableSideloadFlags in managed settings.

Slash commands: session control

CommandWhat it does
/helpShow help and available commands
/clear, /new, /resetStart a new conversation with empty context
/compact [instructions]Summarize the conversation to free context
/context [all]Visualize current context usage as a grid
/autocompact [auto\|<tokens>]Set the auto-compact window
/resume [session-id\|name]Return to an earlier conversation
/rewind [message-count\|from-turn]Roll code and conversation back to a checkpoint
/fork [prompt]Copy the conversation into a new background session
/branch [name]Create a branch of the current conversation
/background [prompt]Detach the session to run as a background agent
/subtask [prompt]Hand a side task to a subagent
/tasksList the session's background work
/statusShow current session status
/usage, /costShow token and cost metrics
/export [filename]Export the conversation as plain text
/diffOpen an interactive diff viewer for uncommitted changes
/exit, /quitExit the CLI

Slash commands: configuration and security

CommandWhat it doesSecurity relevance
/permissionsSet approval rules for file access and tool useThe in-session view of allow/deny/ask rules
/hooksView hook configurations for tool eventsConfirm your PreToolUse hook is actually registered
/config, /settingsOpen settings or set a preference directlyShows what is live, including managed overrides
/doctorRun a setup checkup that diagnoses and fixes issuesSurfaces config drift
/mcpManage MCP servers, connections, and OAuthEach server is an artifact and an egress path
/pluginsManage pluginsOne plugin expands into many artifacts
/skillsManage custom skillsSkills can auto-load without a prompt
/agentsManage subagent configurationsEach subagent is another autonomous actor
/list-agentsList subagents and sessions Claude can messageThe cross-session messaging surface
/memoryEdit CLAUDE.md memory files and auto-memoryInstructions that persist across sessions
/model, /effort, /fastSwitch model, effort level, fast modeCapability changes under a policy set earlier
/remote-control [connect\|disconnect]Continue a local session from another deviceApprovals can be answered off-machine
/security-reviewCheck the diff for security vulnerabilitiesScan-time, not runtime - see the distinction below
/login, /logoutSign in or out of the Anthropic accountforceLoginOrgUUID can pin the org

/security-review and /code-review are genuinely useful and they operate on the diff, before code runs. They do not see what the agent does at runtime on the endpoint. That gap is the subject of scan-time versus runtime governance.

Bundled skills and workflows

Some slash commands are not built into the CLI - they are bundled skills or workflows, which means they load instructions into the turn and can fan work out across subagents. Custom commands and skills have converged: a file at .claude/commands/deploy.md and a skill at .claude/skills/deploy/SKILL.md both create /deploy.

CommandTypeWhat it does
/code-review [level] [--fix] [--comment] [target]SkillReview the diff, a PR, a branch, or a path
/reviewAliasAlias for /code-review
/security-reviewSkillCheck the diff for security vulnerabilities
/verifySkillVerify code correctness without applying changes
/simplify [--fix]SkillSuggest simplifications to recent code
/test <path>SkillWrite, run, and debug tests
/debug [description]SkillEnable debug logging and troubleshoot
/batch <instruction>SkillOrchestrate large-scale changes in parallel
/loop [interval] [prompt]SkillRun a prompt repeatedly while the session stays open
/deep-research <question>WorkflowFan out web searches and synthesize a cited report
/fewer-permission-promptsSkillScan transcripts and propose an allowlist
/doctorSkillSetup checkup that diagnoses and fixes issues

/fewer-permission-prompts is worth flagging for a governance reader. It does exactly what it says - it reduces friction by proposing allowlist entries - which is convenient for the developer and is, by definition, a policy-loosening operation. It belongs behind managed permission rules, not left to per-developer judgment.

Hook events: where enforcement actually lives

There are 31 hook events in 2026. How Claude Code hooks work explains the lifecycle and matcher syntax behind them. These are the ones that matter most for control, and the exit-code semantics that make them work.

EventWhen it firesCan block?
PreToolUseBefore a tool call executesYes - blocks the call
PermissionRequestWhen a tool call needs a permission decisionYes - denies it
PermissionDeniedWhen the auto mode classifier denies a callNo - use JSON retry: true
UserPromptSubmitWhen you submit a prompt, before Claude sees itYes - blocks and erases the prompt
SessionStart / SessionEndSession begins or resumes / terminatesNo
SubagentStart / SubagentStopA subagent is spawned / finishesStop can block
PostToolUse / PostToolUseFailureAfter a tool call succeeds / failsNo - it already ran
PostToolBatchAfter a batch of parallel calls resolvesYes - stops the agentic loop
ConfigChangeA configuration file changes mid-sessionYes (except policy_settings)
InstructionsLoadedA CLAUDE.md or .claude/rules/*.md loads into contextNo
WorktreeCreate / WorktreeRemoveA worktree is created / removedAny non-zero exit fails creation
TeammateIdleAn agent team teammate is about to go idleYes

Exit code semantics are simple and worth memorizing. Exit 0: success, and stdout is parsed for JSON output. Exit 2: blocking error - stdout is ignored, stderr is fed back to Claude as the reason. Any other code: non-blocking error; the action proceeds and a hook-error notice appears.

A PreToolUse hook returns its decision as JSON. The four values are allow, deny, ask, and defer, and updatedInput can rewrite the tool arguments before execution.

{
  "hookSpecificOutput": {
    "hookEventName": "PreToolUse",
    "permissionDecision": "deny",
    "permissionDecisionReason": "Outbound push to non-allowlisted remote blocked by policy"
  }
}

The critical 2026 detail: auto mode can no longer override a hook's ask decision. A hook returning ask floors the decision at a prompt. That is precisely why enforcement belongs at the hook rather than at the permission prompt - the hook is the one control the classifier cannot talk its way past.

Settings precedence and managed policy

Precedence runs highest to lowest: managed, then command-line arguments, then local, then project, then user. Managed policy beating command-line flags is the whole reason managed settings are the enterprise control point.

PlatformManaged settings path
macOS/Library/Application Support/ClaudeCode/managed-settings.json (plus managed-settings.d/*.json, and the com.anthropic.claudecode managed preferences domain)
Linux and WSL/etc/claude-code/managed-settings.json (plus managed-settings.d/*.json)
WindowsC:\Program Files\ClaudeCode\managed-settings.json, plus HKLM\SOFTWARE\Policies\ClaudeCode via Group Policy or Intune

The legacy Windows path C:\ProgramData\ClaudeCode\managed-settings.json stopped being supported in v2.1.75. If your MDM baseline predates that, the policy you think is deployed may not be loading at all - which is exactly the kind of silent gap worth verifying per endpoint rather than assuming.

Managed-only settings worth knowing

SettingEffect
allowManagedPermissionRulesOnlyUser and project settings cannot define permission rules
allowManagedHooksOnlyOnly managed and SDK hooks load
allowManagedMcpServersOnlyOnly managed MCP servers connect
allowedMcpServers / deniedMcpServersExplicit MCP allow and deny lists
disableSideloadFlagsBlocks --plugin-dir and --plugin-url style sideloading
strictKnownMarketplaces / blockedMarketplacesMarketplace allow/block, including "owner/*" org wildcards
requiredMinimumVersion / requiredMaximumVersionPin the acceptable Claude Code version range
forceLoginOrgUUIDRestrict login to a specific organization
sandbox.credentials / sandbox.filesystemCredential masking and filesystem isolation
crossSessionInbound / dialogExpiryControl inbound cross-session messages

What to alert on

If you are building detections rather than reading this as a user, these are the signals that change what the agent is allowed to do:

  • --dangerously-skip-permissions or --permission-mode bypassPermissions on any endpoint, and --allow-dangerously-skip-permissions, which makes bypass reachable via Shift+Tab.
  • --bare or --safe-mode, which skip hook and plugin discovery - meaning they skip your enforcement along with everything else.
  • --plugin-url or --plugin-dir, sideloading a bundle that never passed a marketplace check.
  • --setting-sources dropping project, which discards repo-committed policy.
  • setup-token generating a long-lived OAuth credential for CI.
  • A Claude Code version outside your pinned range, since isolation and sandbox semantics changed repeatedly through 2026.
  • Managed settings absent entirely, which is the quiet failure: an unenrolled laptop has none of the controls above.

Where Anomity fits

Everything on this page is a per-endpoint fact. The flags are typed on one laptop, the hooks live next to the settings that register them, and the managed policy only applies where it was received. Anomity's lightweight, unprivileged Endpoint Sensor runs on Windows, macOS, and Linux and inventories eight AI artifact types - AI agents, MCP servers, extensions, plugins, skills, secrets, hooks, and CLIs - so "which permission mode, which version, which plugins, which hooks" becomes a query instead of a survey (fleet inventory).

At the PreToolUse hook, Anomity returns allow, deny, or log on each tool call before it runs, which turns an in-session approval or an auto-mode classifier decision into enforced org-wide policy (runtime governance). The Sensor sends metadata only over HTTPS, never source or prompts, with secrets redacted on the endpoint. Every decision lands in a queryable 90-day audit trail routed to your SIEM, Slack, email, or Jira (audit and outcomes). Anomity is SOC 2 Type II and complements your EDR, XDR, DLP, network, and GRC controls.

You can't govern what you can't see.

Bookmark this page as the command reference; the governance argument behind it is in deploying Claude Code across a fleet and auditing Claude Code across a fleet. If you want these facts inventoried across every endpoint instead of checked by hand, book a 30-minute demo.

Frequently asked questions

What are the Claude Code permission modes?

The --permission-mode flag accepts default, manual, acceptEdits, plan, auto, dontAsk, and bypassPermissions. Default and manual prompt for approval on tool use; plan holds off on edits and commands until you accept; acceptEdits auto-accepts file edits while commands still prompt; auto hands the decision to a permission classifier instead of prompting; dontAsk suppresses prompts without full bypass; and bypassPermissions skips prompts entirely. The mode is the single most important fact to know about any Claude Code endpoint.

How do I block a tool call in Claude Code?

Use a PreToolUse hook. It fires before a tool call executes and returns a JSON decision of allow, deny, ask, or defer in hookSpecificOutput, with permissionDecisionReason shown to Claude. Exiting the hook with code 2 also blocks, and stderr is fed back as the reason. As of 2026 auto mode cannot override a hook's ask decision, so a hook returning ask forces a prompt. That is why the hook, not the permission prompt, is the reliable place to enforce policy.

Which Claude Code flags should security teams alert on?

--dangerously-skip-permissions and --permission-mode bypassPermissions skip prompts entirely, and --allow-dangerously-skip-permissions makes bypass reachable through the Shift+Tab mode cycle. --bare and --safe-mode skip auto-discovery of hooks, skills, plugins, and MCP servers, which means they skip your enforcement too. --plugin-url and --plugin-dir sideload plugin bundles without a marketplace check. --setting-sources can drop project-scoped policy from the session. Admins can disable the sideload class with disableSideloadFlags in managed settings.

Where does Claude Code load managed settings from?

On macOS, /Library/Application Support/ClaudeCode/managed-settings.json plus managed-settings.d/*.json and the com.anthropic.claudecode managed preferences domain. On Linux and WSL, /etc/claude-code/managed-settings.json plus managed-settings.d/*.json. On Windows, C:\Program Files\ClaudeCode\managed-settings.json plus HKLM\SOFTWARE\Policies\ClaudeCode via Group Policy or Intune. The legacy Windows path C:\ProgramData\ClaudeCode\managed-settings.json stopped being supported in v2.1.75, so an older MDM baseline may be deploying policy that never loads.

What is the Claude Code settings precedence order?

Highest to lowest: managed settings, then command-line arguments, then local settings, then project settings, then user settings. Managed policy beating command-line flags is what makes it the enterprise control point, since a developer cannot loosen it with a flag. Managed-only settings extend this further: allowManagedPermissionRulesOnly stops user and project scopes from defining permission rules, allowManagedHooksOnly restricts hook loading, and allowManagedMcpServersOnly restricts which MCP servers may connect.

Are Claude Code slash commands the same as skills?

Custom commands and skills have converged. A file at .claude/commands/deploy.md and a skill at .claude/skills/deploy/SKILL.md both create /deploy and work the same way. Some built-in slash commands are coded into the CLI, while others such as /code-review, /security-review, /verify, /test, and /batch are bundled skills, and /deep-research is a workflow that fans work across subagents. The security consequence is that a slash command can load instructions into the turn, and a skill can auto-load when Claude judges it relevant rather than only when you type its name.

Does /security-review cover runtime risk?

No, and the distinction matters. /security-review and /code-review operate on the diff, before code runs, which makes them scan-time controls. They do not see what the agent does at runtime on the endpoint: which commands it executes, which MCP servers it reaches, or which files it touches outside the diff. Runtime governance happens at the PreToolUse hook, where a decision is returned before the tool call executes, and in the audit trail that records what was actually allowed.

Ask AI about Anomity
ChatGPT Claude Perplexity Google AI Grok