Last updated: 2025-08-18
Claude Code is Anthropic’s agentic coding tool that lives in your terminal and for now is SOTA for coding. This cheatsheet should give you everything you need to install, config, and use Claude Code for now…
Getting started with Claude code
Once you have a Claude Pro or Max subscription (or are paying for API access), you can start using Claude Code from your terminal.
(Our advice: opt for the subscription if you’re using it consistently and at a reasonable rate. It’s worth getting API tokens if you don’t want to deal with token refresh windows).
Installation
Install globally:
npm install -g @anthropic-ai/claude-code
Prereqs: Node.js 18 or newer
Auth
Set up your Anthropic API key before launching CC.
Get your key: Get an API key from the Anthropic Console.
Set your key: Set the ANTHROPIC_API_KEY
env var:
export ANTHROPIC_API_KEY="YOUR_ANTHROPIC_API_KEY"
Alternatively, if you have a Pro or Max plan, you’ll have the option to auth via your browser.
Add this to your shell profile (e.g., ~/.bashrc
, ~/.zshrc
) to persist across sessions.
Basic usage
Interactive mode (REPL): Start a conversational coding session.
claude
REPL with initial prompt: Start with a specific question.
claude "explain this project"
Print mode: Query once and exit (great for scripting).
claude -p "explain this function"
Piping content: Process piped input.
cat logs.txt | claude -p "explain these errors"
Continue recent conversation:
claude -c
Resume specific session:
claude -r "session-id" "continue working on this feature"
Config
You’re able to write (or generate) files to configure CC’s basic behaviors.
Settings files
Claude Code uses hierarchical settings stored in JSON files:
- User settings:
~/.claude/settings.json
(applies to all projects) - Project settings:
.claude/settings.json
(shared with team, checked into git) - Local project settings:
.claude/settings.local.json
(personal, ignored by git)
Example settings.json:
{
"model": "claude-sonnet-4-20250514",
"maxTokens": 4096,
"permissions": {
"allowedTools": ["Read", "Write", "Bash(git *)"],
"deny": [
"Read(./.env)",
"Read(./.env.*)",
"Write(./production.config.*)"
]
},
"hooks": {
"PostToolUse": [
{
"matcher": "Write(*.py)",
"hooks": [
{
"type": "command",
"command": "python -m black $file"
}
]
}
]
}
}
Memory files (CLAUDE.md)
Use CLAUDE.md
files to give context and instructions to Claude. They save time + tokens, and are super helpful for info you’d otherwise include in your prompts. These are loaded hierarchically:
- Global:
~/.claude/CLAUDE.md
(applies to all projects) - Project root:
./CLAUDE.md
(project-wide context) - Subdirectories: Component-specific instructions
Example CLAUDE.md:
# Project context
## Coding standards
- Use TypeScript for all new code
- Follow existing ESLint configuration
- Write tests for all new functions using Jest
- Use functional components with hooks in React
## Architecture
- Frontend: Next.js with TypeScript
- Backend: Node.js with Express
- Database: PostgreSQL with Prisma
- State: Zustand for client state
## File organization
- Components in `src/components/`
- Utilities in `src/utils/`
- Tests alongside source files with `.test.ts` extension
CLI commands + flags
You can use the following shell commands outside a Claude session.
Core commands
Command | Description | Example |
---|---|---|
claude |
Start interactive REPL | claude |
claude "query" |
Start REPL with initial prompt | claude "explain this project" |
claude -p "query" |
Query via print mode, then exit | claude -p "review this code" |
claude -c |
Continue most recent conversation | claude -c |
claude -c -p "query" |
Continue in print mode | claude -c -p "run the tests" |
claude -r "id" "query" |
Resume session by ID | claude -r "abc123" "finish the PR" |
claude update |
Update to latest version | claude update |
claude mcp |
Configure MCP servers | claude mcp add server-name |
CLI flags
Flag | Description | Example |
---|---|---|
--add-dir |
Add additional working directories | claude --add-dir ../apps ../lib |
--allowedTools |
Allow specific tools without prompting | claude --allowedTools "Write" "Bash(git *)" |
--disallowedTools |
Block specific tools | claude --disallowedTools "Bash(rm *)" |
--model |
Use specific Claude model | claude --model claude-opus-4 |
--max-turns |
Limit conversation turns | claude -p --max-turns 3 "query" |
--output-format |
Set output format (text/json/stream-json) | claude -p --output-format json "query" |
--input-format |
Set input format | claude -p --input-format stream-json |
--verbose |
Enable verbose logging | claude --verbose |
--continue |
Continue most recent conversation | claude --continue |
--resume |
Resume specific session | claude --resume abc123 |
--dangerously-skip-permissions |
Skip all permission prompts (proceed with caution) | claude --dangerously-skip-permissions |
Interactive session commands
You can use these slash commands during a Claude Code session.
Built-in slash commands
Command | Description |
---|---|
/help |
Show all commands + custom slash commands |
/config |
Configure Claude Code settings interactively |
/allowed-tools |
Configure tool permissions interactively |
/hooks |
Configure hooks |
/mcp |
Manage MCP servers |
/agents |
Manage subagents (create, edit, list) |
/vim |
Enable vim-style editing mode |
/terminal-setup |
Install terminal shortcuts (Shift+Enter for iTerm2/VS Code) |
/install-github-app |
Set up GitHub Actions integration |
Note: The /help
command shows all available slash commands, including your custom commands from .claude/commands/
and ~/.claude/commands/
directories, as well as any commands you have from connected MCP servers.
File and directory references (@)
You can reference files or directories in your prompts. (If you don’t have an exact filename/location, CC can grep for it).
Single file:
> Review this component for accessibility issues. @./src/components/Button.tsx
Directory (recursive):
> Add comprehensive error handling to all API routes. @./src/api/
Multiple files:
> Compare these two implementations. @./src/old.js @./src/new.js
Glob patterns:
> Review all test files for completeness. @./src/**/*.test.ts
Shell commands (!)
You can run shell commands directly in a Claude session. Use the !
to bypass Claude’s conversational mode, which will use more tokens to get the same result:
Single command:
> !npm test
Shell mode toggle:
> !
# Now in shell mode. type ! again to exit
Advanced features
We appreciate how customizable CC is, and it’s quite easy to extend it with a few features like custom commands, hooks, MCP, and stored prompts.
Custom slash commands
You can create your own CC slash commands. This is a good “shortcut” for pulling up a common prompt. Again, the more context the better (but also keep these abstract so they can be widely applied). Define them in Markdown files:
Project commands (.claude/commands/
):
# Create a project-specific command
mkdir -p .claude/commands
echo "Analyze this code for performance issues and suggest optimizations:" > .claude/commands/optimize.md
Personal commands (~/.claude/commands/
):
# Create a personal command for all projects
mkdir -p ~/.claude/commands
echo "Review this code for security vulnerabilities:" > ~/.claude/commands/security.md
Commands with arguments:
# Create parameterized command
echo 'Fix issue #$ARGUMENTS following our coding standards' > .claude/commands/fix-issue.md
# Use that command in a Claude session
> /fix-issue 123
Advanced command with context:
---
allowed-tools: Bash(git add:*), Bash(git status:*), Bash(git commit:*)
description: Create a git commit with context
---
## Context
- Current status: !`git status`
- Current diff: !`git diff HEAD`
- Current branch: !`git branch --show-current`
Create a meaningful commit message based on the changes above.
Hooks for automation
Hooks run shell commands automatically after specific prompts/events:
Example: Auto-format Python files
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write(*.py)",
"hooks": [
{
"type": "command",
"command": "python -m black \"$file\""
}
]
}
]
}
}
Hook events:
PreToolUse
: Before tool execution (can block)PostToolUse
: After tool executionUserPromptSubmit
: Before processing user inputSessionStart
: At session startup
Model Context Protocol (MCP)
You can extend what Claude Code can do by adding MCP servers:
Add MCP server:
claude mcp add my-server -e API_KEY=123 -- /path/to/server arg1 arg2
(Check your MCP tool’s docs to get the right syntax here.)
Common MCP use cases:
- Connect to Google Drive for design docs
- Integrate with Jira for ticket management
- Add custom dev tooling
- Access external databases
Conversation management
Continue recent work:
claude --continue
claude --continue --print "show me our progress"
Resume specific session:
claude --resume # Shows picker
claude --resume session-id
Save and restore context: All CC conversations are auto-saved with full message history and tool state.
Common workflows
Here are a few different tasks that CC can help with. Remember, the more context, the better, so if you can provide specifics around your ask, Claude will give better results (and you’ll have fewer things to correct).
Code analysis
> Analyze this codebase structure and suggest improvements. @./src/
Feature development
> Implement a user auth system with JWT tokens and password hashing
Bug fixing
> Debug this error: "TypeError: Cannot read property 'id' of undefined" @./src/user-service.js
Code review
> Review this pull request for potential issues, performance problems, and adherence to our coding standards. @./src/
Testing
> Generate comprehensive unit tests for this utility module. @./src/utils/validation.js
Refactoring
> Refactor this class to use dependency injection and make it more testable. @./src/services/EmailService.js
Docs
> Generate API docs for all endpoints in this directory. @./src/routes/
CI/CD integration
# In GitHub Actions or other CI
claude -p "If there are any linting errors, fix them and suggest a commit message"
Security + permissions
Claude Code defaults to asking permission for every single action it takes. If you trust it for a certain type of action (e.g. fetching links, reading files), you can grant it wider permissions. Most devs approve actions individually.
Permission system
Claude Code lets you grant permissions as you see fit:
Tool permissions:
Read
: File reading operationsWrite
: File writing/modificationBash
: Shell command executionMCP tools
: External integrations
Configuration examples:
{
"permissions": {
"allowedTools": [
"Read",
"Write(src/**)",
"Bash(git *)",
"Bash(npm *)"
],
"deny": [
"Read(.env*)",
"Write(production.config.*)",
"Bash(rm *)",
"Bash(sudo *)"
]
}
}
Best practices
As with anything in dev, keep an eye on what permissions you’re granting, and watch which shell commands are being run. Also:
- ALWAYS review changes before accepting
- Use
.claude/settings.local.json
for personal/sensitive settings - Configure tool permissions for your env; verify everything (don’t use YOLO mode unless you’ve put the proper safeguards in place)
- Use hooks for auto code formatting/validation
- Keep sensitive data in
.env
files; deny CC permission to these
Understanding Claude’s session model
If you want to best plan out your Claude sessions, you’ll want to understand your constraints. Claude’s tokens are granted by plan based on overall server load, so on busier days you’ll get fewer.
If you’re not using the API for pay-as-you-go Claude access, you’ll want to choose the Claude tier that works best for you.
- Pro: for a medium-high coding workload. Expect to use continuously for smaller code changes, and as a supplement to your own coding. $20/month
- Max5: for an intense coding workload. 5x the token allowance of Pro. Opus access. $100/month
- Max20: for near-autonomous, nonstop, heavy development workloads with multiple sessions/agents. Significantly larger context window. 20x the token allowance of Pro. Opus access. $200/month
Sessions kick off as soon as you send your first message, and last five hours. If you’re using Opus, you’ll burn through tokens much faster.
It’s most token-efficient (and guarantees better outputs) if you start different sessions for different tasks.
Extra resources
- Claude has built-in access to its own docs: you can ask questions about features directly
- Check out the official docs
- Use
/help
in your Claude session
Need to take CC to the next level? Give your AI agents ephemeral environments where they can deploy code, pull logs, and fix bugs autonomously. Try Shipyard free for 30 days.