๐ŸŒŸClaude Code Complete Guide

From beginner conversations to advanced command mastery

Build anything with AI - websites, apps, games, and more using simple English conversations

๐Ÿš€Your Journey Starts Here

What is Claude Code?

Imagine having a super-smart coding assistant that lives in your computer's terminal. You just talk to Claude in plain English, and it builds websites, apps, games, and digital projects for you!

Real Example:

"Claude, help me build a website for my photography business"

โ†“

Claude creates a complete professional website with gallery, contact form, and booking system!

๐Ÿ› ๏ธQuick Setup (5 minutes)

1

Install Claude Code

npm install -g @anthropic-ai/claude-code

Don't have npm? Download Node.js from nodejs.org first - it's like getting the toolkit that helps install Claude Code.

2

Test Installation

claude --version

See a version number? Perfect! You're ready to go.

3

Start Your First Chat

claude

This opens a conversation with Claude. Try saying: "Hi! I'm new to this. What can you help me build?"

๐ŸŒBuild Your First Website (15 minutes)

Complete Tutorial

Follow this exact conversation to build a real website:

You: claude
โ†’ Opens chat with Claude
You: Hi! I want to create a personal website. I'm a [your job/hobby] and want something simple and beautiful. Can you help?
โ†’ Claude asks about your preferences
You: Answer Claude's questions about colors, content, style
โ†’ Claude builds your complete website!

Result: A professional website you built just by chatting!

๐Ÿ’กThe Only 5 Commands You Need

Command What It Does When to Use
claude Start chatting with Claude Beginning any project or asking for help
claude -p "question" Quick question, fast answer Need quick help without long conversation
claude -c Continue yesterday's work Picking up where you left off
/help Show all available options When stuck or need to see what's possible
/clear Start fresh conversation When chat gets confusing or switching topics

๐ŸŽฏProject Ideas

  • Personal portfolio website
  • Business website with contact form
  • Photo gallery for vacation pics
  • Recipe collection website
  • Simple calculator or to-do app
  • Interactive quiz about your hobby

๐Ÿ’ฌHow to Talk to Claude

  • Be specific: "Make the text bigger and blue" not "make it better"
  • Ask questions: "What colors would look good for a bakery website?"
  • Request explanations: "Can you explain what this code does?"
  • Don't worry about mistakes! Claude is very patient

โšกComplete Command Reference

Master All Commands

From basic conversations to advanced automation - every command explained with examples.

๐Ÿ”คBasic Commands

Command Description Example
claude Start interactive REPL session claude
claude "prompt" Start with initial message claude "build me a website"
claude -p "query" Print mode - quick answer and exit claude -p "explain CSS flexbox"
claude -c Continue most recent conversation claude -c
claude -r "session-id" Resume specific session by ID claude -r "abc123"
claude update Update Claude Code to latest version claude update
claude --version Show version information claude --version
claude --help Show help and all available options claude --help

๐Ÿ›ก๏ธSecurity & Permission Flags

Flag Description Example
--dangerously-skip-permissions โš ๏ธ Skip all permission prompts (use carefully!) claude --dangerously-skip-permissions
--allowedTools Pre-approve specific tools without prompting claude --allowedTools "Read" "Write" "Bash(git:*)"
--disallowedTools Block specific tools completely claude --disallowedTools "Edit" "Write"
--permission-mode Start with specific permission mode claude --permission-mode plan
--add-dir Add additional working directories claude --add-dir ../frontend ../backend

โš ๏ธSecurity Warning

--dangerously-skip-permissions bypasses all safety prompts. Only use in trusted environments or CI/CD pipelines where human oversight isn't practical. For daily use, prefer --allowedTools to pre-approve specific safe operations.

โš™๏ธConfiguration & Output Flags

Flag Description Example
--verbose Enable detailed logging for debugging claude --verbose
--output-format Specify output format: text, json, stream-json claude -p "help" --output-format json
--input-format Specify input format: text, stream-json claude -p --input-format stream-json
--max-turns Limit conversation length in non-interactive mode claude -p "build app" --max-turns 5
--model Choose AI model: sonnet, opus, or full model name claude --model opus
--permission-prompt-tool Use MCP tool for permission prompts claude --permission-prompt-tool auth_tool

๐Ÿ’ฌInteractive Slash Commands

๐Ÿ†˜Help & Navigation

  • /help - Show all available commands
  • /status - View account and system status
  • /cost - Show token usage statistics
  • /doctor - Check installation health

๐Ÿ”„Session Management

  • /clear - Clear conversation history
  • /compact [instructions] - Compact conversation
  • /model - Switch AI model
  • /login - Switch Anthropic accounts
  • /logout - Sign out from account

