中文

Claude Code Tips & Tricks

Shortcuts, commands, memory system, prompt tips — everything you need

1. Keyboard Shortcuts

ShortcutFunction
Esc + EscUndo menu — revert code changes
Shift+TabToggle permission mode (Normal / Auto / Plan)
Ctrl+CInterrupt current execution
Ctrl+RSearch prompt history
Ctrl+OShow detailed conversation log (thinking process)

2. Slash Commands

CommandPurpose
/memoryView loaded memories
/resumeResume a previous conversation
/clearClear conversation, start fresh
/costCheck session token usage and cost
/contextView remaining context window space
/compactCompress history to free up space
/initAuto-generate project CLAUDE.md
/diffView code changes
/rename nameName the session for easy resume later
/planEnter/exit Plan mode (discuss without executing)
/model sonnetSwitch model (cheaper)

3. Startup Options

claude                        # Normal start
claude --continue             # Continue last conversation
claude --resume               # Choose which session to resume
claude -n "my-project"        # Named session for easy resume
claude -p "check SPY price"   # One-shot question, no interactive mode
claude --dangerously-skip-permissions  # Skip permission prompts
Pro tip: Start with claude -n "session-name", then use claude --resume next time. Saves you from repeating context.

4. Memory System

Memory is the only bridge between conversations. Each conversation is completely independent — anything discussed but not saved to memory is lost next time.

Four Layers of Memory

~/.claude/CLAUDE.md                    → User-level, loaded in ALL conversations
~/project/CLAUDE.md                    → Project-level, only in that directory
~/.claude/projects/.../memory/         → Global memory
~/.claude/projects/...-project/memory/ → Project memory

Key Differences

TypeAuto-loadedBest For
CLAUDE.mdEvery conversationRules, workflows, coding standards
MEMORY.mdFirst 200 linesMemory index (pointers to files)
Memory filesMust be read manuallySpecific info (server configs, API keys)

Best Practices

Important: Opening a conversation in Project A won't load Project B's memory (unless Claude proactively reads it). Always keep critical cross-project info in global memory.

5. Prompt Tips

Be Specific, Not Vague

# Bad
Analyze NVDA

# Good
Check NVDA latest price, compare 3-month trend, give buy/sell
recommendation considering my moderate-conservative risk profile,
save results to log.md

Include Verification Steps

# Deployment
Deploy and test if Telegram messages send correctly

# Development
Run tests after modifying the code

Plan Before Complex Tasks

/plan          # Enter Plan mode, discuss approach
(confirm the plan)
/plan          # Exit Plan mode, start executing

More Tips

6. Cost Saving

MethodSavings
Use /clear between different tasks30-50% tokens
Switch to /model sonnet for simple tasksMuch cheaper & faster
Keep CLAUDE.md conciseLoaded every time, shorter = cheaper
/compact to compress long conversationsFree up context space
Use -p for one-shot questionsMost efficient for non-interactive use

7. Multi-Project Management

Named Sessions + Resume (Recommended)

claude -n "website"          # Project 1
claude -n "trading-bot"      # Project 2
claude -n "stock-analysis"   # Project 3

# Later
claude --resume              # List all sessions, pick one

Parallel Terminals

Open different terminal windows for different project directories, each running its own claude instance independently.

8. Hooks & Automation

Configure hooks in .claude/settings.json to auto-run scripts before/after tool calls.

Example: macOS Notification on Completion

{
  "hooks": {
    "Stop": [{
      "hooks": [{
        "type": "command",
        "command": "osascript -e 'display notification \"Claude finished\" with title \"Claude Code\"'"
      }]
    }]
  }
}

Common Use Cases

9. FAQ

Claude doesn't remember what I said before

Each conversation is independent. Make sure important info is saved to memory files. Use /memory to check.

Conversation getting slow

/context to check usage → /compact to compress → or /clear to start fresh.

Claude keeps asking for info I already provided

Check if it was saved to memory. Cross-project info must be in global memory.

Want Claude to always follow a rule

Write it in CLAUDE.md, not just in conversation. CLAUDE.md is loaded every time.