← Home

Claude Code Cheat Sheet

EN KO

Installation & Quick Start

Installation

npm Installnpm install -g @anthropic-ai/claude-code
Runclaude
Updatenpm update -g @anthropic-ai/claude-code
Versionclaude --version
Requires Node.js 18+. First run requires Anthropic account authentication.

Authentication

Login/login
Logout/logout
Use API KeyANTHROPIC_API_KEY=sk-xxx claude
Account Status/status
Get API key from Anthropic Console, or use Claude Pro/Max subscription.

Basic Usage

Interactive Mode

Startclaude
Specific Directoryclaude /path/to/project
Continue Lastclaude -c
Select Historyclaude -r

One-liner Mode

Single Commandclaude -p "Write tests"
JSON Outputclaude -p "..." --output-format json
Pipe Inputcat file.ts | claude -p "Review this"
Streamingclaude -p "..." --output-format stream-json

Output Format

textDefault text output
jsonJSON format (after completion)
stream-jsonReal-time JSON stream

Permission Mode

--allowedToolsAllow specific tools only
--disallowedToolsBlock specific tools
--dangerouslySkipPermissionsSkip all permission checks
Use --dangerouslySkipPermissions only in trusted environments!

Slash Commands

Session Management

/clearClear conversation
/compactSummarize and compress context
/statusCheck account & session status
/costCheck current session cost

Work Commands

/initCreate CLAUDE.md project file
/add-dir <path>Add working directory
/modelChange model
/permissionsManage permission settings

File & Context

/contextView current context files
/memoryEdit CLAUDE.md memory file
/reviewRequest code review
/pr-commentsHandle PR comments

System

/helpShow help
/configOpen settings
/bugSubmit bug report
/doctorDiagnose installation
/quitExit Claude Code

MCP Commands

/mcpCheck MCP server status
/install-github-appInstall GitHub app
/ideIDE integration settings
/terminal-setupTerminal setup helper

Developer Tools

/vimToggle Vim mode
/diffChange diff view mode
/themeChange theme

Keyboard Shortcuts

Input & Navigation

ShortcutDescriptionShortcutDescription
EnterSend message Ctrl+LClear screen
Shift+EnterNew line Ctrl+RSearch history
Ctrl+CCancel current operation Ctrl+UDelete entire line
Ctrl+DEnd session Ctrl+KDelete to end of line
/ Previous/Next message TabAutocomplete
EscCancel current input
ShortcutDescriptionShortcutDescription
ReturnSend message +KClear screen
+ReturnNew line +RSearch history
+CCancel current operation +UDelete entire line
+DEnd session +KDelete to end of line
/ Previous/Next message TabAutocomplete
EscCancel current input
ShortcutDescriptionShortcutDescription
EnterSend message Ctrl+LClear screen
Shift+EnterNew line Ctrl+RSearch history
Ctrl+CCancel current operation Ctrl+UDelete entire line
Ctrl+DEnd session Ctrl+KDelete to end of line
/ Previous/Next message TabAutocomplete
EscCancel current input

Permission Response

yAllow this time
nDeny
aAlways allow (session)
!Allow once, no retry

Vim Mode (when enabled)

iInsert mode
EscNormal mode
vVisual mode
:Command mode
Toggle Vim mode with /vim command.

CLI Options

Main CLI Flags

OptionShortDescription
--print-pRun single prompt in non-interactive mode
--continue-cContinue most recent conversation
--resume-rResume previous conversation with selector
--model-mSpecify model (e.g., claude-sonnet-4-20250514)
--output-formatOutput format: text, json, stream-json
--max-turnsMax turns limit in non-interactive mode
--system-promptCustom system prompt
--allowedToolsAllowed tools (comma-separated)
--disallowedToolsDisallowed tools (comma-separated)
--permission-modePermission mode: default, plan, bypassPermissions
--dangerously-skip-permissions⚠️ Skip all permission checks
--verboseVerbose logging

Configuration

Config File Paths

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
Priority: Local > Project > Global. Add local settings to .gitignore.

Config Example

{ "model": "claude-sonnet-4-20250514", "permissions": { "allow": ["Bash(*)", "Read(*)", "Write(*)"], "deny": [] } }

Environment Variables

