ChatGPT and Claude trained us to chat: one question, one answer. But Claude Code and OpenAI Codex CLI are agentic coding environments. You describe a goal, and they read files, run commands, edit code, and debug on their own. It feels magical—until you notice the expensive truth: the biggest cost isn’t the model call; it’s the context window you waste.

Anthropic’s own best-practice docs put it plainly:

“Most best practices are based on one constraint: Claude’s context window fills up fast, and performance degrades as it fills.”

The context window is like hiring an engineer with limited memory. For the first 20 turns, they remember everything clearly. By turn 80, early instructions like “don’t touch this file” may have already faded. Then the AI starts repeating mistakes, re-exploring ground you’ve already covered, and giving shakier answers.

“Lazy” doesn’t mean making the AI do less work. It means making every dollar compound: configure once, reuse forever; verify once, cruise automatically; write one clear instruction, skip three rounds of rework.

This post summarizes six techniques that actually save tokens, time, and blood pressure, drawn from our daily use of Claude Code and Codex CLI.

1. Write an Onboarding Manual: CLAUDE.md / AGENTS.md

If you find yourself repeating “we use ESLint, tests run via npm test, tag before committing” every new session, you’re already wasting context.

Claude Code reads CLAUDE.md from the project root; Codex CLI reads AGENTS.md. They are the AI’s onboarding manual, shareable with your whole team.

But don’t turn them into Wikipedia. Claude’s official guidance on what belongs in CLAUDE.md is blunt:

✅ Include❌ Skip
Bash commands the AI can’t guessStandard language conventions it already knows
Project-specific style rulesLong API docs
Test commands and preferred runnersFile-by-file code walkthroughs
Env variables, secrets config, branch naming rulesGeneric advice like “write clean code”
Common pitfalls and non-obvious conventionsFrequently changing info

A good CLAUDE.md is usually 100–300 lines. The rule is simple: delete any line where the AI would still do the right thing without it. Bloated context is worse than no context.

# CLAUDE.md

## Commands
- Type check: `npm run typecheck`
- Run single test: `npm test -- --grep "pattern"` (prefer single tests over full suite)
- Build: `npm run build`

## Code style
- Use ES modules, not CommonJS
- Prefer destructuring imports
- Use `const` until proven otherwise

## Workflow
- Create a failing test before fixing a bug
- Run lint and typecheck before committing
- Don't modify files outside the requested scope

Codex CLI’s AGENTS.md follows a similar pattern. The key win: every new session loads it automatically, so you don’t have to keep repeating the rules out loud.

After writing it, use /context in Claude or codex --context to confirm the AI actually loaded it.

2. Give Enough Clues: Specific Prompts Are the Cheapest Fix

A vague prompt doesn’t save words; it launches expensive rework.

Claude Code’s docs give a classic before/after:

Weak promptStrong prompt
implement a function that validates email addresseswrite a validateEmail function. test cases: user@example.com → true, invalid → false, user@.com → false. run tests after implementing
fix the login bugusers report login fails after session timeout. check src/auth/, especially token refresh. write a failing test that reproduces it, then fix it
the build is failingthe build fails with this error: [paste error]. fix it and verify the build succeeds. address the root cause, don’t suppress the error

Codex CLI works the same way. Compare:

codex "refactor this"

with:

codex "refactor src/auth/login.ts to extract token refresh into a pure function. keep the public API unchanged. update src/auth/__tests__/login.test.ts. run the test suite at the end."

The second version fences the AI’s exploration, so tokens are spent on purpose.

Another small win: reference files with @ instead of describing them. Claude Code reads the file ahead of time, so you don’t have to paste its contents. Codex CLI also supports @file to feed files directly:

claude "@src/auth/login.ts extract the token refresh logic"
codex "@src/auth/login.ts @src/auth/__tests__/login.test.ts refactor token refresh"

3. Make the AI Its Own QA: Force a Pass/Fail Check

AI-generated code and human-written code share one flaw: after writing it, the author usually thinks it works. But without a check, “looks right” is the most common failure mode.

Claude Code’s best practices include a line worth taping to your monitor:

“Give Claude a check it can run: tests, a build, a screenshot to compare. It’s the difference between a session you watch and one you can walk away from.”

For a frontend change, add this to your prompt:

take a screenshot of the result and compare it to the original.
list differences and fix them.

Different verification strengths fit different tasks:

StrengthUse case
Inline prompt checkSmall changes: “run npm test after editing”
/goal conditionsSession-wide guardrails; AI self-checks each turn
Stop hooksAuto-run lint / typecheck / tests after every edit
Subagent reviewHigh-stakes changes reviewed by an isolated context

Codex CLI supports --approval-mode full-auto with test commands, but only enable full-auto where you already have a verification loop. Autonomy without a stop gate isn’t efficiency; it’s gambling.

One simple habit that pays off: end every feature prompt with “run tests and confirm all green before finishing”. The AI runs them itself, and error logs flow back into the next context, saving you from manually copying debug output.

4. Split Tasks: Subagents and Worktrees Protect the Main Context

The context window is your scarcest resource. Ask the AI to explore an unfamiliar module, and it may read 50 files before responding. All that content gets inserted into your main session, polluting the context you need for actual implementation.

Claude Code’s answer is subagents:

use subagents to investigate how our authentication system handles token refresh,
and whether we have any existing OAuth utilities I should reuse.

Subagents investigate in their own context window and return only the conclusion. Your main session stays clean and focused.

Codex CLI has no built-in subagent yet, but it shines at scriptable, parallel work:

# isolate parallel experiments with git worktree
git worktree add ../codex-experiment feature-x
cd ../codex-experiment
codex -p "try approach A: replace sync loop with async batching. run tests."

For batch tasks, use a shell loop:

for file in $(cat files-to-migrate.txt); do
  codex -p "Migrate $file from CommonJS to ESM. Return OK or FAIL." \
    --allowedTools "Edit,Bash(git commit *)"
done

Two money-saving principles here:

  1. Keep research sessions separate from implementation sessions.
  2. Run independent tasks in parallel, not one long serial session.

5. Ruthlessly Clean Context: /clear, /compact, /rewind

If you’ve been chatting for 50 turns and the first five tasks are still lying around, the degraded performance is your session-management fault, not the model’s.

Claude Code gives you context-management tools for exactly this:

CommandEffectWhen to use
/clearWipe the whole sessionBefore switching to an unrelated task
/compactSummarize history into a briefWhen you need continuity but the window is filling
/compact focus on API changesCompress while keeping a focus topicMid-way through a long coding session
/rewindRoll back to a checkpointWhen the AI veered off course
/btwAsk a one-off question without adding contextQuick signature lookups

The rule is simple: if the task is unrelated, /clear first.

We track an informal metric: if you’ve corrected the AI more than twice and it still hasn’t converged, the context is probably poisoned by failed attempts. The most cost-effective move isn’t to keep fixing—it’s to /clear and write a clearer new prompt that incorporates the lesson.

Codex CLI sessions are stateless; each codex -p starts fresh. That is itself a feature: one problem, one command; don’t pile every issue into one long chat.

6. Automate Whenever Possible: Full-Auto, -p, and CI

The advanced form of lazy is letting the AI run in the background.

Claude Code supports headless mode:

claude -p "list all API endpoints in this repo" --output-format json
claude -p "analyze this log file" --output-format stream-json --verbose

Codex CLI is command-first by design:

codex -p "fix all lint errors" --approval-mode auto

You can also restrict permissions with --allowedTools:

codex -p "migrate src/*.ts to ESM" --allowedTools "Edit,Bash(npm test)"

Wire this into CI:

# .github/workflows/codex.yml
- name: Auto-fix lint
  run: codex -p "fix lint errors and commit if changed" --approval-mode auto

Again: automation is only worth it where you already have a verification loop. Without test feedback, the AI may automate bugs at full speed.

Claude Code vs. Codex CLI at a Glance

AspectClaude CodeCodex CLI
Project instructionsCLAUDE.mdAGENTS.md
Non-interactive modeclaude -pcodex -p
Auto-approvalauto mode classifier--approval-mode auto/full-auto
SubagentsBuilt-in .claude/agents/No built-in; emulate with scripts and worktrees
Session management/clear, /compact, /rewind, resumeEach -p is a fresh context
Extensibilityskills, hooks, MCP servers, pluginsskills, slash commands, exec policy
Best forDeep, long-lived, memory-heavy tasksScriptable, batch, CI-driven work

These tools aren’t mutually exclusive. Our day-to-day split: Claude Code for deep, context-heavy features; Codex CLI scripts for standardized batch work.

Maintaining this Hugo site is a concrete example:

  • Long-form posts, theme edits, multi-language sync → Claude Code, because continuity matters.
  • Bulk front-matter updates, lint runs, thumbnail generation → Codex CLI -p scripts, one shot, no context pollution.

The Lazy Formula

Back to the core constraint: the context window fills up, and a full window gets dumber. Every technique in this post does one of three things:

  1. Show it less: use CLAUDE.md/AGENTS.md and specific prompts so the AI doesn’t have to keep guessing.
  2. Fail less: give every task a runnable check and fix errors where they appear.
  3. Don’t put everything in one basket: session isolation, subagents, worktrees, and CI scripts treat context as a scarce resource.

This isn’t about being lazier. It’s about graduating from a supervisor who watches the AI all day to an engineer who designs systems that run themselves.


If you’re using AI coding agents too

What do you want to save most: tokens, time, or sanity? Share your own tricks in the comments.