๐Ÿ“Project & Memory

  • /init - Initialize project with CLAUDE.md
  • /memory - Edit CLAUDE.md memory files
  • /add-dir - Add working directories
  • /permissions - View/update permissions

๐Ÿ”งDevelopment Tools

  • /review - Request code review
  • /pr_comments - View pull request comments
  • /vim - Enter vim editing mode
  • /terminal-setup - Configure terminal for Claude
  • /bug - Report bugs to Anthropic

๐Ÿ”ŒIntegrations

  • /mcp - Manage MCP server connections
  • /config - View/modify configuration

๐Ÿ“Piping & File Operations

# Send file content to Claude cat file.js | claude -p "explain this code" # Send git diff for review git diff | claude -p "review these changes" # Send error logs for debugging tail error.log | claude -p "help debug this error" # Send multiple files cat *.js | claude -p "analyze all JavaScript files" # Send command output ls -la | claude -p "explain this directory structure"

๐Ÿค–Advanced Command Combinations

# Comprehensive project analysis with security restrictions claude --model opus --max-turns 10 --allowedTools "Read" "Bash(git:*)" \ --add-dir ./src --add-dir ./docs \ -p "analyze this project architecture" # Automated code review in CI/CD claude --dangerously-skip-permissions --output-format json \ --max-turns 3 -p "review code changes" < git_diff.txt # Multi-directory development assistance claude --add-dir ../frontend --add-dir ../backend --add-dir ../shared \ --allowedTools "Read" "Write" "Bash(npm:*)" \ "help me refactor the authentication system" # Debug session with full logging claude --verbose --model sonnet --max-turns 5 \ -c "continue debugging the payment integration"

๐Ÿ”งAdvanced Features & Techniques

Power User Territory

These features unlock Claude Code's full potential for complex development workflows, automation, and team integration.

๐Ÿง Memory System Deep Dive

๐ŸŒGlobal Memory

Location: ~/.claude/CLAUDE.md

Personal preferences, coding standards, and patterns used across all projects.

# Access global memory /memory # Example global memory content: - Prefer React with TypeScript - Use Tailwind CSS for styling - Always include error handling - Prefer functional components

๐Ÿ“‚Project Memory

Location: ./CLAUDE.md

Team conventions, project architecture, and shared context.

# Initialize project memory /init # Example project memory: - Uses Next.js 13 with app router - Database: PostgreSQL with Prisma - API endpoints in /api/v1/ - Testing with Jest and RTL

๐Ÿ”’Local Memory

Location: ./CLAUDE.local.md

Personal project notes, sensitive info (not committed to git).

# Local memory (gitignored) - Database URL: localhost:5432 - Personal TODO items - Debug configurations - Local environment specifics

๐Ÿ”’Advanced Permission Management

โš™๏ธProject-Level Permissions (.claude/settings.json) โ–ผ
{ "allowedTools": [ "Read", "Write", "Edit", "Bash(git *)", "Bash(npm *)", "Bash(yarn *)" ], "disallowedTools": [ "Bash(rm *)", "Bash(sudo *)" ], "defaultModel": "claude-sonnet-4", "maxTurns": 20, "autoSkipPermissions": false }

Team Usage: Commit this file to ensure consistent permissions across team members.

๐Ÿ‘คUser-Level Permissions (~/.claude/.claude.json) โ–ผ
{ "personalSettings": { "alwaysAllowedTools": ["Read", "Bash(git status)", "Bash(git diff)"], "neverAllowedTools": ["Bash(rm -rf *)", "Bash(sudo *)"], "preferredModel": "claude-opus-4", "autoCompactAt": 50 }, "mcpServers": { "puppeteer": { "command": "npx", "args": ["@puppeteer/mcp-server"] } } }

Personal Override: These settings override project settings for security.

๐ŸŽฏCustom Slash Commands

1

Create Project Command

# Create .claude/commands/deploy.md mkdir -p .claude/commands cat > .claude/commands/deploy.md << 'EOF' --- allowed-tools: Bash(git add:*), Bash(git commit:*), Bash(git push:*) description: Deploy to production with safety checks --- ## Pre-deployment checks - Current git status: !`git status` - Recent commits: !`git log --oneline -5` - Current branch: !`git branch --show-current` ## Your task 1. Review all changes above 2. If on main branch, create deployment commit 3. Run pre-deployment tests 4. Deploy to production with proper tags Use argument $ARGUMENTS for deployment message if provided. EOF

