Claude Code: CLI Reference Manual
Last updated: 2026-08-31
This is Claude Code's command quick-reference — every command, parameter, and slash command for daily use.
💡 Tip: No need to memorize everything. Daily use only requires
claude, claude "instruction", and a few common slash commands; the rest can be looked up.
📋 Prerequisites: Chapter 18 - Hooks System
1. What You'll Learn
- Complete CLI launch parameter list
- Slash command quick reference
- Control and mode switching
- Configuration options
- Common command combinations
2. CLI Launch Parameters
(1) Basic Usage
BASH
claude # Interactive mode
claude "your instruction" # With instruction
echo "instruction" | claude # Pipeline mode
claude -p "quick query" # Print mode
(2) Complete Parameter List
| Parameter | Description | Example |
|---|---|---|
-p, --print |
Non-interactive mode | claude -p "query" |
--model |
Specify model | --model claude-opus-4-20250514 |
--resume |
Resume last session | claude --resume |
--headless |
No UI mode | claude --headless "task" |
--output |
Output format | --output json |
--style |
Output style | --style concise |
--allowed-tools |
Limit tools | --allowed-tools Read,Write |
--allow-full-auto |
Full auto mode | --allow-full-auto |
--mcp-config |
MCP config file | --mcp-config ./mcp.json |
--no-hooks |
Disable hooks | --no-hooks |
--sandbox |
Sandbox mode | --sandbox |
--version |
Show version | claude --version |
--help |
Show help | claude --help |
3. Slash Commands
(1) Session Control
| Command | Description |
|---|---|
/help |
Show help |
/clear |
Clear conversation history |
/compact |
Compress conversation history |
/cost |
View Token usage and cost |
/exit |
Exit Claude Code |
(2) File and Project
| Command | Description |
|---|---|
/init |
Initialize project, generate CLAUDE.md |
/files |
View loaded files |
/diff |
View current session file changes |
/search <pattern> |
Search pattern in project |
(3) Configuration and Tools
| Command | Description |
|---|---|
/model <name> |
Switch model |
/style <name> |
Switch output style |
/mcp |
View MCP server status |
/hooks |
View hook configuration |
/skills |
List available Skills |
/skill <name> |
Execute specified Skill |
/config |
View current configuration |
(4) Git Integration
| Command | Description |
|---|---|
/commit |
Commit current changes |
/undo |
Undo last operation |
▶ Example 1: Slash Command Usage
TEXT
📖 Display only
> /cost
Token usage: 45,230 / 200,000 (22.6%)
Session cost: $0.91
> /files
Loaded: src/index.ts, src/routes/user.ts, src/services/user.service.ts
> /model claude-opus-4-20250514
Model switched to claude-opus-4-20250514
> /diff
Modified: src/routes/user.ts (+12 -3), src/services/user.service.ts (+28 -0)
4. Control and Modes
(1) Interactive Controls
| Operation | Key | Description |
|---|---|---|
| Send instruction | Enter | Send current input |
| New line | Shift+Enter | Multi-line input |
| Interrupt | Ctrl+C | Stop current operation |
| Exit | Ctrl+D | Exit Claude Code |
| History | ↑/↓ | Browse history |
(2) Permission Confirmation Options
| Option | Description |
|---|---|
y |
Yes (this time) |
n |
No |
a |
Always (this session) |
e |
Edit before applying |
5. Configuration File Locations
| File | Location | Purpose |
|---|---|---|
~/.claude/CLAUDE.md |
Global | Personal preferences |
~/.claude/settings.json |
Global | Global settings |
~/.claude/hooks.json |
Global | Global hooks |
~/.claude/mcp_settings.json |
Global | MCP config |
project/CLAUDE.md |
Project | Project conventions |
project/.claude/hooks.json |
Project | Project hooks |
project/.claudeignore |
Project | Exclude files |
Environment Variables
| Variable | Description | Example |
|---|---|---|
ANTHROPIC_API_KEY |
API key | sk-ant-api03-xxx |
ANTHROPIC_BASE_URL |
API URL | https://api.deepseek.com |
CLAUDE_MODEL |
Default model | claude-sonnet-4-20250514 |
CLAUDE_STYLE |
Default style | concise |
6. Quick Reference: Common Commands
BASH
# Daily development
claude # Interactive mode
claude "Fix login bug" # With instruction
claude --resume # Resume session
# Automation
claude -p "Review code" --output json # Pipeline + JSON
claude --headless "Run tests, fix bugs" # CI mode
# Control
claude --allowed-tools Read,Write # Limit tools
claude --style concise # Concise output
claude --model claude-opus-4-20250514 # Switch model
# In-session
/cost # View cost
/clear # Clear history
/diff # View changes
/commit # Commit code
❓ FAQ
Q How to check Claude Code version?
A
claude --version.Q Difference between -p and pipeline mode?
A
-p is print mode shorthand, outputs directly without interaction. Pipeline mode passes input via stdin, also non-interactive.Q How to reset all configuration?
A Delete
~/.claude/ directory, restart Claude Code. Restores defaults.Q
/compact vs /clear?A
/compact preserves context but reduces Tokens; /clear starts completely fresh.Q How to list all historical sessions?
A
claude --list-sessions.📖 Summary
- Core launch params:
--model,--resume,--headless,--output - Common slash commands:
/cost,/clear,/diff,/commit - Ctrl+C interrupt, Ctrl+D exit
- Config files: global (
~/.claude/) and project (.claude/) - Environment variables control API, model, style
📝 Exercises
- Basic (⭐): Use
claude --helpto view all parameters, try 3 new ones. - Intermediate (⭐⭐): Use 5 different slash commands in a session, record effects.
- Advanced (⭐⭐⭐): Write a Shell script using
claude -p --output jsonfor automated code review pipeline.