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
-
Always commit before big changes
Create a checkpoint commit before asking Claude to make large modifications. You can always revert.
-
Be specific, not vague
Reference file paths, function names, and line numbers. Specific prompts produce specific results.
-
Review every change
Use
git diffto inspect what Claude modified. Trust but verify. -
Maintain your CLAUDE.md
A well-maintained CLAUDE.md is the highest-ROI investment in your Claude Code workflow.
-
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 |
|---|---|---|
| 1 | Use claude -p for quick tasks | 30-60 sec saved per task |
| 2 | Create shell aliases (alias cq='claude -p') | Faster one-shot access |
| 3 | Reference specific file paths in every prompt | Fewer tool calls, faster results |
| 4 | Use /compact every 10-15 turns | Prevents context overflow |
| 5 | Commit before large refactoring | Safe rollback point |
| 6 | Use "edit X to do Y" prompt pattern | Clearer instructions |
| 7 | Ask Claude to run tests after changes | Catches bugs immediately |
| 8 | Use Sonnet for 80% of tasks | 40-60% cost reduction |
| 9 | Start new sessions for new tasks | Cleaner context |
| 10 | Use parallel agents for independent work | 2-5x throughput |
| 11 | Create custom slash commands for team workflows | Consistency across team |
| 12 | Pipe git diff to Claude for reviews | Targeted, efficient reviews |
| 13 | Use --output-format json for scripting | Machine-readable output |
| 14 | Break complex tasks into steps | Better accuracy per step |
| 15 | Reference existing code patterns | Consistent codebase style |
| 16 | Use /cost to monitor spending | Cost awareness |
| 17 | Use git worktrees for parallel agents | No file conflicts |
| 18 | Keep CLAUDE.md under 500 lines | Optimal context usage |
| 19 | Use background execution for long tasks | No waiting |
| 20 | Provide examples of desired output | First-try accuracy |
| 21 | Use Escape to cancel wrong direction | Save time and tokens |
| 22 | Ask for brief responses when exploring | Faster iteration |
| 23 | Use tmux/screen for persistent sessions | Survive disconnections |
| 24 | Update CLAUDE.md when conventions change | Prevents future errors |
| 25 | Use --max-turns in automation | Predictable costs |
| 26 | Batch similar tasks into one session | Context reuse |
| 27 | Read error messages before retrying | Fix root cause |
| 28 | Use /doctor for diagnostic issues | Quick troubleshooting |
| 29 | Keep Claude Code updated | Latest features and fixes |
| 30 | Share effective prompts with your team | Team-wide improvement |
Daily Workflow Checklist
- Start with a fresh Claude Code session for the day's first task
- Check
git statusbefore starting — clean working tree - Reference CLAUDE.md if you've made project changes
- Use
/compactafter every major task completion - Commit working changes before moving to the next task
- Check
/costat 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:
> 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:
{
"hooks": {
"preCommit": "npm run lint && npm test",
"postEdit": "npx tsc --noEmit"
}
}
Worktrees for Isolation
# 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
- Official Documentation: docs.anthropic.com/claude-code
- GitHub: github.com/anthropics/claude-code
- Discord: Join the Anthropic community for tips and support
- Release Notes: Check npm or GitHub for the latest Claude Code updates
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
Lilly Tech Systems