Claude Code: Power Commands
omerโยทApr 03, 2026ยท18 min readยท9
๐ค Claude Code: The Power User's Playbook
From "it's a smart terminal" to "I have a full AI dev platform in my pocket."
Table of Contents
- What Even Is Claude Code?
- The Basics: Getting Around
- Slash Commands: Your Swiss Army Knife
- Inline Bash with
! - CLAUDE.md: The Agent's Constitution
- Permission Modes & The YOLO Flag
- Context Management: Don't Let Your Window Go Stale
- Custom Skills & Commands
- Hooks: Automation That Runs Itself
- Subagents: Delegate Like a CTO
- Bundled Power Skills
- CLI Flags for Scripting & CI/CD
- MCP Servers: Claude Meets the World
- Pro Tips & Mental Models
What Even Is Claude Code?
ELI5: Imagine you had a brilliant programmer friend who could see your entire codebase, remember everything about your project, and type 1,000 words per minute โ and they lived inside your terminal. That's Claude Code.
Claude Code is a command-line AI agent from Anthropic. It's not just a chatbot in a terminal window โ it can read your files, run bash commands, write and edit code, manage git, and orchestrate entire multi-step workflows, all through natural language.
The difference between a casual user and a power user comes down to one thing: knowing what levers to pull. This guide covers all of them.
The Basics: Getting Around
Starting a Session
# Standard interactive session
claude
# Start with a model flag
claude --model opus
# Start with a specific prompt (non-interactive, exits after)
claude -p "What does this codebase do?"
# Pipe content in
cat error.log | claude -p "What caused this crash?"
Keyboard Shortcuts You'll Use Every Day
| Shortcut | What It Does |
|---|---|
Ctrl+C | Interrupt current response (keeps session alive) |
Ctrl+D | End the session entirely |
Tab | Autocomplete slash commands |
โ / โ | Navigate prompt history |
@-tagging Files
You can pull any file into context mid-conversation:
Tell me what's wrong with @src/auth/login.ts
This is cleaner than pasting code manually and keeps the conversation readable.
Slash Commands: Your Swiss Army Knife
Slash commands are text commands you type inside an active session. Think of them as keyboard shortcuts for your AI session. Hit Tab after typing / to see autocomplete suggestions.
Built-in Session Management
| Command | What It Does |
|---|---|
/help | List every available slash command (including custom ones) |
/clear | Wipe conversation history. Use this constantly. |
/compact | Summarize the conversation to reclaim context window space |
/context | Show current context window usage |
/model | Switch models mid-session (e.g., from Sonnet to Opus) |
/permissions | Adjust tool permissions during a live session |
/hooks | Configure hooks interactively via a menu |
/memory | View and manage Claude's memory |
/resume | Resume a previous session by ID |
/init | Scan the project and auto-generate a CLAUDE.md file |
/debug | Enable debug logging and troubleshoot session issues |
/exit | End the session cleanly |
Bundled Skill Commands
These ship with Claude Code and are more powerful than regular commands โ they can spawn parallel agents and adapt to your codebase:
| Command | What It Does |
|---|---|
/simplify | Reviews recently changed files for quality/efficiency, spawns 3 parallel review agents, and applies fixes |
/batch <instruction> | Breaks a large task into 5โ30 units, spawns one agent per unit in isolated git worktrees, each running tests and opening PRs |
/loop [interval] <prompt> | Runs a prompt on a repeating interval (great for polling deploys) |
/claude-api | Loads full Anthropic SDK reference for your language |
/debug [description] | Reads session debug logs to troubleshoot issues |
Example:
/batch migrate src/ from CommonJS to ES Modules /simplify focus on memory efficiency /loop 5m check if the staging deploy finished
Inline Bash with !
This is one of the most underused features. In your SKILL.md and custom command files, you can inject live bash output directly into Claude's prompt using the ! prefix inside backticks.
## Context
- Current git status: !`git status`
- Recent changes: !`git diff HEAD`
- Current branch: !`git branch --show-current`
- Open PRs: !`gh pr list`
Based on the above context, write a commit message.
Why this is powerful: Claude doesn't just get a static prompt โ it gets real-time data baked into its context before it even starts thinking. It's like handing a doctor the lab results before they walk into the exam room.
This works in:
- Custom skill/command
.mdfiles (with!backtick syntax) - Inline during a session by just asking Claude to run a bash command
CLAUDE.md: The Agent's Constitution
The CLAUDE.md file is the single most important thing you can configure. Every session, Claude reads it automatically. Think of it as the standing orders you never have to repeat.
Where Files Live
~/.claude/CLAUDE.md # Global โ applies to every project
<project-root>/CLAUDE.md # Project-specific
packages/frontend/CLAUDE.md # Monorepo sub-package (also loaded!)
A Solid CLAUDE.md Template
# My Project
## What This Is
A TypeScript monorepo for a SaaS billing platform. Backend is Express,
frontend is React + Vite.
## Build & Dev Commands
- Build: `npm run build`
- Dev server: `npm run dev`
- Tests: `npm test`
- Lint: `npm run lint -- --fix`
- Type check: `npx tsc --noEmit`
## Code Conventions
- TypeScript strict mode is ON. Never use `any`.
- No default exports.
- All API responses use the `ApiResult<T>` wrapper type.
- Commit format: `feat/fix/chore(scope): description`
## Things Claude Should Know
- The `src/legacy/` directory is read-only. Do not touch it.
- Environment variables are in `.env.local` (never commit this).
- We use Zod for all runtime validation โ prefer it over manual checks.
Pro Tip: Run
/initto have Claude scan your project and generate a starterCLAUDE.mdautomatically. Then own it yourself from there.
Permission Modes & The YOLO Flag
The Four Permission Modes
Claude Code ships with four permission modes you can toggle with Shift+Tab or set at startup:
| Mode | Behavior |
|---|---|
| Default | Asks permission for most file edits and shell commands |
| AcceptEdits | Auto-approves file edits, still asks for shell commands |
| Plan | No execution โ Claude only plans and describes what it would do |
| Auto | AI classifier decides per-action what needs approval |
# Set a mode at startup
claude --permission-mode acceptEdits
claude --permission-mode auto
The --dangerously-skip-permissions Flag
The most annoying thing about default Claude Code is the permission prompts. Every. Single. File. You go make coffee, come back, and it's been waiting on "Can I run npm test?" for five minutes.
The solution:
claude --dangerously-skip-permissions
What it does: Skips all permission prompts and lets Claude act autonomously. It's not as scary as it sounds for most local development work. Think of it as Cursor's old "YOLO mode."
When to use it: Personal projects, isolated dev environments, when you trust your own CLAUDE.md constraints.
When NOT to use it: Anything touching production, shared systems, or sensitive credentials.
Safety net: You can still scope what Claude can touch using
allowedToolsanddenyrules in your settings โ even without permission prompts.
Fine-Grained Tool Permissions (.claude/settings.json)
{
"permissions": {
"allowedTools": [
"Read",
"Write(src/**)",
"Bash(git *)",
"Bash(npm *)"
],
"deny": [
"Read(.env*)",
"Write(production.config.*)",
"Bash(rm -rf*)",
"Bash(sudo *)"
]
}
}
Context Management: Don't Let Your Window Go Stale
ELI5 for context: The context window is like a whiteboard. Claude can only see what's written on it right now. Old conversations fill it up. When it gets too full, Claude starts forgetting details โ or hallucinating to fill gaps.
The Context Health Scale
| Usage | Status | Action |
|---|---|---|
| 0โ50% | ๐ข Fine | Work freely |
| 50โ70% | ๐ก Watch it | Finish current task cleanly |
| 70โ90% | ๐ Compress | Run /compact |
| 90%+ | ๐ด Critical | /clear immediately |
The "Document & Clear" Pattern
For long, complex tasks that span multiple sessions:
- Before clearing, ask Claude: "Dump your current plan, progress, and any blockers into
progress.md" - Run
/clear - Start a new session: "Read
progress.mdand continue where we left off"
This gives Claude durable external "memory" that survives context resets.
Anti-pattern: Relying on auto-compaction. It doesn't always preserve what matters. Own your context resets manually.
Custom Skills & Commands
Skills are reusable prompts that become slash commands. The newer .claude/skills/ format is preferred โ it supports automatic invocation by Claude, not just manual invocation.
Directory Structure
.claude/
โโโ skills/
โ โโโ review-pr/
โ โโโ SKILL.md # /review-pr command
โโโ commands/ # Legacy format (still works)
โ โโโ catchup.md # /catchup command
โโโ settings.json
Creating a Skill
Create .claude/skills/review-pr/SKILL.md:
---
name: review-pr
description: Fetch and review a pull request for logic errors, security
issues, and missing error handling. Use when asked to review
a PR or check a pull request.
allowed-tools: Bash(gh pr diff:*), Bash(gh pr view:*)
---
Fetch the PR diff for $ARGUMENTS using `gh pr diff`.
Review for:
1. Logic errors and edge cases
2. Security vulnerabilities (injection, auth bypasses, exposed secrets)
3. Missing error handling
4. Violations of rules in CLAUDE.md
Do NOT comment on style, naming conventions, or subjective preferences.
Flag only high-signal issues with clear explanations.
Use it with:
/review-pr 142
A Minimal Personal Command Set Worth Having
# ~/.claude/skills/catchup/SKILL.md
# Reads all changed files since branching from main
# ~/.claude/skills/pr/SKILL.md
# Stages, commits, and opens a PR with a clean message
# ~/.claude/skills/security/SKILL.md
# Reviews current diff for security vulnerabilities
Skill Scoping
| Location | Applies To |
|---|---|
~/.claude/skills/ | All your projects (personal) |
.claude/skills/ | This project only |
| Enterprise managed settings | All users in org |
When names conflict, priority is: Enterprise > Personal > Project.
Hooks: Automation That Runs Itself
Hooks are shell commands that fire automatically at specific points in Claude's lifecycle. Think of them as "if this, then that" rules baked into your Claude session.
Hook Events
| Event | When It Fires |
|---|---|
UserPromptSubmit | Immediately when you submit a prompt |
PreToolUse | Before Claude runs any tool (read, write, bash) |
PostToolUse | After a tool completes |
Notification | When Claude sends a notification |
Stop | When Claude finishes responding |
Configuring Hooks (.claude/settings.json)
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write(*.py)",
"hooks": [
{
"type": "command",
"command": "python -m black $file && python -m mypy $file"
}
]
}
],
"PreToolUse": [
{
"matcher": "Bash(rm *)",
"hooks": [
{
"type": "command",
"command": "echo 'Deletion detected โ logging to audit.log' >> audit.log"
}
]
}
]
}
}
Use
/hooksin an active session to configure these interactively via a menu instead of editing JSON manually. Much easier when starting out.
Practical Hook Ideas
- Auto-format: Run Prettier/Black after every file write
- Type-check: Run
tsc --noEmitafter TypeScript edits - Audit log: Log every bash command Claude runs to a file
- Notifications: Ping Slack or play a sound when Claude finishes a long task
Subagents: Delegate Like a CTO
Subagents are specialized AI agents that Claude can delegate tasks to. They run with their own context, tools, and instructions โ keeping your main session's context clean.
Creating a Subagent
Create .claude/agents/code-reviewer/AGENT.md:
---
name: code-reviewer
description: Expert code reviewer. Use proactively after code changes.
tools: Read, Grep, Glob, Bash
model: sonnet
---
You are a senior code reviewer. When reviewing code:
- Check for security vulnerabilities (SQL injection, XSS, etc.)
- Verify error handling is complete
- Flag any hardcoded secrets or credentials
- Suggest performance improvements
- Check for proper input validation
Invoke with:
# Natural language โ Claude delegates automatically
"Review my latest changes"
# Direct invocation in session
@code-reviewer check my latest changes
# CLI flag
claude --agent code-reviewer
When to Use Subagents (and When Not To)
Good uses:
- Security auditing (isolated, focused)
- Test writing (separate concern from implementation)
- Documentation generation
Watch out for: If you make a PythonTests subagent, the main Claude can no longer reason holistically about test behavior. Sometimes hiding context creates problems. Use subagents for genuinely separable concerns.
Bundled Power Skills (Deep Dive)
/batch โ Parallel Codebase Refactoring
The crown jewel for large refactors. Give it an instruction and it:
- Researches your codebase
- Decomposes the work into 5โ30 independent units
- Shows you a plan for approval
- Spawns one agent per unit in isolated git worktrees
- Each agent runs tests and opens its own PR
/batch migrate all API handlers from callbacks to async/await
/batch add input validation to every public endpoint in src/routes/
/batch replace all `console.log` calls with the structured logger
โ ๏ธ Requires a git repository. Large jobs can use significant token budget โ start with a smaller scope to test.
/simplify โ Post-Feature Cleanup
Run this after shipping a feature to clean up your work. It spawns three parallel review agents (code reuse, quality, efficiency), aggregates their findings, and applies fixes.
/simplify
/simplify focus on memory efficiency
/simplify focus on reducing bundle size
/loop โ Babysit a Deploy
/loop 5m check if the CI pipeline finished and tell me the result
/loop 2m tail the last 20 lines of deploy.log and flag any errors
CLI Flags for Scripting & CI/CD
The -p Flag (Print Mode)
The -p flag makes Claude non-interactive โ it processes the prompt and exits. This is the key to integrating Claude Code into scripts and pipelines:
# Simple one-shot query
claude -p "summarize this file" < README.md
# Git diff review in CI
git diff main | claude -p "review for security issues and output JSON" \
--output-format json
# Pipe error logs for triage
cat error.log | claude -p "what caused this crash and how do I fix it?"
# Cap spending on expensive tasks
claude -p "refactor the API layer" --max-budget-usd 5.00
# Limit turns for automated workflows
claude -p "fix the failing test" --max-turns 5
# Use a specific model
claude -p "analyze this" --model claude-opus-4-5-20251001
Other Useful Flags
| Flag | What It Does |
|---|---|
--model <name> | Set the model for the session |
--permission-mode <mode> | Set permission mode at startup |
--dangerously-skip-permissions | Skip all permission prompts |
--output-format json | Machine-readable output for scripting |
--max-budget-usd <amount> | Cap API spend for a task |
--max-turns <n> | Limit agentic turns (useful in CI) |
--agent <name> | Start session using a named subagent |
--debug | Enable verbose debug logging |
--mcp-config <file> | Load a specific MCP config (great for CI) |
--strict-mcp-config | Only load specified MCP servers, ignore others |
--from-pr <number> | Resume a session linked to a GitHub PR |
Installing the GitHub App
/install-github-app
After running this once, Claude will automatically review your PRs. Given that AI-assisted development tends to increase PR volume, this is genuinely useful as a first-pass reviewer.
MCP Servers: Claude Meets the World
MCP (Model Context Protocol) servers give Claude access to external tools and services โ Figma, GitHub, databases, internal APIs, whatever you need.
Adding MCP Servers
# Add a server globally (available in all projects)
claude mcp add github -s user -- npx @modelcontextprotocol/server-github
# Add a server scoped to the current project only
claude mcp add figma -s project -- npx @modelcontextprotocol/server-figma
# Add with custom JSON config
claude mcp add-json custom-server '{
"command": "node",
"args": ["./my-mcp-server.js"],
"env": { "API_KEY": "your-key" }
}'
# List all configured servers
claude mcp list
# Remove a server
claude mcp remove github
Using MCP in CI (.mcp.json)
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "${GITHUB_TOKEN}"
}
}
}
}
Use --strict-mcp-config in CI to ensure only the servers in your config file load โ no surprises.
Pro Tips & Mental Models
๐ง Mental Models First
The context window is a whiteboard, not a notepad. Claude can only reason about what's currently on it. Old context doesn't help โ it just crowds out space for new thinking. Clear aggressively.
Claude is your team lead, not your employee. Give it the outcome you want, not a step-by-step script. "Make the auth flow robust" beats "edit line 42 of auth.ts." The more autonomous leeway you grant it, the more leverage you get.
CLAUDE.md is the difference between a junior and senior Claude. A fresh session with no CLAUDE.md is Claude operating blind. A rich CLAUDE.md is Claude knowing your whole codebase convention set before it writes a single character.
๐ฅ Quick Power Tips
-
/clearearly,/clearoften. Every new task or context switch deserves a fresh start. Don't drag old conversation crud into new work. -
Queue tasks, go touch grass. Claude Code can queue up a lot of work. Set it going on a long task (especially with
--dangerously-skip-permissionsin a safe environment), go do something else, and check back. It's surprisingly good at staying on task. -
Use Opus for planning, Sonnet for execution. Opus is better at architectural reasoning and multi-step planning. Sonnet is faster and cheaper for the actual implementation grind. Switch mid-session with
/model. -
The "Document & Clear" trick for long tasks:
"Dump your current plan, progress notes, and blockers into progress.md" /clear "Read progress.md and continue from where we left off" -
Let Claude build its own CLAUDE.md hooks. Ask Claude: "Look at this project and set up some default hooks, custom commands, and a CLAUDE.md." It's remarkably good at bootstrapping its own configuration.
-
Monorepos: use nested CLAUDE.md files. A
CLAUDE.mdinpackages/payments/is auto-loaded when you're working in that directory. Each sub-package can have its own context. -
-pmode is perfect for git hooks:# .git/hooks/pre-commit git diff --cached | claude -p "check for hardcoded secrets or API keys" \ --max-turns 1
โ ๏ธ Common Mistakes to Avoid
| Mistake | Better Approach |
|---|---|
| Never clearing context | /clear at every new task |
| Relying on auto-compaction | Manual "Document & Clear" for complex work |
| Overly complex slash commands | Keep commands simple; let CLAUDE.md and natural language carry the weight |
No deny rules with skip-permissions | Always set explicit deny rules in settings.json for destructive ops |
| One giant CLAUDE.md for everything | Use nested CLAUDE.md files in monorepos |
| Using subagents for everything | Reserve subagents for genuinely separable, isolated concerns |
Quick Reference Cheatsheet
# โโ LAUNCH โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
claude # Interactive session
claude --model opus # Start with Opus
claude --permission-mode acceptEdits # Auto-accept file edits
claude --dangerously-skip-permissions # Full YOLO mode
claude -p "prompt" # Non-interactive (exits after)
cat file | claude -p "review this" # Pipe input
# โโ SESSION COMMANDS โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
/clear # Wipe history
/compact # Summarize conversation
/context # Check context usage %
/model opus # Switch model mid-session
/hooks # Configure hooks interactively
/init # Generate CLAUDE.md for this project
/debug # Enable debug logging
/resume <id> # Resume a previous session
# โโ BUNDLED SKILLS โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
/simplify # Cleanup recently changed files
/simplify focus on performance # Focused cleanup
/batch migrate src/ from X to Y # Parallel large-scale refactor
/loop 5m check deploy status # Repeating poll task
/debug describe the issue here # Troubleshoot session
# โโ FILE STRUCTURES โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
~/.claude/CLAUDE.md # Global project memory
.claude/settings.json # Permissions + hooks config
.claude/skills/<name>/SKILL.md # Custom slash command
.claude/agents/<name>/AGENT.md # Custom subagent
.mcp.json # MCP server config (project)
# โโ MCP โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
claude mcp add <name> -- <command>
claude mcp list
claude mcp remove <name>
For the most current features and docs, always check: code.claude.com/docs