10 Ready-to-Use Claude Code Best Practices from the Author
The article presents ten actionable Claude Code techniques—including context‑window management, self‑validation prompts, planning mode, CLAUDE.md rules, parallel sessions, raw‑data bug fixes, sub‑agents, custom skills, prompt tricks, and context clearing—to help developers use the AI coding assistant efficiently and reliably.
Fundamental: The Context Window Is Your Most Expensive Resource
Claude Code operates with a limited context window that works like a whiteboard; every message, file, and command consumes space, and a fuller board degrades performance, causing forgotten instructions and errors. All subsequent tips aim to use this whiteboard more efficiently.
Tip 1: Let Claude Validate Its Own Work
Instead of manually checking Claude’s output, embed verification criteria directly in the prompt. Example prompt:
Write a function that validates email addresses. Test cases: [email protected] should pass, hello@ should fail, @domain.com should fail. After writing, run the tests and report the results.Claude can then run the tests and report pass/fail, reducing manual review. The official docs also suggest giving Claude a design mock to implement, compare screenshots, list differences, and fix them—creating an automatic error‑correction loop.
Tip 2: Plan Before You Code
Use Claude’s Plan Mode to read files and outline the project structure without writing code. Boris’s team follows a five‑step workflow:
Enter Plan Mode and let Claude read relevant files.
Ask Claude to produce a detailed execution plan (files to change, order, potential pitfalls).
Review the plan yourself and make adjustments.
Switch back to normal mode and execute the plan.
After execution, have Claude generate a clear commit message.
Some teams even have a second Claude act as a senior engineer to review the plan before any code is written.
Tip 3: Leverage CLAUDE.md
CLAUDE.md is a file placed at the project root that Claude reads on every start. Rules written here are automatically applied, eliminating repetitive instructions. Common rules include:
Use ES modules only, not CommonJS.
Avoid mocks in tests.
Run the linter after every change.
Branch naming convention: feature/ticket-号 When Claude makes a mistake, the team adds a note at the end of the conversation: “Update your CLAUDE.md to prevent this error next time.” Claude then writes the new rule into the file, allowing the file to evolve over time. The file should stay concise—each line must correspond to a real error; otherwise, delete it.
Tip 4: Parallel Sessions Are a Powerful Efficiency Lever
Claude Code supports multiple sessions simultaneously. Using Git worktrees, a team can run 3‑5 sessions in parallel, each handling a different task. Typical parallel workflow:
Session A : Implement a new feature.
Session B : Review Session A’s code, looking for edge cases and bugs.
Feed B’s feedback back to A.
This “write‑and‑review” pattern yields higher code quality than a single session looping over the same code. Another pattern uses Session A to write tests (TDD) and Session B to write code that passes those tests, letting Claude automate TDD without manual test execution.
Tip 5: Bug Fixing – Feed Raw Data Directly to Claude
Instead of describing a bug in words, paste the original error logs, Slack thread, or Docker output and simply say “fix.” Claude reads the raw data, locates the problematic code, and attempts a fix autonomously. This approach works for CI test failures as well—just say “fix the failing CI test” without specifying the cause.
Tip 6: Sub‑Agents Keep the Main Session Clean
When a deep investigation is needed, launch a sub‑agent (an independent Claude instance) to perform the research in its own context. After completing the investigation, the sub‑agent reports the conclusions to the main session, preserving the main whiteboard’s clarity.
Boris’s team extends this with Hooks + Opus 4.5 as sub‑agents that automatically scan permission requests, intercept suspicious actions, and safely approve legitimate ones—effectively a smart security guard for Claude Code.
Tip 7: Create Skills (Custom Commands) to Eliminate Repetitive Work
If a task is performed twice in a day, turn it into a skill. A skill is a named workflow that can be invoked with a single command. Example skill: /fix-issue – When you type /fix-issue 447, Claude will:
Read GitHub issue #447.
Locate relevant files in the project.
Apply the fix.
Run tests.
Create a Pull Request.
The team also built a BigQuery skill that lets anyone run data analyses inside Claude Code without writing SQL; Boris claims he hasn’t written SQL manually for six months. New skills /simplify and /batch automate PR review and batch code migrations, respectively.
Tip 8: Prompt Engineering Tricks for Better Answers
Three counter‑intuitive prompt patterns:
Make Claude Review You : Before opening a PR, ask Claude to “question the changes in the harshest way until I pass your tests.” This role reversal forces Claude to act as a reviewer, exposing more issues than a self‑review.
Ask Claude to Rewrite Elegantly : After an initial solution, say “You now know all the background. Overwrite the solution with a more elegant implementation.” Claude often produces a cleaner version.
Require Proof : Instead of trusting green tests, prompt Claude to “prove the change works by showing the behavior differences between main and my feature branch.”
Tip 9: Use /clear and Checkpoint to Manage Context Pollution
Long sessions can suffer from context pollution, where the whiteboard becomes cluttered and Claude’s responses drift. Two remedies:
/clear : Hard reset that wipes the entire context, then start with a fresh prompt.
/compact : Soft reset that tells Claude which parts to keep and discards the rest, e.g., /compact focus on payment integration changes.
Claude automatically creates checkpoint snapshots after each change, allowing you to roll back code, conversation, or both—even after the terminal is closed.
Advice: If you have corrected the same issue three times without success, clear the context and rewrite a more precise initial prompt.
Tip 10: Treat Claude Code as a Learning Tool
Beyond production, Claude can serve as a mentor. When starting a new project, ask questions such as “How does the logging system work?” or “Explain the purpose of this function.” Claude answers as a senior engineer would.
Additional learning tricks:
Ask Claude to generate HTML slides that visualize complex code.
Use spaced‑repetition learning: explain a module to Claude, let it probe your understanding, record gaps, and quiz you later.
Common Mistakes and Remedies
Kitchen‑sink session : Topic drifts in many directions – use /clear when switching tasks.
Correction loop : Re‑correcting the same error three+ times – clear context and rewrite the prompt.
CLAUDE.md bloat : Rules file exceeds 500 lines – delete lines that aren’t tied to a concrete error.
Unbounded investigation : Claude reads hundreds of files and exhausts context – limit the investigation scope or use sub‑agents.
Key Takeaways
Replace “hope Claude guesses right” with explicit verification criteria.
Invest time in planning; it saves hours of rework.
Let CLAUDE.md evolve by turning corrections into rules.
Parallel sessions are the biggest efficiency lever.
Sub‑agents keep the main dialogue clean.
/clear beats repeated corrections.
Use Claude Code as an experienced engineer, not just a code generator.
ShiZhen AI
Tech blogger with over 10 years of experience at leading tech firms, AI efficiency and delivery expert focusing on AI productivity. Covers tech gadgets, AI-driven efficiency, and leisure— AI leisure community. 🛰 szzdzhp001
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
