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 CLI3CI/CD14automation37headlessoperations7

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-03-10
GitHub Actions × Antigravity CI/CD Automation Guide — Build and Manage Pipelines with AI
Learn how to build CI/CD pipelines with Antigravity and GitHub Actions. From workflow generation to automated deployment.
Integrations2026-06-13
Running the Antigravity CLI (agy) Headless in CI: Working Around the Non-TTY stdout Problem
Run agy -p inside GitHub Actions or cron and the output you saw locally can vanish, while the exit code still returns 0. Here is how non-TTY detection causes it, plus a robust setup using a pseudo-TTY, defensive text parsing, and API-key auth so you always capture the result.
Integrations2026-05-24
Catching "Running but Doing Nothing" Antigravity Subagents — A 3-Layer Observability Pattern Across Six Production Apps
Running Antigravity subagents across six production apps surfaced more than ten silent failures every month — exits clean, logs green, but nothing actually happened. Here is the Heartbeat / Output Trace / Decision Log pattern I now use to catch them inside 60 seconds, with code, GCP costs, and four months of running numbers.
📚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 →