ANTHROPIC_API_KEYSet API key
CLAUDE_MODELSet default model
CLAUDE_CONFIG_DIRConfig directory path
HTTP_PROXYProxy server

Permission Patterns

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__toolAllow specific MCP tool

Skills

What are Skills?

DefinitionCustom commands that extend Claude via SKILL.md files
InvocationInvoke with /skill-name or Claude applies automatically
ComponentsYAML frontmatter + markdown instructions
Supporting filesCan include templates, examples, scripts
Skills extend Claude capabilities. Create SKILL.md with instructions, Claude adds it to its toolkit.

Skill Locations

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
Each skill is a directory with SKILL.md as the entrypoint. Supports templates, examples, and scripts.

SKILL.md Frontmatter

nameSkill name (becomes /slash-command)
descriptionDescription for when Claude should apply
disable-model-invocationIf true, only user can invoke (no auto)
user-invocableIf false, hidden from / menu
allowed-toolsTools allowed when skill is active
contextfork: run in subagent
agentAgent type (Explore, Plan, etc.)

Skill Example

# 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

Skill Invocation

Direct invoke/skill-name or /skill-name args
Auto applyClaude auto-loads when description matches
$ARGUMENTSSubstitutes arguments passed at invocation
!`command`Run shell command, insert output

Skills vs Commands

Slash commandsSingle .md file, /... autocomplete in terminal
SkillsDirectory structure, supporting files, Claude auto-apply
Compatibility.claude/commands/ files still work
PrioritySkills take precedence over same-name commands

MCP Servers

MCP Config File

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
MCP (Model Context Protocol) servers extend Claude Code functionality.

MCP Config Example

{ "mcpServers": { "github": { "command": "npx", "args": ["-y", "@anthropic-ai/mcp-server-github"], "env": { "GITHUB_TOKEN": "${GITHUB_TOKEN}" } } } }

Popular MCP Servers

server-githubGitHub API integration
server-filesystemExtended filesystem access
server-postgresPostgreSQL database
server-puppeteerBrowser automation
server-slackSlack integration

MCP Commands

/mcpList connected MCP servers
claude mcp addAdd MCP server
claude mcp removeRemove MCP server
claude mcp listList configured servers

Hooks

Hook Events

PreToolUseBefore tool execution
PostToolUseAfter tool execution
NotificationOn notification
StopOn Claude response completion

Hook Config Example

{ "hooks": { "PostToolUse": [{ "matcher": "Write", "hooks": [{ "type": "command", "command": "npm run lint --fix $CLAUDE_FILE_PATH" }] }] } }

Hook Environment Variables

$CLAUDE_TOOL_NAMECurrent tool name
$CLAUDE_TOOL_INPUTTool input (JSON)
$CLAUDE_FILE_PATHTarget file path
$CLAUDE_FILE_CONTENTFile content

Hook Response

Exit 0Success, continue
Exit 2Block tool execution
stdout JSONSend feedback to Claude
Output {"decision": "block", "reason": "reason"} to block tool execution.

Memory (CLAUDE.md)

CLAUDE.md Paths

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
Use /init command to create project CLAUDE.md.

CLAUDE.md Example

# 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 Commands

/memoryEdit memory file
/initCreate project CLAUDE.md
"Remember this"Claude saves to CLAUDE.md

Memory Priority

Priority 1Current directory CLAUDE.md
Priority 2Parent directory CLAUDE.md
Priority 3Home directory CLAUDE.md
MergeAll file contents are merged

Tips & Tricks

Effective Prompts

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"

Common Workflows

# Bug Fixing "Fix this error: [error message]" # Code Review "Review this PR and suggest improvements" # Write Tests "Write unit tests for this function"

Productivity Tips

Attach imagesDrag and drop screenshots
Share URLEnter webpage URL directly
Compress context/compact to save tokens
Continue chatclaude -c for quick resume

Troubleshooting

Auth error/logout then login again
Slow response/compact to clean context
MCP error/mcp to check server status
Config issue/doctor to diagnose

CI/CD Integration

# 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 }}

Security Best Practices

API keyUse environment variables only
Sensitive filesExclude .env, credentials
Review permissionsVerify commands before allowing
Local settingsUse settings.local.json