10 Tips · Save 50% Tokens

Claude Code Tips

Double Your Productivity, Halve Your Token Usage

Claude Code is Anthropic's AI coding assistant that lives in your terminal — writing code, fixing bugs, and refactoring projects. But used poorly, it wastes tokens and delivers mediocre results. Here are the practical tips compiled from daily use to help you get the most out of Claude Code.

1. Be Specific with Your Requests

80% of Claude Code's quality depends on how you describe what you need.

❌

Optimize this function

Too vague. Claude Code doesn't know what to optimize — performance? Readability? Memory? Compatibility?

✅

Optimize this function's performance:
- Currently processes 10,000 records in 3 seconds, target is under 500ms
- Don't change the function signature or return type
- Prefer algorithm optimization over caching

The 5W1H Framework

Element
What to Include
Example
WhatWhat to doOptimize the sort function
WhyThe reasonCurrently takes 3s, too slow
WhereWhich filesrc/utils/sort.ts
WhenIn what contextWhen processing large datasets
WhichConstraintsDon't change the function signature
HowExpected outcomeUnder 500ms

The more specific your description, the more accurate the result — and fewer back-and-forth rounds means fewer tokens wasted.

2. Master the @ Syntax for Context

Claude Code supports @ references to point it at exactly the right files.

Common @ Commands

@file.ts          # Reference a single file
@src/utils/       # Reference an entire directory
@package.json     # Reference a config file
@git diff         # Reference Git diff
@git log -5       # Reference last 5 commits

Why This Saves Tokens

  • No need to copy-paste code into the conversation
  • Claude Code only reads referenced files, not the entire project
  • Avoids misunderstandings from insufficient context
@src/api/user.ts Add pagination to this module,
following the same pattern as @src/api/order.ts

3. One Task at a Time

This is the most overlooked token-saving technique.

❌

Help me:
1. Add pagination to user module
2. Write unit tests
3. Optimize API response speed
4. Update the frontend list component
5. Update docs

Too many tasks at once — Claude Code will likely miss requirements, produce inconsistent code, generate lots of unnecessary code, and burn through tokens.

✅

Step 1: Add pagination to user module, 20 items per page, with page number navigation
Step 2: Write unit tests for the pagination feature we just built

💡 One task at a time. Confirm completion before moving on. Better quality, fewer tokens.

4. Use CLAUDE.md for Project Memory

Claude Code reads a CLAUDE.md file in your project root for persistent context.

What to Put in CLAUDE.md

# Project Overview

- Tech stack: Next.js 14 + TypeScript + Prisma + PostgreSQL
- Code style: ESLint + Prettier, single quotes, 2-space indent
- Naming: PascalCase for components, camelCase for functions
- Test framework: Vitest
- API style: RESTful, response format: { code, data, message }
- Don't modify migration files
- Commit format: feat/fix/docs: description

Why This Matters

  • Claude Code reads CLAUDE.md automatically every session
  • No need to repeat project conventions each time
  • Generated code stays consistent
  • Significantly reduces back-and-forth token usage

5. Use Built-In Slash Commands

Claude Code includes slash commands that save time and tokens.

Command
Purpose
Token-Saving Benefit
/compactCompress conversation historyReduces context length for subsequent requests
/clearClear conversation historyFresh start, removes irrelevant context
/bugAuto-diagnose bugsMore precise than manual descriptions
/reviewCode reviewAuto-checks your recent changes
/initInitialize CLAUDE.mdAuto-generates project config

When to Use /compact

When the conversation gets long and Claude Code starts "forgetting" earlier agreements, run /compact. It compresses history while keeping key information, dramatically reducing token consumption for future requests.

6. Let Claude Code Plan Before Coding

A common mistake: asking Claude Code to write code immediately.

✅

First, review @src/api/user.ts and @src/types/user.d.ts
to understand the existing user module structure.
Then tell me how you plan to implement pagination.
I'll confirm before you start coding.
  • Avoids code that doesn't match expectations
  • Reduces "write, discard, rewrite" token waste
  • You catch misaligned thinking early

💡 Align understanding first, then code. This alone saves ~30% of wasted tokens.

7. Choose the Right Model

Model
Best For
Token Cost
Claude SonnetDaily development, code gen, bug fixesMedium
Claude OpusComplex architecture, large refactorsHigher
Claude HaikuSimple edits, formatting, quick Q&ALowest

Cost Strategy

  • Haiku for simple tasks: Rename a variable, format code, write a simple function
  • Sonnet for daily work: Feature development, bug fixes, write tests
  • Opus for complex tasks only: Architecture design, large-scale refactoring, complex algorithms

Switch models: /model claude-3-haiku-20240307

8. Avoid Common Token Wastes

1. Don't Repeatedly Explain the Same Things

Write project conventions in CLAUDE.md (see Section 4) instead of repeating them every conversation.

2. Don't Ask Claude Code to Do What It's Bad At

Claude Code excels at writing code, but struggles with: running large test suites (run locally instead), handling very long files (split files over 500 lines first), and making design decisions (you decide, it executes).

3. Don't Paste Large Code Blocks in Chat

Use @ to reference files. Pasted code wastes tokens by duplicating content already on disk.

4. Clean Up Conversations Regularly

After 20+ exchanges, use /compact to compress or /clear to start fresh.

9. Ready-to-Use Prompt Templates

Here are battle-tested prompt templates you can copy directly:

📝 Building a New Feature

In @src/api/user.ts, add a function to look up users by email.
Requirements:
- Function name: getUserByEmail
- Parameter: email: string
- Return: User | null
- Return null if user doesn't exist, don't throw
- Follow the style of the existing getUserById function

🐛 Fixing a Bug

The createOrder function at line 45 in @src/api/order.ts
produces duplicate inserts under concurrent calls.
Investigate and fix this issue.
Only modify the minimum necessary code, don't refactor anything else.

🧪 Writing Tests

Write unit tests for validateEmail and validatePhone in @src/utils/validate.ts.
Requirements:
- Use Vitest
- Cover normal cases and edge cases
- Place the test file in the same directory as validate.test.ts

👀 Code Review

Review my recent changes @git diff.
Focus on:
1. Security vulnerabilities (SQL injection, XSS)
2. Performance issues
3. Compliance with project code standards
Only list genuine issues, don't nitpick.

10. Token Usage Comparison

Same requirement, three different approaches:

Approach
Token Usage
Code Quality
Vague description + multiple tasks at once⭐⭐⭐⭐⭐⭐⭐
Specific description + one task at a time⭐⭐⭐⭐⭐⭐⭐
Specific + @references + CLAUDE.md⭐⭐⭐⭐⭐⭐⭐

💡 Invest time upfront in context management, and you'll reduce token usage by 50%+ over time.

Summary

Claude Code efficiency comes down to three things:

01

Be Specific

Tell it exactly what you want, don't make the AI guess

02

Manage Context

Leverage @references and CLAUDE.md

03

Break Tasks Down

One task at a time, confirm before proceeding

Build these habits and your productivity (and token efficiency) will improve dramatically.

Need Reliable Claude Code Relay?

Compare 10+ relay platforms on price and stability

View Claude Code Setup Guide