From Single-Machine Setup to Cross-Host Engineering: Sub-Second Quality Gates, Three-Plugin Split, and Per-Host Toggles
The first five parts got the agyr launcher, lazy MCP loading, multi-session Chrome tab guardrails, and a private environment backup repository running smoothly. Once I rolled that setup out across a daily desktop devbox, headless Linux cloud hosts, and multiple concurrent repositories, four new team and multi-host governance problems surfaced almost immediately:
- Prompt-only rules still let defects slip through: Even with explicit rules in
AGENTS.md(“never rungit add .in the blog repo, never leak local home paths or private IPs, run architecture checks andgofmtbefore committing Go code”), parallel sessions under time pressure still occasionally end a turn early and leave flawed changes for manual cleanup on the next pass. - A monolithic global config collides across machines: A desktop devbox needs Chrome DevTools MCP and internal Jira MCP, whereas a headless cloud host has neither a browser nor corporate VPN access. Because all hooks, skills, and MCP servers lived in global
~/.gemini/config/hooks.jsonandmcp_config.json, every sync overwrote the cloud host and forced manually commenting them out after every restore. - No visibility into quota burn rate during heavy runs: Checking
/usagegives an instant snapshot, not how fast a workload is burning quota or how soon it will run out—yet I refuse to install untrusted closed-source monitors or background agents that continuously spend tokens. - Evaluating official Sidecars without leaving idle daemons behind: Sidecars can observe sessions in the background, but whether they actually fit CLI workflows—and how to keep them at zero token cost—requires a minimal hands-on test rather than guesswork.
This post documents how I upgraded the AGY setup to project-level sub-second quality gates, a three-plugin native split, and per-host toggles, alongside a hands-on evaluation and disciplined trade-offs for quota monitoring and Sidecars, plus the real pitfalls hit along the way.

