Skip to main content
AI
10 min read

Complete Claude Code Installation & Setup Guide: MCP Servers, Sub-Agents & Best Practices 2025

Max van Anen - Profile Picture
By
Complete Claude Code installation and setup guide with MCP servers, sub-agents, CLAUDE.md configuration. Installation instructions, advanced workflows, and proven optimization strategies.
Claude CodeDeveloper ToolsProductivityBest Practices
Complete Claude Code Installation & Setup Guide: MCP Servers, Sub-Agents & Best Practices 2025 - Featured article image for Maxzilla blog

Claude Code can be a game-changer, but only if you set it up right. After months of daily use, I've found patterns that actually work and plenty that don't. This guide cuts through the hype to show you what's genuinely useful.

Fair warning: Claude Code isn't magic. It won't replace your brain, and for simple tasks, you might be faster without it. But for complex refactoring, boilerplate generation, and architectural decisions? That's where it shines. These capabilities are especially valuable when working onReact applications or complex cloud architectures.

Getting Started with Claude Code

Before diving into advanced configurations, let's cover the fundamentals of setting up Claude Code for success. The installation and initial setup process is straightforward, but getting it right from the start saves significant time later.

Installation

Claude Code is available as a command-line interface (CLI) tool that integrates directly into your development workflow. The installation is straightforward and works across all major platforms.

Installation Steps

macOS/Linux (via curl):

bash
# Install Claude Code CLI curl -fsSL https://claude.ai/install.sh | sh # Or using package managers: # macOS with Homebrew brew install anthropic/claude/claude-code # Linux with apt (Ubuntu/Debian) curl -fsSL https://claude.ai/debian.key | sudo apt-key add - sudo apt update && sudo apt install claude-code

Windows (via PowerShell):

powershell
# Using PowerShell Invoke-WebRequest -Uri https://claude.ai/install.ps1 | Invoke-Expression # Or using Chocolatey choco install claude-code # Or using winget winget install Anthropic.ClaudeCode

Node.js (via npm):

bash
# Global installation npm install -g @anthropic/claude-code # Or using yarn yarn global add @anthropic/claude-code # Or using pnpm pnpm add -g @anthropic/claude-code

Authentication

After installation, authenticate using your Anthropic account:

bash
# Authenticate with your Anthropic account claude-code auth login # Verify installation and authentication claude-code --version claude-code auth status

The CLI will open your browser for authentication, then store your credentials securely for future use.

Project Initialization with /init

The /init command is your starting point for any new project. This command:

  • Analyzes your project structure and dependencies
  • Generates an initial CLAUDE.md file with project-specific context
  • Suggests relevant MCP server configurations based on your tech stack
  • Sets up basic workflows tailored to your development environment
bash
# Navigate to your project directory cd /path/to/your/project # Initialize Claude Code for this project /init # Claude will analyze your project and ask clarifying questions about: # - Primary programming languages and frameworks # - Database systems in use # - Deployment and hosting preferences # - Testing frameworks and preferences # - Team collaboration requirements

The initialization process is interactive. Claude Code asks targeted questions about your project to generate the most relevant configuration. This includes identifying package.json files, README files, and existing documentation to understand your project's context.

Basic Getting Started Workflow

Here's the essential workflow that sets you up for success:

  1. Initialize your project: Run /init in your project root
  2. Review the generated CLAUDE.md: Edit and customize the file for your specific needs
  3. Test basic functionality: Ask Claude Code to read a few key files to verify setup
  4. Configure MCP servers: Add the specific servers your project needs
  5. Create your first sub-agent: Start with a simple, project-specific agent

This workflow ensures Claude Code has the context it needs to be genuinely helpful from day one, rather than requiring multiple sessions to understand your project.

The Foundation: CLAUDE.md File Strategy

The single most impactful optimization you can make is creating a comprehensive CLAUDE.md file in your project root. This isn't just documentation, it's context that makes Claude Code exponentially more effective.

Essential CLAUDE.md Sections

After working with dozens of projects, here's the structure that consistently delivers the best results:

CLAUDE.md
# CLAUDE.md - Project Guidelines ## Project Overview Brief description of what this project does and its main purpose. ## Project Structure & Module Organization ``` your-project/ ├── src/ # Main source code │ ├── components/ # React components (if applicable) │ ├── utils/ # Utility functions │ └── types/ # TypeScript definitions ├── tests/ # Test files ├── docs/ # Documentation └── scripts/ # Build and deployment scripts ``` ## Development Commands - **Setup**: npm install or equivalent - **Local Development**: npm run dev - **Testing**: npm test - **Build**: npm run build - **Deploy**: npm run deploy ## Coding Standards & Conventions - Use TypeScript strict mode - Prefer functional components - Follow existing naming patterns - Write tests for business logic ## Common Patterns Document recurring patterns specific to your codebase ## Dependencies & Tools List key dependencies and their purposes ## Important Context Any domain-specific knowledge Claude needs to understand your project

The magic happens when Claude Code reads this file automatically at the start of each session. It immediately understands your project structure, conventions, and context without you having to explain it repeatedly.

Pro Tips for CLAUDE.md

  • Keep it updated: When you change project structure or add new patterns, update the file immediately
  • Include gotchas: Document common pitfalls or non-obvious aspects of your codebase
  • Reference external docs: Link to API documentation, design systems, or architectural decision records
  • Version control it: This file should be committed and shared with your team

MCP Server Configuration: Supercharging Your Capabilities

Model Context Protocol (MCP) servers are where Claude Code really shines. The right MCP setup can eliminate entire categories of manual work and give you capabilities that feel like magic.

Essential MCP Servers for Development

Here are the MCP servers that have become indispensable in my daily workflow:

.claude_config.json
{ "mcpServers": { "filesystem": { "command": "npx", "args": ["@modelcontextprotocol/server-filesystem", "/path/to/your/project"], "env": {} }, "postgres": { "command": "npx", "args": ["@modelcontextprotocol/server-postgres"], "env": { "POSTGRES_CONNECTION_STRING": "postgresql://user:password@localhost:5432/dbname" } }, "web-search": { "command": "npx", "args": ["@modelcontextprotocol/server-web-search"], "env": {} } } }

GitHub CLI: The Superior Choice

While there is a GitHub MCP server available, the GitHub CLI is far superior for actual development work. Claude Code can execute gh commands directly through the bash tool, giving you access to the full power of GitHub's command-line interface.

Why the CLI approach wins:

  • Full feature parity: Every GitHub feature is available, not just a subset
  • Real-time operations: Create PRs, manage issues, review code in real-time
  • Workflow integration: Seamlessly integrate with your existing git workflows
  • No token management: Uses your existing gh auth setup
  • Advanced operations: Complex queries, bulk operations, and custom scripts

Install and authenticate the GitHub CLI once, and Claude Code can perform any GitHub operation:

bash
# One-time setup brew install gh # or your preferred installation method gh auth login # Now Claude Code can do things like: gh pr create --title "Fix user authentication" --body "Details here" gh issue list --assignee @me --state open gh repo clone user/repository gh workflow run deploy.yml gh pr checks --watch

Game-Changing MCP Workflows

Once you have MCP servers configured, these workflows become possible:

  • Figma-to-Code Pipeline: "Convert this Figma layout to React components" - Claude generates production-ready code tailored to your design system
  • Database-aware development: Claude reads your PostgreSQL schema, suggests optimized migrations, and writes performant queries in natural language
  • End-to-end Testing Automation: Using Playwright MCP, Claude creates comprehensive browser tests using structured accessibility trees instead of brittle screenshots
  • Multi-app Automation: Via Zapier MCP, Claude orchestrates complex workflows across Slack, Gmail, Trello, and hundreds of other services
  • Repository-wide refactoring: Find and update patterns across hundreds of files with surgical precision
  • Intelligent debugging: Analyze logs, stack traces, and database states in context with Sequential Thinking MCP for complex problem-solving

Advanced MCP Setups for Enterprise

For production environments, consider these powerful MCP server configurations:

  • Headless CI/CD Integration: Use Claude Code in headless mode with --output-format stream-json for automated code reviews and deployments
  • Custom Slash Commands: Store prompt templates in .claude/commands/ for repeated workflows like debugging loops and log analysis
  • Team-Shared Configurations: Version control your MCP configurations to ensure consistency across development teams
  • Security-First Architecture: Use environment variables for sensitive MCP server credentials instead of hardcoding API keys

Workspace Organization for Maximum Efficiency

How you organize your development environment directly impacts Claude Code's effectiveness. Here's the setup that has consistently delivered the best results:

The Three-Window Layout

  1. Primary Editor: Your main IDE (VS Code, IntelliJ, etc.) for code review and final edits
  2. Claude Code Terminal: Full-screen terminal dedicated to Claude Code interactions
  3. Browser/Documentation: Quick reference and testing

This layout allows you to see Claude Code's changes in real-time while maintaining your familiar editing environment for review and refinement.

Directory Structure Best Practices

Claude Code works best with well-organized codebases. These patterns consistently improve results:

text
✅ Good: Clear separation of concerns src/ ├── components/ │ ├── ui/ # Reusable UI components │ ├── forms/ # Form-specific components │ └── layout/ # Layout components ├── hooks/ # Custom React hooks ├── utils/ │ ├── api.ts # API utilities │ ├── validation.ts # Validation helpers │ └── constants.ts # Application constants └── types/ ├── api.ts # API response types └── common.ts # Shared types ❌ Avoid: Everything mixed together src/ ├── stuff/ ├── components-and-utils/ └── random-files/

