Claude Code
Claude Code is Anthropic’s official CLI for Claude. It runs in your terminal and acts as an AI coding agent — reading, editing, and running code in your project with your approval.
Installation
npm install -g @anthropic-ai/claude-codeStarting a session
claude # interactive session in current directory
claude "fix the failing tests" # one-shot commandKey concepts
CLAUDE.md — project instructions file read at session start. Place one in the repo root to give Claude persistent context about the codebase, conventions, and commands.
Brain files — extended context documents (e.g. in brain/) referenced from CLAUDE.md with architecture, commands, and content guides.
MCP servers — Model Context Protocol servers extend Claude Code with external tools. Configure them in ~/.claude/mcp.json.
Skills — reusable prompt workflows stored in ~/.claude/skills/ and invoked with /skill-name. See Skills.
Memory — persistent notes stored in ~/.claude/projects/<path>/memory/ and loaded automatically across sessions.
Configuration
| File | Purpose |
|---|---|
~/.claude/settings.json | Global settings, hooks, and permissions |
~/.claude/mcp.json | MCP server definitions |
~/.claude/skills/ | Custom skill files |
CLAUDE.md (project root) | Per-project instructions |
Useful slash commands
| Command | Description |
|---|---|
/clear | Clear conversation context |
/compact | Compress conversation to save tokens |
/cost | Show token usage for the session |
/help | List all available commands |
/memory | View or edit persistent memory |
Hooks
Hooks are shell commands that run automatically on events (tool calls, session start/end). Configure them in settings.json under hooks. Useful for auto-formatting, linting, or logging.
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit",
"hooks": [{ "type": "command", "command": "prettier --write $FILE" }]
}
]
}
}Tips
- Prefix a shell command with
!to run it directly in the session and include output in context - Use
/compactbefore starting a large task to free up context - Put frequently needed commands (build, test, lint) in
CLAUDE.mdso Claude can run them without asking