1. Project-Level Sub-Second Quality Gates: Check Diffs Only, Never Slow Down Turns
The first ironclad rule of adding .agents/hooks.json to a repository is strict latency discipline: a Stop hook fires every time the agent prepares to finish a turn. If you stuff full unit test suites or hexo generate into it and stall every turn ending for 10–15 seconds, you will delete the hook yourself within three days.
So I set a hard budget for my two most active repositories: inspect only the incremental changes from git status, and keep total wall-clock latency under 1 second.
1.1 Blog Repo Two-Layer Guard (Measured 36ms)
The blog repository (Hexo + Butterfly) runs two lightweight checks—PreToolUse and Stop—dispatched through a single script, .agents/hooks/blog-guard.py:
PreToolUse(run_command): Uses Pythonshlexto split command lines on;/&&/|into independent command segments and inspects only actual executables and arguments. It precisely blocksgit add ./-A/--all(preventing drafts or unrelated untracked files from being staged wholesale) andhexo server/npm run server, without triggering false positives on string arguments likegit commit -m "ban git add .".Stop(incremental content gate): Scans only modified or untrackedsource/_posts/**/*.mdfiles. Running all four checks takes 36ms:- Required frontmatter fields (
title,date,categories) are present; - No shortcodes incompatible with the active theme;
- Strict redaction scan (real local home-directory paths, private-subnet IP addresses, plaintext tokens, or private-key blocks);
- Every local
/img/...path referenced in the post body orcover:exists on disk undersource/.
- Required frontmatter fields (
1.2 Application Repo Incremental Routing (All 4 Checks < 0.9s)
In a mixed Go + TypeScript + Protobuf repository, .agents/hooks/opc-quality-gate.py reads git status --porcelain=v1 -uall and routes checks by file type—only running the checks that match what actually changed:
| Changed File Pattern | Triggered Check | Measured Latency |
|---|---|---|
*.go (excluding generated files) |
scripts/check-architecture.py + gofmt -l |
~30ms |
frontend/**/*.{ts,tsx} (excluding generated files) |
pnpm --dir frontend typecheck |
~390ms |
proto/**, buf*.yaml |
Generated protobuf consistency check check-generated |
~430ms |
1.3 The Biggest Pitfall: Why Did the Stop Hook Loop 10 Times?
After writing the gate scripts and passing unit tests, I started a fresh agy -p session and intentionally introduced a rule violation for an end-to-end test. It blew up immediately: after the Stop hook returned {"decision": "continue", "reason": "..."}, even though our script checked payload.get("continuationActive"), the agent on this CLI version hit the gate 10 consecutive times until MAX_FORCED_INVOCATIONS forcibly aborted the turn.
A second real-world annoyance showed up at the same time: during parallel multi-terminal work, the working tree often holds uncommitted changes from a sibling session. If the current session only answered a read-only question (touching zero files), having Stop scan git status and block the session over someone else’s half-finished edit ruins the workflow.
Root-cause fix: inspect the tail of transcriptPath to eliminate both infinite loops and read-only false positives in one pass.
The stdin payload delivered to a Stop hook includes transcriptPath, pointing to the current session’s JSONL transcript. We read only the last 256 KB of the file and scan backward to the most recent USER_INPUT record (the start of the current turn):
- If the current turn already contains a
SYSTEM_MESSAGEwith"Stop hook blocked termination:", this turn has already been blocked and warned once—let it pass immediately. This hard-caps blocking at once per turn and eliminates infinite loops. - If none of the
PLANNER_RESPONSE.tool_callsin this turn invoked a mutating tool (write_file,edit_file,run_command, etc.), the turn is purely read-only—pass immediately with zero false positives even when sibling sessions leave dirty files in the repo.
The core helper is under 45 lines and directly reusable:
1 | MUTATING_TOOLS = { |
Re-running fresh-session end-to-end verification after the fix:
- Intentionally break a blog post → blocked exactly once, no loop;
- Ask a read-only question while parallel dirty edits sit in the working tree → completes cleanly in 5 seconds, zero false positives.
2. Run a 5-Second Probe First, Then Split Global Config into Three Native Plugins
With project-level gates sorted out, the next bottleneck was the global ~/.gemini/config/ monolith: hooks, skills, and MCP servers were all mixed into top-level JSON files. Disabling Chrome and Jira on a headless cloud host meant hand-editing JSON, only for the next sync to clobber it.
AGY natively supports directory-based plugins under ~/.gemini/config/plugins/<plugin-name>/. Each plugin bundles its own plugin.json, hooks.json, mcp_config.json, and skills/, and toggles cleanly with agy plugin enable/disable <name>.
2.1 Probe Two Subtle Runtime Behaviors Before Refactoring
Before migrating anything, I created a throwaway minimal probe plugin and ran a real agy -p session to verify two behaviors (deleting the probe immediately afterward). That five-second check saved at least two hours of debugging:
- A plugin MCP server starts with its working directory set to the plugin root: Writing
"args": ["./bin/mcp-lazy-proxy.py", ...]directly inmcp_config.jsonworks out of the box—no more hardcoded/home/<user>paths or template placeholder substitution in backup scripts. Addingos.path.expanduserinsidemcp-lazy-proxy.py(expanding~in commands, arguments, andMEMORY_FILE_PATH) achieves zero hardcoded paths and zero template rendering across all plugin directories. - Plugin MCP server names automatically gain a
<plugin>_namespace prefix, while tool names stay unprefixed: For example,chrome-devtoolsdeclared insidehippo-desktop-chromeloads into the session ashippo-desktop-chrome_chrome-devtools, while tools likeclickandnew_pagekeep their bare names.
That second finding immediately caught a guaranteed regression:
ui-action-state.pyfrom Part 5, which lights up the🟠status indicator, originally used an exact matchserver == "chrome-devtools". Without changing it to a substring check ("chrome-devtools" in server or "chrome_devtools" in server) during plugin migration, the orange indicator would have silently stopped working.
2.2 Split by Runtime Environment Boundary, Not File Type
The worst way to split plugins is by file type (all hooks in one bundle, all MCP servers in another)—you still cannot toggle capabilities per host. The right boundary is runtime environment, keeping each plugin cohesive with its own hooks, MCP servers, and skills:
| Plugin | Target Environment | Bundled Capabilities | Cloud Host State |
|---|---|---|---|
hippo-core |
All platforms | deny-docker, title-waiting-choice, session-context-snapshot, lazy context7 & memory MCPs, sub Skill |
✅ Enabled |
hippo-desktop-chrome |
Desktop devboxes only | Lazy chrome-devtools proxy with bidirectional tab isolation, browser-tab-group Skill + helper scripts, title-ui-action (🟠 status hook) |
⛔ disable |
hippo-work-jira |
Corporate-network hosts only | jira-internal lazy MCP proxy |
⛔ disable |
After migration, empty out legacy global ~/.gemini/config/hooks.json to {} and ~/.gemini/config/mcp_config.json to {"mcpServers": {}}, then validate each plugin with the official strict validator:
1 | agy plugin validate --strict ~/.gemini/config/plugins/hippo-core |
(Tip: --strict requires name in plugin.json to be kebab-case and version to be declared explicitly. All three plugins pass with 0 errors and 0 warnings.)
2.3 Zero-Downtime Migration Trick: Temporary Shims for Live Terminals
One real operational snag surfaced during the cutover: already-running agy terminal sessions cache absolute hook paths from the old hooks.json at startup. If you delete ~/.gemini/config/hooks/deny-docker-agy.py immediately after migrating, any terminal you have not restarted will throw a missing-script error on its very next run_command.
The fix is tiny: drop three sub-10-line os.execv forwarding shims into local ~/.gemini/config/hooks/ (excluded from backup manifest.json) so legacy sessions transparently forward to the new plugin directories. Once old terminals exit naturally, delete the three local shims.
3. Per-Host Toggles Across Machines: One strip_keys Line Keeps Cloud Disables Persistent
With three plugins in place, enabling per-host toggles in the private backup repo (see Part 4) takes a single config line.
When you run agy plugin disable <name>, AGY records each plugin’s toggle state under the top-level plugins key in ~/.gemini/config/config.json. Adding "plugins" to strip_keys for config.json in manifest.json (right alongside host-specific cliRemoteControlHostname) keeps per-host toggle state local:
1 | { |
Backup and restore now diverge cleanly by machine role:
flowchart LR
REPO["Private Backup Repo (All 3 Plugins Synced)<br/>manifest.json: strip_keys += plugins"] --> DEV["Desktop Devbox<br/>All plugins remain enabled"]
REPO --> CLOUD["Headless Cloud Host (Linux)<br/>agy plugin disable chrome & jira"]
CLOUD --> PULL["Nightly sync.py pull Auto-Restore<br/>Preserves local plugins & hostname"]
PULL --> VERIFY["New Session Loads hippo-core Only<br/>No extra MCPs / No desktop hook errors"]
End-to-end verification on a headless cloud host confirmed the entire loop:
- Pulled all three plugins and passed
agy plugin validate --strict; - Ran
agy plugin disable hippo-desktop-chromeandagy plugin disable hippo-work-jira; - Re-ran
sync.py restore(simulating the nightly scheduled pull) and verified both the disabledpluginsentries and the cloud host’scliRemoteControlHostnameremained intact inconfig.json; - Launched a fresh
agysession: onlyhippo-core_context7,hippo-core_memory, and thesubSkill loaded;docker pswas blocked bydeny-docker;memoryMCP queries worked normally; Chrome and Jira never loaded.
4. Evaluating Quota Monitoring & Sidecars: Knowing When to Hold Back
After finishing gates and plugins, I also tested two popular community and official additions: quota burn-rate monitoring (agy-usage) and background Sidecars. Both are easy traps for over-engineering—after verifying each end-to-end, my conclusion was disciplined restraint: leave neither running as a background daemon.
4.1 agy-usage: Why I Audited It, Verified the Timer, and Uninstalled It
The open-source community Rust CLI agy-usage tracks remaining quota per model bucket, computes burn rates (Rate/h), and generates an offline local HTML dashboard. Before installing it, I audited the source code and Cargo.toml line by line:
- Zero extra network libraries: Makes no outbound HTTP requests of its own; it only invokes local
agy -p /usage --output-format json; - Purely local storage: Appends JSONL samples to
~/.local/share/agy-usage/samples.jsonland embeds offline charting code in its HTML output.
After verifying the release SHA-256 checksum and installing the binary, I ran the full pipeline: agy-usage install-timer (a 5-minute user-level systemd timer), the TUI panel (agy-usage show --once), and the offline report (agy-usage html).
Ubuntu 22.04 note: On GLIBC 2.35, the official prebuilt binary prints
weak version 'GLIBC_2.39' not foundto stderr. It is a harmless weak-symbol notice—every subcommand andagy-usage.serviceexited 0 and wrote samples cleanly (measuredcollected 4 buckets).
Once it was running, I asked myself a blunt question:
agy-usagedoes not live inside my active terminal UI; spawningagy -p /usageevery 5 minutes (~1.9s CPU per run) only pays off if you want continuous historical curves andRate/hexhaustion forecasts;- In practice, I only care how much headroom is left right now—typing native
/usageinside a session is faster and requires zero background polling.
With that clear, I ran agy-usage uninstall-timer, removed the binary and data directory, and returned to native /usage. If you genuinely want weekly/monthly quota trend charts or Waybar/tmux status bar integration, it is a clean, safe tool; if you just glance at remaining quota occasionally, skip the background timer.
4.2 Read-Only Sidecar Prototype: Verified End-to-End, Disabled by Default
To understand AGY’s official Sidecar contract, I built a minimal read-only prototype at ~/.gemini/config/sidecars/<demo>/sidecar.json that uses ANTIGRAVITY_AGENTAPI_EXE to call agy agentapi get-conversation-metadata against the local Language Server—consuming 0 LLM tokens and returning agentapi_ok: true cleanly.
Testing also revealed its sharp scope boundary: agy -p non-interactive CLI runs do not auto-start background Sidecars; resident Sidecars primarily target the Antigravity 2.0 desktop app. After confirming the full contract, I disabled the prototype in config.json and kept it out of the backup repo and cloud hosts—never run an idle background daemon without a concrete need.
5. Production Verification Checklist
Every claim verified with live command output before sign-off:
- Project-level gates: Blog repo
PreToolUseblocksgit add .without false positives andStopincremental checks finish in 36ms; all 4 incremental checks in the application repo finish in< 0.9s;transcriptPathtail scanning caps blocks at once per turn with zero read-only false positives; - Three-plugin split:
hippo-core,hippo-desktop-chrome, andhippo-work-jiraall passagy plugin validate --strict(0 warnings); globalhooks.jsonandmcp_config.jsonare emptied; fresh sessions show zero duplicate loading; - Per-host toggles: Adding
"plugins"tostrip_keysinmanifest.jsonpreserves desktop/corporate plugin disables on headless cloud hosts acrosssync.py pull/restore; - Disciplined restraint & zero idle daemons:
agy-usageaudited, tested end-to-end, and cleanly uninstalled once confirmed non-essential; read-only Sidecar prototype verified, left disabled locally with zero cloud rollout, and zero stray background polling processes left running.
Summary
From a single launcher script in Part 1 to Part 6, this Antigravity engineering setup has evolved from single-machine convenience into a governable multi-repo, multi-host system:
- Repository rules belong in sub-second
.agents/hooks.json, guarded bytranscriptPathscanning against infinite loops and read-only false positives; - Personal tooling splits into native plugins by runtime boundary, eliminating monolithic config files and hardcoded home paths;
- Host differences collapse into
strip_keys+agy plugin disable, letting one backup repository cleanly serve both desktop devboxes and headless cloud hosts; - Background components earn their keep or get turned off: audit the source, probe the runtime boundary, and disable or uninstall anything without a real high-frequency need.








