Unlock the full power of Claude Code CLI with expert tips, hidden features, and productivity hacks.
think, ultrathink, etc.) are now deprecated.
See #19098 for details.
Extended thinking allows Claude to reason through complex problems with up to 31,999 tokens of internal reasoning. Previously triggered by magic words, it's now automatic.
| Method | Status | Notes |
|---|---|---|
| think | Deprecated | No longer triggers extended thinking |
| ultrathink | Deprecated | No longer triggers extended thinking |
| Automatic | Active | Thinking enabled by default in v2.0.x+ |
| MAX_THINKING_TOKENS | Supported | Environment variable to control budget |
think keywordthink hard / megathinkultrathinkCLAUDE.md is a special markdown file that Claude Code reads automatically to understand your project context, coding standards, and preferences.
| Location | Scope | Priority |
|---|---|---|
| ~/.claude/CLAUDE.md | Global (all projects) | Lowest |
| .claude/CLAUDE.md | Project-specific | Highest |
| CLAUDE.md | Project root | Medium |
Slash commands provide quick access to common actions and settings. Type / to see all available commands.
| Command | Description |
|---|---|
| /compact | Compress conversation context to save tokens |
| /cost | Show token usage and estimated cost |
| /clear | Clear conversation history |
| /init | Generate CLAUDE.md for your project |
| /doctor | Diagnose configuration issues |
| /config | Open configuration settings |
| /help | Show help and available commands |
| /review | Review code changes or PR |
| /bug | Report a bug to Anthropic |
/compact regularly in long sessions to reduce token usage and keep responses fast. It summarizes the conversation while preserving important context.
Master these keyboard shortcuts to navigate Claude Code like a pro.
| Shortcut | Action |
|---|---|
| Esc | Interrupt current generation |
| Ctrl + C | Cancel operation / Exit |
| Ctrl + D | Exit Claude Code |
| Ctrl + L | Clear terminal screen |
| โ / โ | Navigate command history |
| Tab | Autocomplete file paths |
| Shift + Enter | Multi-line input |
Claude Code supports different models optimized for different use cases. Choose based on your needs for speed, cost, or capability.
| Model | Best For | Speed | Cost |
|---|---|---|---|
| Haiku | Quick tasks, simple edits | โกโกโก Fastest | ๐ฐ Lowest |
| Sonnet | Balanced (default) | โกโก Fast | ๐ฐ๐ฐ Medium |
| Opus | Complex reasoning, architecture | โก Slower | ๐ฐ๐ฐ๐ฐ Highest |
Hooks let you run custom scripts automatically when Claude Code performs certain actions. Perfect for linting, testing, or custom workflows.
| Hook | Trigger |
|---|---|
| PreToolUse | Before a tool executes |
| PostToolUse | After a tool completes |
| Notification | When Claude wants your attention |
| Stop | When Claude finishes a response |
Sub-agents allow Claude to delegate complex tasks to specialized agents that run in isolated contexts. They enable parallelization, better context management, and domain-specific expertise.
| Benefit | Description |
|---|---|
| Parallelization | Run multiple tasks simultaneously |
| Context Isolation | Each agent has its own context window |
| Specialization | Fine-tuned instructions for specific domains |
| Tool Control | Different tool access per agent type |
| Agent | Use Case |
|---|---|
| general-purpose | Default agent for any task |
| Explore | Fast codebase exploration |
| Plan | Architecture and implementation planning |
Task Tools allow Claude to create and manage visible task lists in the terminal. Track progress, show dependencies, and display real-time status with animated spinners.
| Tool | Description |
|---|---|
| TaskCreate | Create a new task with subject, description, activeForm |
| TaskUpdate | Update status (pending โ in_progress โ completed) |
| TaskList | List all tasks with their current status |
| TaskGet | Get details of a specific task |
| Parameter | Usage |
|---|---|
| blockedBy | Task IDs that must complete first |
| addBlockedBy | Add dependencies to existing task |
Model Context Protocol (MCP) servers allow Claude Code to interact with external tools, databases, and APIs. Connect to GitHub, databases, or custom services.
| Server | Capabilities |
|---|---|
| GitHub | Issues, PRs, repos, actions |
| PostgreSQL | Query databases directly |
| Filesystem | Extended file operations |
| Slack | Send messages, read channels |
| Puppeteer | Browser automation |
github.com/modelcontextprotocol/servers
Serena is an MCP server that provides semantic code understanding through LSP integration. It enables symbol-level navigation, intelligent editing, and persistent project memories.
| Feature | Description |
|---|---|
| Symbolic Tools | find_symbol, replace_symbol_body, rename_symbol |
| Memories | Persistent context stored in .serena/memories/ |
| References | Find all usages of a symbol across codebase |
| Multi-language | TypeScript, Python, Swift, Go, and more |
.serena/memories/ survive between sessions. Use them for project context, current work status, and team conventions.
Run Claude Code in headless mode for scripting, CI/CD pipelines, and automation. No interactive prompts needed.
Claude Code integrates seamlessly with Git for intelligent commits, PR reviews, and version control workflows.
| Feature | How to Use |
|---|---|
| Smart Commits | Ask Claude to commit with a meaningful message |
| PR Review | /review or ask to review changes |
| Diff Analysis | Paste diff or ask about changes |
| Conflict Resolution | Ask Claude to resolve merge conflicts |
Keep track of your token usage and costs, and learn how to optimize for efficiency.
| Strategy | Impact |
|---|---|
| /compact regularly | Reduces context size by 50-80% |
| Use Haiku for simple tasks | 10x cheaper than Opus |
| Clear with /clear | Start fresh, no accumulated tokens |
| Be specific in prompts | Fewer back-and-forth exchanges |
Claude Code works in your terminal, but also integrates with popular IDEs for an enhanced experience.
| IDE | Integration |
|---|---|
| VS Code | Terminal panel, integrated commands |
| JetBrains | IntelliJ, WebStorm, PyCharm terminal |
| Vim / Neovim | Terminal mode, buffer integration |
| Zed | Native terminal support |
Ctrl+` and run claude:term claude to open in splitConfigure Claude Code to match your workflow and diagnose issues with the built-in doctor command.
| File | Purpose |
|---|---|
| ~/.claude/settings.json | Global settings (model, hooks, MCP) |
| .claude/settings.json | Project-specific settings |
| CLAUDE.md | Project instructions |
| Variable | Purpose |
|---|---|
| ANTHROPIC_API_KEY | Your API key |
| CLAUDE_MODEL | Default model |
| MAX_THINKING_TOKENS | Override thinking budget |
Claude Code has a 200K token context window (500K for Enterprise, 1M beta). Learn to manage it effectively for optimal performance on long-running tasks.
| Strategy | When to Use |
|---|---|
| /compact | When context exceeds 50% - summarizes while preserving key info |
| /context | Check current context usage mid-session |
| Sub-agents | Isolate complex tasks to separate context windows |
| @ Mentions | Load files on-demand instead of all at once |
Claude Code uses a hierarchical memory system through CLAUDE.md files to remember preferences, project context, and instructions across sessions.
| Level | Location | Scope |
|---|---|---|
| Enterprise | Organization policy | IT rules, compliance |
| Project | .claude/CLAUDE.md | Team instructions |
| Project Rules | .claude/rules/ | Modular rule files |
| User | ~/.claude/CLAUDE.md | Personal preferences |
docs/ folder, reference with @ when needed/init to bootstrap a CLAUDE.md for your projectUse @ mentions to reference files, folders, or URLs directly in your prompts. Claude will automatically read and understand the content.
| Syntax | What it does |
|---|---|
| @file.ts | Reference a specific file |
| @src/ | Reference an entire folder |
| @https://... | Fetch and reference a URL |
| @git:branch | Reference a git branch diff |
Tab for autocomplete when typing file paths. Claude will suggest matching files and folders.
Claude Code asks for permission before making changes. You can configure trust levels and auto-accept behaviors.
| Action | Default Behavior |
|---|---|
| Read files | Always allowed |
| Write/Edit files | Asks permission |
| Run commands | Asks permission |
| Delete files | Always asks |
--dangerously-skip-permissions. Only use in trusted environments or for automated scripts.
Claude Code saves your conversation history. You can resume previous sessions to continue where you left off.
| Command | Description |
|---|---|
| /resume | Show list of recent sessions |
| claude --resume | Resume most recent session |
| claude -c | Continue last conversation |
/compact before resuming long sessionsClaude can see and analyze images! This is incredibly useful for debugging UI issues, understanding designs, or extracting information from screenshots.
| Format | Use Case |
|---|---|
| PNG | Screenshots, UI mockups |
| JPG/JPEG | Photos, designs |
| GIF | Simple graphics |
| WebP | Modern web images |
| Documents with images |
Love Vim? Claude Code has optional Vim keybindings for the input field. Navigate, edit, and write prompts using familiar Vim motions.
| Command | Action |
|---|---|
| i | Insert mode |
| Esc | Normal mode |
| h/j/k/l | Navigation |
| w/b | Word navigation |
| dd | Delete line |
| yy/p | Yank/Paste |
Create custom slash commands to automate repetitive prompts. Define templates that expand when you type them.
| Variable | Expands To |
|---|---|
| $FILE | Current file path |
| $SELECTION | Selected text (if any) |
| $PROJECT | Project root path |
Skills are more powerful than custom commands. They can include multi-step instructions,
trigger specific behaviors, and create complete workflows invoked with a simple /skill-name.
| Aspect | Custom Commands | Custom Skills |
|---|---|---|
| Location | settings.json |
skills.json |
| Complexity | Simple text expansion | Multi-step workflows |
| Description | Not shown | Shown in help |
| Best For | Quick shortcuts | Complex processes |
~/.claude/skills.json, restart Claude Code for changes to take effect.
Plan Mode lets Claude explore the codebase and design an implementation approach before writing code. Perfect for complex tasks where you want to review the strategy first.
| Tool | Description |
|---|---|
| EnterPlanMode | Start planning (read-only, no edits) |
| ExitPlanMode | Request approval and start implementing |
| Phase | Actions |
|---|---|
| 1. Explore | Launch Explore agents to understand codebase |
| 2. Design | Launch Plan agents for implementation strategy |
| 3. Review | Read critical files, clarify questions |
| 4. Write Plan | Document approach in plan file |
| 5. Approve | User approves, Claude implements |
EnterPlanMode tool. Claude can also proactively enter plan mode for complex tasks.
Claude Code excels at multi-file operations, using agentic search to understand your entire codebase without manual context selection. Perfect for refactors, feature implementation, and cross-cutting changes.
| Feature | Description |
|---|---|
| Agentic Search | Automatically finds relevant files without manual selection |
| Cross-file Refactors | Rename symbols, update imports across the codebase |
| Parallel Instances | Run multiple Claude instances on different parts of codebase |
| Deep Understanding | Follows dependencies, understands architecture |
Follow these tips to get the best results from Claude Code and maximize your productivity.
| Instead of... | Try... |
|---|---|
| "Fix the bug" | "Fix the null pointer error in @auth.ts line 42" |
| "Make it faster" | "Optimize the database query in @users.ts to use indexing" |
| "Add tests" | "Add unit tests for the login function covering edge cases" |
Combine Tasks, Agents, Plan Mode, and Background operations to create powerful development workflows.
| Step | Description | Tools Used |
|---|---|---|
| 1 | Create GitHub Issue | gh CLI |
| 2 | Plan implementation | Plan Mode, Explore agents |
| 3 | Implement changes | Edit tools, git |
| 4 | Open Pull Request | gh CLI |
| 5 | Test (user action) | TaskUpdate (wait) |
| 6 | Merge PR | gh CLI |
| 7 | Wait for CI | Background task |
| 8 | Release | Build scripts, gh CLI |
| Combination | Use Case |
|---|---|
| Tasks + blockedBy | Sequential workflow with dependencies |
| Parallel Agents | Explore multiple codepaths simultaneously |
| Background + Tasks | Long builds without blocking conversation |
| Plan Mode + Tasks | Get approval before executing workflow |
| Memories + Workflow | Persist workflow patterns between sessions |
Common issues and how to fix them. Run /doctor first to diagnose most problems.
| Error | Solution |
|---|---|
| Rate limit exceeded | Wait a few minutes, or use /compact to reduce tokens |
| API key invalid | Check ANTHROPIC_API_KEY env variable |
| Context too long | Use /compact or /clear to reduce context |
| File not found | Check file path and use Tab for autocomplete |
| Permission denied | Check file permissions or run with sudo |
| MCP connection failed | Check MCP server config and restart Claude |
/bug to report issues to Anthropic, or check GitHub Issues for known problems.
Claude can run tasks in the background while you continue working. Great for long builds, tests, or complex operations.
| Command | Description |
|---|---|
| /tasks | List all running background tasks |
| Notification hook | Get notified when tasks complete |