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 CLI32CI/CD17automation93headless4operations31

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 $15 for lifetime access
View Membership →

Related Articles

Integrations2026-09-12
Antigravity CLI 1.1.28 turns a print-timeout overrun into a successful exit — rechecking unattended runs
Since 1.1.28, an expired --print-timeout returns partial output and exits successfully instead of failing. Fetching an external URL now asks for approval first. Here is how I rebuilt an unattended pipeline that judged everything by the exit code.
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-08-22
Driving Antigravity CLI with stream-json Input: Where to Split the Conversation
The print mode now accepts --input-format stream-json, letting an external driver hold one session open and feed it jobs one at a time. I measured how much a single conversation carries across 24 jobs, found that a byte budget splits work in the wrong place, and worked out how to choose the split boundary instead.
📚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