Files
claude-code-best-practice/best-practice/claude-commands.md
T
2026-03-07 14:38:08 +05:00

12 KiB

Commands Best Practice

Last Updated
Implemented

Complete reference for Claude Code commands — command definitions, frontmatter fields, and current built-in slash commands.

← Back to Claude Code Best Practice Claude

Frontmatter Fields

Custom commands are defined in .claude/commands/<name>.md with optional YAML frontmatter.

Field Type Required Description
description string Recommended What the command does. Shown in autocomplete and used by Claude for auto-discovery
argument-hint string No Hint shown during autocomplete (e.g., [issue-number], [filename])
allowed-tools string No Tools allowed without permission prompts when this command is active
model string No Model to use when this command runs (e.g., haiku, sonnet, opus)

String Substitutions

Available inside command markdown for dynamic values:

Variable Description
$ARGUMENTS All arguments passed when invoking the command
$ARGUMENTS[N] Access a specific argument by 0-based index
$N Shorthand for $ARGUMENTS[N] (e.g., $0, $1)
${CLAUDE_SESSION_ID} Current session identifier
!`command` Dynamic context injection — shell command output replaces the placeholder before Claude sees it

Invocation

Custom commands are invoked by typing /command-name in Claude Code's interactive mode:

Method Description
/command-name Invoke directly from the command menu
/command-name [args] Pass arguments that map to $ARGUMENTS
Autocomplete Type / to see all available commands with descriptions
Subdirectories Commands in subdirectories use /subdir:command-name

Example: Minimal Command

---
description: Fetch weather data for Dubai and create an SVG weather card
model: haiku
---

Fetch the current temperature for Dubai, UAE and create a visual SVG weather card.
---
description: Fix a GitHub issue by number, following team coding standards
argument-hint: [issue-number]
allowed-tools: Read, Edit, Write, Bash(gh *), Bash(npm test *)
model: sonnet
---

Fix GitHub issue $0 following our coding standards.

## Context
- PR diff: !`gh pr diff`
- Issue details: !`gh issue view $0`

## Steps
1. Read the issue description
2. Understand the requirements
3. Implement the fix
4. Write tests
5. Create a commit

Session: ${CLAUDE_SESSION_ID}

Scope and Priority

When multiple commands share the same name, the higher-priority location wins:

Location Scope Priority
Project (.claude/commands/) This project only 1 (highest)
Personal (~/.claude/commands/) All your projects 2
Plugin (<plugin>/commands/) Where plugin is enabled 3 (lowest)

Claude Commands

All Commands

Built-in slash commands available in Claude Code's interactive mode:

Command Tag Description
/add-dir Project Add additional working directories to the current session
/agents Extensions Manage custom subagents — view, create, edit, delete
/bug [description] Debug Alias for /feedback
/chrome Extensions Manage Claude in Chrome browser integration
/clear Session Clear conversation history and start fresh
/compact [prompt] Session Compress conversation to free context window. Optional prompt focuses the compaction
/config Config Open the interactive settings interface with search
/context Context Visualize current context usage as a colored grid with token counts
/copy Export Copy the last assistant response to the clipboard
/cost Context Show token usage statistics for the current session
/desktop Remote Connect to or manage the desktop companion app
/diff Project Review the current git diff in the active repo
/doctor Debug Check the health of your Claude Code installation
/exit Session Exit the REPL
/export [filename] Export Export the current conversation to a file or clipboard
/extra-usage Context Configure pay-as-you-go overflow billing for subscription plans
/fast Model Toggle fast mode — same Opus 4.6 model with faster output
/feedback [description] Debug Generate a GitHub issue URL for reporting bugs or feedback
/fork Session Fork the current conversation into a new session
/help Debug Show slash-command help
/ide Extensions Connect to IDE integration
/init [prompt] Project Initialize a new project with a CLAUDE.md guide
/install-github-app Remote Install the GitHub app for PR-linked workflows
/install-slack-app Remote Install the Slack app for notifications and sharing
/keybindings Config Customize keyboard shortcuts per context and create chord sequences
/login Auth Authenticate with Claude Code via OAuth
/logout Auth Log out from Claude Code
/mcp Extensions Manage MCP server connections
/memory Memory View and edit memory files
/mobile Remote Connect to or manage the mobile companion app
/model Model Switch models (haiku, sonnet, opus) and adjust effort level
/output-style Config Pick an output style preset
/passes [number] Model Set the number of review passes for certain workflows
/permissions Config View or update tool permissions
/plan Model Enter read-only planning mode — suggests approaches without making changes
/pr-comments Project Review or reply to pull-request comments
/privacy-settings Config Manage privacy and telemetry preferences
/release-notes Debug Show recent Claude Code release notes
/reload-plugins Extensions Reload installed plugins without restarting
/remote-control Remote Continue the current session from another device
/remote-env Remote Inspect or copy the remote-control environment setup
/rename <name> Session Rename the current session for easier identification
/resume [session] Session Resume a previous conversation by ID or name, or open the session picker
/review Project Review the current code changes
/rewind Session Rewind conversation and/or code to an earlier point
/sandbox Config Configure sandboxing with dependency status
/security-review Project Run a focused security review on current changes
/status Context Show a concise session status summary
/stats Context Visualize daily usage, session history, streaks, and model preferences
/statusline Config Set up Claude Code's status line UI
/stickers Config Choose sticker packs shown in the UI
/tasks Debug List and manage background tasks
/terminal-setup Config Enable shift+enter for newlines in IDE terminals
/theme Config Change the color theme
/usage Context Show plan usage limits and rate limit status (subscription plans only)
/vim Config Enable vim-style editing mode

Bundled skills such as /debug can also appear in the slash-command menu, but they are not built-in commands.

Commands in This Repository

Custom commands defined in .claude/commands/ for this project:

Command Description Model
weather-orchestrator Fetch weather data for Dubai and create an SVG weather card haiku
workflows/best-practice/workflow-claude-settings Track Claude Code settings report changes and find what needs updating
workflows/best-practice/workflow-claude-subagents Track Claude Code subagents report changes and find what needs updating
workflows/best-practice/workflow-concepts Update the README CONCEPTS section with the latest Claude Code features and concepts

Sources