Usage: /deploy "version 2.1.0"

2

Create Personal Command

# Create ~/.claude/commands/security-audit.md mkdir -p ~/.claude/commands cat > ~/.claude/commands/security-audit.md << 'EOF' --- description: Comprehensive security audit of codebase allowed-tools: Read, Bash(find:*), Bash(grep:*) --- ## Security Audit for $ARGUMENTS Perform comprehensive security analysis focusing on: 1. Authentication and authorization 2. Input validation and sanitization 3. SQL injection prevention 4. XSS protection 5. CSRF tokens 6. Dependency vulnerabilities Scan these areas: - @./src/auth/ - @./src/api/ - @./package.json - @./package-lock.json EOF

Usage: /security-audit "payment system"

๐Ÿ”ŒMCP (Model Context Protocol) Integration

What is MCP?

MCP extends Claude Code with external tools and services - browser automation, databases, APIs, file systems, and more.

๐ŸŒPopular MCP Servers โ–ผ
# Browser automation with Puppeteer claude mcp add puppeteer npx @puppeteer/mcp-server # SQLite database access claude mcp add sqlite npx @modelcontextprotocol/server-sqlite --args ./database.db # File system operations claude mcp add filesystem npx @modelcontextprotocol/server-filesystem --args /path/to/directory # Web search capabilities claude mcp add search npx @modelcontextprotocol/server-search # GitHub integration claude mcp add github npx @modelcontextprotocol/server-github --args YOUR_TOKEN # PostgreSQL database claude mcp add postgres npx @modelcontextprotocol/server-postgres --args postgresql://user:pass@localhost/db
โš™๏ธMCP Server Configuration โ–ผ
# Manual MCP configuration in ~/.claude/.claude.json { "mcpServers": { "browser": { "command": "npx", "args": ["@puppeteer/mcp-server"], "env": { "PUPPETEER_HEADLESS": "true" } }, "database": { "command": "npx", "args": ["@modelcontextprotocol/server-postgres"], "env": { "POSTGRES_CONNECTION_STRING": "postgresql://localhost/myapp" } }, "custom-api": { "command": "node", "args": ["./mcp-servers/custom-server.js"], "env": { "API_KEY": "${API_KEY}" } } } }

Usage: MCP commands become available as /mcp__server__command

๐Ÿš€Automation & CI/CD Integration

โš™๏ธGitHub Actions Example โ–ผ
name: AI Code Review on: [pull_request] jobs: ai-review: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: '18' - name: Install Claude Code run: npm install -g @anthropic-ai/claude-code - name: AI Code Review env: ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} run: | git diff origin/main...HEAD > changes.diff claude --dangerously-skip-permissions --output-format json \ --max-turns 3 -p "Review these changes for security issues, bugs, and best practices" \ < changes.diff > review.json - name: Post Review Comment uses: actions/github-script@v6 with: script: | const review = require('./review.json'); github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, body: `## AI Code Review\n\n${review.content}` });
๐Ÿ“œAutomated Refactoring Script โ–ผ
#!/bin/bash # automated-refactor.sh - Batch refactor legacy code echo "๐Ÿ”„ Starting automated refactoring..." # Start Claude session for refactoring SESSION_ID=$(claude --output-format json -p "Starting legacy code refactoring session" | jq -r '.session_id') # Process each legacy file for file in src/legacy/*.js; do echo "Processing $file..." claude --resume "$SESSION_ID" --max-turns 2 --output-format json \ --allowedTools "Read" "Write" "Edit" \ "Refactor this legacy file to modern ES6+: $(cat $file)" \ > "refactor-$(basename $file .js).json" # Wait between files to avoid rate limits sleep 2 done # Generate summary report claude --resume "$SESSION_ID" --output-format json \ "Generate a summary report of all refactoring changes made" \ > refactoring-summary.json echo "โœ… Refactoring complete! Check refactoring-summary.json for details."

๐Ÿ”Performance & Debugging

๐Ÿ“ŠToken Usage Monitoring

# Check current session costs /cost # Monitor costs in automation claude -p "simple query" --output-format json | jq '.usage' # Set up cost alerts in scripts if [[ $(claude /cost | grep -o '[0-9]*' | head -1) -gt 10000 ]]; then echo "Warning: High token usage!" fi

๐Ÿ›Debug Mode

# Full verbose logging claude --verbose -p "debug this error: $(cat error.log)" # MCP debugging claude --mcp-debug -p "test mcp integration" # Session state inspection claude -c "/status" --verbose

๐ŸขTeam & Enterprise Features

Team Collaboration Setup

