Claude Code Command System Explained: 3 Types, 7 Categories, 50+ Commands

This article provides a comprehensive guide to Claude Code’s command system, covering all slash commands, CLI flags, keyboard shortcuts, hidden features, and practical workflows, showing how to initialize projects, manage context, switch models, control costs, and automate development tasks efficiently.

DeepHub IMBA
DeepHub IMBA
DeepHub IMBA
Claude Code Command System Explained: 3 Types, 7 Categories, 50+ Commands

Three Command Types

Before diving into specific commands, it is useful to distinguish the three command modalities in Claude Code.

CLI commands are executed when launching Claude Code from the terminal:

claude                # Start in current directory
claude -c            # Continue most recent session
claude --print "question"  # One‑shot query, then exit

Slash commands are entered inside an interactive session and are filtered as you type:

/init      # Initialize CLAUDE.md
/compact   # Compress context
/model     # Switch models

Typing / shows all available commands and filters them in real time.

Keyboard shortcuts work directly during a session:

Ctrl+C      # Cancel current generation
Ctrl+R      # Search command history
Shift+Tab   # Cycle modes (normal → auto‑accept → plan)

Part 1: Daily Core Commands (Core 10)

1. /init — Project initialization

Creates a CLAUDE.md file in the project root, which Claude reads as persistent memory for every session. /init The initial CLAUDE.md contains project description, tech stack, code‑style preferences, and common patterns.

According to developer feedback, running /init can eliminate about 80 % of repetitive context setup. For example, instead of explaining "use async/await, not promises" in each session, you write it once in CLAUDE.md and it persists.

# CLAUDE.md
Authentication
- Use JWT tokens, not sessions
- Store in httpOnly cookies

Testing
- Write tests for all API endpoints
- Use Jest, not Mocha

Error Handling
- Return structured errors: { error: string, code: number }

2. /compact — Context compression

When the context window is nearly full, /compact summarizes and discards less‑important dialogue to free space. It is recommended to run it when usage reaches 70‑80 %.

The 2026‑02 release notes state that /compact execution speed has been reduced to near‑instant (previously 3‑5 seconds).

Compressed content retains CLAUDE.md, task list items, key decisions, and patterns, while discarding long back‑and‑forth dialogue and superseded code iterations.

# Basic compression
/compact

# Targeted compression (retain specific context)
/compact retain the error handling patterns and auth module changes

Use /context to check current usage before compressing.

3. /clear — Hard reset

Completely clears conversation history, starting from a clean slate. Useful when switching to a completely different task or after finishing a feature. /clear Note: /clear also removes the command history for the current directory; use /compact instead if you want to keep the history.

4. /model — Switch model

Interactively picks between Sonnet 4.6 (default for Pro/Max 5, good for everyday coding), Opus 4.6 (best for complex multi‑step planning and production code), and Haiku 4.5 (fastest, cheap, suitable for simple edits).

/model                # Interactive picker
/model sonnet         # Switch to Sonnet 4.6
/model opus            # Switch to Opus 4.6
/model haiku           # Switch to Haiku 4.5

Typical strategy: start with Sonnet, switch to Opus when hitting a bottleneck, and use Haiku for quick, cheap tasks.

5. /cost — Token usage and cost

Shows current session token consumption and estimated cost.

/cost
Session cost: $2.47
Input tokens: 48,392
Output tokens: 12,847
Model: claude-sonnet-4-20250514

Active development sessions typically cost between $5 and $50, depending on model and duration. Regularly running /compact, downgrading from Opus to Sonnet, and checking /cost after large interactions helps control expenses.

6. /context — Context window usage

Displays the current context usage as a percentage.

/context
Context usage: 67% (134,400 / 200,000 tokens)

When usage reaches 70‑80 %, proactively run /compact because Claude may start forgetting earlier context, and excess context can degrade performance.

7. /diff — Show recent changes

Displays a git‑style diff of changes Claude made in the current session.

/diff               # Show all changes
/diff src/auth.ts    # Show changes to a specific file

Run after each feature to review what was altered before committing.

8. /help — List commands

Shows all available slash commands. The list updates with each Claude Code version. /help Use claude --version to verify the current version.

Part 2: Advanced Commands

11. /btw — Ask without interrupting context

Insert a side question without breaking the main task. Example:

/btw What is the difference between useEffect and useLayoutEffect?

The process is: cancel current task → ask question → resume original task.

12. /fast — Fast mode

Enables a speed‑optimized API configuration while keeping the same Opus 4.6 model. Suitable for rapid iteration, debugging, and experiments; disable for production‑critical work. /fast # Toggle on/off Activating Fast Mode mid‑session re‑rates all accumulated context according to Fast Mode pricing.

13. /plan — Plan mode (read‑only)

Proposes code changes as a plan; execution occurs only after approval. Switch with Shift+Tab or explicitly with /plan. /plan Claude Code has three modes: Normal (requires confirmation), Auto‑Accept (executes immediately), and Plan (shows plan first). Use Auto‑Accept for tests and scaffolding; use Plan for configuration files, database migrations, or any production‑critical changes.

