Best Practices Advanced

The ultimate reference for Claude Code power users. Top 30 tips, golden rules, daily and weekly checklists, expert-level techniques, and a comprehensive FAQ covering every common question.

The Golden Rules

  1. Always commit before big changes

    Create a checkpoint commit before asking Claude to make large modifications. You can always revert.

  2. Be specific, not vague

    Reference file paths, function names, and line numbers. Specific prompts produce specific results.

  3. Review every change

    Use git diff to inspect what Claude modified. Trust but verify.

  4. Maintain your CLAUDE.md

    A well-maintained CLAUDE.md is the highest-ROI investment in your Claude Code workflow.

  5. Use the right model for the task

    Sonnet for routine work (80% of tasks), Opus for complex reasoning (20%).

Top 30 Power Tips

# Tip Impact
1Use claude -p for quick tasks30-60 sec saved per task
2Create shell aliases (alias cq='claude -p')Faster one-shot access
3Reference specific file paths in every promptFewer tool calls, faster results
4Use /compact every 10-15 turnsPrevents context overflow
5Commit before large refactoringSafe rollback point
6Use "edit X to do Y" prompt patternClearer instructions
7Ask Claude to run tests after changesCatches bugs immediately
8Use Sonnet for 80% of tasks40-60% cost reduction
9Start new sessions for new tasksCleaner context
10Use parallel agents for independent work2-5x throughput
11Create custom slash commands for team workflowsConsistency across team
12Pipe git diff to Claude for reviewsTargeted, efficient reviews
13Use --output-format json for scriptingMachine-readable output
14Break complex tasks into stepsBetter accuracy per step
15Reference existing code patternsConsistent codebase style
16Use /cost to monitor spendingCost awareness
17Use git worktrees for parallel agentsNo file conflicts
18Keep CLAUDE.md under 500 linesOptimal context usage
19Use background execution for long tasksNo waiting
20Provide examples of desired outputFirst-try accuracy
21Use Escape to cancel wrong directionSave time and tokens
22Ask for brief responses when exploringFaster iteration
23Use tmux/screen for persistent sessionsSurvive disconnections
24Update CLAUDE.md when conventions changePrevents future errors
25Use --max-turns in automationPredictable costs
26Batch similar tasks into one sessionContext reuse
27Read error messages before retryingFix root cause
28Use /doctor for diagnostic issuesQuick troubleshooting
29Keep Claude Code updatedLatest features and fixes
30Share effective prompts with your teamTeam-wide improvement

Daily Workflow Checklist

  • Start with a fresh Claude Code session for the day's first task
  • Check git status before starting — clean working tree
  • Reference CLAUDE.md if you've made project changes
  • Use /compact after every major task completion
  • Commit working changes before moving to the next task
  • Check /cost at end of day to track spending

Weekly Optimization Checklist

  • Review and update CLAUDE.md with any new patterns or conventions
  • Check for Claude Code updates: npm update -g @anthropic-ai/claude-code
  • Review weekly cost trends on the Anthropic dashboard
  • Share effective prompts with the team
  • Update custom slash commands if workflows have changed

Do's and Don'ts

Do Don't
Commit before big changes Trust Claude blindly with production code
Provide specific file paths Say "fix everything" or "make it better"
Use /compact regularly Let sessions run until context overflow
Review git diff after changes Skip code review on AI-generated code
Use Sonnet for routine tasks Use Opus for everything
Break complex tasks into steps Send massive multi-task prompts
Maintain CLAUDE.md Rely solely on conversation context
Store API keys in secret managers Hardcode keys anywhere

Expert-Level Techniques

Sub-Agents

Use Claude Code to spawn sub-agents for parallel independent tasks:

Terminal
> I need to implement 3 independent features: user avatars, email notifications,
> and API rate limiting. Use sub-agents to work on all three simultaneously.
> Each should work in a separate git worktree to avoid conflicts.

Hooks

Set up Claude Code hooks to automate pre/post actions:

JSON (.claude/settings.json)
{
  "hooks": {
    "preCommit": "npm run lint && npm test",
    "postEdit": "npx tsc --noEmit"
  }
}

Worktrees for Isolation

Terminal
# Create isolated worktrees for parallel Claude agents
$ git worktree add ../feature-a feature/avatars
$ git worktree add ../feature-b feature/notifications

# Run Claude in each worktree independently
# Terminal 1:
$ cd ../feature-a && claude -p "Implement user avatars"
# Terminal 2:
$ cd ../feature-b && claude -p "Implement email notifications"

# Merge back when both are done
$ cd ../main-project
$ git merge feature/avatars
$ git merge feature/notifications

FAQ

How much does Claude Code cost per month?

It depends on usage. Light usage (5-10 tasks/day) costs $10-30/month. Moderate usage (20+ tasks/day) costs $50-150/month. Use Sonnet for routine tasks and /compact regularly to optimize.

Can Claude Code access the internet?

Claude Code can run shell commands that access the internet (curl, npm install, git clone), but Claude itself does not browse the web. It works with your local files and tools.

Is my code sent to Anthropic?

Files that Claude reads are sent to Anthropic's API as part of the conversation context. Anthropic does not use API data for training. Review Anthropic's data policy for details.

How do I prevent Claude from modifying certain files?

Add instructions to your CLAUDE.md: "Do NOT modify files in src/legacy/ or any .env files." You can also use the --allowedTools flag to restrict capabilities.

Should I use Claude Code or Cursor?

Claude Code is best for terminal-native developers, SSH/remote workflows, and CI/CD automation. Cursor is best if you prefer a visual IDE experience. Many developers use both.

How often should I use /compact?

Use /compact every 10-15 turns, or whenever you notice responses slowing down. It is better to compact proactively than to hit context limits.

Can I use Claude Code with any programming language?

Yes. Claude Code works with any programming language, framework, or tech stack. It is particularly strong with Python, TypeScript/JavaScript, Rust, Go, and Java.

What's the maximum project size Claude Code can handle?

There is no hard limit. Claude Code reads files on-demand, not all at once. With a good CLAUDE.md and specific prompts, it works well with codebases of 500K+ lines. The key is providing focused context.

How do I share Claude Code workflows with my team?

Create custom slash commands in .claude/commands/, maintain a shared CLAUDE.md, and document effective prompts in your team wiki. All of these can be version-controlled with the project.

Is Claude Code safe to use with sensitive codebases?

Claude Code sends file contents to Anthropic's API. Anthropic does not train on API data. For highly sensitive projects, review Anthropic's enterprise data policies, use a dedicated API key, and add CLAUDE.md rules to prevent reading sensitive files.

Community Resources

Congratulations!

You have completed the Claude Code Mastery course. You now have the knowledge to use Claude Code at an expert level — from crafting perfect prompts to managing costs, leading team adoption, and leveraging advanced techniques like sub-agents and worktrees. Keep practicing, keep optimizing, and share what you learn with your team.

← Back to Course Overview