The Complete Guide to Claude Code — Tips, Tricks & Advanced Workflows

The Complete Guide to Claude Code — Tips, Tricks & Advanced Workflows

Everything you need to master Claude Code — from setup to advanced multi-agent workflows, MCP servers, hooks, memory systems, and the daily workflow of a power user.

Anshuman Biswas Anshuman Biswas
11 min read
Table of Contents

    Why Claude Code Changes Everything

    I've been using Claude Code daily since it launched, and it's fundamentally changed how I build software. Not incrementally — fundamentally. The difference between using Claude Code and not using it is like the difference between having a senior engineer pair-programming with you 24/7 versus working alone.

    This guide captures everything I've learned — the tips that actually matter, the workflows that save hours, and the features most people don't know about.


    Getting Started in 60 Seconds

    # Install
    npm install -g @anthropic-ai/claude-code
    
    # Navigate to your project
    cd ~/my-project
    
    # Start Claude Code
    claude
    

    That's it. Claude Code reads your codebase, understands your project structure, and you can start asking it to do things. No configuration files. No API keys to set up (it uses your Anthropic account). No plugins to install.

    First thing to try: Just describe what you want in plain English.

    > Fix the bug where users can't login after changing their password
    

    Claude Code will:

    1. Search your codebase for authentication-related code

    2. Find the bug

    3. Show you the fix

    4. Apply it (with your permission)


    The CLAUDE.md File — Your Project's Brain

    The single most important file in your project is CLAUDE.md. This is where you tell Claude Code about your project's conventions, architecture, and rules.

    # CLAUDE.md
    
    ## Project: My SaaS App
    - Stack: Go + PostgreSQL + React + TypeScript
    - Always use prepared statements for SQL
    - Use Zap logger, never fmt.Println for logging
    - Test commands: `make test` (backend), `npm test` (frontend)
    - Deploy: `./script/deploy staging`
    
    
    ## Code Style
    - Go: table-driven tests, error wrapping with context
    - React: functional components, TypeScript strict mode
    - No `any` types in TypeScript
    
    
    ## Architecture
    - /api/internal/api/ — HTTP handlers
    - /api/internal/db/ — Database layer
    - /web/src/routes/ — Page components
    
    

    Pro tip: You don't need to write this from scratch. Just tell Claude Code:

    > Create a CLAUDE.md for this project based on the codebase
    

    It will analyze your project and generate one automatically.

    Where CLAUDE.md Files Live

    Location Scope Example Use
    ./CLAUDE.md This project only Project conventions, deploy commands
    ~/.claude/CLAUDE.md All your projects Your personal preferences
    ~/.claude/projects/{path}/CLAUDE.md Per-project persistent Notes Claude remembers between sessions

    Slash Commands — The Power User's Toolkit

    These are the commands I use dozens of times a day:

    Command What It Does When to Use
    /init Creates CLAUDE.md from your codebase First time in a new project
    /compact Compresses conversation context When Claude starts forgetting earlier context
    /clear Starts fresh conversation When you're switching to a completely different task
    /cost Shows token usage and cost To keep track of spending
    /review Reviews code changes (like a PR review) Before committing
    /memory Shows what Claude remembers about you To check persistent knowledge

    The /compact Trick

    Long conversations eat context. When you notice Claude forgetting things you said earlier, run /compact. It summarizes the conversation and frees up space without losing important context.

    When to compact vs. clear:

    • /compact — You're still working on the same task but the conversation is long

    • /clear — You're done with one task and starting something completely different


    Hooks — Automate Your Workflow

    Hooks are shell commands that run automatically when Claude Code does things. They're configured in your settings and they're incredibly powerful.

    Example: Auto-format on every file edit

    Add this to .claude/settings.json:

    {
      "hooks": {
        "PostToolUse": [
          {
            "matcher": "Edit|Write",
            "command": "prettier --write \"$CLAUDE_FILE_PATH\" 2>/dev/null || true"
          }
        ]
      }
    }
    

    Now every time Claude edits a file, Prettier automatically formats it.

    Example: Run tests after code changes

    {
      "hooks": {
        "PostToolUse": [
          {
            "matcher": "Edit|Write",
            "command": "if echo \"$CLAUDE_FILE_PATH\" | grep -q '_test\\.go$'; then go test ./... 2>&1 | tail -5; fi"
          }
        ]
      }
    }
    

    Example: Lint check before commits

    {
      "hooks": {
        "PreToolUse": [
          {
            "matcher": "Bash",
            "command": "if echo \"$CLAUDE_COMMAND\" | grep -q 'git commit'; then make lint 2>&1 || echo 'BLOCK: Fix lint errors first'; fi"
          }
        ]
      }
    }
    

    Multi-Agent Workflows — The Real Superpower

    Claude Code can spawn sub-agents to handle complex tasks in parallel. This is where it gets truly powerful.

    How It Works

    When you give Claude Code a complex task, it can:

    1. Launch an Explore agent to search your codebase

    2. Launch a Plan agent to design the implementation

    3. Launch worker agents in isolated git worktrees to write code without affecting your working directory

    Practical Example

    > Refactor the authentication system to use JWT instead of sessions.
    > Use multiple agents to research, plan, and implement.
    

    Claude Code will:

    1. Spawn an Explore agent to find all auth-related code

    2. Spawn a Plan agent to design the migration

    3. Create an implementation in an isolated worktree

    4. Present you with the complete changeset for review

    The Worktree Trick

    When Claude spawns an agent with isolation: "worktree", it creates a temporary git branch. If the agent's changes are good, the worktree path and branch are returned so you can merge them. If not, the worktree is automatically cleaned up.

    This means Claude can experiment freely without risking your working code.


    Context Window Management

    Claude Code uses the Opus model with a massive context window, but you still need to manage it wisely.

    The Context Hierarchy

    Tips for Context Efficiency

    1. Be specific about files. Instead of "look at the auth code," say "read api/internal/auth/jwt.go"

    2. Use /compact proactively — don't wait until Claude starts forgetting

    3. Start new conversations for new tasks — don't reuse long conversations

    4. Use agents for research — they have their own context windows

    5. Keep CLAUDE.md concise — it's loaded every conversation


    MCP Servers — Extend Claude's Reach

    Model Context Protocol (MCP) servers give Claude Code access to external tools and data sources.

    Server What It Does
    context7 Fetches latest library documentation
    filesystem Advanced file operations
    github Full GitHub API access (PRs, issues, actions)
    Custom servers Your own tools, databases, APIs

    Setting Up MCP

    In .claude/settings.json:

    {
      "mcpServers": {
        "context7": {
          "command": "npx",
          "args": ["-y", "@anthropic-ai/context7-mcp"]
        },
        "my-database": {
          "command": "node",
          "args": ["./scripts/db-mcp-server.js"],
          "env": {
            "DATABASE_URL": "postgresql://localhost:5432/myapp"
          }
        }
      }
    }
    

    When to Use MCP vs. Built-in Tools

    Need Use
    Read/write files Built-in Read/Write/Edit tools
    Search code Built-in Grep/Glob tools
    Run commands Built-in Bash tool
    Access external APIs MCP server
    Query databases MCP server
    Fetch documentation context7 MCP

    Headless Mode — Claude Code in CI/CD

    Run Claude Code without interactive input for automation:

    # Fix all lint errors automatically
    claude -p "Fix all ESLint errors in src/" --allowedTools Edit,Write,Bash
    
    # Generate release notes from git log
    claude -p "Generate release notes for the last 10 commits" --print
    
    # Code review a PR
    claude -p "Review the changes in this PR and flag any issues" --print
    

    In GitHub Actions

    - name: AI Code Review
      run: |
        npx @anthropic-ai/claude-code -p \
          "Review the diff and comment on any issues" \
          --print \
          --allowedTools Read,Grep,Glob
    

    The Memory System

    Claude Code has a persistent memory system that remembers things across conversations.

    What Gets Remembered

    ~/.claude/projects/{project-path}/memory/
    ├── MEMORY.md          ← Index of all memories
    ├── user_role.md       ← Your role and preferences
    ├── feedback_testing.md ← How you like tests written
    └── project_deploy.md  ← Deployment procedures
    

    Teaching Claude About You

    > Remember: I prefer small, focused commits over large ones
    > Remember: Always run tests before suggesting a commit
    > Remember: I'm a senior backend engineer, skip basic explanations
    

    Claude saves these as memory files and applies them in future conversations.

    Checking What's Remembered

    > /memory
    

    Or just ask:

    > What do you remember about my preferences?
    

    Advanced Tips That Nobody Talks About

    1. The "Simplify" Trick

    After Claude writes code, run:

    > /simplify
    

    This reviews the changes for reuse, quality, and efficiency, then fixes any issues. It catches over-engineering, unnecessary abstractions, and missed edge cases.

    2. Vim Mode

    If you're a Vim user:

    > /keybindings
    

    Set up Vim-style keybindings for the Claude Code interface.

    3. The Screenshot Trick

    Claude Code can read images. If you have a bug that's visual:

    > Here's a screenshot of the broken UI: /tmp/screenshot.png
    > Fix the layout issue shown in the image
    

    4. Extended Thinking

    For complex architectural decisions, Claude uses extended thinking — you can see it reasoning through the problem step by step. This is especially useful for:

    • Database schema design

    • API architecture decisions

    • Complex debugging

    5. The Plan Mode Pattern

    For any non-trivial task, start with:

    > Let's plan this before coding. Enter plan mode.
    

    Claude will:

    1. Explore the codebase

    2. Identify affected files

    3. Design the approach

    4. Present the plan for your approval

    5. Only then start coding

    This prevents wasted effort and ensures alignment.

    6. Parallel Tool Calls

    Claude Code can make multiple tool calls simultaneously. When it needs to read 5 files, it reads them all at once instead of sequentially. This makes complex operations significantly faster.

    7. Background Agents

    > Run the test suite in the background and let me know when it's done
    

    Claude can run long-running tasks in the background while you continue working on other things.


    Common Mistakes to Avoid

    1. Don't Give Vague Instructions

    Bad Good
    "Make the app faster" "Add Redis caching to the /api/users endpoint"
    "Fix the bug" "Fix the login error when email contains a + character"
    "Clean up the code" "Extract the validation logic from UserHandler into a separate validator package"

    2. Don't Fight the Permission System

    When Claude asks for permission, it's protecting you. If a tool gets denied, Claude adapts its approach. Don't just approve everything blindly.

    3. Don't Ignore CLAUDE.md

    A good CLAUDE.md is the difference between Claude writing code that fits your project and Claude writing generic code. Invest 10 minutes in it.

    4. Don't Use One Long Conversation

    Start fresh conversations for different tasks. Context pollution from unrelated work degrades quality.


    My Daily Workflow

    Here's how I actually use Claude Code every day:

    Morning:

    1. claude — Start a session

    2. Check what I was working on yesterday

    3. Pick up where I left off

    During development:

    1. Describe the feature/fix in plain English

    2. Let Claude plan the approach

    3. Review and approve the plan

    4. Let Claude implement

    5. Review the code changes

    6. Run tests

    7. Commit

    Before committing:

    > Review the changes I'm about to commit. Check for:
    > - Security issues
    > - Missing error handling
    > - Test coverage
    > - Performance concerns
    

    End of day:

    > Summarize what we accomplished today
    


    Quick Reference Card

    Action Command/Approach
    Start Claude Code claude
    Initialize project /init
    Compress context /compact
    Clear conversation /clear
    Check cost /cost
    Review changes /review
    Remember something "Remember: [preference]"
    Read a screenshot "Here's a screenshot: /path/to/image.png"
    Run headless claude -p "task" --print
    Plan before coding "Let's plan this. Enter plan mode."
    Use sub-agents "Use multiple agents to research and implement"
    Background task "Run tests in the background"

    What's Next

    Claude Code is evolving fast. The multi-agent architecture, MCP ecosystem, and memory system are just the beginning. The engineers who master these tools now will have a significant advantage as AI-assisted development becomes the norm.

    The key insight: Claude Code isn't just a code generator. It's a collaborative development environment. Treat it like a brilliant pair programmer who never gets tired, never forgets the codebase, and can explore 10 approaches in the time it takes you to think through one.

    Start small. Learn the fundamentals. Then push the boundaries.

    Share this guide

    Comments

    Loading comments...

    / Search J Next section K Prev section H Hide nav