1. Shared Configuration: Commit .claude/settings.json with team permissions

2. Memory Management: Use project CLAUDE.md for shared context, local CLAUDE.local.md for personal notes

3. Custom Commands: Share team-specific slash commands in .claude/commands/

4. Security Policies: Enforce permission boundaries with disallowedTools

๐Ÿ’กPro Tips for Advanced Users

  • Session Management: Use meaningful session IDs for parallel development workflows
  • Context Optimization: Use /compact strategically to maintain focus while reducing token usage
  • Security First: Always prefer --allowedTools over --dangerously-skip-permissions
  • Automation Best Practices: Set --max-turns in scripts to prevent infinite loops
  • MCP Integration: Create custom MCP servers for organization-specific tools and APIs

๐Ÿ“…Daily Development Workflows

Real Developer Workflows

Practical, copy-paste workflows for common development tasks. These are battle-tested patterns used by developers daily.

๐ŸŒ…Morning Startup Routine

# 1. Check what you were working on claude -c "/status" # 2. Review yesterday's changes git log --oneline --since="yesterday" | claude -p "summarize what I worked on yesterday" # 3. Plan today's work claude -c "What should I focus on today? Here's my current project status: $(git status)" # 4. Update memory with any new insights claude -c "/memory"

๐Ÿ’ปFeature Development Workflow

๐Ÿš€New Feature Implementation โ–ผ
# 1. Start feature development session claude --add-dir ./src --add-dir ./tests \ --allowedTools "Read" "Write" "Edit" "Bash(git:*)" \ "I need to implement user authentication. Let's plan this feature." # 2. Generate component structure /review @./src/components/ # 3. Implement with tests claude -c "Create the login component with TypeScript and comprehensive tests" # 4. Code review before commit git diff --cached | claude -p "review these changes for bugs and improvements" # 5. Generate commit message git diff --cached | claude -p "generate a concise commit message for these changes"
๐Ÿ›Bug Investigation & Fixing โ–ผ
# 1. Analyze error logs tail -n 50 app.log | claude -p "help me debug this error" # 2. Investigate code around the bug claude --add-dir ./src \ "I'm getting this error: [paste error]. Help me find and fix the root cause." # 3. Create minimal reproduction claude -c "create a minimal test case that reproduces this bug" # 4. Fix with proper testing claude -c "fix the bug and add tests to prevent regression" # 5. Verify fix across codebase claude -p "search for similar patterns that might have the same bug" @./src/

๐Ÿ”„Code Review & Refactoring

๐Ÿ‘€Pre-Commit Review

# Review staged changes git diff --cached | claude -p "review for bugs, security issues, and style" # Check for TODO/FIXME comments git diff --cached | claude -p "find any TODO or FIXME comments and prioritize them" # Verify test coverage claude -p "do these changes need additional tests?" @./src/new-feature.js

โ™ป๏ธLegacy Code Refactoring

# Analyze legacy code claude --add-dir ./src/legacy \ "analyze this legacy code and suggest modern refactoring approach" # Gradual refactoring claude -c "refactor one function at a time, maintaining backward compatibility" # Update dependencies npm outdated | claude -p "which of these packages should I update and in what order?"

๐ŸšขDeployment & Release Workflow

# 1. Pre-deployment checklist claude -p "create a deployment checklist for this project" @./package.json @./README.md # 2. Generate changelog git log --oneline $(git describe --tags --abbrev=0)..HEAD | \ claude -p "generate changelog from these commits" # 3. Security scan before deploy claude --allowedTools "Read" "Bash(find:*)" \ "scan this project for common security vulnerabilities before deployment" # 4. Performance optimization check claude -p "analyze bundle size and suggest optimizations" @./webpack.config.js # 5. Deploy with monitoring claude -c "/deploy production" # Using custom slash command

๐ŸงชTesting & Quality Assurance

๐ŸŽฏComprehensive Testing Strategy โ–ผ
# 1. Generate unit tests claude --add-dir ./src --add-dir ./tests \ "create comprehensive unit tests for the authentication module" # 2. Integration test planning claude -c "plan integration tests for the API endpoints" @./src/api/ # 3. E2E test scenarios claude -c "create user journey tests for the main application flows" # 4. Test data generation claude -p "generate realistic test data for user accounts and transactions" # 5. Performance testing claude -c "create load tests for the authentication endpoints using appropriate tools"

๐Ÿ“šDocumentation Workflow

# 1. Auto-generate API docs claude --add-dir ./src/api \ "generate comprehensive API documentation from these endpoint files" # 2. Update README claude -p "update README with current project structure and setup instructions" @./ # 3. Code comments and JSDoc claude -c "add proper JSDoc comments to all public functions" @./src/utils/ # 4. Architecture documentation claude -c "create architecture diagrams and explanations for this system"

