Claude Code Setup

Claude Code is an AI coding assistant CLI from Anthropic.

Prerequisites

  • Node.js 18+
  • Anthropic API key (or Anthropic account for OAuth)

Step 1: Install

npm install -g @anthropic-ai/claude-code

Step 2: Authenticate

Option A: API Key

export ANTHROPIC_API_KEY="your-api-key"

Option B: OAuth (opens browser)

claude login

Step 3: Run

# Interactive mode
claude
 
# With initial prompt
claude "explain this code"
 
# In specific directory
claude --cwd /path/to/project

Configuration

Global Config

Located at ~/.claude.json:

{
  "permissions": {
    "allow": ["Bash", "Read", "Write", "Edit"],
    "deny": []
  },
  "mcpServers": {
    "obsidian": {
      "command": "npx",
      "args": ["@mauricio.wolff/mcp-obsidian@latest", "/path/to/vault"]
    }
  }
}

Project Config

Create CLAUDE.md in project root with instructions:

# CLAUDE.md
 
## Project Overview
This is a Node.js API server...
 
## Rules
- Use TypeScript
- Follow existing code style
- Run tests before committing

Claude reads this file automatically.

MCP Servers

MCP (Model Context Protocol) extends Claude with custom tools.

Add to ~/.claude.json:

{
  "mcpServers": {
    "server-name": {
      "command": "npx",
      "args": ["mcp-package-name", "arg1", "arg2"]
    }
  }
}

Directory Structure

~/.claude/
├── cache/           # Cached data
├── projects/        # Project metadata
├── todos/           # Task lists
├── history.jsonl    # Conversation history
└── stats-cache.json # Usage statistics

Useful Commands

In the Claude CLI:

  • /help — Show help
  • /clear — Clear conversation
  • /compact — Summarize conversation to save context
  • /cost — Show token usage

Tips

  • Use CLAUDE.md to give Claude project context
  • Add MCP servers for specialized tools
  • Claude remembers conversation until you /clear
  • Works best with specific, clear instructions