Lesson 12: Tips, Tricks, and Best Practices
Learning Objectives
After completing this lesson, you will be able to:
- Communicate effectively with Claude for optimal results
- Recognize and avoid common mistakes
- Optimize performance and speed
- Manage costs effectively with
/statsand/cost - Collaborate efficiently in team environments
- Troubleshoot common issues independently
Prerequisites
- Completed Lessons 1-11 - Full Claude Code knowledge
- Real project experience - Applied workflows to your code
- Encountered challenges - Hit some roadblocks to overcome
Estimated Time: 20 minutes
Communication Tips for Better Results
How you talk to Claude significantly impacts the quality of assistance.
Be Specific and Clear
❌ Vague:
You> Fix the code
✅ Specific:
You> The login endpoint in src/api/auth.js line 45 is throwing
a 500 error when the password contains special characters.
Please fix the validation regex.
Provide Context
❌ No context:
You> Why doesn't this work?
✅ With context:
You> I'm trying to implement OAuth2 login using the library in
package.json. I followed the docs at example.com/oauth but
I'm getting a "invalid_grant" error. Here's my implementation:
[shows code]
Use Examples
❌ Abstract:
You> Make it faster
✅ With example:
You> Optimize this query. Currently it takes 3 seconds on a
table with 10k rows. I'd like it under 100ms.
[current query shown]
State Your Goal
❌ Task-focused:
You> Change the function
✅ Goal-focused:
You> I need to validate user input before saving to database
to prevent SQL injection. Please update the saveUser function.
Break Down Complex Requests
❌ Monolithic:
You> Refactor the entire application to use TypeScript,
add tests, fix bugs, improve performance, and document everything
✅ Incremental:
You> Let's start with the authentication module. Convert it to
TypeScript first, then we'll move to other modules.
Common Mistakes to Avoid
Learn from others' mistakes to avoid frustration.
Mistake 1: Not Reading File Before Editing
Problem:
You> Add error handling to the process function
Claude guesses wrong about file structure.
Solution:
You> Read @src/process.py first, then add error handling
Mistake 2: Ignoring Claude's Questions
Problem: Claude asks clarifying questions, you ignore them, get wrong result.
Solution:
Claude: Do you want this validation on client or server side?
You: Server side, using the existing validation middleware
Mistake 3: Too Large Changes at Once
Problem:
You> Refactor everything to use microservices
Overwhelming, prone to errors.
Solution:
You> Let's start by extracting the user service into a separate module
Mistake 4: Not Using Plan Mode
Problem: Jumping into complex tasks without planning.
Solution:
You> /plan
You> I want to migrate from PostgreSQL to MongoDB
Mistake 5: Blindly Accepting Changes
Problem: Always pressing Y without reviewing diffs.
Solution:
- Always review diffs
- Understand what's changing
- Ask questions if unsure
Mistake 6: Not Providing Enough Context
Problem:
You> It's broken
Solution:
You> The payment flow fails at step 3 with error code E5001.
Here's the error log: [paste log]
Performance Optimization
Make Claude Code faster and more efficient.
Reduce Token Usage
Use targeted reading:
❌ You> Read the entire src directory
✅ You> Read @src/auth.js and @src/user.js
Use @ for files:
❌ You> Can you look at the file src/api/users.js and tell me...
✅ You> @src/api/users.js - how does this work?
Be concise:
❌ You> I was wondering if you could perhaps help me understand
✅ You> Explain the auth flow
Leverage Context
Don't repeat information:
❌ You> Read the file
[Claude reads]
You> Now that you've read it, add error handling
[Don't need to re-explain]
✅ Just continue: "Add error handling" (Claude knows context)
Use CLAUDE.md:
Put repeated context in CLAUDE.md instead of explaining
every session.
Use Background Tasks Wisely
Good for background:
- Long test runs
- Large file searches
- Build processes
Not for background:
- Quick questions
- Simple edits
- Urgent fixes
Choose Right Model
Haiku for:
- Quick questions
- Simple code generation
- Cost-sensitive tasks
Sonnet for:
- Most development work (default)
- Balanced speed and quality
Opus for:
- Complex reasoning
- Architecture decisions
- Critical features
Cost Management
Track and control your API usage.
Using /stats
Check session stats:
You> /stats
SESSION STATISTICS:
Duration: 45 minutes
Total tokens: 125,000
Input tokens: 80,000
Output tokens: 45,000
Estimated cost: $0.75
Operations:
- Read: 45 files
- Edit: 12 files
- Bash: 8 commands
Using /cost
Detailed cost breakdown:
You> /cost
COST BREAKDOWN:
Model: claude-sonnet-4-5
Input: $0.003/1K tokens × 80K = $0.24
Output: $0.015/1K tokens × 45K = $0.675
Total: $0.915
Most expensive operations:
1. Long explanation of architecture ($0.30)
2. Code generation for feature ($0.25)
3. Refactoring discussion ($0.20)
Cost Optimization Tips
Reduce input tokens:
- Use targeted file reading
- Avoid repeating context
- Keep CLAUDE.md concise
Reduce output tokens:
- Ask for concise answers
- Request code without explanations when you understand
- Use Haiku for simple tasks
Monitor regularly:
# Check stats periodically
You> /stats
# Set budget alerts in settings
{
"budget": {
"alertThreshold": 10.00,
"hardLimit": 50.00
}
}
Team Collaboration Tips
Use Claude Code effectively in teams.
Shared Configuration
Project-level settings:
.claude/settings.json - Commit to git
Shared by entire team.
Team Skills
Create shared skills:
.claude/skills/team-review/SKILL.md
Standardized code review checklist.
CLAUDE.md Convention
Document in CLAUDE.md:
# Team conventions
- We use PEP 8 for Python
- Test file name: test_<module>.py
- PR requires 1 approval
Git Attribution
Keep attribution enabled:
{
"git": {
"attribution": {
"enabled": true
}
}
}
Transparent about AI assistance.
Communication
Document AI usage:
- In PR descriptions: "Assisted by Claude Code"
- In commit messages: Co-Authored-By
- In documentation: Note AI-generated sections
Troubleshooting Common Issues
Solve problems independently.
Issue: "Permission Denied" Errors
Symptoms: Claude can't read/write files.
Solutions:
- Check file permissions:
ls -la file.py
chmod +r file.py
- Run with appropriate user:
sudo claude # Be careful with sudo!
- Check permission mode:
You> What permission mode am I in?
Issue: Slow Responses
Symptoms: Claude takes long to respond.
Solutions:
- Check internet connection
- Try smaller model (Haiku)
- Reduce context:
You> /compact # Compact conversation
- Check API status:
curl https://status.anthropic.com
Issue: "File Not Found"
Symptoms: Claude can't find files.
Solutions:
- Use absolute paths:
You> @/full/path/to/file.py
- Check current directory:
You> Show current directory
- List files:
You> List all Python files
Issue: Wrong Model Behavior
Symptoms: Claude gives unexpected responses.
Solutions:
- Check model:
You> What model are you using?
- Switch model:
claude --model claude-opus-4-5
- Clear and rephrase:
You> Let me clarify: [rephrase question]
Issue: Configuration Not Applied
Symptoms: Settings changes don't take effect.
Solutions:
- Check settings location:
# User vs project vs local
claude --show-config
- Restart session:
You> /exit
claude
- Validate JSON:
cat ~/.config/claude-code/settings.json | jq .
Issue: Memory/Context Loss
Symptoms: Claude forgets earlier conversation.
Solutions:
- Use CLAUDE.md for persistent context
- Reference earlier parts:
You> Remember when we discussed the auth flow? Apply that here.
- Manual compaction:
You> /compact
Pro Tips
Keyboard Shortcuts
Essential shortcuts:
Ctrl+C- Cancel current operationCtrl+D- Exit sessionCtrl+P- Cycle permission modesCtrl+L- Clear screen (keep history)
Alias Creation
Create convenient aliases:
# In ~/.bashrc or ~/.zshrc
alias cc='claude'
alias ccd='claude --develop'
alias ccr='claude --resume'
alias ccc='claude --commit'
Session Automation
Start with project:
# Function to start in project with context
ccd() {
cd ~/projects/$1
claude
}
Quick Commands
One-liners:
# Quick question
claude -p "What's the syntax for Python list comprehension?"
# Quick file check
claude -r @src/auth.py -p "Review this file"
# Quick commit
claude -c "git status" -c "git add ." -c "git commit -m 'WIP'"
✅ Check Your Understanding
-
What's the best way to ask about a specific file?
- "Look at the file"
- Use @filename
- "Read the thing"
- "Check file.py"
-
What command shows session statistics?
- /info
- /stats
- /session
- /show
-
Why should you use plan mode for complex tasks?
- It's faster
- It creates a roadmap before implementation
- It uses less tokens
- It's required
-
True or False: You should always accept Claude's changes without reviewing.**
- True
- False - always review diffs
-
What's a common mistake?
- Asking questions
- Being specific
- Not providing enough context
- Using @ for files
Answers: 1-b, 2-b, 3-b, 4-False, 5-c
Summary
In this lesson, you learned:
- Communication - Be specific, provide context, use examples
- Common mistakes - Not reading files, ignoring questions, large changes
- Performance - Reduce tokens, leverage context, choose right model
- Cost management - Use
/stats, monitor usage, optimize prompts - Team collaboration - Shared config, team skills, attribution
- Troubleshooting - Solve common issues independently
Next Steps
In Lesson 13: Reference Materials, you'll find:
- Complete slash command reference
- All CLI flags documentation
- Built-in tools reference
- Keyboard shortcuts
- Settings reference
- File locations cheat sheet
Further Reading
Continue to Lesson 13: Reference Materials →