Sub-Agents: Your Specialized AI Development Team

Perhaps the most revolutionary feature in Claude Code is Sub-Agents. Think of them as specialized AI assistants that work alongside your main Claude session, each with their own expertise, tools, and context windows.

What Makes Sub-Agents Game-Changing

Sub-agents operate in complete isolation from each other and your main conversation. This means:

  • No context pollution: Each agent maintains focused expertise without interference
  • Parallel processing: Multiple agents can work on different aspects simultaneously
  • Specialized toolsets: Each agent can have access to only the tools it needs
  • Predictable results: Isolated context leads to more consistent outputs

Practical Sub-Agent Applications

Sub-agents excel at focused, repeatable tasks that benefit from specialized context. Here are proven applications:

  • Content workflows: Processing structured data files and generating variations based on performance criteria
  • Code quality automation: Automated code review, test generation, and Pull Request analysis
  • Documentation maintenance: Keeping technical documentation in sync with code changes
  • Security auditing: Systematic security review using consistent criteria and checklists
  • Performance analysis: Analyzing application performance across different metrics and environments

Setting Up Your Sub-Agent Army

Each sub-agent is defined in a simple Markdown file:

.claude/sub-agents/security-reviewer.md
--- name: security-reviewer description: Reviews code for security vulnerabilities with the intensity of Linus Torvalds tools: Read, Grep, WebSearch --- You are a brutally honest security-focused code reviewer with the direct communication style of Linus Torvalds. When reviewing code: - Call out SQL injection vulnerabilities like they're personal insults to computing - Treat XSS vulnerabilities as crimes against humanity - Mock authentication bypasses with creative Finnish profanity equivalents - Shame developers who hardcode secrets ("What braindead monkey commits API keys?") - Ridicule insecure dependencies like they're Windows ME Always provide specific remediation steps, but deliver them with the subtle warmth of a Finnish winter. End reviews with: "Now go fix this garbage before I lose what's left of my faith in developers."

Pro Sub-Agent Strategies

  • Task delegation: Use sub-agents early in conversations to investigate specific questions
  • Specialized roles: Create agents for security, testing, documentation, and performance
  • Deep analysis: Request thorough analysis and step-by-step reasoning for complex problems
  • Verification loops: Have sub-agents verify each other's work for critical tasks

Real Sub-Agent Prompts That Work

Here are actual prompts that demonstrate the power of sub-agent delegation:

text
💡 Delegating Security Review: "Use the security-reviewer sub-agent to analyze our authentication middleware. I want a comprehensive assessment of our JWT implementation and session management." 🔍 Performance Investigation: "Have the performance-analyzer sub-agent conduct a thorough analysis of why our React app is slow on mobile. Focus on bundle size, rendering patterns, and API calls." 📝 Documentation Generation: "Use the tech-writer sub-agent to create comprehensive API documentation for our GraphQL schema. Make it developer-friendly with practical examples." 🧪 Test Strategy Planning: "Deploy the test-strategist sub-agent to design a testing approach for our payment processing workflow. Consider edge cases, error scenarios, and integration points." 🔄 Cross-Verification: "Have both the security-reviewer and performance-analyzer sub-agents evaluate this database query optimization. I want different perspectives before we deploy."

Notice how each prompt clearly delegates to a specific sub-agent and provides focused context. This approach keeps your main conversation clean while getting specialized expertise exactly when you need it.

Communication Patterns That Get Results

How you communicate with Claude Code dramatically affects the quality of results. After thousands of interactions, these patterns consistently produce better outcomes:

The Context-First Approach

Always provide context before making requests:

text
✅ Effective communication: "I'm working on a Next.js 14 app with TypeScript. We use Tailwind CSS and have a design system with consistent spacing. I need to create a user profile component that follows our existing card pattern but adds avatar functionality." ❌ Vague requests: "Make a user profile thing"

Encouraging Better Problem-Solving

For complex problems, encourage Claude Code to think through solutions more thoroughly by being explicit about the depth of analysis you need:

  • Request step-by-step analysis: "Walk me through the trade-offs of each approach"
  • Ask for multiple perspectives: "Consider this from both performance and maintainability angles"
  • Encourage comprehensive thinking: "Consider all the implications before suggesting a solution"
  • Request detailed reasoning: "Explain your reasoning for this architectural decision"

Example: "Please analyze the optimal database schema for this e-commerce system, considering both read performance and data consistency requirements. Walk through the trade-offs of different approaches."

Incremental Development Strategy

Break complex features into logical steps:

  1. Start with structure: "Create the basic component structure and props interface"
  2. Add core functionality: "Implement the main user data display logic"
  3. Enhance with features: "Add edit mode and form validation"
  4. Polish and optimize: "Add loading states and error handling"

