JP
JP Codes
Change theme
AI Tools

Claude Code — Commands & Guide

A complete reference for Claude Code, Anthropic's AI-powered CLI tool. From basic installation and navigation through to advanced automation, MCP integration, and enterprise workflows.

James Platt

James Platt

November 10, 2025 · 8 min read

8 min read
Claude Code Guide

Claude Code is Anthropic's official AI-powered CLI tool — a terminal-based coding assistant that can understand your project, write and edit code, run commands, and iterate based on your feedback. Here's a complete command reference to help you get productive quickly.

Quick Start

# Install Claude Code (requires Node.js)
npm install -g @anthropic-ai/claude-code

# On Windows, first open WSL
wsl

# Launch the interactive REPL
claude

# Start with an initial prompt
claude "summarise this project"

# Check installed version
claude --version

# Update to the latest version
claude update

Level 1: Basic Commands

REPL Navigation

/help          # Show help and available commands
/exit          # Exit the REPL
/clear         # Clear conversation history
/config        # Open configuration panel
/doctor        # Check Claude Code installation health

File Operations

# Print mode — execute a query and exit
claude -p "explain this function"

# Process piped content
cat logs.txt | claude -p "explain"

# Continue the most recent conversation
claude -c

# Continue with a follow-up prompt
claude -c -p "Check for type errors"

Session Management

# Resume a session by ID
claude -r "abc123" "Finish this PR"

# Continue current session
claude --continue

# Show cost and duration of current session
/cos

Keyboard Shortcuts

Shortcut Action
Ctrl+CCancel current operation
Ctrl+DExit Claude Code
TabAuto-complete
Up/DownNavigate command history

Level 2: Model & Output Configuration

# Switch models
claude --model sonnet
claude --model opus
claude --model claude-sonnet-4-20250514

# Output formats
claude -p "query" --output-format json
claude -p "query" --output-format text
claude -p "query" --output-format stream-json

# Limit conversation turns
claude -p --max-turns 3 "query"

# Enable verbose logging
claude --verbose

# Add additional working directories
claude --add-dir ../apps ../lib

Level 3: Tool & Permission Management

# Allow specific tools without prompting
claude --allowedTools "Bash(git log:*)" "Bash(git diff:*)" "Write"

# Disallow specific tools
claude --disallowedTools "Bash(rm:*)" "Bash(sudo:*)"

# Skip all permission prompts (use with caution)
claude --dangerously-skip-permissions

Level 4: Advanced Piping & Automation

# Git integration
git log --oneline | claude -p "summarise these commits"
git diff HEAD~1 | claude -p "review this PR for security issues"

# Log analysis
cat error.log | claude -p "find the root cause"

# JSON output for scripting
SESSION=$(claude -p "start analysis" --output-format json | jq -r '.session_id')
claude -r "$SESSION" "continue analysis"

Level 5: Custom Slash Commands

Create markdown files in .claude/commands/ to define your own slash commands. These become available in any Claude Code session within that project.

# Example: .claude/commands/review.md
# This creates a /review slash command

Perform a thorough code review of the current changes.
Check for: security issues, performance problems, and code style.
Suggest specific improvements with code examples.

Slash Commands Reference

Command Description
/helpShow help and available commands
/exitExit the REPL
/clearReset conversation history and context
/configOpen configuration panel
/doctorCheck installation health
/cosShow cost and duration of session
/compact [instructions]Summarise conversation to reduce context
/ideManage IDE integrations (VS Code etc.)
/mcpAccess Model Context Protocol functionality

Best Practices

Performance

Security

Workflow

Tags

James Platt

James Platt

Web Developer

James is a Microsoft-qualified C# .NET developer with extensive experience building robust, data-rich web applications. He writes about web development, software architecture, and best practices at JP Codes.

Read more about James

More articles