14. /fork — Experimental branch

Creates a temporary conversation branch for exploring ideas without affecting the main context.

/fork
# Try experimental refactor
# Not good?
# Close branch, return to main

Ideal for high‑risk refactors, multiple architecture options, or quick experiments.

15. /rewind — Undo conversation or code

Rewinds dialogue and/or code changes. After the 2026‑02 enhancement, you can choose to rewind conversation only, code only, or both.

Esc Esc   # Open rewind menu
# Options:
# - Rewind conversation only (keep code)
# - Rewind code only (keep conversation)
# - Rewind both

Useful when an accidental approval needs to be undone.

16. /todos — Persistent task list

Maintains a cross‑session task list (added in v2.1.16, 2026‑01). Tasks survive session closure and are unaffected by context compression.

# Toggle task list
Ctrl+T
# Create task with natural language
"Add authentication feature. Break it down into tasks by dependency"

Set the environment variable CLAUDE_CODE_TASK_LIST_ID to share the same list across multiple Claude Code sessions for team scenarios.

17. /review → /simplify (2026‑03)

Runs three parallel agents to perform code review, covering quality, security, best‑practice violations, performance, and test coverage. /simplify # Replaces deprecated /review Workflow: write feature → /simplify → review feedback → fix → commit.

18. /output-style — Adjust Claude’s output style

Customizes response style (Concise, Educational, Code Reviewer, Rapid Prototyping).

/output-style
# Options:
# - Concise
# - Educational
# - Code Reviewer
# - Rapid Prototyping

An undocumented entry point @agent-output-mode-setup creates the four custom modes under ~/.claude/output-modes/.

19. /permissions — Manage auto‑approval

Configures which operations Claude can auto‑approve versus which require manual confirmation.

/permissions
# Example config:
# Auto‑approve: npm install, git status, file reads
# Require approval: git push, file deletions, npm publish

Use auto‑approval for routine actions and keep critical decisions manual.

20. /agents — Sub‑agent management

Create and manage dedicated sub‑agents for specific tasks.

/agents
# Create sub‑agent
@agent-create test-writer "Writes comprehensive Jest tests"
# Or define via JSON at launch:
claude --agents '{ "test-writer": { "role": "Write comprehensive Jest tests", "model": "claude-sonnet-4" } }'

Sub‑agents keep the main conversation focused while handling specialized work.

Part 3: CLI Flags and Startup Options

21. claude --print — One‑shot query

claude --print "Explain the difference between async/await and promises"
# Useful for scripts and CI pipelines

Executes a single query and exits without entering interactive mode.

22. claude -c / --continue — Resume recent session

cd ~/projects/my-app
claude -c   # Continues latest session in this directory

Can also resume by session ID or from a pull request using claude --from-pr 123.

23. --append-system-prompt vs --system-prompt

# Append (safe)
claude --append-system-prompt "Always use TypeScript strict mode"

# Replace entirely (dangerous)
claude --system-prompt "You are a Python expert"

Appending keeps default Claude Code capabilities; replacing overrides everything and should only be used when full control is required.

24. --dangerously-skip-permissions

# ⚠️ DANGER: Use only in trusted containers
claude --dangerously-skip-permissions

Skips all permission confirmations; intended for trusted CI/CD containers, never on a local machine with production data.

25. --agents — Define sub‑agents at launch

claude --agents '{ "test-writer": { "role": "Write comprehensive Jest tests", "model": "claude-sonnet-4" } }'

Facilitates team workflows and CI/CD scenarios.

26. --output-format json — Structured output

claude --print "List all functions in app.js" --output-format json

Returns results as JSON for programmatic consumption.

Part 4: Keyboard Shortcuts (Efficiency Boosters)

Core shortcuts

Ctrl+C          Cancel current generation
Ctrl+R          Search command history
Tab             Toggle thinking display
Shift+Tab       Cycle modes (normal → auto‑accept → plan)
Esc Esc          Open rewind menu

Navigation & editing

Ctrl+T          Toggle task list
Alt+M           Toggle mode (same as Shift+Tab)
Alt+P           Previous message
Alt+N           Next message
Alt+B           Back in conversation
Alt+F           Forward in conversation

On macOS, configure the Option key as Meta in the terminal (e.g., iTerm2 → Settings → Profiles → Keys → Set Left/Right Option to "Esc+").

Advanced shortcuts

Shift+Enter     Multi‑line input without sending
Ctrl+L          Clear screen (cosmetic)
Ctrl+D          Exit Claude Code

In WSL/Windows Terminal, Shift+Enter may need the /terminal-setup command to bind correctly.

File & command shortcuts

@ + path        File autocomplete
! + command     Direct bash execution (output fed into context)
# + text        Quick memory add

Part 5: Hidden and Undocumented Features