This approach allows you to course-correct early and ensures each step builds logically on the previous one.

Performance Optimization Strategies

Claude Code performance isn't just about response time - it's about getting the right results efficiently.

File Reading Strategy

Be strategic about which files you ask Claude Code to read:

  • Start with key files: Main components, type definitions, and configuration files first
  • Use glob patterns: "Read all TypeScript files in the components directory"
  • Reference before reading: Let Claude Code suggest which files it needs to see
  • Avoid redundancy: Don't re-read files unnecessarily within the same session

Context Management

Manage conversation context strategically:

  • Session planning: Start each session by outlining what you want to accomplish
  • Checkpoint summaries: Periodically summarize progress and current state
  • Fresh starts: Begin new sessions for unrelated work to avoid context pollution
  • Documentation: Keep track of important decisions and patterns that emerge

Quality Assurance and Testing Integration

Integrate quality checks into your Claude Code workflow from the beginning:

Automated Validation

Configure your project so Claude Code can run quality checks:

package.json
{ "scripts": { "lint": "eslint src --ext .ts,.tsx", "type-check": "tsc --noEmit", "test": "jest", "test:watch": "jest --watch", "validate": "npm run lint && npm run type-check && npm run test" } }

Always ask Claude Code to run these checks after making changes. This catches issues early and ensures consistent code quality.

Testing Strategy

Integrate test creation into your development workflow:

  1. Test-driven development: Ask Claude Code to write tests first for complex logic
  2. Component testing: Create tests for each component as you build it
  3. Integration testing: Test complete user flows, not just isolated functions
  4. Error scenarios: Always test error conditions and edge cases

Advanced Workflow Patterns

These advanced patterns can significantly accelerate development once you've mastered the basics:

The Documentation-First Pattern

Start complex features by writing documentation:

  1. Describe the feature requirements in detail
  2. Create API documentation or component interfaces
  3. Generate implementation based on the documentation
  4. Keep documentation and code in sync throughout development

The Refactoring Safety Net

Use Claude Code for confident large-scale refactoring:

  1. Comprehensive test coverage: Ensure existing functionality is well-tested
  2. Gradual transformation: Break refactoring into small, testable steps
  3. Pattern consistency: Apply the same refactoring pattern across the codebase
  4. Validation after each step: Run tests and type checks continuously

The Research and Implementation Loop

Leverage Claude Code's knowledge for implementation decisions:

  1. Research phase: Ask about best practices for your specific use case
  2. Options evaluation: Compare different approaches with pros and cons
  3. Implementation: Build the solution using the chosen approach
  4. Optimization: Refine based on real-world usage patterns

Real Pitfalls Worth Avoiding

Context Overload

Don't dump your entire codebase. Claude performs better with focused context.

Session Marathons

Long sessions degrade quality. Plan breakpoints and start fresh when tackling new features.

Metrics That Actually Matter

  • Prototype speed: Getting from idea to working code in hours, not days
  • Refactoring confidence: Tackling tech debt without fear
  • Bug reduction: Fewer issues in production (Claude catches edge cases)
  • Learning velocity: Exposure to patterns you wouldn't discover alone

Claude Code vs. The Competition

Let's be honest: Claude Code isn't the only AI pair programmer in town. Here's how it stacks up:

GitHub Copilot

  • Copilot wins: IDE integration, autocomplete speed, multi-line suggestions
  • Claude wins: Complex refactoring, architectural decisions, full file understanding
  • Verdict: Use Copilot for quick completions, Claude for heavy lifting

Cursor

  • Cursor wins: Native IDE experience, codebase indexing
  • Claude wins: CLI flexibility, MCP servers, sub-agents
  • Verdict: Cursor for IDE-centric workflow, Claude for command-line power users

Raw GPT-4

  • GPT-4 wins: Broader knowledge, visual understanding
  • Claude wins: Code-specific optimizations, better context handling, safer outputs
  • Verdict: Claude for coding, GPT-4 for everything else

The reality: Most productive developers use multiple tools. Claude Code excels at complex, context-heavy tasks but isn't always the right tool for every job.

Quick Start

  1. Run /init to initialize your project
  2. Create your CLAUDE.md with project context
  3. Set up MCP servers (filesystem, database, web-search)
  4. Build specialized sub-agents for your workflow
  5. Request thorough analysis for complex architectural decisions

The Bottom Line

Claude Code works best as a pair programmer for complex tasks, not a replacement for thinking. The setup effort pays off quickly if you're doing heavy refactoring, architectural work, or dealing with large codebases.

Don't expect miracles. Do expect faster prototyping, better test coverage, and exposure to patterns you might not have discovered on your own.