ANTIGRAVITY LABJP
Articles/Integrations
Integrations/2026-06-19Intermediate

Running Antigravity CLI Unattended: Notify Only on Real Failures

A small wrapper for scheduled Antigravity CLI runs that stays silent on success and alerts you only on failures a human needs to act on, covering exit codes, transient-error triage, and duplicate suppression.

Antigravity CLI9automation54notificationsscheduled tasks2shell scripting

Premium Article

A few nights ago, my own automation kept me from sleeping. A scheduled job stalled for just a moment, and my phone buzzed again and again. When I opened the logs the next morning, exactly one failure had needed my attention. Everything else was a transient hiccup that had cleared itself within minutes.

When Gemini CLI was retired on June 18 and I moved my unattended scripts over to the Go-rewritten Antigravity CLI, all of those scripts had to be ported at once. The new CLI is fast and starts lightly. But the question of what to notify on is still mine to design, regardless of which CLI sits underneath. Today I want to share the small mechanism I use to stay silent on success and quietly surface only the failures that actually need a person.

Over-alerting is as dangerous as under-alerting

When I first started building unattended jobs, I set them to "notify on everything." Success and failure alike landed in my pocket. It felt reassuring; in practice it was the opposite.

Once your eyes adjust to a constant stream of success pings, the single failure buried among them slips past. During a stretch when I was running automated updates for four blogs alongside AdMob revenue checks for several apps, dozens of notifications piled up each day, and the one anomaly that mattered scrolled off into the distance.

The value of a notification lives not in volume but in trust — the trust that when it arrives, you will stop what you're doing. So the design starts with subtraction, not addition. Decide first what you will never send, then ring only what's left.

Anchor silence-on-success in the exit code

The first foundation is the Antigravity CLI's exit code. Launched from a shell, the CLI returns 0 on success and non-zero on failure. That value is the primary gate that decides whether to notify at all.

Collect stdout and stderr into a single log file. Whether you're reading the failure later or assembling the body of an alert, that one log is what you'll lean on.

#!/usr/bin/env bash
set -uo pipefail
 
LOG_DIR="${HOME}/.agy-runs"
STATE_DIR="${HOME}/.agy-state"
mkdir -p "$LOG_DIR" "$STATE_DIR"
 
# Take the first argument as the task name; pass the rest through to the CLI
TASK="${1:?task name required}"
shift
 
LOG="${LOG_DIR}/${TASK}-$(date +%Y%m%d-%H%M%S).log"
 
# Run the Antigravity CLI, funneling all output into the log
agy run "$@" >"$LOG" 2>&1
CODE=$?
 
echo "task=${TASK} exit=${CODE} log=${LOG}"

The deliberate choice here is to not use set -e. If the whole script halted the moment the CLI failed, you'd never reach the part that classifies the failure and decides whether to notify. A failure isn't something to halt on — it's something to observe and handle. Keep only set -uo pipefail and capture the exit code yourself.

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
An unattended-run wrapper built on exit codes and logs that stays silent on success
Classification logic that separates transient rate limits and auth expiry from failures worth a human's time
Duplicate suppression that won't re-alert the same failure for 6 hours, preventing alert fatigue
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-06-14
After Migrating to Antigravity CLI: Deciding How Much to Delegate to Scheduled Runs
When the June 18 Gemini CLI sunset pushes you onto Antigravity CLI, you gain background scheduled runs. Convenient, but delegate everything and you won't notice when it breaks. Here is how I separate what to schedule from what to keep manual, with the actual routing rules.
Integrations2026-06-17
When the Antigravity CLI Stalls on a 401 During Unattended Runs
If your scheduled Antigravity CLI job suddenly stops producing output after a single 401 in the logs, here is how to separate an expired token from a silent re-login prompt and rebuild your unattended setup.
Integrations2026-06-17
Ask Antigravity CLI Once Whether It Actually Answers, Right Before a Scheduled Run
When Gemini CLI shuts down on June 18 and you move to Antigravity CLI, an expired token or a bad first day can let an unattended job fail silently. Here is a preflight that probes the CLI once, classifies the failure, and decides whether the real job should start at all.
📚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 →