Start Every Project Right
Run /init immediately in a new project. A well-crafted CLAUDE.md with the 6 essential sections (Overview, Architecture, Conventions, Commands, Constraints, Context) saves more time than any other single action.
Start Every Project Right
Run /init immediately in a new project. A well-crafted CLAUDE.md with the 6 essential sections (Overview, Architecture, Conventions, Commands, Constraints, Context) saves more time than any other single action.
The .env.example Pattern
Never let Claude read .env directly. Create .env.example with placeholders and tell Claude: “Read .env.example and generate config using process.env.” This simple habit prevents 100% of accidental secret exposure.
Permission Muscle Memory
Build the habit: Read-only commands → auto-approve. Write commands → read first. Destructive commands → always deny. After a week, you will instinctively know what to approve and what to check.
The CREF Framework
Structure every non-trivial prompt with Context, Reference, Expectation, Format. Teams using CREF reduced code review rejection from 35% to 12%.
Selective Reading Saves 60% Context
Never say “read all files in src/.” Instead: (1) Ask for directory structure, (2) Ask for function signatures, (3) Only then read the specific file you need. This 3-layer approach uses 60% less context.
The /compact Sweet Spot
Compact at 50-70% context usage, not at 90%. Early compaction preserves more useful context. Think of it like defragmenting — better done proactively than in an emergency.
Always Set Boundaries for Auto Mode
Before any auto-coding session, specify: ALLOWED files, FORBIDDEN files, stop conditions, and a verification command. Without boundaries, Claude may modify files you did not intend.
The 3-Strike Rule
If the same approach fails 3 times with similar results, stop immediately. Ask: “What are we assuming that might be wrong?” This one rule saves an average of $8 and 45 minutes per stuck session.
Archeology Before Surgery
On legacy codebases, spend the first session ONLY reading — no modifications. Use the 3-layer strategy: Structure (the map) → Patterns (the routes) → Details (the streets). One team mapped a 50,000-line Java codebase in 5 days vs. estimated 3 weeks.
One Logical Change Per Commit
During incremental refactoring, commit after every single logical change. An 800-line legacy function refactored via 33 small commits over 4 weeks had zero production incidents. A big-bang rewrite of the same function broke payment, shipping, and audit logging.
Model Matching Saves 68%
A Vietnamese startup reduced Claude costs from $1,200 to $380/month simply by matching models to task complexity. Their discovery: “Haiku could do 80% of what we were using Opus for.”
Prompt Templates Are Multipliers
Create reusable templates for your most common tasks (/screen, /api-call, /debug). Teams report 40-60% faster task completion once their template library reaches 5-10 recipes.
Screenshot Paste Trick
On macOS: Cmd+Shift+Ctrl+4 to screenshot to clipboard, then Ctrl+V (NOT Cmd+V!) to paste into Claude Code. This is the fastest way to share visual context — faster than saving files and referencing paths.
Resume Sessions
claude -c continues your most recent conversation. claude -r opens a session picker. Never lose context when you close your terminal — your full conversation is preserved.
Multi-line Input
Type \ + Enter for multi-line prompts. Or run /terminal-setup once to enable Shift+Enter for multi-line in iTerm2, Ghostty, Kitty, and WezTerm.
Bash Mode
Prefix any command with ! to run it directly without AI interpretation. ! npm test runs your tests instantly. No waiting for Claude to process.
File References with @
Type @ followed by a file path for autocomplete. @src/utils/auth.js adds the file as context. Press Tab to autocomplete paths.
Quick Model Switch
Option+P (macOS) / Alt+P switches model without restarting. Jump from Sonnet to Opus for complex reasoning, back to Haiku for simple edits — all within one session.
Permission Mode Cycling
Shift+Tab cycles between Normal → Auto-Accept → Plan modes. Quick way to change permission level without typing commands.
| # | Technique | How | Savings |
|---|---|---|---|
| 1 | Selective reading | Ask for signatures/types first, full files later | -60% |
| 2 | Filtered output | Use head -20, tail -50, grep -A 5 | -80% |
| 3 | Strategic /compact | Compact at 30%, 60%, 80% markers | Resets to ~50% |
| 4 | Prompt brevity | ”Fix bug in saveUser” not a 500-word essay | -50% |
| 5 | File chunking | ”Read lines 1-100 of X” for large files | Read only needed parts |
| 6 | Avoid re-reads | Ask “Do you still have auth.ts in context?” | -100% duplicate cost |
# Check cost every 20-30 minutes/cost
# Sample output:# Input: 45,231 tokens ($0.14)# Output: 12,847 tokens ($0.19)# Total: 58,078 tokens ($0.33)
# If context > 60%, compact proactively/compactLarge Android/KMP projects (100K+ lines) require special strategies to stay within context limits.
Layer 1: Structure (The Map)├── "Show me the project directory structure"├── "What are the main modules?"└── "Where are the entry points?"
Layer 2: Patterns (The Routes)├── "What architecture pattern is used?"├── "Show me the dependency graph between modules"└── "How does data flow from API to UI?"
Layer 3: Details (The Streets)├── "Read src/auth/LoginViewModel.kt"├── "Trace the payment flow from button click to API call"└── "What happens when the token expires?"CLAUDE.md for Android Projects
Include: Clean Architecture layers, MVVM conventions, Compose vs XML preference, module boundaries, Gradle commands (./gradlew assembleDebug, ./gradlew test), and ProGuard rules to never modify.
KMP Shared Module Strategy
For Kotlin Multiplatform, tell Claude which code is shared (commonMain) vs platform-specific (androidMain, iosMain). Without this, Claude may write platform-specific code in shared modules.
Phase 1: Map (1 session)"Identify all files using deprecated API X"
Phase 2: Plan (1 session)"Create a migration plan — which files first, which have dependencies"
Phase 3: Execute (N sessions, batched)"Migrate files 1-10 from the plan. Test after each file."/compact"Migrate files 11-20..."| Pattern | Use Case | Example |
|---|---|---|
| Sequential Pipeline | Multi-step transformation | Email → Extract data → Generate report |
| Fan-Out/Fan-In | Parallel independent tasks | Analyze 10 PRs simultaneously |
| Classification Router | Different handling per type | Bug vs feature vs question triage |
| Human-in-the-Loop | Need approval | Code review with human sign-off |
| Batch Processing | Many items | Process 200+ customer reviews |
Always Use Full Path
In n8n Execute Command nodes, use /usr/local/bin/claude instead of just claude. The n8n process may not have your shell PATH.
Set Timeouts
Always set timeout in Execute Command nodes to 60000ms or more. Claude Code operations can take 30-60 seconds, especially for code generation tasks.
Prepare Prompts in Set Nodes
For complex prompts with quotes and special characters, build the prompt string in a Set node first, then pass it to the Execute Command. This prevents quote-breaking issues.
Watch for these signs that Claude may be hallucinating:
| Red Flag | Example | What to Do |
|---|---|---|
| Generic descriptive names | awesome-validator, fast-json-loader | Verify package exists: npm view <name> |
| No source links provided | ”Use the X library” with no URL | Ask: “Link me to the GitHub repo” |
| Version number claims | ”Added in v3.2.1” | Check official changelog |
| Suspiciously perfect match | Exactly the API you need, no trade-offs | Too good? Verify independently |
| Mixed syntax styles | React class + hooks in same component | Ask Claude to pick one approach |
| Confident but wrong | ”This is the standard way to…” | Confidence does not equal accuracy |
| What to Verify | Command | Source |
|---|---|---|
| npm package exists | npm view <package> | npmjs.com |
| Python package exists | pip show <package> | pypi.org |
| CLI flag exists | command --help | Official docs |
| File path exists | ls -la <path> | Your system |
| API endpoint works | curl -I <url> | Live server |
When Claude gets stuck in a loop or produces incorrect output:
| Step | Action | Prompt |
|---|---|---|
| 1. Redirect | Change approach | ”Stop. Try a completely different approach.” |
| 2. Inform | Provide missing context | ”You might be missing: the API returns XML, not JSON.” |
| 3. Decompose | Break into smaller parts | ”Forget the full solution. Just solve the auth part first.” |
| 4. Refresh | Clear stale context | /compact |
| 5. Reset | Start fresh | /clear |
| 6. Human | Take over | You write the code manually |
The Phantom Package
Claude suggests npm install super-fast-orm. You install it. It does not exist. Prevention: Always npm view <package> before installing.
The Invented API Field
Claude uses response.auto_confirm in payment integration. The field does not exist in the API. One fintech team lost 2 days debugging this in staging. Prevention: Cross-reference every API field with official docs.
The Deprecated Method
Claude uses componentWillMount in React. It was deprecated years ago. Prevention: If Claude suggests any lifecycle method, verify it against current React docs.
The Confident Wrong Answer
Claude says “PostgreSQL supports UPSERT natively since version 9.0.” Actually, it was version 9.5. Small detail, big consequences if you target older versions. Prevention: Always verify version-specific claims.
Add this section to your CLAUDE.md to reduce hallucinations:
## Verification Rules- NEVER suggest packages without confirming they exist on npm/pypi- ALWAYS provide GitHub or docs URLs for third-party libraries- If unsure about an API, say "needs verification" instead of guessing- When suggesting version-specific features, cite the changelog