๐Ÿ”งMaintenance & Monitoring

๐ŸฅHealth Checks

# Weekly codebase health check claude --add-dir ./src \ "analyze code quality, identify technical debt, and suggest improvements" # Dependency audit npm audit | claude -p "prioritize these security vulnerabilities by severity" # Performance monitoring claude -p "set up monitoring alerts for this application" @./

๐Ÿ”„Automated Maintenance

# Automated dependency updates claude -p "create a safe dependency update strategy" @./package.json # Code formatting and linting claude -c "set up automated code formatting and linting for this project" # Backup and recovery planning claude -p "create backup and disaster recovery procedures"

๐Ÿ‘ฅTeam Collaboration Workflows

๐ŸคPull Request & Code Review โ–ผ
# 1. Create PR with AI assistance git diff origin/main | claude -p "generate PR title and description for these changes" # 2. Self-review before submitting claude --add-dir ./src \ "review my changes as if you're a senior developer" @./src/new-feature.js # 3. Address review comments claude -c "help me address these PR review comments: [paste comments]" # 4. Merge conflict resolution git status | claude -p "help me resolve these merge conflicts safely" # 5. Post-merge cleanup claude -c "suggest any cleanup tasks after merging this feature branch"
๐Ÿ“‹Sprint Planning & Task Management โ–ผ
# 1. Break down epic into tasks claude -p "break down this feature epic into development tasks: [epic description]" # 2. Estimate development effort claude --add-dir ./src \ "estimate development time for implementing user notifications system" # 3. Identify dependencies and risks claude -c "identify technical dependencies and risks for this sprint" # 4. Daily standup preparation claude -c "summarize my progress: $(git log --oneline --since='1 day ago')" # 5. Sprint retrospective analysis claude -p "analyze our sprint performance and suggest improvements" @./sprint-data.json

๐ŸšจEmergency Response Workflows

๐Ÿ”ฅProduction Incident Response

# 1. Rapid log analysis tail -n 100 production.log | claude --max-turns 3 -p "urgent: analyze this error" # 2. Quick hotfix development claude --dangerously-skip-permissions --max-turns 5 \ "emergency hotfix needed for: [describe issue]" # 3. Rollback decision support claude -p "should I rollback or hotfix? Here's the situation: [describe]" # 4. Incident communication claude -p "draft incident status update for stakeholders: [incident details]" # 5. Post-incident analysis claude -c "create post-mortem analysis and prevention strategies"

๐ŸŽฏProductivity Optimization

โšกSpeed Up Common Tasks

# Create aliases for frequent commands alias claude-review="git diff | claude -p 'quick code review'" alias claude-commit="git diff --cached | claude -p 'generate commit message'" alias claude-explain="claude -p 'explain this error'" # Quick project analysis alias project-health="claude --add-dir ./src -p 'project health check'" # Instant documentation alias quick-docs="claude -c 'update documentation for recent changes'"

๐Ÿง Context Management

# Save important context echo "Key decisions and rationale" >> CLAUDE.local.md # Switch context efficiently /clear # Clear when switching between unrelated tasks /compact "focus on authentication work" # Compact for related tasks # Maintain project knowledge /memory # Regular memory updates with new patterns and decisions

๐Ÿ’กWorkflow Optimization Tips

  • Session Strategy: Use -c for related work, start fresh with claude for new topics
  • Batch Operations: Process multiple files with piping: find . -name "*.js" -exec cat {} \; | claude -p "analyze"
  • Template Commands: Create custom slash commands for repeated workflows
  • Permission Presets: Set up project-specific .claude/settings.json to avoid repeated prompts
  • Output Formatting: Use --output-format json for scriptable workflows

๐Ÿ“ŠAnalytics & Reporting

๐Ÿ“ˆDevelopment Metrics & Insights โ–ผ
# 1. Code quality trends git log --stat --since="1 month ago" | \ claude -p "analyze development trends and code quality over the past month" # 2. Team productivity analysis git shortlog --since="1 week ago" --numbered --summary | \ claude -p "analyze team productivity and contribution patterns" # 3. Technical debt assessment claude --add-dir ./src \ "identify and quantify technical debt across the codebase" # 4. Security posture review claude --allowedTools "Read" "Bash(find:*)" \ "comprehensive security assessment of current codebase" # 5. Performance benchmarking claude -p "create performance benchmarking strategy" @./package.json
โ†‘ ?