ANTIGRAVITY LABJP
Articles/Integrations
Integrations/2026-06-13Advanced

Running Antigravity CLI Headless: Design Before It Hits CI and cron

The Antigravity CLI was rewritten in Go. Here is how to run it unattended in CI and cron, covering exit codes, idempotency, timeouts, and output parsing.

Antigravity CLI18CI/CD17automation87headless3operations26

Premium Article

On June 18, Gemini CLI and Gemini Code Assist stop serving individual users, and the successor is the Antigravity CLI. The new binary is rewritten in Go, so it starts and responds noticeably faster. At your terminal, it is close to a drop-in replacement.

The trouble starts after that. I run four sites from a single machine, with agent runs wired into cron and CI. The smoother a tool feels interactively, the more quietly it stalls when nobody is watching. A confirmation prompt waits for an answer that never comes, and the job sits there until it times out. As an indie developer running everything myself, I have hit that exact failure more than once.

This article covers the gap between "it worked interactively" and "I trust it unattended," narrowed to four points: exit codes, idempotency, timeouts, and output parsing.

Why an interactive-first CLI freezes inside CI

Agent CLIs are built to ask humans for confirmation. "Overwrite this file?" "Commit now?" At a terminal you press Enter and move on.

A CI runner or cron has nobody to press Enter. Because stdin is not a TTY, some tools auto-answer "no" and abort, while others wait forever and hang. The second case is the dangerous one: the job log shows nothing while billable minutes drain away.

The first job is to remove every chance of a prompt.

# Auto-approve every confirmation and empty stdin so a human wait is physically impossible
antigravity run \
  --prompt-file ./tasks/update-articles.md \
  --yes \
  --no-color \
  --output json < /dev/null

--yes (the auto-approve flag; confirm its exact name with antigravity --help for your version) skips confirmations, and < /dev/null empties stdin. Even if you miss a flag, empty input means it cannot wait. That redundancy is what holds. --no-color keeps ANSI escapes out of the log so downstream parsing stays clean.

Building idempotency that survives a double launch

Unattended jobs will overlap. A previous run drags on while the next cron fires. CI retries and processes the same commit twice. That overlap produces double commits to the same file, or a push of half-finished state.

I handle it in two layers: mutual exclusion of the run itself, and idempotency of the result.

Exclusion comes from a lock file.

LOCK="/tmp/antigravity-articles.lock"
# flock prevents concurrent launches. -n means do not wait, give up immediately
exec 9>"$LOCK"
if ! flock -n 9; then
  echo "Another run is in progress; skipping"
  exit 0
fi
# Only one passes this point at a time
antigravity run --prompt-file ./tasks/update-articles.md --yes --output json < /dev/null

Result idempotency comes from making the output target unique per run. Appending to a fixed filename invites contamination from a previous run's leftovers, so I avoid it. I write to a unique name that includes the slug, verify it, then move it into place. In my own Dolice workflow, adding that one step is what made half-written commits disappear.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
How to stop an unattended run from hanging on a hidden prompt, using --yes plus blocked stdin
A lock-file and idempotency-key pattern that survives a double-fired trigger without corrupting state
A 30-line wrapper that judges success from both exit code and JSON output, and alerts only on failure
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Antigravity Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

Integrations2026-07-18
Turning Silent Auto-Approvals into Allow Rules, One Soft-Deny at a Time
In Antigravity CLI 1.1.3, headless -p stops silently auto-approving confirmation-required tools and instead soft-denies them, printing the required allow-rule name to stderr. This piece uses that output as a discovery source to build least privilege from an empty allow set upward, with a working harness and real numbers from a personal automation.
Integrations2026-07-19
When an Unresponsive MCP Server Freezes Your Agent: Separate Timeouts for Connect, List, and Call
Antigravity CLI 1.1.3 closed the case where an unresponsive MCP server stalls an agent forever, by adding timeouts to connect, list-tools, and call-tool. This walks through why the three boundaries fail differently, and builds a defensive wrapper with a circuit breaker and failure-only notifications, backed by working code and a week of overnight runs.
Integrations2026-07-08
Antigravity Now Saves OAuth Tokens to the OS Keyring — Keeping Auth Alive in Headless Runs
In v2.2.1, refreshed OAuth tokens are saved to the OS keyring automatically. Pleasant on the desktop, but on headless scheduled runs the vault itself may not exist and auth quietly breaks. We design explicit backend selection, a safe file fallback, and per-location liveness checks.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →