Claude Code Complete Installation Guide: From Node.js Setup to MCP Server Integration
Claude Code Complete Installation Guide: First Run to Full Configuration
Claude Code is Anthropic’s agentic AI coding tool that operates directly in your terminal. This guide walks you through every step — from installing Node.js to configuring CLAUDE.md project instructions, connecting MCP servers, and setting up permission modes — so you can go from zero to a fully productive environment in one session.
Step 1: Install Node.js (v18+)
Claude Code requires Node.js version 18 or later. Verify your current version or install it fresh.
# Check current version
node —version
Install via nvm (recommended)
nvm install 20
nvm use 20
Or download directly from https://nodejs.org
Confirm the installation succeeded:
node —version
Expected: v20.x.x or higher
npm —version
Step 2: Install Claude Code Globally
Install Claude Code as a global npm package:
npm install -g @anthropic-ai/claude-code
After installation, verify it works:
claude --version
On first launch, Claude Code will prompt you to authenticate with your Anthropic account or API key.
# Launch Claude Code
claude
Or set your API key as an environment variable
export ANTHROPIC_API_KEY=YOUR_API_KEY
Step 3: Configure CLAUDE.md Project Instructions
CLAUDE.md files are persistent instruction files that Claude Code reads automatically on every session. They control how the AI behaves within your project.
File Hierarchy
| File Location | Scope | Purpose |
|---|---|---|
~/.claude/CLAUDE.md | Global (all projects) | Personal preferences, universal rules |
./CLAUDE.md (project root) | Project-wide | Coding standards, architecture notes, tool configs |
./src/CLAUDE.md | Directory-specific | Module-level instructions |
# In your project root
cat > CLAUDE.md << 'EOF'
# Project Instructions
Tech Stack
- Framework: Next.js 14 (App Router)
- Language: TypeScript (strict mode)
- Styling: Tailwind CSS
- Database: PostgreSQL with Prisma ORM
Coding Standards
- Use functional components with hooks
- Prefer named exports over default exports
- All functions must have JSDoc comments
- Tests required for business logic (use Vitest)
File Structure
- src/app/ — route handlers and pages
- src/components/ — reusable UI components
- src/lib/ — utility functions and shared logic
- src/db/ — Prisma schema and migrations
Commands
- Dev server: npm run dev
- Run tests: npm run test
- Lint: npm run lint
Build: npm run build EOF
Step 4: Set Up MCP Server Integration
Model Context Protocol (MCP) servers extend Claude Code's capabilities by connecting it to external tools and data sources. Configuration lives in JSON settings files.
MCP Configuration Locations
- Project-level:
.claude/mcp.jsonin your project root- User-level:~/.claude/mcp.jsonfor global MCP servers
Example: Adding a Filesystem and Database MCP Server
# Create the project MCP config directory
mkdir -p .claude
cat > .claude/mcp.json << ‘EOF’
{
“mcpServers”: {
“filesystem”: {
“command”: “npx”,
“args”: [“-y”, “@anthropic-ai/mcp-server-filesystem”, “/path/to/allowed/dir”]
},
“postgres”: {
“command”: “npx”,
“args”: [“-y”, “@anthropic-ai/mcp-server-postgres”],
“env”: {
“DATABASE_URL”: “postgresql://user:password@localhost:5432/mydb”
}
},
“github”: {
“command”: “npx”,
“args”: [“-y”, “@anthropic-ai/mcp-server-github”],
“env”: {
“GITHUB_TOKEN”: “YOUR_API_KEY”
}
}
}
}
EOF
After saving the config, restart Claude Code. You can verify connected servers by running:
# Inside Claude Code session, type:
/mcp
Step 5: Configure Permission Modes
Claude Code has three permission modes that control how much autonomy the AI has when executing tools:
| Mode | Behavior | Best For |
|---|---|---|
| **Default** | Prompts for approval on risky actions (file writes, shell commands) | Daily development |
| **Plan Mode** | Claude Code can only read files and propose changes, never execute | Code review, planning |
| **Auto-accept (yolo)** | All tool calls execute without prompting | Trusted automation pipelines |
# Start in plan mode (read-only)
claude --plan
Start with auto-accept for all actions
claude —dangerously-skip-permissions
Configure allowed tools in settings
claude config set autoApprove “Bash(npm run test),Read,Glob,Grep”
You can also configure permissions per-project in .claude/settings.json:
{
“autoApprove”: [
“Read”,
“Glob”,
“Grep”,
“Bash(npm run test)”,
“Bash(npm run lint)”
]
}
Step 6: Your First Productive Session
With everything configured, start Claude Code in your project directory:
cd /your/project
claude
Try these workflows to validate your setup:
- **Explore the codebase:** Ask Claude to summarize the project structure- **Run tests:** Ask Claude to run and analyze your test suite- **Fix a bug:** Point Claude at an issue and let it diagnose, fix, and verify- **Add a feature:** Describe what you need and let Claude implement it across files# Example: start a session with an initial prompt
claude "Review the authentication module and identify any security issues"
Resume a previous conversation
claude —resume
Continue the most recent session
claude —continue
Pro Tips for Power Users
- Use slash commands: Type
/helpinside a session to see all commands./compactcompresses conversation context when you are running long.- Pipe input: Feed files or command output directly —cat error.log | claude “What caused this crash?”- Multi-turn memory: Claude Code remembers context within a session. Chain requests without repeating background.- Custom slash commands: Create.claude/commands/directory with markdown files for reusable prompt templates.- Headless mode for CI/CD: Useclaude -p “Run tests and report” —output-format jsonin pipelines for structured output.- Use the Explore subagent: For complex codebase research, Claude Code dispatches a dedicated exploration agent that searches broadly without consuming your main conversation context.
Troubleshooting Common Errors
| Error | Cause | Fix |
|---|---|---|
command not found: claude | npm global bin not in PATH | Run npm config get prefix and add its bin/ directory to your PATH |
ANTHROPIC_API_KEY not set | Missing authentication | Export the variable or log in via the interactive prompt on first run |
Node.js version too old | Node < 18 detected | Upgrade with nvm install 20 or download from nodejs.org |
| MCP server not appearing | Invalid JSON config or wrong path | Validate .claude/mcp.json syntax and restart Claude Code |
Permission denied on tool call | Default permission mode blocking | Approve when prompted or add the tool to autoApprove in settings |
Can I use Claude Code without an Anthropic API key?
Yes. Claude Code supports authentication through your Anthropic account via an interactive login flow on first launch. You can also use it through Claude Pro, Team, or Enterprise subscriptions. The API key method is an alternative for users who prefer environment-variable-based auth or need headless/CI usage.
How do I add MCP servers without restarting Claude Code?
Currently, MCP server configuration changes require restarting your Claude Code session. After editing .claude/mcp.json, exit and relaunch Claude Code. You can verify your servers loaded correctly by running the /mcp slash command inside the session.
What is the difference between CLAUDE.md and .claude/settings.json?
CLAUDE.md contains natural-language instructions that guide the AI’s behavior — coding standards, project context, and workflow rules. The .claude/settings.json file is a structured configuration file that controls Claude Code’s operational settings like permission auto-approvals and tool configurations. Use CLAUDE.md for “how to code in this project” and settings.json for “how Claude Code should operate.”