| npm Install | npm install -g @anthropic-ai/claude-code |
| Run | claude |
| Update | npm update -g @anthropic-ai/claude-code |
| Version | claude --version |
| Login | /login |
| Logout | /logout |
| Use API Key | ANTHROPIC_API_KEY=sk-xxx claude |
| Account Status | /status |
| Start | claude |
| Specific Directory | claude /path/to/project |
| Continue Last | claude -c |
| Select History | claude -r |
| Single Command | claude -p "Write tests" |
| JSON Output | claude -p "..." --output-format json |
| Pipe Input | cat file.ts | claude -p "Review this" |
| Streaming | claude -p "..." --output-format stream-json |
text | Default text output |
json | JSON format (after completion) |
stream-json | Real-time JSON stream |
--allowedTools | Allow specific tools only |
--disallowedTools | Block specific tools |
--dangerouslySkipPermissions | Skip all permission checks |
/clear | Clear conversation |
/compact | Summarize and compress context |
/status | Check account & session status |
/cost | Check current session cost |
/init | Create CLAUDE.md project file |
/add-dir <path> | Add working directory |
/model | Change model |
/permissions | Manage permission settings |
/context | View current context files |
/memory | Edit CLAUDE.md memory file |
/review | Request code review |
/pr-comments | Handle PR comments |
/help | Show help |
/config | Open settings |
/bug | Submit bug report |
/doctor | Diagnose installation |
/quit | Exit Claude Code |
/mcp | Check MCP server status |
/install-github-app | Install GitHub app |
/ide | IDE integration settings |
/terminal-setup | Terminal setup helper |
/vim | Toggle Vim mode |
/diff | Change diff view mode |
/theme | Change theme |
| Shortcut | Description | Shortcut | Description |
|---|---|---|---|
| Enter | Send message | Ctrl+L | Clear screen |
| Shift+Enter | New line | Ctrl+R | Search history |
| Ctrl+C | Cancel current operation | Ctrl+U | Delete entire line |
| Ctrl+D | End session | Ctrl+K | Delete to end of line |
| ↑ / ↓ | Previous/Next message | Tab | Autocomplete |
| Esc | Cancel current input |
| Shortcut | Description | Shortcut | Description |
|---|---|---|---|
| Return | Send message | ⌘+K | Clear screen |
| ⇧+Return | New line | ⌃+R | Search history |
| ⌃+C | Cancel current operation | ⌃+U | Delete entire line |
| ⌃+D | End session | ⌃+K | Delete to end of line |
| ↑ / ↓ | Previous/Next message | Tab | Autocomplete |
| Esc | Cancel current input |
| Shortcut | Description | Shortcut | Description |
|---|---|---|---|
| Enter | Send message | Ctrl+L | Clear screen |
| Shift+Enter | New line | Ctrl+R | Search history |
| Ctrl+C | Cancel current operation | Ctrl+U | Delete entire line |
| Ctrl+D | End session | Ctrl+K | Delete to end of line |
| ↑ / ↓ | Previous/Next message | Tab | Autocomplete |
| Esc | Cancel current input |
| y | Allow this time |
| n | Deny |
| a | Always allow (session) |
| ! | Allow once, no retry |
| i | Insert mode |
| Esc | Normal mode |
| v | Visual mode |
| : | Command mode |
| Option | Short | Description |
|---|---|---|
--print | -p | Run single prompt in non-interactive mode |
--continue | -c | Continue most recent conversation |
--resume | -r | Resume previous conversation with selector |
--model | -m | Specify model (e.g., claude-sonnet-4-20250514) |
--output-format | Output format: text, json, stream-json | |
--max-turns | Max turns limit in non-interactive mode | |
--system-prompt | Custom system prompt | |
--allowedTools | Allowed tools (comma-separated) | |
--disallowedTools | Disallowed tools (comma-separated) | |
--permission-mode | Permission mode: default, plan, bypassPermissions | |
--dangerously-skip-permissions | ⚠️ Skip all permission checks | |
--verbose | Verbose logging |
| Global Settings | %USERPROFILE%\.claude\settings.json |
| Project Settings | .claude\settings.json |
| Local Settings | .claude\settings.local.json |
| Global Settings | ~/.claude/settings.json |
| Project Settings | .claude/settings.json |
| Local Settings | .claude/settings.local.json |
| Global Settings | ~/.claude/settings.json |
| Project Settings | .claude/settings.json |
| Local Settings | .claude/settings.local.json |
{
"model": "claude-sonnet-4-20250514",
"permissions": {
"allow": ["Bash(*)", "Read(*)", "Write(*)"],
"deny": []
}
}ANTHROPIC_API_KEY | Set API key |
CLAUDE_MODEL | Set default model |
CLAUDE_CONFIG_DIR | Config directory path |
HTTP_PROXY | Proxy server |
Bash(*) | Allow all Bash commands |
Bash(npm:*) | Allow npm commands only |
Read(*) | Allow all file reads |
Write(src/*) | Allow write to src/ only |
mcp__server__tool | Allow specific MCP tool |
| Definition | Custom commands that extend Claude via SKILL.md files |
| Invocation | Invoke with /skill-name or Claude applies automatically |
| Components | YAML frontmatter + markdown instructions |
| Supporting files | Can include templates, examples, scripts |
| Global Skills | %USERPROFILE%\.claude\skills\<name>\SKILL.md |
| Project Skills | .claude\skills\<name>\SKILL.md |
| Global Skills | ~/.claude/skills/<name>/SKILL.md |
| Project Skills | .claude/skills/<name>/SKILL.md |
| Global Skills | ~/.claude/skills/<name>/SKILL.md |
| Project Skills | .claude/skills/<name>/SKILL.md |
name | Skill name (becomes /slash-command) |
description | Description for when Claude should apply |
disable-model-invocation | If true, only user can invoke (no auto) |
user-invocable | If false, hidden from / menu |
allowed-tools | Tools allowed when skill is active |
context | fork: run in subagent |
agent | Agent type (Explore, Plan, etc.) |
# Skill directory structure
~/.claude/skills/my-skill/
├── SKILL.md # Required: main instructions
├── template.md # Optional: template
└── scripts/
└── helper.py # Optional: script
# SKILL.md example
---
name: code-review
description: Review code and provide feedback
disable-model-invocation: false
allowed-tools: Read, Grep
---
Review the code changes:
1. Check code quality
2. Find bugs/issues
3. Suggest improvements| Direct invoke | /skill-name or /skill-name args |
| Auto apply | Claude auto-loads when description matches |
$ARGUMENTS | Substitutes arguments passed at invocation |
!`command` | Run shell command, insert output |
| Slash commands | Single .md file, /... autocomplete in terminal |
| Skills | Directory structure, supporting files, Claude auto-apply |
| Compatibility | .claude/commands/ files still work |
| Priority | Skills take precedence over same-name commands |
| Global | %USERPROFILE%\.claude\mcp_servers.json |
| Project | .claude\mcp_servers.json |
| Global | ~/.claude/mcp_servers.json |
| Project | .claude/mcp_servers.json |
| Global | ~/.claude/mcp_servers.json |
| Project | .claude/mcp_servers.json |
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@anthropic-ai/mcp-server-github"],
"env": { "GITHUB_TOKEN": "${GITHUB_TOKEN}" }
}
}
}server-github | GitHub API integration |
server-filesystem | Extended filesystem access |
server-postgres | PostgreSQL database |
server-puppeteer | Browser automation |
server-slack | Slack integration |
/mcp | List connected MCP servers |
claude mcp add | Add MCP server |
claude mcp remove | Remove MCP server |
claude mcp list | List configured servers |
PreToolUse | Before tool execution |
PostToolUse | After tool execution |
Notification | On notification |
Stop | On Claude response completion |
{
"hooks": {
"PostToolUse": [{
"matcher": "Write",
"hooks": [{
"type": "command",
"command": "npm run lint --fix $CLAUDE_FILE_PATH"
}]
}]
}
}$CLAUDE_TOOL_NAME | Current tool name |
$CLAUDE_TOOL_INPUT | Tool input (JSON) |
$CLAUDE_FILE_PATH | Target file path |
$CLAUDE_FILE_CONTENT | File content |
| Exit 0 | Success, continue |
| Exit 2 | Block tool execution |
| stdout JSON | Send feedback to Claude |
| Project Root | .\CLAUDE.md |
| Global | %USERPROFILE%\.claude\CLAUDE.md |
| Local (gitignore) | .\CLAUDE.local.md |
| Project Root | ./CLAUDE.md |
| Global | ~/.claude/CLAUDE.md |
| Local (gitignore) | ./CLAUDE.local.md |
| Project Root | ./CLAUDE.md |
| Global | ~/.claude/CLAUDE.md |
| Local (gitignore) | ./CLAUDE.local.md |
# Project Overview
This is a React + TypeScript web application.
## Build Commands
- Development: `npm run dev`
- Test: `npm run test`
## Notes
- Do not modify .env file/memory | Edit memory file |
/init | Create project CLAUDE.md |
| "Remember this" | Claude saves to CLAUDE.md |
| Priority 1 | Current directory CLAUDE.md |
| Priority 2 | Parent directory CLAUDE.md |
| Priority 3 | Home directory CLAUDE.md |
| Merge | All file contents are merged |
| Be specific | "Add error handling to login function" |
| Specify file | "Modify src/auth.ts file" |
| Step by step | "1. First analyze 2. Then fix" |
| Provide context | "This is an Express server" |
# Bug Fixing
"Fix this error: [error message]"
# Code Review
"Review this PR and suggest improvements"
# Write Tests
"Write unit tests for this function"| Attach images | Drag and drop screenshots |
| Share URL | Enter webpage URL directly |
| Compress context | /compact to save tokens |
| Continue chat | claude -c for quick resume |
| Auth error | /logout then login again |
| Slow response | /compact to clean context |
| MCP error | /mcp to check server status |
| Config issue | /doctor to diagnose |
# GitHub Actions Example
- name: Claude Code Review
run: |
npm i -g @anthropic-ai/claude-code
claude -p "Review this PR" --output-format json
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_KEY }}| API key | Use environment variables only |
| Sensitive files | Exclude .env, credentials |
| Review permissions | Verify commands before allowing |
| Local settings | Use settings.local.json |