Skip to content

Instantly share code, notes, and snippets.

@ronco
Last active January 7, 2026 00:44
Show Gist options
  • Select an option

  • Save ronco/58c16f06563d33d02b5bb8ccff25b38e to your computer and use it in GitHub Desktop.

Select an option

Save ronco/58c16f06563d33d02b5bb8ccff25b38e to your computer and use it in GitHub Desktop.
Claude Code Power User Cheatsheet

Claude Code Cheatsheet

Golden Rule:

Always use claude!

Quick Reference Commands

Session Management

Command Description
claude Start fresh session
claude -c Continue last session
claude --resume Pick from recent sessions
claude -p "prompt" Headless mode (for scripts/CI)
claude --add-dir ../path Add directories to context
claude --model sonnet Use faster/cheaper model

Shell Aliases (add to ~/.zshrc or ~/.bashrc)

alias cc="claude -c"
alias cr="claude --resume"
alias cs="claude --model sonnet"

In-Session Commands

Command Description
/help Show all commands
/compact Compress context (keeps working, saves tokens)
/clear Clear conversation entirely
/cost Show token usage
Esc Cancel current operation
Ctrl+C Interrupt / exit

Configuration Files

Locations

~/.claude/
├── CLAUDE.md          # Your global preferences
├── settings.json      # Permissions, MCP servers
└── .env               # Credentials (NEVER commit)

<project>/
└── .claude/
    ├── CLAUDE.md      # Project-specific instructions
    └── settings.json  # Project settings

Priority Order

Project CLAUDE.md > User CLAUDE.md > Defaults


Model Selection

Model Best For Flag
Opus Complex reasoning, large refactors (default)
Sonnet Quick tasks, simple edits, cost savings --model sonnet

Hooks

Pre/post execution scripts. Add to ~/.claude/settings.json:

{
  "hooks": {
    "post-tool-use": {
      "edit": "npm run lint --fix"
    }
  }
}

Custom Skills (Slash Commands)

Create ~/.claude/skills/<skill-name>.md:

---
name: commit
description: Create a conventional commit
---

Create a git commit following Conventional Commits format.
Include a descriptive message based on staged changes.

Usage: /commit in session


MCP Server Setup

Add to ~/.claude/settings.json:

{
  "mcpServers": {
    "atlassian": {
      "command": "npx",
      "args": ["-y", "@anthropic/mcp-server-atlassian"]
    },
    "slack": {
      "command": "npx",
      "args": ["-y", "@anthropic/mcp-server-slack"]
    }
  }
}

Effective Prompting Patterns

Be Specific

# Vague (avoid)
"Fix the bug"

# Specific (better)
"Investigate why login fails when email contains '+' character"

Provide Context

# Good pattern
"In the UserService class, add a method to validate email
addresses. Follow the existing validation pattern used
for phone numbers."

Iterative Refinement

1. "Run the tests"
2. "Fix the failing test in auth.test.ts"
3. "Run tests again to verify"

Context Management

When to /compact

  • Context getting long but still relevant
  • Want to continue same task with less token usage

When to Start Fresh (claude)

  • Switching to unrelated task
  • Claude seems confused or stuck
  • Accumulated context is polluting responses

Signs of Context Pollution

  • Referencing old/deleted code
  • Repeating previous mistakes
  • Slower responses
  • Inconsistent behavior

Plan Mode

For complex tasks, use plan mode:

"Enter plan mode and save the plan to PLAN.md"

Claude will:

  1. Explore the codebase
  2. Write a plan to the file
  3. Wait for your approval
  4. Execute after approval

Multi-Agent Parallelism

Claude can spawn background agents:

  • Explore agent - Codebase research
  • Plan agent - Architecture design

These run concurrently while you continue working.


Ad-Hoc Scripting

Great for one-off tasks:

"Write a Python script that scrapes attendee names
from this conference page: [URL]"

"Summarize the last 50 messages in #alerts Slack channel"

"Parse this CSV and generate SQL insert statements"

Test-Driven Debugging Loop

Powerful pattern for fixing issues:

1. "Run the test suite"
2. Claude sees failures
3. "Fix the failing tests"
4. Claude makes changes
5. "Run tests again"
6. Repeat until green

Code Review Workflow

"Review the changes in this PR: [URL]"

"What are the potential issues with the code
in src/auth/login.ts?"

"Review my staged changes before I commit"

Cost Awareness Tips

  1. Use sonnet for simple tasks
  2. /compact to reduce context size
  3. Start fresh sessions for new topics
  4. Be specific to avoid back-and-forth
  5. Use /cost to monitor usage

Keyboard Shortcuts

Key Action
Esc Cancel current operation
Ctrl+C Interrupt
Up Arrow Previous command
Tab Autocomplete

Extra Credit Resources


Generated for Claude Code Power User Tutorial

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment