10 min read
Lesson 4 of 5
Best Practices & Real-World Tips
From the course Claude Code: AI Terminal Agent
Maximize Claude Code effectiveness with proven strategies from power users.
Writing Effective Prompts
Good: "Refactor the user service to use the repository pattern. Create a UserRepository interface, implement it with PostgresUserRepository, and update all 12 files that currently access the users table directly."
Bad: "Clean up the code."
Principles:
- Be specific about scope and desired outcome
- Mention file counts and affected areas
- Reference specific patterns or architectures
- Include constraints (don't break existing tests, maintain API compatibility)
CLAUDE.md Best Practices
# Project: E-commerce API
## Architecture
- Express + TypeScript + Prisma
- PostgreSQL database
- Redis for caching and sessions
## Commands
- `npm test` — Run Jest tests
- `npm run build` — TypeScript compilation
- `npm run lint` — ESLint check
## Conventions
- Use barrel exports (index.ts) for modules
- Error handling via custom AppError class
- All API responses use ResponseBuilder
- Database queries go through repository layer
## Common Issues
- Redis connection requires local Docker: `docker compose up redis`
- Test database needs migration: `npm run db:test:migrate`
When to Use Claude Code vs. IDE Copilots
| Task | Best Tool |
|---|---|
| Quick inline completion | IDE Copilot |
| Multi-file refactoring | Claude Code |
| Bug investigation | Claude Code |
| Boilerplate generation | Either |
| Architecture planning | Claude Code |
| Test writing | Claude Code |
| Documentation | Claude Code |
| One-line fixes | IDE Copilot |
Security Considerations
- Review all changes before committing
- Never run in YOLO mode on production codebases
- Audit command executions in sensitive environments
- Don't paste secrets into the chat
- Use
.claudeignoreto exclude sensitive files
Key Takeaways
- •Specific, scoped prompts with clear outcomes produce the best results
- •A well-structured CLAUDE.md dramatically improves Claude Code's effectiveness
- •Use Claude Code for multi-file tasks and IDE copilots for quick completions
- •Always review changes and maintain security boundaries
0 of 5 lessons marked complete
Progress is kept in this browser only.