Claude Code Setup Guide: From Installation to CLAUDE.md Configuration for Local Development

Claude Code Setup Guide: Complete Local Development Environment Configuration

Claude Code is Anthropic’s AI-powered coding assistant that runs directly in your terminal, providing context-aware code generation, debugging, and project management. This guide walks you through the complete setup process — from initial installation to advanced CLAUDE.md configuration — so you can maximize productivity in your local development environment.

Prerequisites

  • Node.js 18+ installed on your system- An Anthropic API key or Claude Pro/Max subscription- A terminal application (Terminal, iTerm2, Windows Terminal, etc.)- Git installed and configured

Step-by-Step Installation

Step 1: Install Claude Code via npm

Open your terminal and run the following command to install Claude Code globally: npm install -g @anthropic-ai/claude-code

Verify the installation was successful: claude —version

Step 2: Authenticate with Your API Key

Launch Claude Code for the first time by navigating to any project directory and running: cd /path/to/your/project claude

On first launch, you will be prompted to authenticate. If using an API key, set the environment variable before launching: export ANTHROPIC_API_KEY=YOUR_API_KEY claude

For persistent configuration, add the export to your shell profile: # For bash echo 'export ANTHROPIC_API_KEY=YOUR_API_KEY' >> ~/.bashrc source ~/.bashrc

For zsh

echo ‘export ANTHROPIC_API_KEY=YOUR_API_KEY’ >> ~/.zshrc source ~/.zshrc

Step 3: Verify the Setup

Run a quick test to confirm everything works: claude "explain the structure of this project"

If Claude responds with a summary of your project directory, you are ready to proceed.

Understanding CLAUDE.md Configuration

CLAUDE.md is a special markdown file that provides persistent instructions to Claude Code. It acts as a project-level system prompt, giving Claude context about your codebase, coding standards, and workflow preferences. There are three levels of CLAUDE.md:

LevelLocationScope
Global (User)~/.claude/CLAUDE.mdAll projects for the current user
Project Root./CLAUDE.md (repo root)Everyone working on this project
Subdirectory./src/CLAUDE.mdContext for specific directories
### Step 4: Create a Global CLAUDE.md Set up user-wide preferences that apply to every project: mkdir -p ~/.claude cat > ~/.claude/CLAUDE.md << 'EOF' # Global Claude Code Preferences

Coding Style

  • Use TypeScript over JavaScript when possible
  • Prefer functional programming patterns
  • Always add error handling for async operations

Response Preferences

  • Be concise in explanations
  • Show code diffs rather than full file rewrites
  • Use conventional commits for git messages EOF

Step 5: Create a Project-Level CLAUDE.md

Navigate to your project root and create a project-specific configuration: cat > CLAUDE.md << 'EOF' # Project: My Web Application

Tech Stack

  • Framework: Next.js 14 (App Router)
  • Language: TypeScript
  • Styling: Tailwind CSS
  • Database: PostgreSQL with Prisma ORM
  • Testing: Vitest + React Testing Library

Project Structure

  • src/app/ — Next.js app router pages
  • src/components/ — Reusable UI components
  • src/lib/ — Utility functions and shared logic
  • prisma/ — Database schema and migrations

Coding Conventions

  • Components use PascalCase file names
  • Utilities use camelCase file names
  • All database queries go through Prisma client in src/lib/db.ts
  • API routes return typed responses using zod schemas

Commands

  • Dev server: npm run dev
  • Tests: npm run test
  • Lint: npm run lint
  • Database migrate: npx prisma migrate dev EOF

Step 6: Start Using Claude Code with Context

Now when you launch Claude Code in your project, it automatically reads the CLAUDE.md files and applies the instructions: claude

Example prompts that leverage your CLAUDE.md context:

create a new API route for user authentication write tests for the UserProfile component fix the database connection error in src/lib/db.ts refactor the dashboard page to use server components

Common Workflow Commands

Here are essential Claude Code commands for daily development: # Start an interactive session claude

Run a single command without interactive mode

claude “add input validation to the signup form”

Resume the previous conversation

claude —continue

Pipe content into Claude

cat error.log | claude “explain this error and suggest a fix”

Use a specific model

claude —model claude-opus-4-6

Pro Tips for Power Users

  • Use slash commands: Type /help inside a session for available commands. Use /compact to compress conversation context when it gets long.- Leverage memory: Claude Code has a persistent memory system. Tell it to remember key decisions, and it will save them for future sessions.- Permission modes: Use claude —dangerously-skip-permissions in CI/CD pipelines for non-interactive automation (use with caution).- Multi-file edits: Claude Code can read, edit, and create multiple files in a single request. Describe the full feature you want rather than file-by-file changes.- Chain with git: Ask Claude to review staged changes with prompts like “review my staged changes and suggest improvements before I commit.”- Keep CLAUDE.md updated: Treat it like living documentation. When your stack evolves, update the file so Claude stays aligned.

