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-codeStep 2: Authenticate
Option A: OAuth via Claude Max (recommended)
claude loginThis opens a browser for OAuth authentication. Uses your Claude Max subscription — no per-token billing.
Credentials stored in ~/.claude/.credentials.json.
Option B: API Key
export ANTHROPIC_API_KEY="your-api-key"Pay-per-token via Anthropic API.
Step 3: Run
# Interactive mode
claude
# With initial prompt
claude "explain this code"
# In specific directory
claude --cwd /path/to/projectConfiguration
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 committingClaude 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/
├── .credentials.json # OAuth tokens (if using claude login)
├── 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.mdto give Claude project context - Add MCP servers for specialized tools
- Claude remembers conversation until you
/clear - Works best with specific, clear instructions