06
Docs

Claude Code: Tips & Power Features

Advanced capabilities that multiply your productivity

Project Configuration: CLAUDE.md

What: A markdown file in your project root that gives Claude persistent context.

Location: /project-root/CLAUDE.md (or .claude/CLAUDE.md)

What to Include

# Project: [Name]

## Overview
Brief description of what this project does.

## Tech Stack
- Frontend: React 18, TypeScript, Tailwind
- Backend: Node.js, Express, PostgreSQL
- Testing: Jest, Playwright

## Architecture
- /src/components - React components
- /src/api - API routes
- /src/utils - Shared utilities

## Conventions
- Use functional components with hooks
- Prefer named exports
- Tests go in __tests__ folders
- Use kebab-case for file names

## Common Commands
- `npm run dev` - Start development server
- `npm test` - Run tests
- `npm run build` - Production build

## Important Notes
- Never commit to main directly
- All API keys are in .env (not committed)
- Database migrations are in /migrations

Why It Matters

Memory: memory.md

What: A file where Claude stores learnings that persist across sessions.

Location: .claude/memory.md

Example Content

# Memory

## Learned Preferences
- User prefers verbose error messages
- Always run tests before committing
- Use conventional commits format

## Project Discoveries
- The auth module has a bug with special characters (ticket #123)
- Performance issues traced to N+1 queries in /api/users
- Design system colors are in /src/theme/colors.ts

## Session Notes
- 2025-02-10: Refactored payment module, tests passing
- 2025-02-11: Started work on dashboard feature

Subagents: Parallel Execution

What: Spawn separate Claude instances to work on tasks in parallel.

When to Use

How to Invoke

You: "Work on the login page while a subagent writes tests for the API"

Best Practices

Do Don't
Use for truly independent tasks Use for sequential dependencies
Merge results intentionally Let subagents conflict
Give clear, scoped instructions Give vague, overlapping tasks

Hooks: Automation Triggers

What: Shell commands that trigger automatically at specific events.

Hook Events

Event When It Fires Example Use
PreToolUse Before Claude uses a tool Validate commands
PostToolUse After Claude uses a tool Run linter after edits
Notification When Claude wants to notify Send Slack message
Stop When Claude finishes Run test suite

Example: Auto-run Tests After File Changes

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Write|Edit",
        "command": "npm test --watchAll=false"
      }
    ]
  }
}

Example: Log Failures for Learning

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Bash|Execute",
        "command": "if [ $EXIT_CODE -ne 0 ]; then echo \"$(date -Iseconds) | $TOOL | $COMMAND | Exit: $EXIT_CODE\" >> .claude/failures.log; fi"
      }
    ]
  }
}

Slash Commands

Essential Built-in Commands:

Command What It Does
/help Show available commands
/clear Clear conversation context
/compact Summarize and compress context
/config View/edit configuration
/cost Show token usage and costs
/doctor Diagnose setup issues
/init Initialize CLAUDE.md for project
/mcp Manage MCP servers
/memory View/edit memory
/review Review recent changes
/revert Undo recent file changes

Plan Mode vs. Auto Mode

Plan Mode (Recommended for Learning)

claude --plan

Auto Mode (For Trusted Tasks)

claude --auto

Hybrid Approach

Tips from Power Users

  1. Start with the end in mind — "Create a working login page" is better than "Help me code"
  2. Give Claude the full picture — Share error messages completely, include relevant file context, explain the why not just the what
  3. Iterate, don't restart — Build on what Claude produces; refine rather than re-prompt
  4. Let Claude read first — "Read the codebase and understand the patterns before making changes"
  5. Use Claude for code review — "Review this PR for bugs, security issues, and style"
  6. Automate the boring stuff — Tests, documentation, boilerplate. Claude is tireless for repetitive tasks
  7. Trust but verify — Run the tests, review the diff, understand the changes