Claude Code vs Codex CLI vs Copilot CLI vs Antigravity CLI: How to Cut Token Costs and Manage…
A practitioner’s comparison of Claude Code, Codex CLI, GitHub Copilot CLI, and Antigravity CLI
Claude Code vs Codex CLI vs Copilot CLI vs Antigravity CLI: How to Cut Token Costs and Manage Context (2026 Guide)
A practitioner’s comparison of Claude Code, Codex CLI, GitHub Copilot CLI, and Antigravity CLI
Researched July 2026. Where a claim comes from official docs it’s marked; where it comes from community benchmarks, blog posts, or GitHub issues, that’s called out explicitly — this space moves fast and vendors don’t document everything.

Why this matters
All four tools sit on top of prefix-based prompt caching (Anthropic, OpenAI, and Google all implement some flavor of it). The mechanics are similar everywhere: a model re-encodes your prompt prefix once, caches the resulting KV tensors, and reuses them on the next call if the prefix matches byte-for-byte. Break the prefix — change a system prompt, add a tool, switch models, wait too long — and you pay full price again. The five levers below are where you have actual control over that behavior in each tool.
The repos, for reference
ToolRepositoryDocsClaude Codeanthropics/claude-codecode.claude.com/docsCodex CLIopenai/codexdevelopers.openai.com/codex/cliGitHub Copilot CLIgithub/copilot-clidocs.github.com/copilotAntigravity CLI (agy)google-antigravity/antigravity-cliantigravity.google/docs/cli-getting-started
1. Output Compression
Cutting down generation tokens by forcing terser prose. This only touches output tokens — input/prefill cost is untouched, which matters a lot for your Java/Scala monorepo work where the prompt (code context) usually dwarfs the reply.
Claude Code. The ecosystem has genuinely productized this. JuliusBrussee/caveman is a real, actively maintained Claude Code skill (also ported to Codex, Gemini CLI, Cursor, and others) that instructs the agent to drop filler and narration while explicitly preserving code, commands, and error text untouched. The maintainer’s own benchmark claims a 65% mean output-token reduction across a 10-prompt suite, with the honest caveat printed right in the README: input and reasoning tokens are untouched, the skill itself adds ~1–1.5k input tokens per turn as overhead, and independent community reproductions on r/ClaudeCode found a plain one-line “be brief” instruction captures most of the benefit on its own. A companion /caveman-compress command also shrinks CLAUDE.md and other memory files permanently, which is the more durable win since that savings compounds every session. Realistically, for a full working session this lands around 5–10% total token savings once you net out input/reasoning tokens, not the headline 65%. The more standard, officially-supported route is simpler: put a "be concise, no filler, no meta-commentary" instruction directly in your project's CLAUDE.md, and use /effort low or /effort medium (see §5) for boilerplate work, since lower reasoning effort also produces shorter final answers.
Codex CLI. OpenAI hasn’t shipped or endorsed an equivalent compression skill. Compression here is achieved through AGENTS.md instructions (Codex's equivalent of CLAUDE.md) and the --output-schema flag, which forces structured JSON output instead of free-form prose — useful in CI where you're parsing Codex's result programmatically anyway (see openai/codex-action docs). Codex's built-in code-review subagent and reasoning effort settings are the main cost levers; there's no dedicated "terse mode" flag as of the current release.
GitHub Copilot CLI. No user-facing terseness toggle either, but it has a genuinely useful automatic behavior: it compresses conversation history in the background once you approach 95% of the token limit, without interrupting your session (see GitHub Docs). For output specifically, your main lever is choosing a smaller/faster model via /model for mechanical tasks, since Copilot CLI multiplexes Anthropic, OpenAI, and Google models and lets you pick per-task.
Antigravity CLI. No documented output-compression feature specific to agy. Verbosity control here is entirely prompt-based via AGENTS.md, same pattern as Codex. Community coverage of the tool (see DEV Community walkthrough) doesn't mention a caveman-style skill; if you want that behavior here you'd import the same JuliusBrussee/caveman skill, which the vendor's own list of supported agents includes.
2. Inactivity Cache Expiry
This is the one area where the underlying vendor documentation is genuinely precise, and it’s worth knowing the real numbers rather than folklore.
Claude Code / Anthropic API. Anthropic’s prompt caching docs are explicit: cache entries have a minimum lifetime of 5 minutes (standard) or 1 hour (extended, opt-in via “ttl”: “1h” in cache_control). The clock resets on every cache read, so a chatty session keeps itself warm without incurring the write cost repeatedly. Cache writes cost 25% more than base input tokens (5-minute TTL) or roughly 2x for the 1-hour tier; cache reads are ~10% of base input price. Inside Claude Code itself you can’t set the TTL directly — it’s server-controlled by plan tier, and per third-party writeups (not official Anthropic docs, treat with appropriate skepticism) Max subscribers reportedly get 1-hour TTL by default while Pro/API-key users get 5 minutes. Worth flagging: there’s an open, well-documented GitHub issue — anthropics/claude-code#46829 — from a user who analyzed their own session JSONL logs and found evidence the default silently regressed from 1h to 5m TTL around March 2026, causing a measurable spike in quota consumption. This is a community-reported finding based on log analysis, not an Anthropic-confirmed changelog entry, so treat the exact mechanism as unverified — but the practical lesson holds either way: if your session sits idle more than ~5 minutes, assume your cache is cold and the next turn re-prices your whole context.
Codex CLI / OpenAI Responses API. OpenAI’s own docs are consistent across multiple sources: the default in-memory cache policy keeps prefixes active for 5–10 minutes of inactivity, occasionally stretching to a max of 1 hour during off-peak periods, with hard eviction always within an hour (see OpenAI API docs). If you need longer retention, prompt_cache_retention can be set to an extended policy that offloads KV tensors to GPU-local storage for up to 24 hours — but this isn't universal; it's excluded for gpt-5.5/gpt-5.5-pro and future models per the same docs. For Codex CLI specifically this isn't user-configurable from the CLI surface; it's an API-level parameter, so if you're driving Codex through your own automation (e.g. openai/codex-action in CI) you have more control than in the interactive terminal.
GitHub Copilot CLI. GitHub doesn’t publish Copilot-specific cache TTL numbers — Copilot CLI is a multiplexer over Anthropic, OpenAI, and Google models, so whatever provider you’ve selected via /model almost certainly inherits that provider's own cache policy underneath. No official Copilot doc confirms this explicitly, so treat it as a reasonable inference rather than a documented fact. What is documented is the AI Credits billing model — each interaction draws down a plan-based credit allowance regardless of caching, which changes the cost calculus somewhat compared to raw per-token API billing.
Antigravity CLI. Also undocumented at the CLI level. Antigravity CLI shares its backend “agent engine” with the Antigravity 2.0 desktop app (see antigravity.google docs), and the models it routes to (Gemini 3.x, plus Claude and GPT-OSS options exposed via /model) each carry their own provider-side caching behavior. No official Google source specifies an idle-cache-expiry number for agy sessions specifically — any figure you see quoted for this is speculative.
3. Context Window Management
Keeping the prefix stable and avoiding indiscriminate full-repo ingestion.
Claude Code. This is the most mature tooling of the four. /context renders a colored grid showing exactly what's consuming your window (see Claude Code commands reference); /compact summarizes history in place; /clear wipes it entirely while keeping project memory (CLAUDE.md). The practical pattern practitioners converge on: keep stable material (architecture docs, schemas, CLAUDE.md) early in the conversation and your active working file referenced last via @path, since prefix caching means anything appended after a stable block doesn't invalidate what came before it. SLASH_COMMAND_TOOL_CHAR_BUDGET is a real env var that caps how much of your context skill/command descriptions consume (default ~1% of window or 8,000 chars) — useful once you've installed a lot of skills. For your Spring Boot/Scala migration work specifically, loading ADRs and schema files before touching the working file, rather than the reverse, is the concrete habit that pays off.
Codex CLI. Context here is tied more to your invocation mode than to explicit slash commands. In codex exec (non-interactive/CI mode) you control scope via --cd (working directory) and explicit prompt files rather than open-ended repo scanning. A meaningful recent change: MCP tools now default to tool search rather than loading every server's full JSON schema up front (see openai/codex release notes) — this mirrors the "lazy tool loading" pattern and keeps your stable prefix (system + repo context) from being diluted by tool definitions you're not using this turn.
GitHub Copilot CLI. Two concrete, documented mechanisms: automatic history compression at 95% of the token limit (mentioned above), and a genuinely well-designed default for its built-in GitHub MCP server — it exposes only a curated read-only toolset by default, explicitly to preserve context window efficiency, with write-capable tools requiring --enable-all-github-mcp-tools or per-tool opt-in (see github-mcp-server install docs). /usage shows session statistics including AI Credits burned.
Antigravity CLI. Context visibility comes via agy inspect, which shows exactly what context the agent currently holds (see DEV Community guide), and /agents, which tracks active parallel subagents alongside their token usage. Scope control leans on the Tool Permission tiers set via /config: strict (read-only, zero-trust), request-review (default — pauses for approval on writes/execution), proceed-in-sandbox, and always-proceed (see Google Codelabs walkthrough). Routing large, context-heavy file reads to a background subagent rather than the primary conversation is the documented pattern for keeping the main session's prefix lean.
4. Model Switching Pitfalls
Switching the underlying model changes the request signature (model ID is part of what gets hashed for cache lookup), so a cache built under one model is not reusable under another — this is a general property of how prefix caching works across all three vendors, not something unique to any CLI.
Claude Code. /model switches instantly, mid-response if needed (see Commands reference), between Sonnet, Opus, Haiku, and (where available) Fable. Practitioner guides are split on this: some recommend combining /model with /effort for granular cost control (drop to Haiku + low effort for mechanical work), while others — e.g. the Learnia Claude Code reference — explicitly warn that mid-session model swaps tend to cause context inconsistency and recommend starting a fresh session with the intended model instead of switching mid-stream. Both are reasonable positions depending on task; the safer default for architecture-critical work is to decide the model up front.
Codex CLI. Model and reasoning effort are both configurable, either interactively or via --model/effort flags in CI usage through openai/codex-action (see GitHub Action docs). Since Codex's Responses API caching is tied to exact prompt/parameter matches, changing model or reasoning effort between calls is expected to force a fresh cache write on the next request — this follows from OpenAI's general caching mechanics rather than a Codex-specific warning in the docs.
GitHub Copilot CLI. Genuinely differentiated here: Copilot CLI supports multiple foundation model providers in the same tool — Anthropic, Google, and OpenAI — switchable per task via /model or --model (see GitHub Copilot CLI FAQ). Switching providers (not just model tier) necessarily means a completely different cache namespace, since Anthropic, OpenAI, and Google caches don't interoperate. If you're doing cost-sensitive long sessions, picking one provider and sticking with it for that session matters more here than in single-vendor tools.
Antigravity CLI. /model exposes a real, documented list that spans Gemini 3.5 Flash/3.1 Pro tiers, Claude Sonnet 4.6/Opus 4.6 (Thinking), and GPT-OSS 120B (see Medium tutorial walkthrough). Given the multi-provider nature (same as Copilot CLI), switching the coordinating/primary model likely resets whatever context cache exists — no official Google doc confirms this explicitly for agy, but it follows from the same cross-vendor caching mechanics described above. The one thing that is documented: keep the primary/coordinator model consistent and delegate varied work to subagents instead of swapping the main model repeatedly.
5. Parameter & Configuration Changes
Smaller, easier to overlook — but tweaking flags mid-session changes the prompt/parameter signature just as much as switching models does.
Claude Code. /effort is real and well documented: levels are low, medium, high, max, and session-only ultracode (which combines xhigh reasoning with automatic multi-agent orchestration and can spawn 100+ agents if you're not careful — worth knowing before you type it) (see DataCamp slash commands guide). low/medium/high persist across sessions; max requires Opus and is session-scoped; auto resets to the model's default. Because effort level is part of the request, changing it mid-session is a parameter change like any other and should be expected to affect caching the same way a model switch does.
Codex CLI. Reasoning effort is configurable per-run via the effort field in codex-args or the GitHub Action's effort input (see openai/codex-action). Changing config.toml values (sandbox mode, model defaults) between invocations is the CLI-native way to adjust behavior; there's no interactive slash-command equivalent to Claude Code's /effort toggle inside a running TUI session as of the current release.
GitHub Copilot CLI. Environment variables like COPILOT_HOME (relocates the MCP config directory) and approval flags (--allow-tool, --deny-tool, --allow-all/--yolo) are the main levers (see About GitHub Copilot CLI docs). No official documentation ties these specifically to cache invalidation, but per general prefix-caching mechanics, anything that changes what gets sent as part of the system/tool prefix (like toggling which MCP tools are allowed) will do so.
Antigravity CLI. /config toggles the Tool Permission tier described in §3 (strict → request-review → proceed-in-sandbox → always-proceed), plus theming and rendering mode (Alt-Screen vs Inline) (see Antigravity CLI Tutorial). Community documentation notes that changing structural settings mid-session (e.g. shifting security level) can trigger a TUI reload — worth locking down your permission tier before starting a long multi-agent debugging session rather than adjusting it partway through.
Practical takeaways for a Spring Boot / Scala shop
- Cache-window discipline beats micro-optimization. The single biggest lever across all four tools is simply not letting sessions go idle past 5 minutes if you’re on a 5-minute-TTL tier — that’s a bigger cost swing than any output-compression skill. If Anthropic’s Max-tier 1-hour TTL claim holds for your plan, long architecture-review sessions are far cheaper there than on Pro/API-key.
- Order your context deliberately in Claude Code: schemas/ADRs/CLAUDE.md first, active file last, and use
/contextto verify before a long agentic run rather than after. - Don’t chase the 65% caveman number as a real session-wide saving — treat output-compression skills as a 5–10% net win plus a genuine readability improvement, and get the bigger win from
CLAUDE.md/AGENTS.mdcompression instead, since that saving compounds every session. - If you’re bouncing between providers (Copilot CLI, Antigravity CLI), pick one per session rather than per-task-switching — the cache reset cost from crossing vendor boundaries is real and unavoidable, unlike same-vendor model tier changes which are at least sometimes worth it.
- Lock in effort/permission settings before starting, not mid-task — this is consistent advice across Claude Code’s
/effort, Antigravity's Tool Permission tiers, and general prefix-caching behavior in Codex.
Sources are linked inline. Where a claim traces to a GitHub issue, community blog, or third-party writeup rather than official vendor documentation, that’s noted explicitly in the text above — this is a genuinely fast-moving space and several of these behaviors (especially exact cache TTLs inside CLI wrappers, as opposed to the raw APIs) aren’t formally documented by the vendors yet.
메타데이터
- post_id
- 52b0cd89cf32
- slug
- claude-code-vs-codex-cli-vs-copilot-cli-vs-antigravity-cli-how-to-cut-token-costs-and-manage-52b0cd89cf32
- url
- https://medium.com/@shubham.dxyt/claude-code-vs-codex-cli-vs-copilot-cli-vs-antigravity-cli-how-to-cut-token-costs-and-manage-52b0cd89cf32
- canonical_url
- https://medium.com/@shubham.dxyt/claude-code-vs-codex-cli-vs-copilot-cli-vs-antigravity-cli-how-to-cut-token-costs-and-manage-52b0cd89cf32
- author_url
- https://medium.com/@shubham.dxyt
- status
- ok
- fetched_at
- 2026-07-10 19:45:50