Troubleshooting Common Issues

IssueCauseSolution
command not found: claudenpm global bin not in PATHRun npm config get prefix and add the /bin directory to your PATH
Authentication failureInvalid or expired API keyRegenerate your key at console.anthropic.com and update the env variable
CLAUDE.md not being readFile placed in wrong directoryEnsure the file is in the repo root or ~/.claude/ directory, and named exactly CLAUDE.md
Context window exceededVery large codebase or long sessionUse /compact to compress context, or start a new session with claude
Slow responsesLarge files being readAdd a .claudeignore file to exclude build artifacts, node_modules, and large binary files
## Frequently Asked Questions

Do I need a paid Anthropic plan to use Claude Code?

Claude Code requires either an Anthropic API key with available credits or a Claude Pro or Max subscription. The Pro plan provides a generous usage allowance suitable for individual developers, while the Max plan is designed for heavy, professional usage with higher rate limits. You can sign up at anthropic.com and generate an API key from the developer console.

Can I commit CLAUDE.md to my repository for team-wide use?

Yes, and it is strongly recommended. Placing a CLAUDE.md file at your repository root ensures that every team member who uses Claude Code gets the same project context, coding conventions, and workflow instructions. This promotes consistency across the team. Personal preferences should go in the global ~/.claude/CLAUDE.md file, which is not committed to the repo.

How does CLAUDE.md differ from .cursorrules or .github/copilot-instructions.md?

While all three serve as AI assistant configuration files, CLAUDE.md is specifically designed for Claude Code and supports a hierarchical, directory-scoped system. Unlike flat instruction files, you can place CLAUDE.md files in subdirectories to provide context specific to that part of your codebase. Claude Code also features a persistent memory system that works alongside CLAUDE.md to learn your preferences over time, creating a more adaptive development experience.

Explore More Tools

Grok Best Practices for Academic Research and Literature Discovery: Leveraging X/Twitter for Scholarly Intelligence Best Practices Grok Best Practices for Content Strategy: Identify Trending Topics Before They Peak and Create Content That Captures Demand Best Practices Grok Case Study: How a DTC Beauty Brand Used Real-Time Social Listening to Save Their Product Launch Case Study Grok Case Study: How a Pharma Company Tracked Patient Sentiment During a Drug Launch and Caught a Safety Signal 48 Hours Before the FDA Case Study Grok Case Study: How a Disaster Relief Nonprofit Used Real-Time X/Twitter Monitoring to Coordinate Emergency Response 3x Faster Case Study Grok Case Study: How a Political Campaign Used X/Twitter Sentiment Analysis to Reshape Messaging and Win a Swing District Case Study How to Use Grok for Competitive Intelligence: Track Product Launches, Pricing Changes, and Market Positioning in Real Time How-To Grok vs Perplexity vs ChatGPT Search for Real-Time Information: Which AI Search Tool Is Most Accurate in 2026? Comparison How to Use Grok for Crisis Communication Monitoring: Detect, Assess, and Respond to PR Emergencies in Real Time How-To How to Use Grok for Product Improvement: Extract Customer Feedback Signals from X/Twitter That Your Support Team Misses How-To How to Use Grok for Conference Live Monitoring: Extract Event Insights and Identify Networking Opportunities in Real Time How-To How to Use Grok for Influencer Marketing: Discover, Vet, and Track Influencer Partnerships Using Real X/Twitter Data How-To How to Use Grok for Job Market Analysis: Track Industry Hiring Trends, Layoff Signals, and Salary Discussions on X/Twitter How-To How to Use Grok for Investor Relations: Track Earnings Sentiment, Analyst Reactions, and Shareholder Concerns in Real Time How-To How to Use Grok for Recruitment and Talent Intelligence: Identifying Hiring Signals from X/Twitter Data How-To How to Use Grok for Startup Fundraising Intelligence: Track Investor Sentiment, VC Activity, and Funding Trends on X/Twitter How-To How to Use Grok for Regulatory Compliance Monitoring: Real-Time Policy Tracking Across Industries How-To NotebookLM Best Practices for Financial Analysts: Due Diligence, Investment Research & Risk Factor Analysis Across SEC Filings Best Practices NotebookLM Best Practices for Teachers: Build Curriculum-Aligned Lesson Plans, Study Guides, and Assessment Materials from Your Own Resources Best Practices NotebookLM Case Study: How an Insurance Company Built a Claims Processing Training System That Cut Errors by 35% Case Study