Claude Code Installation and Core Workflows: CLI / Desktop / VS Code / JetBrains Across All Platforms
Chapter 39: Claude Code Installation and Configuration: CLI, IDE Plugins, and Keyboard Shortcuts
39.1 What Is Claude Code
Claude Code is Anthropic's official command-line AI programming assistant. Unlike the Claude.ai web interface, Claude Code runs directly in your terminal and can read and write local files, execute bash commands, and manage git repositories — fundamentally, it's an AI Agent that can truly operate your codebase.
Core characteristics of Claude Code:
- Deep codebase understanding: indexes and analyzes entire project structures, not limited to pasted content
- Multi-step autonomous execution: independently completes multi-step tasks like "fix tests → commit code → push PR"
- Native tool integration: built-in file editing, bash execution, and git operations — no plugins needed
- MCP extension: integrates external tools and data sources via the MCP protocol
- IDE integration: supports VS Code and JetBrains series IDE plugins
The key distinction between Claude Code and Cursor/GitHub Copilot: it's an Agent, not a code completion tool. Claude Code doesn't just complete code as you type — it understands intent, forms plans, and autonomously executes multi-step operations.
39.2 Installing Claude Code
39.2.1 System Requirements
| Item | Requirement |
|---|---|
| OS | macOS 10.15+, Linux (Ubuntu 20.04+), Windows 10/11 (WSL2) |
| Node.js | 18.0 or higher |
| RAM | 8GB+ recommended |
| Disk | At least 500MB free |
| Network | Access to Anthropic API (api.anthropic.com) |
39.2.2 Installation
Method 1: Global npm install (recommended)
# Verify Node.js version
node --version # Requires >= 18.0.0
# Install Claude Code globally
npm install -g @anthropic-ai/claude-code
# Verify installation
claude --version
# Output: Claude Code 1.x.x
Method 2: Temporary run with npx (no global install)
npx @anthropic-ai/claude-code
Windows (WSL2):
# Open WSL2 in Windows Terminal
wsl
# Inside WSL2:
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
npm install -g @anthropic-ai/claude-code
39.2.3 Updating
npm update -g @anthropic-ai/claude-code
# or
npm install -g @anthropic-ai/claude-code@latest
39.3 API Key Configuration
39.3.1 Obtaining an API Key
- Visit
https://console.anthropic.com - Log in or create an account
- Navigate to "API Keys"
- Click "Create Key" with appropriate permissions
- Copy the generated key (starts with
sk-ant-)
Claude Code uses claude-sonnet-4-5 or claude-opus-4-5 models and consumes API tokens. Ensure your account has sufficient credits.
39.3.2 Configuring the API Key
Method 1: Environment variable (recommended)
# Add to ~/.bashrc or ~/.zshrc
export ANTHROPIC_API_KEY="sk-ant-api03-xxxxxxxxxxxx"
# Apply immediately
source ~/.zshrc
Method 2: Prompted on first run
claude
# If no API key is set, Claude Code automatically prompts:
# > Enter your Anthropic API key:
Method 3: Project-level .env file
echo "ANTHROPIC_API_KEY=sk-ant-api03-xxxxxxxxxxxx" >> .env
echo ".env" >> .gitignore # Never commit this
39.3.3 Connecting via Claude.ai Account
If you have a Claude.ai Pro subscription but no API account:
claude login
# Opens browser, guides through claude.ai login
# After login, Claude Code uses your Pro account permissions
39.4 Global Configuration File
Claude Code's global configuration is stored in ~/.claude.json:
{
"model": "claude-opus-4-5",
"smallFastModel": "claude-haiku-4-5",
"theme": "dark",
"verbose": false,
"maxFileSize": 10485760,
"ignorePatterns": [
"node_modules",
".git",
"dist",
"build",
"*.min.js",
"*.lock"
]
}
Key fields:
| Field | Description | Default |
|---|---|---|
model |
Primary model | claude-sonnet-4-5 |
smallFastModel |
Lightweight model for simple tasks | claude-haiku-4-5 |
theme |
Terminal color theme (dark/light/auto) | auto |
verbose |
Show detailed logs | false |
maxFileSize |
Max single file read size (bytes) | 10MB |
ignorePatterns |
Globally ignored file/directory patterns | see above |
Modify via CLI:
claude config set model claude-opus-4-5
claude config list
claude config get model
39.5 Project-Level Configuration: CLAUDE.md
CLAUDE.md is Claude Code's most important project-level configuration file, located in the project root. When Claude Code starts in a project directory, it automatically reads and follows all instructions in CLAUDE.md.
39.5.1 What CLAUDE.md Does
- Communicates project context: architecture, tech stack, special conventions
- Defines code standards: naming conventions, file organization, forbidden patterns
- Declares MCP tools: available MCP Servers and usage principles
- Specifies bash commands: test, build, and run commands
- Describes workflows: development flow, commit conventions, release process
39.5.2 Complete CLAUDE.md Example
# Project: TechBlog Platform
## Tech Stack
- Backend: Python 3.11, FastAPI, PostgreSQL 15, Redis
- Frontend: React 18, TypeScript, Tailwind CSS v3
- Infrastructure: Docker Compose (development), Kubernetes (production)
- Testing: pytest (backend), Vitest (frontend)
## Common Commands
### Development
```bash
# Start full development environment
docker compose up -d
# Run backend (dev mode)
cd backend && uvicorn app.main:app --reload --port 8000
# Run frontend
cd frontend && npm run dev
Testing
# Backend unit tests
cd backend && pytest tests/ -v
# Frontend tests
cd frontend && npm run test
Database
# Generate migration
cd backend && alembic revision --autogenerate -m "description"
# Apply migrations
cd backend && alembic upgrade head
Code Standards
Python
- Use Black formatting, line length 100
- All functions must have type annotations
- Use pydantic v2 models, not dicts
- Async functions preferred
TypeScript
- strict mode enabled, no
any - Functional components only (no classes)
- State management via Zustand, not Redux
Git Commits
Format: <type>(<scope>): <description>
- type: feat/fix/docs/style/refactor/test/chore
- scope: backend/frontend/infra/deps
- Example:
feat(backend): add user authentication endpoint
Critical Rules
- Never commit directly to main — all changes via PR
- Tests first: write tests before implementation
- Secrets: all sensitive values via environment variables, never in code
- Database migrations: always generate migration files after model changes
### 39.5.3 Hierarchical CLAUDE.md Inheritance
CLAUDE.md supports hierarchical inheritance — subdirectory files inherit from parent directories and can override specific settings:
project/ ├── CLAUDE.md # Global project configuration ├── backend/ │ └── CLAUDE.md # Backend-specific overrides └── frontend/ └── CLAUDE.md # Frontend-specific overrides
## 39.6 Slash Command System
Claude Code provides a rich set of slash commands — typed directly in the session, prefixed with `/`.
### 39.6.1 Core Slash Commands
**General commands**:
/help Show all available commands /clear Clear current session context history /exit or /quit Exit Claude Code /verbose Toggle verbose logging mode /model Show or switch the active model
**Version control commands**:
/commit Analyze unstaged changes, generate a commit message, and commit /pr Create a Pull Request /review-pr Review a Pull Request
**Project commands**:
/init Initialize Claude Code in the current directory (generates CLAUDE.md template) /status Show project status (git status, pending tasks, etc.) /summarize Generate a summary of the current project or file
**Debugging commands**:
/doctor Check Claude Code's configuration and environment /cost Show current session token usage and estimated cost /terminal-setup Configure terminal integration (macOS iTerm2, Ghostty, etc.)
### 39.6.2 The /commit Command in Detail
```bash
/commit
# Claude Code's execution flow:
# 1. Run git status to see changed files
# 2. Run git diff --staged for staged changes
# 3. Run git diff for unstaged changes
# 4. Analyze CLAUDE.md for commit conventions
# 5. Generate a convention-compliant commit message
# 6. Display for user confirmation
# 7. After confirmation: git add -A && git commit -m "..."
Example output:
$ /commit
Analyzing changes...
Files changed:
M src/api/auth.py
M tests/test_auth.py
A docs/authentication.md
Proposed commit message:
feat(backend): implement JWT refresh token rotation
- Add RefreshToken model with device tracking
- Implement token rotation on each refresh
- Add cleanup job for expired tokens
- Update authentication docs
Confirm? [Y/n]
39.6.3 The /review-pr Command in Detail
# Review a specific PR by number
/review-pr 123
# Review the PR for the current branch
/review-pr
# Review and generate a structured report
/review-pr 123 --format report
Default review coverage includes:
- Code logic correctness
- Potential bugs and edge cases
- Security vulnerabilities (SQL injection, XSS, etc.)
- Performance issues
- Code style consistency
- Test coverage
- Documentation completeness
39.7 IDE Plugin Integration
39.7.1 VS Code Integration
Installing the Claude Code VS Code plugin:
- Open VS Code
- Open the Extensions Marketplace (Ctrl+Shift+X / Cmd+Shift+X)
- Search "Claude Code"
- Install the official Anthropic plugin
Plugin capabilities:
- Claude Code conversation panel in the VS Code sidebar
- Right-click menu Claude Code options when code is selected
- Inline suggestions (similar to GitHub Copilot completions)
- Shared session with the CLI in the terminal panel
VS Code configuration (settings.json):
{
"claude-code.model": "claude-sonnet-4-5",
"claude-code.enableInlineSuggestions": true,
"claude-code.enableCodeLens": true,
"claude-code.contextLines": 50,
"claude-code.theme": "auto",
"claude-code.keybindings.openPanel": "ctrl+shift+a",
"claude-code.keybindings.explain": "ctrl+shift+e",
"claude-code.keybindings.fix": "ctrl+shift+f"
}
39.7.2 JetBrains Series Plugins
Supports IntelliJ IDEA, PyCharm, WebStorm, GoLand, and others:
- Go to File → Settings → Plugins (macOS: Preferences → Plugins)
- Search "Claude Code"
- Install the official plugin and restart the IDE
Default JetBrains shortcuts:
| Shortcut | Function |
|---|---|
| Alt+Shift+C | Open Claude Code panel |
| Alt+Shift+E | Explain selected code |
| Alt+Shift+F | Fix issues in selected code |
| Alt+Shift+T | Generate tests for selected code |
| Alt+Shift+D | Generate documentation for selected code |
39.8 Keyboard Shortcut System
39.8.1 In-Terminal Shortcuts
When running Claude Code in the terminal (REPL mode):
| Shortcut | Function |
|---|---|
Ctrl+C |
Interrupt current AI response |
Ctrl+D |
Exit Claude Code |
Ctrl+L |
Clear screen (without clearing context) |
↑ / ↓ |
Browse command history |
Tab |
Autocomplete commands and slash commands |
Ctrl+R |
Search command history |
Esc |
Cancel current input |
39.8.2 VS Code Shortcuts
Default shortcuts after installing the VS Code plugin:
| Shortcut | Function |
|---|---|
Ctrl+Shift+A / Cmd+Shift+A |
Open/close Claude Code sidebar |
Ctrl+Shift+E / Cmd+Shift+E |
Explain selected code |
Ctrl+Shift+F / Cmd+Shift+F |
Fix selected code |
Ctrl+Shift+T / Cmd+Shift+T |
Generate tests for selected code |
Ctrl+Shift+D / Cmd+Shift+D |
Generate documentation comments |
Custom keybindings (keybindings.json):
[
{
"key": "ctrl+alt+c",
"command": "claude-code.openPanel",
"when": "editorFocus"
},
{
"key": "ctrl+alt+r",
"command": "claude-code.reviewFile",
"when": "editorFocus"
},
{
"key": "ctrl+alt+t",
"command": "claude-code.generateTests",
"when": "editorTextFocus && editorHasSelection"
}
]
39.9 Hooks Configuration
Hooks are an advanced Claude Code feature that automatically execute custom scripts when specific events occur. These hooks are executed by the Claude Code process itself, not the AI model.
39.9.1 Configuring Hooks
Hooks are configured in ~/.claude/settings.json (global) or .claude/settings.json (project-level):
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "echo 'About to execute bash command:' && cat"
}
]
}
],
"PostToolUse": [
{
"matcher": "Write",
"hooks": [
{
"type": "command",
"command": "npx prettier --write \"$TOOL_ARG_PATH\" 2>/dev/null || true"
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "osascript -e 'display notification \"Task completed!\" with title \"Claude Code\"'"
}
]
}
]
}
}
39.9.2 Hook Event Types
| Event | When It Fires |
|---|---|
PreToolUse |
Before a tool call (can block execution) |
PostToolUse |
After a tool call completes |
Notification |
When Claude Code sends a notification |
Stop |
When the AI completes its task |
SubagentStop |
When a sub-agent completes |
39.9.3 Practical Hook Examples
Auto-format written code files:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write",
"hooks": [{
"type": "command",
"command": "npx prettier --write \"$TOOL_ARG_PATH\" 2>/dev/null || true"
}]
}
]
}
}
Safety check before dangerous commands:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [{
"type": "command",
"command": "if echo \"$TOOL_ARG_COMMAND\" | grep -qE '\\brm\\b|\\bdelete\\b|\\bdrop\\b'; then echo 'WARNING: Potentially destructive command detected'; fi"
}]
}
]
}
}
39.10 Proxy Configuration
In corporate environments or when network access requires a proxy:
export HTTPS_PROXY=http://proxy.company.com:8080
export HTTP_PROXY=http://proxy.company.com:8080
export NO_PROXY=localhost,127.0.0.1,.internal.company.com
Or configure in .claude.json:
{
"proxy": "http://proxy.company.com:8080"
}
Summary
This chapter provided a comprehensive introduction to Claude Code's installation, configuration system, and integration options. From npm installation to API key configuration, from CLAUDE.md project setup to Hooks automation, Claude Code offers a deeply customizable development workflow.
Key takeaways:
- CLAUDE.md is the cornerstone of project configuration — it tells Claude Code the project background, standards, and workflows
- Slash commands (/commit, /review-pr, etc.) dramatically simplify Git workflows
- VS Code and JetBrains plugins provide native IDE integration
- The Hooks mechanism enables custom automation before and after tool calls
- Global config (
~/.claude.json) and project config (.claude/settings.json) are managed in a layered hierarchy
The next chapter dives deep into Claude Code's core workflow: practical techniques for file editing, bash execution, and project navigation.