npm install -g @anthropic-ai/claude-code
claude --versionRequires Node.js 18+.
claude # interactive session
claude "your prompt" --print # one-shot, print and exit| Flag | Purpose |
|---|---|
--model claude-opus-4-6 |
Override model |
--print |
Non-interactive output |
--no-stream |
Disable streaming |
GitHub → Settings → Developer settings → Personal access tokens → Fine-grained tokens
| Permission | Level |
|---|---|
| Contents | Read and Write |
| Issues | Read and Write |
| Pull requests | Read and Write |
| Metadata | Read (auto) |
Run once in terminal. Replace YOUR_TOKEN with your PAT.
claude mcp add github -s user -e GITHUB_PERSONAL_ACCESS_TOKEN=YOUR_TOKEN -- npx -y @modelcontextprotocol/server-github
claude mcp add filesystem -s user -- npx -y @modelcontextprotocol/server-filesystem /your/work/directory
claude mcp add fetch -s user -- npx -y @modelcontextprotocol/server-fetchRestart Claude Code after adding servers.
/mcp
Lists all connected servers and tools. Ask Claude "list my GitHub repos" to confirm it's working.
| Command | What it does | When |
|---|---|---|
/compact |
Compress context, keep summary | Before starting a new task in a long session |
/clear |
Full context wipe | Switching to a completely different task |
/cost |
Show token usage | Check if context is getting full |
/mcp |
List connected MCP servers | Verify tools are loaded |
/model |
Show or switch model | Use faster model for simple tasks |
/memory |
View/edit memory files | Review what Claude has saved |
/help |
All commands | Reference |
| Package | Purpose |
|---|---|
@modelcontextprotocol/server-postgres |
Query PostgreSQL |
@modelcontextprotocol/server-brave-search |
Web search |
@modelcontextprotocol/server-slack |
Slack messages |
Browse all: https://github.com/modelcontextprotocol/servers
| File | Purpose |
|---|---|
~/.claude.json |
MCP servers, API key, global defaults |
~/.claude/settings.json |
Auto-approve, theme, model |
~/.claude/skills/ |
Custom slash commands |
CLAUDE.md (project root) |
Project instructions — loaded every session |
{
"theme": "dark",
"model": "claude-sonnet-4-6",
"autoApprove": ["read", "glob", "grep", "bash(git *)"]
}Put a CLAUDE.md in your project root. Claude reads it at session start every time — use it for rules, stack info, and anything you'd otherwise repeat every session.
Claude auto-saves context across sessions at ~/.claude/projects/<hash>/memory/.
| Type | Stores |
|---|---|
| user | Your role, preferences, background |
| feedback | Corrections and confirmed approaches |
| project | Ongoing work, decisions, deadlines |
| reference | Where to find things (dashboards, trackers) |
Create ~/.claude/skills/my-skill.md:
---
name: my-skill
description: What it does
---
Steps for Claude to follow when invoked.Invoke with /my-skill or /my-skill some args.
- Be specific upfront — "update the README, remove X, add Y" beats "update the readme" every time
- Number your tasks — list 5 things as 1–5, not a paragraph; Claude tracks them in order
- Correct immediately — don't let a wrong direction run for 3 messages
- Use
/compactproactively — after finishing a big task, before starting the next one - Multi-task in one message — Claude runs independent tasks in parallel, saves round trips
- Use CLAUDE.md for rules — if you say the same thing every session, put it there instead
| Shortcut | Action |
|---|---|
Esc |
Cancel current operation |
Ctrl+C |
Exit |
↑ / ↓ |
Navigate history |
Shift+Enter |
New line in prompt |