The full guide
AI coding agents, step by step
An AI coding agent is a program that takes a task in plain language, then reads your code, runs commands and edits files until the task is done, calling a language model at every step. This page compares five: Claude Code, OpenAI Codex, Cursor, OpenCode and Gemini CLI. They differ less in what they do than in who makes them, which models they run, how you pay, and how the plan stops you.
What an AI coding agent is
A chat assistant answers; an agent acts. You ask for a change, and the agent reads the files it needs, runs the tests, edits, runs them again, and reports back. Each of those steps is a call to a model, and each call re-sends the conversation so far. That is why agentic coding tools cost more than a chat: on one machine, the median Claude Code call re-sent 169K tokens of context, almost all of it read from the cache.
All five run in a terminal or an editor, on your own files. Claude Code and Codex also run on the web and in desktop apps; Cursor is an editor of its own, with an agent built in.
How the five differ
Who makes them. Anthropic makes Claude Code, OpenAI makes Codex, Anysphere makes Cursor, Google makes Gemini CLI, and Anomaly, the team behind SST, makes OpenCode.
Which models they run. Claude Code runs only Claude, Codex only OpenAI's GPT models, and Gemini CLI only Gemini. Cursor's agent runs models from Anthropic, OpenAI and Google, plus its own pool: Grok and Composer. OpenCode connects to more than 75 providers, so the model, and its price, is yours to pick.
How you pay. Claude Code and Codex come with a plan from their maker, paid plans from $20 a month (Codex also comes with ChatGPT Go at $8, in the desktop app), or bill an API key per token. Cursor sells its own plans, from $8 a month, with a weekly pool for its own models; Claude, GPT and Gemini bill at API list price on top, from Premium at $30. OpenCode costs nothing itself; you pay the provider of the model. Gemini CLI runs on a Gemini Code Assist licence or a paid API key; its free tier ended on 18 June 2026.
How the plan stops you. A Claude plan resets every five hours, with a weekly limit on top, shared with claude.ai. Codex on ChatGPT Plus has a five-hour window and a weekly limit; ChatGPT Pro has no five-hour limit, and weekly limits may apply to any plan. Cursor counts a weekly pool. Gemini CLI counts model requests a day — and one prompt can make several. OpenCode Go caps dollars per model.
Free AI coding agents
Two of the five start at $0. OpenCode is free and open source, but the model is not: on a cheap open model the median call on my machine cost $0.002. Cursor's Free plan includes limited use of its own models. ChatGPT Free and Go include Codex in the desktop app, subject to rollout. Claude Free does not include Claude Code. Gemini CLI's free tier ended on 18 June 2026; Google moved free users to Antigravity CLI, with a weekly quota: Antigravity vs Claude Code.
Open-source coding agents
OpenCode is MIT-licensed, Gemini CLI Apache-2.0, and the Codex CLI Apache-2.0. Claude Code's licence reserves all rights to Anthropic, and Cursor's terms keep the software Anysphere's. Open source here means you can read and change the agent; the model it calls is still billed by whoever serves it. Every open-source agent, the editor extensions and the ones that stopped included, is in open-source AI coding agents.
Claude Code alternatives, free and paid
If you are leaving Claude Code over price or limits, the alternatives split in two. Codex and Gemini CLI swap the model as well as the agent: GPT or Gemini instead of Claude. Cursor's agent and OpenCode can keep Claude, but bill it at API rates rather than on a Claude plan; Anthropic does not allow a Claude Pro or Max sign-in in OpenCode. If it is Claude you want, most of the day, a Claude plan is the flat-fee way to get it — and Claude Code runs inside Cursor as an extension, covered by that plan.
The free ones are Antigravity, Google's agent, on a weekly quota; OpenCode, with a model you pay for or one of Zen's free models; Codex on ChatGPT Free, in the desktop app; and Cursor's Free plan. What $0 gets on each, and the cheapest way into Claude Code itself: Is Claude Code free?
What they cost, measured
Plans say what you may use, not what the work costs. Caprock reads Claude Code, Codex and OpenCode on my machine and prices every call: at list prices for the first two, at OpenCode's own figure for the third. The medians are in the chart above. Most of the gap is the model — most Claude Code calls ran Opus 5 or Opus 4.8, a third of Codex's ran its cheaper Luna models, and most OpenCode calls ran DeepSeek V4 Pro — and the rest is how much context each call carried.
None of this ranks the agents. The three ran on different projects, in different weeks, on models priced very differently. Cursor is not measured, because Caprock does not read it; Gemini CLI is not measured, because Caprock has measured no Gemini CLI session on this machine. The head-to-head pages go further on each pair: Codex, Cursor, OpenCode and Gemini CLI against Claude Code.
Using several at once
You can: Claude Code or Codex on a plan for long work, OpenCode on a cheap model for chores. Each keeps its own sign-in, its own limits and its own record. Each also sees only itself: /usage in Claude Code, /status in Codex.
Caprock puts them in one record. It is a free desktop app for macOS, Windows and Linux that reads Claude Code's and Codex's transcripts and OpenCode's database from disk, with nothing to configure, so the sessions you start in your own terminal are there too, and the telemetry of the Gemini CLI sessions it starts. Who is waiting on you, who is stuck, how close each subscription is to its limit, and what each session and repository cost at list price, in one table; the tabs and split panes it runs them in are how you live with that record. It does not read Cursor. How it compares with other apps for running agents is in desktop apps for coding agents.
Free, open source; nothing leaves your machine. Install Caprock and it reads back every session those agents still have on disk.
Questions people ask
- What is an AI coding agent?
- A program that reads your code, runs commands and edits files on its own to finish a task you describe, calling a language model at each step. Claude Code, Codex, Cursor's agent, OpenCode and Gemini CLI all work this way.
- What is the best free AI coding agent?
- OpenCode is free and open source but you pay for the model, and Cursor's Free plan has limited use of its own models. Gemini CLI's free tier ended on 18 June 2026; Google's free agent is now Antigravity, with a weekly quota.
- What are the best Claude Code alternatives?
- Codex with ChatGPT Plus at $20, Cursor from $8 (Premium at $30 for Claude and GPT), OpenCode, free with any of 75+ providers, and Gemini CLI on a Code Assist licence or a paid API key. Cursor's agent and OpenCode can also run Claude, at API rates.
- Is there a free alternative to Claude Code?
- Yes: Google Antigravity on a weekly quota, OpenCode with a model you pay for or a free Zen model, Codex on ChatGPT Free in the desktop app, subject to rollout, and Cursor's Free plan with limited use of its own models.
- Which AI coding agent is cheapest?
- To start, OpenCode costs nothing; Claude Code's paid entry plan is $20 a month; Codex comes with ChatGPT Go at $8 in the desktop app, subject to rollout, or Plus at $20; Cursor's is $8 for Grok models only. Per call on one machine, OpenCode cost $0.002 at the median, Codex $0.032 and Claude Code $0.094.
- Are there open-source AI coding agents?
- Yes: OpenCode under MIT, Gemini CLI under Apache-2.0, and the Codex CLI under Apache-2.0. Claude Code and Cursor are not open source.
- Can I use several AI coding agents at once?
- Yes; each keeps its own sign-in and limits, and Claude Code also runs inside Cursor on a Claude plan. Caprock, a free desktop app, records Claude Code, Codex and OpenCode sessions whether or not it started them, and the Gemini CLI sessions it starts, in one table with each one's cost and limit; it does not read Cursor.
Sources
- Claude plans and prices, read 3 October 2026
- Claude Code licence: all rights reserved, read 3 October 2026
- Codex pricing and usage limits, read 3 October 2026
- Codex CLI on GitHub — Apache-2.0, read 3 October 2026
- Cursor pricing, read 20 October 2026
- Cursor docs — models and pricing
- Cursor terms of service — Anysphere, read 3 October 2026
- OpenCode docs, read 3 October 2026
- OpenCode docs — providers
- OpenCode Go — plans
- OpenCode Zen — free models, read 3 October 2026
- OpenCode on GitHub — MIT, read 3 October 2026
- Gemini CLI docs — quotas and pricing, read 3 October 2026
- Gemini CLI on GitHub — Apache-2.0, read 3 October 2026
- Google AI plans (US), read 3 October 2026
- Google Developers Blog — Transitioning Gemini CLI to Antigravity CLI, 19 May 2026
- Google Antigravity pricing — individual plan, read 8 October 2026
- How Caprock joins five agents in one table
Try it
The record of every coding agent you run, the sessions it did not start included. Free, open source; nothing leaves your machine.
Notarized by Apple. One file for Apple silicon and Intel, macOS 13 or later.
Or run it yourself:
Paste in Terminal: it installs Caprock and opens it.Or with Homebrew: brew install --cask dspv/tap/caprock-app