27. /vim — Vim keybindings /vim Enables full Vim editing capabilities (Normal/Insert modes, navigation, text objects, etc.) inside Claude Code prompts.

28. /remote-control — Control from phone /remote-control Allows a mobile Claude.ai web interface to control a local Claude Code session, useful for fixing bugs while away from the workstation.

29. /export — Save session as searchable document /export Exports the conversation for knowledge‑base or documentation purposes.

31. /usage-report — Monthly analysis report /usage-report Generates an HTML report covering total sessions, token consumption, cost breakdown, most used commands, and per‑project usage time.

Part 6: Configuration Files and Customization

File locations

~/.claude/                 # Main config directory
~/.claude/projects/        # Session history
~/.claude/commands/        # Legacy custom slash commands
~/.claude/skills/          # Agent skills (2026 standard)
~/.claude/output-modes/    # Custom output styles
~/.claude/keybindings.json # Keyboard shortcuts

CLAUDE.md — Project memory

Stored at the project root, it holds description, tech stack, rules, and patterns. Example:

# Project: E‑Commerce API

Tech Stack
- Node.js + Express
- PostgreSQL via Prisma
- JWT authentication

Rules
- Use async/await, never callbacks
- Write tests for all endpoints
- Return structured errors: { error, code }

Patterns
- All database queries in /services
- Route handlers in /routes
- Middleware in /middleware

Skills (replaces legacy commands)

Located in ~/.claude/skills/. Skills use front‑matter for auto‑invoke control and follow the Agent Skills Open Standard.

---
name: deploy-staging
description: Deploy current branch to staging
auto_invoke: false
---
# Deploy to Staging
1. Run tests
2. Build production bundle
3. Push to staging server
4. Run smoke tests

Keybinding customization

{
  "toggle_thinking": "Tab",
  "cancel": "Ctrl+C",
  "search_history": "Ctrl+R",
  "toggle_task_list": "Ctrl+T"
}

Changes take effect immediately without restarting Claude Code.

Part 7: Production Workflows

Workflow 1: Feature Development

# Start session
claude
# Initialize context if needed
/init
/memory # Add feature requirements
# Quick memory additions
# Use JWT for auth
# Write tests for all endpoints
# Follow RESTful conventions
# Implement
"Create authentication middleware for Express that validates JWT tokens"
# Review changes
/diff
# Run tests
! npm test
# Check cost
/cost
# Commit
! git add .
! git commit -m "feat: add JWT auth middleware"

Workflow 2: Debugging

# Continue existing session
claude -c
# Show error
"Here's the error I'm getting:"
[paste error]
# Investigate without interrupting main task
/btw "What could cause this error?"
# Apply fix
/diff   # Review changes
! npm test
# If successful, compress context
/compact

Workflow 3: Large‑scale Refactor

# Start in plan mode
claude
Shift+Tab   # Enable plan mode
"Refactor auth module to use bcrypt instead of plain passwords"
# Review plan, approve or adjust
# Monitor context
/context
# Proactively compress at 70%
/compact retain auth patterns and migration strategy
# Switch to auto‑accept for routine changes
Shift+Tab   # Auto‑accept mode
# Final review
/diff
/simplify   # Code review
# Export documentation
/export

Workflow 4: Multi‑Agent Delegation

# Main conversation: architecture design
"Design the database schema for user authentication"
# Create sub‑agent
/agents
@agent-create test-writer "Write comprehensive Jest tests"
# Continue main task
"Now implement the auth middleware"
# Sub‑agent works in parallel
@test-writer "Generate tests for auth middleware"
# Merge results, keep main conversation clean

Key Takeaways

Master the core 10 commands: /init, /compact, /clear, /model, /cost, /context, /diff, /help, /memory, /resume. These alone can boost efficiency 3‑4×.

Use /btw to ask side questions without breaking the main workflow.

Compress context proactively at 70‑80 % usage; waiting until 95 % harms performance.

Configure CLAUDE.md once per project to save 10‑15 minutes per session.

Switch modes wisely: Auto‑Accept for scaffolding/tests, Plan mode for production‑critical files, Normal for everything else.

Monitor costs; Opus sessions can reach $50. Run /cost after major interactions.

Remember four essential shortcuts: Shift+Tab, Ctrl+T, Esc Esc, Ctrl+R.

Leverage sub‑agents to keep the main conversation focused.

Explore hidden features like /vim, /remote-control, /usage-report regularly via /help.

Claude Code offers 50+ commands; most developers use only 3‑5. Expanding your toolbox weekly and exporting key sessions builds a reusable knowledge base.

By treating Claude Code as both a terminal‑based ChatGPT and a programmable coding partner, and by progressively mastering its command system, developers can dramatically accelerate development cycles and maintain high‑quality output.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

CLIautomationproductivityAI coding assistantClaude Code
DeepHub IMBA
Written by

DeepHub IMBA

A must‑follow public account sharing practical AI insights. Follow now. internet + machine learning + big data + architecture = IMBA

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.