Claude Code Commands
Terminal commands and slash commands for Claude Code sessions. Verify with claude --help on your installed version.
Last reviewed: June 2026
Full guide: Claude Code · Commands change between releases.
CLI launch
| Command | Purpose |
|---|---|
claude | Start interactive session in cwd |
claude -p "prompt" | Print mode — single response, exit |
claude --continue | Resume last conversation |
claude --model <id> | Override model for session |
claude --help | List flags for your version |
In-session slash commands
Commands vary by version. Common ones (confirm in-app with /help):
| Command | Purpose |
|---|---|
/help | List available slash commands |
/clear | Clear conversation context |
/compact | Summarize context to free tokens |
/cost | Show session token usage (if enabled) |
/model | Switch model mid-session |
/memory | View or edit project memory (if enabled) |
/init | Generate CLAUDE.md from repo (if enabled) |
Prompt patterns
| Task | Example |
|---|---|
| Scoped fix | Fix the failing test in src/foo.test.ts only. Run npm test after. |
| Plan first | Propose a plan only — do not edit files yet. |
| Review | Review git diff against main for security issues. Checklist format. |
| Commit | Stage only src/lib/foo.ts and write a Conventional Commit message. |
See Prompting for Code and AI Prompting.
Project files
| File | Purpose |
|---|---|
CLAUDE.md | Project instructions (Claude Code reads at start) |
AGENTS.md | Often read by Claude Code and other agents |
.claude/settings.json | Hooks, MCP servers, permissions |
Mirror stack/commands from AGENTS.md Template.
Hooks (settings.json)
| Hook | Use |
|---|---|
before_file_write | Block protected paths |
after_file_write | Run linter |
| Custom scripts | Audit log agent edits |
Example pattern in Claude Code guide.
MCP
Add mcpServers to Claude Code settings — same JSON shape as MCP Config Cheat Sheet.
Skills
Invoke with /skill-name or rely on auto-discovery. Author in .cursor/skills/ or Claude skills path — see Agent Skills.
CI / headless
| Pattern | Notes |
|---|---|
claude -p "..." | Scriptable one-shot |
| Claude Code SDK | Custom pipelines — verify SDK docs |
| Read-only checkout | Scope files in prompt; no auto-merge |
See AI in CI/CD.