OpenCode vs Codex CLI on one bug fix, and where Claude Code stopped
By Flavio
Updated
Tagged: AI
I ran OpenCode and Codex CLI on the same bug fix and checked both with my own tests. Claude Code stopped at sign-in. Here's the fixture to repeat it.
When I hand a bug to a coding agent, I want a clean fix I can review, along with a clear picture of what happened between my prompt and the final diff.
In this post, you’ll build a small JavaScript project you can use to test AI coding tools side by side on your own machine. The code has a real pagination bug with archived bookmarks.
I ran this test with three CLIs: OpenCode, Codex CLI and Claude Code. OpenCode and Codex both fixed the bug, so the results below come from those two runs. Claude Code hit a sign-in wall before touching any code, so I’ve included the command to run it yourself without a result of my own.
OpenCode and Codex ran with different models and my existing local configs, so treat the notes below as a template for what to track when you run your own comparison.
We’ll start from identical copies of the same folder, run each tool on its own, and verify the fixes with our own test cases.
The bug we’re asking them to fix
The project is a bookmark search function that returns one page of results at a time. Regular searches should skip archived bookmarks unless you pass an option to include them.
The bug is in the order of operations. The function slices the page before filtering out archived bookmarks. So if the first matching bookmark happens to be archived and you ask for a page of one result, you get an empty array back even when visible matches exist.
The total count is off too, because it counts archived bookmarks that regular search is supposed to hide. Here’s how the bug plays out:
Because the task is small, it’s easy for an agent to hide the archived item and still leave pagination broken. You need clear tests that catch a partial fix. I wrote more about spelling out expected behavior up front in What teaching can tell us about prompting.
Everything runs on Node’s built-in test runner with zero dependencies, no framework, and no database. That keeps package installs and setup noise out of the test.
Create the starting project
Create a folder called bookmark-trial and save the search code in search.mjs:
export const searchBookmarks = (records, {
query = '', offset = 0, limit = 2, includeArchived = false
} = {}) => {
const matching = records.filter(record =>
record.title.toLowerCase().includes(query.toLowerCase())
)
const page = matching.slice(offset, offset + limit)
return {
items: page.filter(record => includeArchived || !record.archived),
total: matching.length
}
}
Next, save the starting test suite in search.test.mjs:
import test from 'node:test'
import assert from 'node:assert/strict'
import { searchBookmarks } from './search.mjs'
const records = [
{ id: 'a', title: 'CSS layout', archived: true },
{ id: 'b', title: 'CSS grid', archived: false },
{ id: 'c', title: 'CSS selectors', archived: false },
{ id: 'd', title: 'JavaScript arrays', archived: false }
]
test('fills the first page with visible matches', () => {
assert.deepEqual(
searchBookmarks(records, { query: 'CSS', limit: 1 }),
{ items: [records[1]], total: 2 }
)
})
test('paginates the visible set', () => {
assert.deepEqual(
searchBookmarks(records, { query: 'CSS', limit: 1, offset: 1 }),
{ items: [records[2]], total: 2 }
)
})
test('allows archived records when requested', () => {
assert.deepEqual(
searchBookmarks(records, {
query: 'CSS', limit: 1, includeArchived: true
}),
{ items: [records[0]], total: 3 }
)
})
Run node --test before you bring any agent in. You should see the first two tests fail while the archive opt-in test passes.
Once that’s working, make three separate copies of the folder, one for each tool. Don’t let one agent see another agent’s changes, and keep your notes outside those folders so they don’t leak into the agent’s context as hints.
Give each agent the same prompt
Here’s the exact prompt I gave each tool:
Fix searchBookmarks so filtering archived records happens before pagination
and totals describe the eligible matching set. Preserve input order and do
not mutate input records or options. By default exclude archived records;
includeArchived:true includes both archived and visible matching records.
Keep case-insensitive title substring search and the current exported API.
Do not add dependencies. Add useful tests, run node --test, and report what
you changed. Work only in this folder. Do not commit, push, access external
services, or read files outside this project.
It spells out the expected behavior, including the archive option, and keeps the agent scoped to that folder.
Don’t tweak the prompt halfway through. If you spot something unclear after your first run, update the prompt and re-run every agent from scratch on fresh copies of the files. Only rewording it for the tool that stumbled skews the whole comparison.
Check setup before measuring coding work
Get every CLI installed and signed in before you start timing anything. The OpenCode tutorial walks through the current install, and the other tutorials linked above cover Claude Code and Codex CLI.
Each tool picks its model differently. OpenCode pairs a provider with a model, Claude Code uses its own account and model picker, and Codex CLI pulls from whatever models your signed-in account has access to.
Write down the exact setup you used. Running a local model through Ollama is a very different setup from a hosted model on a subscription, even with the exact same prompt.
Double-check which binary you’re calling too. If you still have an older OpenCode installed, opencode might launch that one while v2 runs as opencode2. Check with which or print the version before you start.
Track setup and login snags separately from coding time. Onboarding friction matters when you’re picking a daily tool, so log it, then measure the coding run once you’re signed in.
Run the agents independently
You can run this interactively by opening each CLI in its own folder and pasting the prompt. That’s the best way to get a feel for the UI you’ll look at every day.
For my runs, I used noninteractive commands so I could save the event logs. Save the prompt in a prompt.txt file right next to your three folders before running these.
In OpenCode, the CLI documentation covers the run command. Using the v2 binary, run:
opencode2 run --standalone --format json "$(cat ../prompt.txt)"
The standalone flag spins up a private server for the run, while still giving the agent normal access to your OS.
For Claude Code, you can use print mode:
claude -p "$(cat ../prompt.txt)" --output-format json \
--permission-mode acceptEdits \
--allowedTools 'Read,Edit,Write,Bash(node --test)'
Those allowed tools make sense for a small test folder like this one. Check the permissions before running anything similar on a real repo, since shell patterns and tool names differ from one CLI to the next.
For Codex, use exec:
codex exec --skip-git-repo-check --sandbox workspace-write \
--ephemeral --json "$(cat ../prompt.txt)"
Adding --skip-git-repo-check lets us skip initializing Git in this throwaway folder. Drop that flag when you’re working in a real repo.
If Codex rejects your default model before it starts editing, pick one of the models available to your CLI account and note the swap.
Example observations from the fixture
Here’s what happened when I ran all three tools on October 15, 2026, with the same prompt and starting files:
| Tool and configuration | Result | My acceptance tests |
|---|---|---|
OpenCode v2 with qwen3.5:35b-a3b-coding-nvfp4 through Ollama | Fixed the function, finished with 18 passing tests. | 8 of 8 passed. |
| Claude Code | Stopped at an expired OAuth session before changing any code. | Nothing to test. |
Codex CLI with gpt-5.6-sol | After swapping out a rejected default model, fixed the function and finished with 6 passing tests. | 8 of 8 passed. |
OpenCode finished in about 149 seconds, and the Codex run took about 23 seconds once I picked a valid model. Both numbers are single runs including startup, with failed setup attempts left out. Because OpenCode used a local Ollama model while Codex used a hosted one, you’ll want multiple runs with the model, provider, and hardware logged if you care about speed.
Neither fix needed a follow-up prompt. The only step I had to intervene on was choosing an available model for Codex, while Claude Code needed a fresh login before it could start.
Both OpenCode and Codex moved archive filtering ahead of pagination and computed the total from the filtered list, which is what the prompt asked for.
Run acceptance checks outside the agent’s tests
Agents often write plenty of tests that just mirror the assumptions in their own code, so test count alone (18 versus 6 here) isn’t a useful score.
Instead, I ran both fixes against my own separate test file covering these cases:
- The first page returns the first visible match.
- The second page returns the next visible match.
- Passing the archive opt-in includes both archived and visible matches.
- Search stays case-insensitive.
- An empty query keeps the default page size.
- A query with no matches returns an empty list and a total of zero.
- A page size of zero still reports the right total.
- Frozen records and options work without throwing mutation errors.
The prompt described these requirements, though neither agent ever saw my test file. Both fixes passed all eight checks.
Read the diff carefully too. Check whether it keeps the existing API intact, skips unnecessary extra validation, preserves how missing options behave, and leaves behind tests you’d want to maintain.
For a tiny project like this, both diffs were quick to read. On a bigger change, write your own test cases before you launch the agent, and build separate tests if you want to see how it handles a large repo, browser state, or an unfamiliar database.
Compare cost without inventing a price
If you want the broader comparison between API billing and local hardware, read how to use a coding agent without another subscription.
In the event logs, OpenCode reported zero cost for the Ollama run. That number leaves out the hardware, the electricity, and running the local model server.
Codex reported token usage for its completed run. Since it ran through a subscription rather than per-token billing, you can’t turn those tokens into a clean per-task price, especially once caching and different provider rates enter the picture. Claude Code never completed a call, so there’s no cost data for it.
If you’re testing pay-as-you-go APIs, pull the real numbers from your provider’s billing dashboard and include cache hits and retries. On a subscription, track how much real work you get before hitting your account limits, since that matters more than the sticker price. My AI subscription value comparison compares the plans and their usage limits.
Count your own review time too. A cheap first pass that takes a few rounds of cleanup can eat up more of your day than a pricier run that hands back a small, clean diff.
Run your own comparison
Verify your logins first, hand each agent a fresh copy of the project with the exact same prompt, and log setup hiccups separately from coding results. Run each tool more than once if you want meaningful timing numbers.
Once you’ve tried this small bug, move on to a task with more moving parts from a real repo: changing a route, keeping an existing data format intact, and testing a browser flow. Spell out what counts as done and jot down every time you have to step in.
Spend time in each tool’s interactive mode too. Headless runs show whether an agent can finish a contained task, while interactive sessions show you whether the permission prompts and diff review feel good in your daily workflow.
Keep the starting folder and your test file next to your notes. Whenever a new model drops or a tool ships a big update, you can re-run the exact same test and see how it stacks up against what you’re already using.
Want me to talk about your product? You can sponsor this site.
Related posts about ai: