Level 2

Advanced Claude Code

For Developers Ready to Go Deep

Prerequisites: Level 1 (basic prompting, file operations, simple workflows)

Overview

What We'll Cover

Deep patterns and advanced features for power users.

🤖 Agentic Patterns

TodoWrite, deep reasoning, parallelism

⚙️ Power Features

CLAUDE.md hierarchy, commands, hooks

🔌 Integration

MCP servers, browser, Git workflows

🏗️ Real-World

Large codebases, refactoring, debugging

Agentic Patterns

Multi-Step Autonomous Workflows

Claude automatically decomposes complex requests into tracked tasks.

The Power of TodoWrite

  • Real-time progress visibility as Claude works
  • Know when to intervene vs. let Claude run
  • Complex tasks auto-decompose into 8-10+ subtasks

Trigger Patterns

"Add user authentication to this API" → 8-10 auto-decomposed tasks "Refactor this module to use dependency injection" → systematic multi-file changes "Set up CI/CD for this project" → infrastructure + config + testing
Agentic Patterns

Deep Reasoning Triggers

Standard Responses

Quick, surface-level analysis for simple tasks

Extended Thinking

Deep architectural reasoning, subtle bug detection

Trigger Phrases

ultrathink
Maximum analysis depth
think deeply about...
Extended reasoning

When to Use

Architecture decisions, complex debugging (race conditions, memory leaks), security-sensitive code review, performance optimization.

Agentic Patterns

Parallel Execution & Batching

Speed through parallelism — Claude identifies independent operations automatically.

Enable Parallel Execution

"Read all test files and identify patterns" → parallel reads "Search for usages across these 5 modules" → parallel greps "Run lint, test, and build checks" → parallel commands

Anti-Pattern (Forces Sequential)

"Read file A, then based on that read file B" → sequential dependency

Pro tip: Proper prompting enables vs. blocks parallelism. Avoid creating artificial dependencies.

Agentic Patterns

Context Window Mastery

Your most precious resource — use it wisely.

The Pyramid Pattern

  • Broad search (Grep/Glob) → identify candidates
  • Narrow focus → read only relevant files
  • Deep dive → detailed analysis of critical sections

Context Management

/compact
Summarize and compress context
Line ranges
"Read lines 50-100 of file.py"

Don't read entire files when you need one function. Let Claude search first, then read matches.

Power User Features

CLAUDE.md Configuration Hierarchy

Three-Level Configuration

~/.claude/CLAUDE.md # Global (all projects) ├── ProjectRoot/CLAUDE.md # Project-specific │ ├── backend/CLAUDE.md # Directory-specific │ └── frontend/CLAUDE.md # Directory-specific

Override Precedence: Directory > Project > Global

Global Example

- Use python3, not python - Ask public/private before GitHub repos - Prefer functional patterns

Project Example

# E-commerce API - Framework: FastAPI + SQLAlchemy - Testing: pytest with fixtures
Power User Features

Custom Commands vs Skills

📜 Commands (User-invoked)

.claude/commands/ ├── release.md → /release ├── deploy.md → /deploy └── review-pr.md → /review-pr

Usage: /release 2.1.0

🎓 Skills (Auto-discovered)

.claude/skills/ ├── database-migrations/ │ └── SKILL.md └── api-documentation/ └── SKILL.md

Claude uses automatically when relevant

Key Difference: Commands = explicit user invocation, Skills = automatic capability discovery

Power User Features

Hooks System

Automated actions on Claude events.

Hook Types

Pre-edit
Validate before changes
Post-edit
Format after changes
Pre-commit
Check before committing

Configuration (.claude/hooks.json)

{ "post-edit": { "*.py": ["black", "isort"], "*.ts": ["prettier --write"] }, "pre-commit": { "*": ["npm run lint", "npm run test"] } }
Power User Features

Model Selection Strategy

Right model for the job.

Model Best For Speed Cost
Haiku Simple operations, high volume Fastest Lowest
Sonnet Routine coding, most tasks Fast Medium
Opus Complex reasoning, architecture Slower Highest

Strategic Pattern

  • Opus for architecture analysis
  • Sonnet for implementation
  • Haiku for bulk operations (formatting, simple fixes)
Integration

MCP Server Architecture

Model Context Protocol = Extensibility

What MCP Enables

  • Database queries (Postgres, SQLite)
  • Cloud platform integration (Cloudflare, AWS)
  • External APIs (Notion, Linear, GitHub)
  • Custom tool servers

Configuration (.mcp.json)

