
TL;DR
A fair comparison of running Claude Code, OpenAI's Codex CLI, Gemini CLI, and opencode in non-interactive CI pipelines: invocation flags, sandboxing, auth, and output formats.
Direct answer
A fair comparison of running Claude Code, OpenAI's Codex CLI, Gemini CLI, and opencode in non-interactive CI pipelines: invocation flags, sandboxing, auth, and output formats.
Best for
Developers comparing real tool tradeoffs before choosing a stack.
Covers
Verdict, tradeoffs, pricing signals, workflow fit, and related alternatives.
Running an AI coding agent interactively in a terminal is one thing. Running it unattended inside a CI job, where nobody is there to click "allow" on a tool call, is a different problem: you need a non-interactive invocation mode, a way to constrain what the agent can touch, a machine-readable output format, and a sane way to hand it credentials without leaking them into logs.
Four tools currently ship first-class headless modes worth comparing for real pipelines: Claude Code, OpenAI's Codex CLI, Google's Gemini CLI, and the open-source opencode. This is not a benchmark of which one writes better code. It's a comparison of the plumbing: how each one is actually invoked in CI, what its sandbox and permission model does when there's no human to ask, and what the output looks like when you need to parse it.
Claude Code runs headless with the -p/--print flag, which prints a single response and exits instead of opening the REPL. Combine it with --output-format json or --output-format stream-json for machine-readable output, and --permission-mode to control tool approval without a human present. Official docs: Claude Code SDK / headless mode.
Codex CLI has a dedicated non-interactive subcommand, codex exec (aliased codex e), built specifically for scripts and CI rather than being a flag bolted onto the interactive command. It takes a --sandbox/-s policy (see below) and a --json flag for newline-delimited JSON events, which can be paired with --output-last-message <path> to also capture a plain-text final summary. Note that the older --full-auto flag is deprecated in favor of --sandbox workspace-write and will print a warning if used - update any scripts still relying on it. Reference: OpenAI Codex CLI docs and the Codex CLI GitHub repo.
Gemini CLI runs non-interactively when you pipe a prompt to stdin or pass -p, and supports --output-format json. Google documents this in the Gemini CLI headless/scripting docs and the Gemini CLI GitHub Actions guide.
opencode exposes opencode run "<prompt>" as its headless entry point, with -m to pin a model and -c/-s for session continuation, which matters for multi-step CI workflows that need to resume a prior run. Docs: opencode documentation.
This is the part that actually matters for CI safety, because the default assumption of an interactive agent (a person will approve risky actions) is false in a pipeline.
--permission-mode and settings-based tool allowlists let you pre-approve exactly which tools (bash, file edit, etc.) run without a prompt; anything outside that list should fail closed rather than block on an approval that will never come. See the Claude Code settings and permissions reference.read-only, workspace-write, danger-full-access) are documented in the Codex CLI config reference; workspace-write is the sane default for a CI job that needs to edit files but not touch the rest of the filesystem or network.--sandbox flag backed by Docker/Podman or macOS Seatbelt profiles, described in the Gemini CLI sandboxing docs.opencode.jsonc (the permission block on each agent), so a CI-specific agent definition can be scoped tighter than your interactive build agent.None of these are a substitute for running the whole job inside an already-sandboxed CI runner or container. Treat the tool's own sandbox flag as a second layer, not the only layer.
Newsletter
Get the weekly deep dive
Tutorials on Claude Code, AI agents, and dev tools, delivered free every week.
From the archive
Jul 9, 2026 • 9 min read
Jul 9, 2026 • 8 min read
Jul 9, 2026 • 7 min read
Jul 9, 2026 • 5 min read
All four expect an API key or OAuth token via environment variable rather than an interactive login, which is the right shape for CI secrets managers:
ANTHROPIC_API_KEY, documented in the Claude Code CI/CD guide.OPENAI_API_KEY, or GitHub App auth via the Codex GitHub Action.GEMINI_API_KEY or Google Cloud Application Default Credentials, per the Gemini CLI authentication docs.opencode auth login or environment variables per provider, per the opencode providers docs.Whichever you use, scope the key to the minimum project/model access your CI job needs and rotate it separately from any key you use interactively, since a leaked CI secret has a much bigger blast radius than a local session.
A CI job needs a deterministic way to tell "the agent succeeded and did X" from "the agent failed, timed out, or refused." Structured output matters more here than in a terminal session:
stream-json output gives you an event stream you can tee into a log processor and still get a final result block for pass/fail logic.codex exec --json emits newline-delimited JSON events plus a proper process exit code, which is the simplest thing to gate a pipeline step on.--output-format json gives a single JSON object per invocation.run command output is primarily plain text by design; if you need structured events, opencode serve (the headless server mode) is the better fit for programmatic polling than parsing run output.codex exec was purpose-built for this and has the most explicit sandbox levels of the four. Start with the Codex CLI GitHub repo.opencode.jsonc config is the most flexible for mixed-provider pipelines. See opencode's agent docs.Whatever you pick, start every CI integration in the most restrictive sandbox mode available, run it against a throwaway branch or fork first, and only loosen permissions once you've watched it operate on real diffs.
Yes, all four have a documented non-interactive/headless mode built for exactly this: claude -p, codex exec, gemini -p (or piped stdin), and opencode run. Each still requires you to pre-configure permissions, since there's no one to approve individual tool calls mid-run.
Codex CLI and Gemini CLI both expose explicit sandbox levels (read-only, workspace-write, full-access for Codex; Docker/Podman/Seatbelt profiles for Gemini CLI). Claude Code and opencode rely more on allowlist-style permission configuration. In all cases, running the whole CI job inside an already-isolated container or ephemeral runner is still the baseline you should not skip.
Yes. Anthropic publishes a Claude Code GitHub Action, OpenAI publishes a Codex Action, and Google publishes a Gemini CLI Action. opencode does not ship an official first-party GitHub Action as of this writing, so a headless opencode run step inside a standard actions/checkout + install job is the common pattern.
Headless mode swaps the REPL for a single prompt-in, response-out invocation (or a resumable session), disables interactive approval prompts in favor of pre-set permission configuration, and typically adds a structured output format so a pipeline can parse success/failure without parsing raw terminal text.
opencode is built for this directly, letting you define separate agents pinned to different models in one config file. The others are generally single-provider per invocation, though you can still run separate CI steps with different tools or different -m flags to approximate the same effect.
| Tool | Link | Type | Verified |
|---|---|---|---|
| Claude Code SDK / Headless Mode | https://docs.claude.com/en/docs/claude-code/sdk | Official Docs | July 25, 2026 |
| Claude Code GitHub Actions Guide | https://docs.claude.com/en/docs/claude-code/github-actions | Official Docs | July 25, 2026 |
| Claude Code Settings & Permissions | https://docs.claude.com/en/docs/claude-code/settings | Official Docs | July 25, 2026 |
| OpenAI Codex CLI Docs | https://developers.openai.com/codex/cli | Official Docs | July 25, 2026 |
| Codex CLI GitHub Repo | https://github.com/openai/codex | Official Repo | July 25, 2026 |
| Codex CLI Config Reference | https://github.com/openai/codex/blob/main/docs/config.md | Official Docs | July 25, 2026 |
| Codex GitHub Action | https://github.com/openai/codex-action | Official Action | July 25, 2026 |
| Gemini CLI Docs | https://github.com/google-gemini/gemini-cli | Official Docs | July 25, 2026 |
| Gemini CLI GitHub Actions Guide | https://github.com/google-gemini/gemini-cli-action | Official Action | July 25, 2026 |
| Gemini CLI Sandboxing | https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/sandbox.md | Official Docs | July 25, 2026 |
| opencode Documentation | https://opencode.ai/docs/ | Official Docs | July 25, 2026 |
| opencode Agents Docs | https://opencode.ai/docs/agents/ | Official Docs | July 25, 2026 |
Read next
12 AI coding tools across 4 architecture types, compared on pricing, strengths, weaknesses, and best use cases. The definitive comparison matrix for 2026.
15 min readTerminal agent, IDE agent, local-plus-cloud agent. Three architectures compared - how to decide which fits your workflow, or why you should use all three.
8 min readGoal, loop, routine. Three verbs, two tools, one hard part. A complete field guide to running agentic loops in Claude Code and Codex, the real commands, the patterns people actually run, and the two failure modes that burn money.
16 min readTechnical content at the intersection of AI and development. Building with AI agents, Claude Code, and modern dev tools - then showing you exactly how it works.
Mac app for running parallel Claude Code, Codex, and Cursor agents in isolated workspaces. Watch every agent work at onc...
View ToolA hosted infinite canvas your headless AI agents drive over MCP. Any MCP-speaking agent - Claude Code, Codex, Cursor, or...
View ToolOpen-source AI coding agent for terminal, desktop, and IDE. Works with 75+ LLM providers including Claude, GPT, Gemini,...
View ToolAnthropic's agentic coding CLI. Runs in your terminal, edits files autonomously, spawns sub-agents, and maintains memory...
View ToolEvery coding agent in one window. Stop alt-tabbing between Claude, Codex, and Cursor.
View AppDesign subagents visually instead of editing YAML by hand.
View AppScore every coding agent on your own tasks. Catch regressions in CI.
View AppDeep comparison of the top AI agent frameworks - LangGraph, CrewAI, Mastra, CopilotKit, AutoGen, and Claude Code.
AI AgentsConfigure Claude Code for maximum productivity -- CLAUDE.md, sub-agents, MCP servers, and autonomous workflows.
AI AgentsDefine custom subagent types within your project's memory layer.
Claude Code
Check out Zed here! https://zed.dev In this video, we dive into Zed, a robust open source code editor that has recently introduced the Agent Client Protocol. This new open standard allows...

Nimbalyst Demo: A Visual Workspace for Codex + Claude Code with Kanban, Plans, and AI Commits Try it: https://nimbalyst.com/ Star Repo Here: https://github.com/Nimbalyst/nimbalyst This video demos N...

Leveraging Anthropic's Subagent for Claude Code: A Step-by-Step Guide In this video, we explore Anthropic's newly released subagent feature for Cloud Code, which allows developers to create...

One dev, one CLI, 24 subdomains, and a lot of parallel agents. The playbook for shipping an AI app portfolio.

A security researcher found a GitHub personal access token with admin privileges to hundreds of repos baked into Hanwha...

Prompt injection, sandbox escapes, and hallucinated dependencies are now documented, patched, CVE-numbered realities. He...

GitHub Spec Kit and gstack are trending for the same reason: coding agents need durable specs, plans, and task ledgers m...

A new Vera paper tests Codex, Claude Code, OpenClaw, and Hermes with executable safety cases. The useful lesson is not p...

Claude Code and Codex both ship great agents and terrible transcripts. AgentCanvas is a visual adapter that puts the art...

New tutorials, open-source projects, and deep dives on coding agents - delivered weekly.