Real AI agent use cases, with sources and setup prompts
How to cut Claude Code, Codex and Cursor costs: commands, settings and prompts that save tokens (Nov 2026)
Short answer: Most coding-agent spend is context: every message re-sends the whole conversation, files the agent read, tool output and your CLAUDE.md. So the biggest savings come from sending less. Run /usage in Claude Code or /status in Codex to see where your limit goes, and `npx ccusage@latest daily` for a per-day report from local logs. Then: /clear between unrelated tasks, /compact with a focus line on long ones, keep CLAUDE.md under about 200 lines, turn off unused MCP servers in /mcp, and have tests print only failures. Use Sonnet (or Codex's GPT-6 Luna) by default and save Opus or GPT-6.1 Sol for hard problems, lower /effort on simple edits, and send searches to a Haiku subagent. In Cursor, use Composer 2.5 ($0.50 in / $2.50 out per million tokens) or Auto's Cost mode for routine edits and set a monthly additional usage limit. For unattended runs, add `--max-budget-usd`. Anthropic's own figure: enterprise Claude Code users average about $13 per developer per active day, and 90% stay under $30.
Measure first, then shrink context, pick cheaper models and cap spend. Exact Claude Code, Codex and Ollama commands with current prices. 24 matching use cases below, each with a public source.
Reads local logs from Claude Code, Codex, OpenCode, Gemini CLI, Copilot CLI and more, and prints daily, weekly, monthly and session token and cost reports.
Cursor's own fast coding model and its Cost-mode Auto router. Both draw from your weekly included pool instead of prepaid credit, so they're the cheapest way to do routine edits in Cursor.
Included in paid plans; beyond the pool $0.50 in / $2.50 out per 1M tokens
Prices are from each official page, checked Nov 9, 2026; they exclude tax and can change. Swipe the table sideways on a phone.
Claude Code: measure, shrink context, pick the cheaper model
These commands come from Anthropic's cost documentation for Claude Code. They work the same on a Pro or Max plan (where they stretch your 5-hour and weekly limits) and on API billing (where they cut the bill).
See where the tokens go. /usage shows session cost, a prompt-cache line and which skills, subagents, plugins and MCP servers used the most of your plan, with suggestions. ccusage gives you history across days and tools from your local logs.
bash
# Inside Claude Code
/usage # session cost, prompt-cache line, plan usage by skill/subagent/MCP
# press d / w for the last 24 hours / 7 days, f to fix a flagged item
/context # what is filling the context window right now
/mcp # turn off MCP servers you are not using this session
# Inside Codex CLI
/status # remaining 5-hour and weekly limits
# Across tools, from your local logs (free, open source)
npx ccusage@latest daily --since 2026-10-01
npx ccusage@latest claude daily
npx ccusage@latest codex daily
npx ccusage@latest blocks # Claude Code 5-hour windows
Clear, compact and rewind instead of piling on. Old context is re-sent on every message. Clear between tasks, compact long ones with a focus, and rewind when the agent goes the wrong way instead of explaining the fix in three more messages.
text
/clear # start fresh between unrelated tasks (/rename first, /resume later)
/compact Focus on the failing test and the files I changed
/rewind # go back instead of piling corrections on a wrong turn
/effort low # simple edits; raise to medium/high for hard bugs
/model sonnet # default for most coding; /model opus only for hard planning
/model opusplan # Opus while planning, Sonnet while writing code
Make CLAUDE.md cheap. CLAUDE.md loads into every session, so keep it short and move long workflows into skills, which only load when used. A "# Compact instructions" section controls what survives /compact.
markdown
# CLAUDE.md (keep it under ~200 lines; move long workflows into skills)
# Compact instructions
When compacting, keep: the task goal, files changed, test commands and
the last error. Drop: full file contents, old command output, search results.
## Cost rules
- Read only the files you need. Use rg with a path, not repo-wide searches.
- Use the gh CLI instead of the GitHub MCP server.
- Run tests with failures-only output. Never paste whole logs.
- Ask before starting subagents or agent teams.
Send reading and searching to a Haiku subagent. Subagents keep noisy search output out of your main context, and model: haiku runs them on the cheapest model. Set CLAUDE_CODE_SUBAGENT_MODEL to force one model on every subagent.
markdown
# ~/.claude/agents/explorer.md - a cheap subagent for reading and searching
---
name: explorer
description: Reads code, searches the repo and summarizes findings. Use for any lookup or exploration.
model: haiku
tools: Read, Grep, Glob
---
Search and read only what the task needs. Return a short summary with file
paths and line numbers. Never edit files.
Let /usage fix the big items and stop idle usage. On Pro, Max, Ultra, Team or Enterprise, /usage lists anything behind 10% or more of your recent usage with a suggested fix. Press f to have Claude Code apply the ones it can (needs v2.1.305 or later). /insights writes an HTML report of how you work. Sessions also spend tokens while idle: scheduled /loop tasks, goal check-ins, messages from your other sessions, and prompt suggestions. Turn off what you don't use.
bash
/usage # press f to apply fixable recommendations
/insights # report saved to ~/.claude/usage-data/report.html
/effort low # simple edits; thinking tokens bill as output
# shell: stop idle goal check-ins for this session
export CLAUDE_CODE_GOAL_CHECKIN_MINUTES=0
# fixed-thinking-budget models only (adaptive models ignore it)
export MAX_THINKING_TOKENS=8000
# settings.json: hold messages from your other sessions until you're back
{ "crossSessionInbound": "hold" }
Cut tool output and cap spend: hooks, budgets and a cost status line
Test logs, search results and MCP output can be thousands of tokens per call. A hook can trim them before the agent sees them, and a dollar cap stops a loop from running up a bill.
Register a PreToolUse hook. This is Anthropic's example: before every Bash command, a script checks if it is a test run.
Add the script that shows only failures. Needs jq. Verify with /hooks, or start claude --debug-file ./claude-debug.txt and ask it to run npm test.
bash
mkdir -p ~/.claude/hooks
cat > ~/.claude/hooks/filter-test-output.sh <<'EOF'
#!/bin/bash
input=$(cat)
cmd=$(echo "$input" | jq -r '.tool_input.command')
# If running tests, filter to show only failures
pattern='^(npm test|pytest|go test)( [^;&|<>`$#\\[:cntrl:]]*)?$'
if [[ "$cmd" =~ $pattern ]]; then
filtered_cmd="$cmd 2>&1 | grep -A 5 -E '(FAIL|ERROR|error:)' | head -100"
echo "$input" | jq --arg filtered "$filtered_cmd" \
'{hookSpecificOutput: {hookEventName: "PreToolUse", updatedInput: (.tool_input + {command: $filtered})}}'
else
echo "{}"
fi
EOF
chmod +x ~/.claude/hooks/filter-test-output.sh
# Check it loaded: run /hooks in Claude Code (it should be under PreToolUse)
Cap scripted runs and watch the meter. --max-budget-usd stops a print-mode run once its estimated API spend reaches the amount (it can go slightly past, so leave headroom). The status line shows context percent and estimated cost at all times.
bash
# Hard dollar cap for scripted / unattended runs (print mode, API billing)
claude -p --max-budget-usd 5.00 --max-turns 30 "Fix the failing test in tests/test_api.py"
# Show estimated session cost all the time in the status line
# ~/.claude/settings.json
{
"statusLine": {
"type": "command",
"command": "jq -r '\"[\\(.model.display_name)] \\(.context_window.used_percentage // 0)% context $\\(.cost.total_cost_usd // 0)\"'"
}
}
Codex and free local models
On a ChatGPT plan, the model you pick decides how far your 5-hour limit goes: on Plus, OpenAI lists about 350 to 3,000 local messages per 5 hours on GPT-6 Luna versus 15 to 160 on GPT-6.1 Sol. Fast mode uses 2.5x the usage. For bulk or private work, local models through Ollama cost nothing per token.
Set a cheaper default in config.toml. Use the small model and low reasoning effort by default; switch per session when a task is hard. OpenAI also suggests shorter prompts, fewer MCP servers and nested AGENTS.md files so only the relevant rules load.
toml
# ~/.codex/config.toml
model = "gpt-6-luna" # cheapest model: most messages per 5 hours
model_reasoning_effort = "low" # raise to "medium" or "high" only for hard tasks
# One-off: use a bigger model just for this session
codex -m gpt-6.1-sol
# Inside Codex
/status # check remaining limits before a big job
Run routine work on local models. Ollama launches Codex or Claude Code against local models. Local models are slower and weaker on big refactors, so use them for renames, tests, docs and boilerplate.
bash
# Free local models through Ollama (needs a 64k+ context window)
ollama pull qwen3-coder # or another tool-capable model from ollama.com/search
ollama launch codex # Codex CLI on Ollama models; /model to switch
ollama launch claude # Claude Code on Ollama's Anthropic-compatible API
# Configure without launching
ollama launch codex --config
Split the work. Plan and review with the strong model, let the cheap or local one do the reading and typing. KitRank's [Claude Code and Codex together](/how-to/how-to-use-claude-code-and-codex-together.html) guide shows a reviewer setup.
Cursor: stay inside the weekly pool and cap paid usage
From Cursor's pricing docs (Nov 2026). Paid plans include one weekly pool for Cursor's own models, shared with Grok. Third-party models (Claude, GPT, Gemini) are paid from prepaid credit at API list price on Premium and above, so they're where surprise bills come from.
Check what's left and when it resets. Your remaining weekly usage and next reset date are shown in your editor settings and under Usage at grok.com/dashboard. The pool refreshes weekly, so one heavy day doesn't use up your month.
text
# Browser
https://grok.com/dashboard # Usage: remaining pool + reset date
https://grok.com/dashboard/billing # Additional usage credits, Auto Top-up, monthly limit
Default to Cursor models for routine work. Composer 2.5 is the cheapest model in the pool table ($0.50 input / $2.50 output per million tokens). Grok 4.7 is $2 / $6. Fast mode doubles the price, and Grok 4.7 above 256k input tokens bills at 2x. Auto in Cost mode bills as a Cursor-model request whatever model serves it. Pick a third-party model only for the hard step, then switch back.
text
# Cursor model picker, cheapest first (per 1M tokens, in / out)
Composer 2.5 $0.50 / $2.50
Grok 4.7 $2 / $6 (Fast and >256k context: 2x)
Claude Sonnet 5.5 $2 / $10 (third-party: prepaid credit)
Claude Opus 5.5 $4 / $20 (third-party: prepaid credit)
Set a monthly cap before turning on Auto Top-up. Under Additional usage credits at grok.com/dashboard/billing, set a monthly additional usage limit first. It caps paid usage each month no matter how much credit you hold. Only then decide whether you want Auto Top-up to refill credit below a threshold.
text
grok.com/dashboard/billing
> Additional usage credits
1. Monthly additional usage limit: e.g. $20
2. Auto Top-up: off (or a small threshold)
Further reading:How to compare AI models on the same prompt Test whether a cheaper model passes your checklist before you switch: blind A/B script, promptfoo and Dec 2026 prices.
Further reading:How to use Claude Code and Codex together Split work between a Claude plan and a ChatGPT plan: Claude builds, Codex reviews, and a capped loop keeps both limits safe.
Further reading:How to run local LLMs with AI agents Move routine coding work to a free local model: Claude Code, Codex or OpenCode on Ollama, LM Studio or llama.cpp with a 64k context.
Further reading:How to get AI code review on your pull requests What AI PR review really costs: Copilot $10/mo, Codex with ChatGPT Plus, CodeRabbit free on public repos, PR-Agent with your own key.
Further reading:How to build with Gemini 4 Argon Estimate what Gemini 4 Argon costs now that its price doubled to $4/$20 on Dec 1, 2026.
Copy-paste prompts
Written for this setup. Replace anything in [brackets] before you send it.
1. Find what is costing the most
Start of a cost cleanup, in Claude Code
Run /usage and /context and read my CLAUDE.md and .mcp.json. List the 5 biggest things filling my context or using my plan (files, MCP servers, skills, long outputs), with a rough token estimate for each and one concrete fix per item. Don't change anything yet.
2. Shrink my CLAUDE.md
CLAUDE.md is over ~200 lines
Rewrite CLAUDE.md to under 120 lines. Keep only rules that apply to every task: build and test commands, code style, things you must never do. Move each task-specific workflow (releases, migrations, PR review) into its own skill in .claude/skills/<name>/SKILL.md, and add a "# Compact instructions" section saying what to keep when compacting. Show me the diff before saving.
3. Scoped task prompt
Any normal coding task
Fix <bug> in <path/to/file>. Only read these files unless you hit something you can't resolve: <file1>, <file2>. Run `<test command>` and show only failing tests. Don't refactor anything else. Stop and ask if the fix needs changes in more than 3 files.
4. Plan cheap, build cheap
Bigger feature
Plan mode: write a numbered plan for <feature> with the files to change and a test for each step. Keep it under 15 lines. Don't write code. After I approve, do each step in order with the smallest diff, run the tests after each, and give me a one-line status instead of full output.
5. Make a cheap explorer subagent
Lots of searching and reading
Create ~/.claude/agents/explorer.md: a subagent with model: haiku and only Read, Grep and Glob tools that searches the repo and returns a short summary with file paths and line numbers. Then use it for every lookup in this session instead of reading files yourself.
6. Compact before a break
Stopping for more than a few minutes
Before I leave: write a 10-line handoff in notes/handoff.md with the goal, what's done, files changed, the next step and the exact test command. Then I'll /clear and start the next session from that file.
7. Weekly cost review
Once a week, in a terminal
Run `npx ccusage@latest weekly` and `npx ccusage@latest session`. Show me the 5 most expensive sessions, what model and project each used, and for each one a concrete change (smaller model, /clear earlier, filter output, subagent) that would have cut it. Keep it to a table.
8. Apply my /usage recommendations safely
After /usage shows rows like 'Trim CLAUDE.md' or 'Switch to /effort high'.
Here are the recommendations from my /usage screen:
[paste the rows]
For each one, show me the exact change you'd make (diff for files, command for settings) and the rough token saving per request. Do them one at a time and wait for my OK before each. Don't touch anything not on this list.
9. Move CLAUDE.md sections into skills
CLAUDE.md is over about 200 lines or holds workflow-specific instructions.
Read CLAUDE.md. Keep only what every session needs (project purpose, build/test commands, hard rules) and keep it under 200 lines.
Move each workflow-specific section (e.g. PR reviews, migrations, releases) into its own skill in .claude/skills/<name>/SKILL.md with a one-line description saying when to use it.
Show me the new CLAUDE.md and the list of skills before writing anything.
10. Cheap model first, escalate only on failure
Routine bug fixes in Cursor, Codex or Claude Code.
Use the cheapest model for this task: [task, with exact file paths].
Run [test command] after the change. If the tests still fail after two attempts, stop and tell me what you tried and why it failed, so I can switch to a stronger model for just this step. Don't read files outside [folder] unless the error points there.
11. Audit idle and background usage
Your limit drops even on days you barely code.
Check this Claude Code setup for anything that uses tokens while I'm idle: scheduled /loop tasks, goals with check-ins, agent teammates still running, subagents left open, prompt suggestions, and messages from other sessions.
List each one you find with where it's configured and the exact command or setting to stop it. Don't change anything yet.
Safety checklist
Prompt-cache expiry makes resuming a long session after a break the most expensive thing you can do. One builder found 280 times his context was rewritten after the cache expired. Compact or hand off before long breaks.
--max-budget-usd and ccusage use client-side estimates at list price, not your real bill. Check the provider's billing page and set a spending limit there too.
Agent teams use about 7 times the tokens of a normal session in plan mode, per Anthropic. Ask the agent to get your OK before starting teams or many subagents.
Local and very cheap models make more mistakes. Review their diffs and run tests before you merge, and keep secrets out of prompts no matter which model you use.
Running out of plan usage can switch you to paid usage credits at API rates if you have them turned on. Check /usage-credits in Claude Code and your Cursor spending caps.
Pressing f on /usage changes settings like /effort right away. Review what it applied, especially before long unattended runs.
Claude Pro (includes Claude Code): $20/mo, or $17/mo billed yearly. Max $100/mo for 5x usage; Ultra $200/mo
Claude API, per 1M tokens: Haiku 5.5 $0.10/$0.50; Sonnet 5.5 $2/$10; Opus 5.5 $4/$20. Input / output. Cache reads are 10% of input price (Sonnet $0.10, Opus $0.20)
Typical Claude Code spend (Anthropic's figure): About $13 per developer per active day. $150 to $250 per developer per month; 90% of users under $30 per active day
ChatGPT plans (include Codex): Free $0, Go $8/mo, Plus $20/mo, Pro from $100/mo. Plus: about 350 to 3,000 GPT-6 Luna messages per 5 hours, or 15 to 160 on GPT-6.1 Sol
Cursor: Free; Plus $8; Premium $30; Super $100; Ultra $200 per month. Third-party models billed at API list price on top
ccusage, jq, OpenCode: Free. Open source
Ollama: Free locally. Cloud Pro $20/mo, Max $100/mo; local models need a 64k+ context window
Cursor models beyond the weekly pool (per 1M tokens): Composer 2.5 $0.50 / $2.50; Grok 4.7 $2 / $6. Fast mode 2x; Grok 4.7 over 256k input 2x; Auto Cost mode draws from the pool
The Daily 5
Get five new use cases like these tomorrow morning
Five new real AI use cases every morning. Free. Unsubscribe any time.
One of his Claude Code sessions ran 9,849 turns with 68 compactions, and 280 times he came back after the cache expired so the whole context was rewritten. He built a free offline tool with an AI agent to show where his tokens went.
A developer tested resuming long sessions in Claude Code with Opus 5.5 and in Codex with GPT-6.1 Sol, both on medium effort, and watched the usage meters. Resuming a long Claude Code session took a big chunk of the 5-hour limit, while codex resume did not show the same jump.
After watching Claude Code spend many tool calls on regex searches that returned bloat, the builders made Indexio to index the codebase so agents stop rediscovering it.
Shipped Boost, a layer in front of coding agents that compresses noisy command and MCP output, with a cold-resume card for Claude Code prompt-cache spend.
SpendVeto adds a budget, a loop detector and a kill switch to Claude Code and Codex. When an agent kept rerunning a failing test, each retry being a paid model call, it stopped the loop at call 7.
LunoPeak is an open-source local dashboard for Claude Code, Codex and Cursor sessions with live view, replay, transcript search and per-session token cost. Version 2.1.0 rolls subagent tokens into the parent session across your history.
A cold-email operator had his chief-of-staff bot install the Codex CLI on its computer and sign in with ChatGPT, plus an API key for cheaper models. Grok Bot keeps the judgment calls (Calendly booking, CRM follow-ups) and offloads CSV classification, scrapers, spintax and transcript summaries.
devinstubbs connected Grok Bot to the Tibber and Tesla APIs so it watches live house power use and controls charging on both cars, staying under grid fee limits and shifting charging to cheaper hours.
realMattAbrams runs a custom Grok Bot team that is translating a Hebrew tome and producing the book. He found ArtCraft's DesignCraft can be driven headless by agents through a CLI at about the same token spend, so the bots can use it for layout.
Two founders kept switching coding agents whenever usage limits ran out or a better model came out, and had to re-explain tasks, workflows and past mistakes each time. They built an open-source, cross-harness memory layer the agents share.
A trader runs a Grok Bot that scans Solana memecoins and low-cap tokens, finds setups, places leveraged trades through Arqen's Telegram trading bot and watches stops and targets 24/7.
Cloudflare's open-source, MIT-licensed security audit skill installs with npx skills add and runs when you prompt "security audit this codebase". Because several agents double-check each finding it is slow and costly on big monorepos, so scope it to specific directories.
How do you cut Claude Code, Codex and Cursor costs: commands, settings and prompts that save tokens (Nov 2026)?
Most coding-agent spend is context: every message re-sends the whole conversation, files the agent read, tool output and your CLAUDE.md. So the biggest savings come from sending less. Run /usage in Claude Code or /status in Codex to see where your limit goes, and `npx ccusage@latest daily` for a per-day report from local logs. Then: /clear between unrelated tasks, /compact with a focus line on long ones, keep CLAUDE.md under about 200 lines, turn off unused MCP servers in /mcp, and have tests print only failures. Use Sonnet (or Codex's GPT-6 Luna) by default and save Opus or GPT-6.1 Sol for hard problems, lower /effort on simple edits, and send searches to a Haiku subagent. In Cursor, use Composer 2.5 ($0.50 in / $2.50 out per million tokens) or Auto's Cost mode for routine edits and set a monthly additional usage limit. For unattended runs, add `--max-budget-usd`. Anthropic's own figure: enterprise Claude Code users average about $13 per developer per active day, and 90% stay under $30.
Why does Claude Code use so many tokens?
Every message re-sends the conversation so far, plus CLAUDE.md, files the agent read, tool output and MCP tool definitions. Long sessions, big search results and test logs add up fast. /context shows what is filling the window, and /usage shows what used your plan.
How do I see what Claude Code costs me?
Run /usage inside Claude Code for session cost and plan usage by skill, subagent and MCP server (press d or w for 24 hours or 7 days). For history across days and tools, run `npx ccusage@latest daily` in a terminal. On API billing, the Claude Console shows the real bill.
Does /compact save tokens?
Yes on long sessions: it replaces the history with a summary, so later messages send less. Add a focus, like /compact Focus on the failing test. But compacting after a long break costs the most because the cache has expired, so compact before you step away, and use /clear when you switch to an unrelated task.
Which model is cheapest for coding?
In Claude Code, Haiku 5.5 is the cheapest ($0.10 in / $0.50 out per million tokens up to 100K), then Sonnet 5.5 ($2 / $10). Use Sonnet by default and Haiku for subagents. In Codex, GPT-6 Luna gives the most messages per 5 hours. Local models through Ollama cost nothing per token.
How do I stop hitting the Claude Code usage limit?
Measure with /usage, clear between tasks, keep CLAUDE.md short, turn off unused MCP servers, lower /effort on simple edits, use Sonnet and Haiku subagents instead of Opus, and filter test output with a hook. KitRank's [usage limits guide](/how-to/how-to-track-claude-code-and-codex-usage-limits.html) covers trackers that warn you before you hit it.
Is it cheaper to use the API or a subscription?
For daily use, usually a subscription: Anthropic's average is about $13 per active day on the API, roughly $150 to $250 a month, while Pro is $20 and Max $100. The API makes sense for light or scripted use, where --max-budget-usd gives you a hard cap per run.
Why does my Claude Code limit drop when I'm not using it?
Open sessions can still send requests: scheduled /loop tasks fire on their interval, goals run idle check-ins (set CLAUDE_CODE_GOAL_CHECKIN_MINUTES=0 to stop them), messages from your other sessions start new turns, and prompt suggestions send a small request after each reply. Each of these resends your context. Close sessions you're done with, or /clear them.
What is the cheapest model in Cursor?
In Cursor's Nov 2026 pricing table, Composer 2.5 is the cheapest model in the included pool at $0.50 per million input tokens and $2.50 per million output. Auto in Cost mode also bills as a Cursor-model request. Third-party models like Claude and GPT are paid separately from prepaid credit at API list price.
Is /compact free?
No. /compact reads the whole conversation to summarize it, so compacting a big context is itself a big request. If you don't need continuity, /clear costs nothing. Compact before a long break so you don't pay to rebuild an expired cache.
Which AI tools do people use to cut Claude Code, Codex and Cursor costs: commands, settings and prompts that save tokens (Nov 2026)?
Across the 24 sourced use cases in this guide, the most used tools are Claude Code, OpenAI Codex, Cursor, Grok Bot, Ollama.
How much does it cost to get started?
3 of the 24 use cases can start on a free plan. The most common paid starting price is $17/mo (13 use cases). Prices come from each tool's official pricing page.
How long does setup take?
8 of the 24 use cases list a setup time of an hour or less. Each card shows the setup time the builder reported.
Are these real examples?
Yes. Every use case links to its public source (an X post, a Hacker News thread or a GitHub repo) with the author and date, so you can check it yourself.
The Daily 5
Liked this guide? Get five new use cases tomorrow morning
Five new real AI use cases every morning. Free. Unsubscribe any time.