AI News / 2026-06-23

Claude Code vs Codex vs Gemini CLI: Real Dev Workflow Tested

XycAi
Claude Code vs Codex vs Gemini CLI: Real Dev Workflow Tested

Three tools on the table: Anthropic's Claude Code, OpenAI's Codex, and Google's Gemini CLI. If you're just asking AI to autocomplete a line here and there, any of them will do. But if your daily workflow genuinely depends on a CLI tool — refactoring a 5,000-line legacy system, chasing down a race condition, keeping cross-team API docs in sync — picking the wrong one costs you real productivity, not just vibes.

This article runs all three through four concrete tasks: code generation, refactoring, debugging, and documentation. The differences are more specific than most comparisons let on.

What You're Actually Choosing Between

Some context first. Claude Code runs on Claude Sonnet 4.6 / Opus 4.8 with deep integration of Anthropic's long-context capabilities — roughly 200K tokens of codebase per conversation. Codex is OpenAI's coding-optimized CLI, backed by GPT-5.4 or GPT-5.4-mini, built for fast responses and reliable tool calls. Gemini CLI runs on the Gemini 3 series and has the largest context window of the three — large enough to ingest an entire mid-size project in one shot.

All three support local file read/write, terminal command execution, and multi-turn conversation. The real difference is in default behavior: Claude Code leans toward clarifying before acting; Codex leans toward shipping you runnable code immediately; Gemini CLI is the most aggressive about multi-file operations, actively tracking cross-file references on its own.

Code Generation: Speed vs. Completeness

Typical scenario: write a paginated REST endpoint in TypeScript with input validation, error handling, and a unit test scaffold.

Codex is the fastest here. Feed it a requirement and you have a working skeleton in 8–12 seconds. It auto-detects whatever framework is in your current directory — Express, Fastify, Hono — without you having to spell out the stack:

codex "create a paginated GET /users endpoint with zod validation and vitest unit tests"

Claude Code runs about 15–20% slower, but the output is more complete. It defaults to cursor-based pagination over offset-based and drops a comment explaining why. Edge case handling is noticeably denser. If you're writing production code rather than a prototype, that extra few seconds is worth it.

Gemini CLI lands somewhere between the two in raw generation quality, but it has a distinct behavior worth noting: it scans your existing API routes before writing anything new, and the generated endpoint aligns itself to your project's naming conventions and error code formats automatically. On a project with an established codebase, that "context-aware generation" cuts out a surprising amount of manual cleanup.

Refactoring: Does It Actually Understand What the Old Code Was Doing?

Refactoring is where you find out whether an AI tool is reading your code or just pattern-matching on it. Test case: 300 lines of nested-callback Node.js, converted to async/await with reusable functions extracted.

Claude Code Codex Gemini CLI
Preserves original comments ✅ Intact ⚠️ Partial loss ✅ Intact
Flags implicit business logic ✅ Annotates uncertainties ❌ Rewrites silently ⚠️ Occasionally misses
Tracks cross-file references ⚠️ Needs manual pointing ❌ Single-file only ✅ Auto-scans
Generates tests post-refactor ✅ Proactively ⚠️ Needs a prompt ⚠️ Needs a prompt

Claude Code's edge is clearest here. When it hits ambiguous logic, it doesn't guess quietly — it flags it inline: # ⚠️ Please confirm: original code may exhibit X behavior; refactored version assumes Y. You stay in control of the decision. Codex is more confident, which is efficient for simple rewrites but becomes a liability when business logic is genuinely opaque. Gemini CLI handles cross-file scope better than either, but occasionally glosses over logic that isn't structurally obvious.

Debugging: From Stack Trace to Root Cause

Real scenario: a Node.js service throwing ECONNRESET under load. The stack trace is vague — something in the HTTP connection pool, but not much more to go on.

Claude Code's debugging conversation feels the closest to working with a senior engineer. Paste in the logs and it doesn't hand you a fix — it lays out three plausible root causes (pool exhaustion, keep-alive misconfiguration, upstream timeout) and gives you a command to test each hypothesis:

# Check connection pool state
node -e "const http = require('http'); console.log(http.globalAgent)"

Codex takes a more linear approach: most likely cause, here's the fix, try it. For common errors that's perfectly efficient. For ambiguous bugs with multiple plausible explanations, the single-path strategy can send you down the wrong road before you realize it.

Gemini CLI responds to debugging prompts by pulling in more context first — it'll ask to read package.json, .env, and relevant middleware configs before drawing conclusions. In a complex project, that thoroughness is an asset. In a quick debugging session, it can feel like unnecessary ceremony.

Documentation: Quality You Can Actually Ship

Generating JSDoc comments and README.md files is where you see how well a tool understands code semantics rather than just structure.

Codex is the fastest for documentation, produces clean formatting, and works well for batch generation across a directory:

codex "generate JSDoc comments for all exported functions in src/utils/"

Claude Code writes denser documentation — it explains the why behind a function, not just the what. For API docs and architecture writeups, that distinction matters. Gemini CLI has one practical trick that stands out: it auto-generates usage examples that reference your project's actual data structures, not generic placeholders. That alone can save significant time when writing public-facing README files.

For internal technical documentation, Claude Code produces the highest-quality output. For npm package READMEs or public API docs where working examples do the heavy lifting, Gemini CLI's auto-examples are hard to beat.

Which One to Pick

No single tool dominates every scenario, but the selection logic is straightforward:

Claude Code — team environments, legacy refactoring, any project where you need the AI to flag uncertainty rather than paper over it. Deep context understanding, but more sensitive to network latency.

Codex — rapid prototyping, greenfield projects, solo developers who prioritize response speed. Smoothest integration with the OpenAI ecosystem, most reliable tool-call behavior.

Gemini CLI — large monorepos, refactoring tasks that require global cross-file awareness, documentation automation at scale. Largest context window, most aggressive multi-file operations.

One thing worth keeping in mind: all three tools support model switching via OpenAI-compatible APIs, so you're not locked into a single vendor's model lineup. That flexibility matters more than it might seem — the best tool for your project today might not be the best one six months from now.


If you want to run all three CLI tools without juggling separate API keys and billing accounts, XycAi is worth a look. One OpenAI-compatible endpoint gives you access to 200+ global models, with Claude Opus 4.8 and GPT-5.4 starting at 14% of list price, and CN2 direct-connect latency around 5ms — which genuinely matters when you're running tight debugging loops in the CLI. Setup for Claude Code, Codex, and Gemini CLI is one command each.

One API for 200+ global AI models

GPT · Claude · Gemini official models from 14% of list price. Licensed LLM filing, CN2 direct connect at ~5ms, compliant global invoicing.

Try XycAi →