Skip to content
All posts

AI Coding Tips · Claude Code · Efficiency

AI Coding Tip #1: How to set up agents to save tokens and increase speed in Claude Code

· 5 min read

When you build with Claude Code or Codex, it's easy to start a session, pick an expensive model (e.g. Fable, Astra) for a complex task, and then stick with it for every prompt, even simple ones like drafting an email.

That costs you twice. You pay top-model prices for work a smaller model does just as well, and you wait longer for it. On top of that, every side task piles more text into your main session, so every later turn has more to re-read and gets slower and more expensive.

The fix takes about five minutes: subagents.

What a subagent is

A subagent is a helper that Claude Code can hand a task to. Each one is a small Markdown file with three things:

  • A description that tells Claude Code when to use it.
  • A model, so simple jobs can run on a cheaper, faster model like Haiku or Sonnet while your main session stays on the strong one.
  • A list of tools it's allowed to use, so a helper that only needs to read can't edit anything.

Each subagent also runs in its own context window. It does the work, then returns only the result. The files it read and the drafts it threw away never reach your main session, which keeps the main session short, fast and cheap.

Where the files go

Put subagent files in .claude/agents/ inside your project, or in ~/.claude/agents/ if you want them in every project. The file name doesn't matter much; the name field inside is what counts.

Here are three I use every day.

1. An email drafter on Haiku

.claude/agents/email-drafter.md

---
name: email-drafter
description: Drafts or rewrites emails, Slack posts, customer replies and other short messages. Use for any writing task that is not code, a translation, or a summary.
model: haiku
tools: Read
---

You draft short messages for the user: emails, Slack posts, replies to customers, partners and teammates.

- Write in the user's voice: direct, friendly, no filler. Match the language of the request (Korean or English) unless told otherwise.
- Use only facts given in the request or in files you are pointed to. Mark anything you had to assume with [brackets] so the user can fill it in.
- For an email, return a subject line and the body. For Slack, use short paragraphs and bullets that read well when pasted.
- Return only the draft, followed by a one-line note if something is missing. Never send anything yourself.

Short messages don't need your strongest model. Haiku writes them in seconds for a fraction of the cost. The [brackets] rule matters: a smaller model should flag what it doesn't know instead of making it up.

2. A translator on Sonnet

.claude/agents/translator.md

---
name: translator
description: Translates between Korean and English, and summarizes or rewrites existing text (for example "summarize in Korean", "make this easy to read in Slack"). Use for any translation or summary of text that already exists.
model: sonnet
tools: Read
---

You translate and summarize text for the user.

- Translate meaning and tone, not word by word. Keep names, numbers, URLs, code and product terms unchanged.
- Keep the source's structure (headings, lists, tables) unless asked to reformat.
- For a summary, lead with the outcome or decision, then the key points, in the requested language and length.
- When a phrase is ambiguous, pick the most likely reading and note it in one line after the result.
- Return only the result and any such note.

Translation needs more nuance than a quick email, so this one gets Sonnet: a middle step between speed and quality. Choose the model per job, not per session.

3. A read-only repo explorer on Haiku

.claude/agents/repo-explorer.md

---
name: repo-explorer
description: Read-only exploration of code and docs - find files, locate where something is implemented, read and summarize how a part works. Use before making changes, or to answer "where is" and "how does" questions.
model: haiku
tools: Read, Grep, Glob
---

You explore repositories for the main session and never change anything.

- Find what was asked with Glob and Grep, then read only the relevant parts.
- Report file paths with line numbers, a short explanation of how the pieces connect, and anything that looked surprising or inconsistent.
- Say plainly what you could not find. Do not guess.
- Keep the report under 300 words unless asked for more.

This one saves the most. Searching a codebase means reading lots of files that turn out not to matter. Done in your main session, all of that text stays there for the rest of the conversation. Done by the explorer, your main session gets back a 300-word report with file paths, and nothing else. It only has read tools, so it can't change anything by accident.

How Claude Code picks a subagent

Claude Code reads each subagent's description and hands a task over when it matches. That makes the description the most important line in the file:

  • Say when to use it, not just what it is. "Use for any translation or summary of text that already exists" works better than "A translator."
  • Draw clear lines between agents. Notice how the email drafter says "not code, a translation, or a summary." That keeps it from competing with the translator.
  • Call one by name when you want to be sure: "Use the repo-explorer agent to find where billing is handled."

You can also add a standing rule to your CLAUDE.md so delegation happens without asking:

For emails, Slack posts and translations, delegate to the email-drafter or translator subagent.
Before changing code, use repo-explorer to find the relevant files.

Keep the hard thinking on the main model

Subagents are for work that is well defined and easy to check. Keep these in your main session, on your strongest model:

  • Design and architecture decisions
  • Anything that needs the full history of the conversation
  • Security-sensitive changes
  • Final review of what the subagents returned

A good rule of thumb: if you could hand the task to a new teammate with a one-paragraph brief, a subagent can do it.

The payoff

  • Lower cost. Simple tasks run on models that cost a fraction as much per token.
  • More speed. Smaller models answer faster, and Claude Code can run several subagents at once.
  • A leaner main session. Less leftover text means every later turn is quicker and cheaper, and the main model stays focused on the hard part.

See whether it's working

How do you know you're actually spending less? That's one of the things Vibemetric measures. It reads your Claude Code and Codex sessions on your Mac and scores how you work with the agent across 10 dimensions, including Efficiency & Cost and Orchestration: Task Mapping, which looks at whether work goes to the right place. Each score cites the sessions behind it and comes with the exact rule or prompt to fix it. It rescores every day, so you can set up these three agents today and see the difference in your score.

Next tip: how to keep Claude Code read-only on your production database, so the agent can answer data questions but can never write to live data.

See how your own sessions score.

Vibemetric reads your Claude Code and Codex sessions on your Mac and shows you exactly what to change.

Download for Mac