{ "mcpServers": { "cloudflare": { "command": "npx", "args": ["@anthropic/mcp-cloudflare"] }, "postgres": { "command": "npx", "args": ["@anthropic/mcp-postgres"], "env": { "DATABASE_URL": "${DATABASE_URL}" } } } }

After adding: Must restart Claude Code (/exit and reopen)

Integration

Browser Automation

Claude sees and controls browsers.

Capabilities

  • Navigate to URLs
  • Read page content (accessibility tree)
  • Click, type, fill forms
  • Take screenshots
  • Execute JavaScript

Key Patterns

  • Snapshot-based interaction
  • Accessibility tree > screenshots
  • GIF recording for demos

Use Cases

E2E testing workflows, web scraping with intelligence, form automation, visual debugging.

Integration

Git Workflow Mastery

Beyond basic commits — smart messages, HEREDOC formatting.

Smart Commit Messages

  • Claude reads diffs automatically
  • Generates contextual messages
  • Follows repo conventions

HEREDOC Formatting (Required for multi-line)

git commit -m "$(cat <<'EOF' feat: Add user authentication - Implement JWT token generation - Add login/logout endpoints - Create auth middleware EOF )"
Integration

External Tool Chain Integration

Claude in your ecosystem.

🐳 Docker

"Build and run docker-compose" "Debug why container isn't picking up config changes"

☁️ Cloud CLIs

"Deploy this worker to Cloudflare" "Check AWS Lambda logs for errors"

🔄 Background Processes

"Start dev server in background" "Run test suite, let me know when done"

🚀 CI/CD

"Trigger GitHub Actions workflow" "Check why the build is failing"
Integration

LSP Integration

Language Server Protocol gives Claude IDE-level code intelligence.

📐 What LSP Provides

  • Instant diagnostics & errors
  • Go to definition
  • Find all references
  • Type information on hover
  • Code completion context

🚀 Why It Matters

  • Faster than grep for navigation
  • Understands type relationships
  • Catches errors before running
  • Works across languages

Enable LSP

claude --mcp-server "npx @anthropic/claude-code-lsp"

LSP is especially powerful for refactoring — Claude can find all usages instantly instead of relying on text search.

Real-World Mastery

Large Codebase Navigation

The Explore Agent

"Use the Explore agent to understand how authentication works" → Spawns specialized agent for codebase exploration

Spiral Search Pattern

  • Grep — find keyword occurrences
  • Glob — find file patterns
  • Read — dive into specific files
  • Understand — build mental model

Pro Tips: Start with README, package.json, main entry points. Follow imports to understand dependencies. Don't read everything — sample strategically.

Real-World Mastery

Complex Multi-File Refactoring

The safe refactoring pattern.

1.
Map dependencies first — "Find all usages of UserService before we rename it"
2.
Plan the change — "Enter plan mode - I want to rename User to Account"
3.
Execute atomically — Claude tracks all changes, can rollback if tests fail
4.
Verify — "Run tests to verify the refactoring didn't break anything"
Real-World Mastery

Advanced Debugging Patterns

Systematic bug hunting.

1. Gather Evidence

"Read error logs, identify patterns" "Check network requests for failures"

2. Form Hypotheses

"Think deeply about what could cause this intermittent failure"

3. Trace Through Code

"Follow the code path from API endpoint to database"

4. Test Fix

"Implement the fix and add a regression test"

Browser Debugging

read_console_messages for JavaScript errors, read_network_requests for API failures, screenshots at each step.

Real-World Mastery

Security-Conscious Development

🚫 What Claude Should NOT See

  • API keys and secrets
  • Production database credentials
  • Private keys

✅ Safe Patterns

  • Use environment variables
  • Reference secrets by name, not value
  • Share .env structure without contents

Security Audit Workflow

"Scan for hardcoded secrets in the codebase" "Check dependencies for known vulnerabilities" "Identify potential SQL injection points" "Generate a security report"
Reference

Quick Reference Card

Trigger Phrases

ultrathink Max depth
think deeply Extended
plan mode Arch first
in parallel Concurrent

File Locations

~/.claude/CLAUDE.md
./CLAUDE.md
.claude/commands/*.md
.mcp.json

Subagent Types

Explore Navigation
Plan Architecture
general-purpose Multi-step
claude-code-guide Docs
Level 2 Complete

You're Now a Power User

You've mastered the advanced patterns. Now combine them — use TodoWrite for complex tasks, ultrathink for architecture, parallel execution for speed, and MCP for integration.

🎯 Practice

Try refactoring a real codebase with plan mode

🔧 Customize

Set up your CLAUDE.md hierarchy and hooks

Want hands-on training? We run workshops on Claude Code and agent development.
Get in touch →

1 / 21
Navigate M Menu