These are patterns I’ve picked up from using Claude Code daily. Some I figured out through trial and error, others from reading Anthropic’s docs and the community.
1. Writing effective prompts
The biggest mistake I see people make is being too vague. Claude Code is powerful, but it’s not a mind reader.
a. Bad vs good
Bad: “Fix the bug”
Good: “The login form submits even when the email field is empty. Add client-side validation to prevent submission when email or password is blank.”
Bad: “Make it better”
Good: “Refactor the fetchUsers function in src/api/users.ts to handle pagination. Currently it only fetches the first page.”
b. Be specific about scope
When you want changes in a specific file, say so:
In src/lib/utils/date.ts, add a function that converts
a Unix timestamp to a relative time string like "3 hours ago" When you want a broader change, state the scope explicitly:
Across all components in src/components/forms/, replace
direct DOM manipulation with reactive Svelte bindings 2. Plan mode for complex tasks
For anything non-trivial, I always use plan mode. It makes Claude Code think before acting.
Plan how to implement user authentication with JWT tokens.
Don't write any code yet, just outline the approach,
files to create/modify, and any architectural decisions. Or use the built-in plan mode:
/plan Add a search feature to the docs sidebar Why this matters:
- You review the approach before any code is written
- Catches wrong assumptions early
- You can redirect before Claude Code goes down the wrong path
- Saves context window by avoiding wasted exploration
For any task that touches more than 2-3 files, I always plan first. The 30 seconds spent reviewing a plan saves minutes of undoing wrong implementations.
3. Managing the context window
The context window is your most limited resource. Every file read, every command output, every back-and-forth message eats into it. When the window fills up, Claude Code starts compressing older messages, and quality drops.
a. Keep sessions focused
One task per session. Don’t fix a bug, then refactor a module, then add a feature all in the same conversation. Start fresh:
# Task 1: Fix the login bug
claude
> Fix the email validation bug in LoginForm.tsx
# Done. Exit.
# Task 2: Add the search feature
claude
> Add search functionality to the docs sidebar b. Use /compact proactively
When you notice the conversation getting long (especially after lots of file reads), run /compact to compress the history. This frees up context for the actual work.
c. Avoid unnecessary exploration
Instead of:
Look at my entire project and tell me what you think Be targeted:
Read src/lib/api/client.ts and explain the retry logic 4. Working with large codebases
Claude Code handles large projects well, but you need to guide it.
a. Point it to the right files
The authentication logic is in these files:
- src/lib/auth/session.ts (session management)
- src/routes/api/login/+server.ts (login endpoint)
- src/hooks.server.ts (auth middleware)
Add rate limiting to the login endpoint. b. Use CLAUDE.md for navigation
In your CLAUDE.md, include a project structure map so Claude Code knows where things live:
## Project Structure
src/
├── lib/
│ ├── api/ # API client and endpoints
│ ├── auth/ # Authentication logic
│ └── components/ # Shared UI components
└── routes/
├── api/ # Server endpoints
├── (app)/ # Authenticated routes
└── (public)/ # Public routes c. Break big tasks into steps
Instead of:
Refactor the entire API layer to use a new HTTP client Do it incrementally:
Step 1: Create the new HTTP client wrapper in src/lib/api/client.ts Then in a new session:
Step 2: Migrate the user endpoints in src/lib/api/users.ts
to use the new client from src/lib/api/client.ts 5. CLAUDE.md best practices
Your CLAUDE.md is the single most impactful thing you can do for Claude Code’s effectiveness.
a. What to include
- Build/test/dev commands: so it can run your project
- Key conventions: naming patterns, file organization
- Non-obvious constraints: “always use server-side rendering for this route”
- Tech stack specifics: framework version, runtime (Bun vs Node)
b. What not to include
- Obvious things (don’t explain what TypeScript is)
- Long documentation (link to docs instead)
- Frequently changing information (keep it stable)
c. Use rules files for topic-specific instructions
Instead of one massive CLAUDE.md, split into focused rules:
~/.claude/rules/
├── comments.md # Comment policy
├── anti-slop.md # Anti-pattern rules
└── testing.md # Test conventions These get loaded automatically alongside CLAUDE.md.
6. Multi-file editing workflow
Claude Code excels at coordinated changes across files. Here’s how to make the most of it.
a. Describe the full picture
Add a new "status" field to the User model. This needs:
1. Update the Prisma schema
2. Create a migration
3. Update the UserCard component to show the status
4. Add status to the API response type Claude Code will handle all four steps in sequence and keep the changes consistent.
b. Review changes before accepting
When Claude Code shows you file diffs, read them carefully. It’s easy to approve everything on autopilot, but a quick review catches issues early.
c. Use git as your safety net
Before a big multi-file change, make sure your working tree is clean:
git status # Should be clean
claude
> [your complex task]
# If something goes wrong:
git checkout . # Revert everything 7. Common pitfalls
a. Don’t let it spiral
If Claude Code goes down the wrong path (making changes you didn’t ask for, or trying overly complex solutions), interrupt it. Press Escape and redirect:
Stop. That's overengineered. Just add a simple if-check
in the handleSubmit function. No new abstractions. b. Don’t trust blindly
Claude Code is good, but it makes mistakes. Especially with:
- External API integrations: it may use outdated endpoints or wrong parameters
- Complex business logic: it doesn’t know your domain as well as you do
- Security-sensitive code: always review auth, encryption, and input validation manually
c. Watch for context degradation
If Claude Code starts giving weird answers, repeating itself, or forgetting what you just told it, the context window is probably full. Start a fresh session.
d. Don’t fight the tool
If you find yourself repeatedly correcting Claude Code on the same thing, add it to your CLAUDE.md instead. Persistent instructions beat repeated corrections every time.