ANTIGRAVITY LABJP
Articles/Agents & Manager
Agents & Manager/2026-07-10Advanced

When Your Agent's Files Vanish Into .gitignore — A Pre-Commit Detection Gate

When an agent writes files that match .gitignore, the diff review looks perfect but nothing lands in the commit. Here is a gate script that catches ignored build output before you push, plus the tuning it needs.

Antigravity317Agents17Git5CI4Quality Gate

Premium Article

I asked an agent to write generated HTML into public/content, reviewed the diff in the artifact viewer, and committed with confidence. Nothing showed up in production. When I traced it back, the file had never appeared in git status at all. public/content/ was in .gitignore.

It cost me most of a day. The agent really had written the file. It existed on disk. The diff UI displayed it. Only Git stayed silent — and that is exactly what makes the bug hard to see.

The agent's diff and Git's diff are not the same thing

Antigravity's artifacts show you every file the agent touched. That is a filesystem fact. git status shows you something narrower: changes that are tracked, or untracked but not matched by an ignore rule.

AspectArtifact viewergit status (default)
ScopeEvery file the agent wroteTracked + untracked non-ignored
Matches .gitignoreShown normallyCompletely silent
How failure looksSuccessEmpty diff — as if nothing happened

"Agent succeeded, Git detected nothing" is indistinguishable from the happy path. Any repository that ignores build output will hit this the moment you actually want some generated file committed: prebuilt static assets, bundled content HTML, generated type definitions.

List only the ignored files

Git can surface ignored paths explicitly. The default --ignored collapses them by directory, so ask for matching when you need file-level granularity.

# List ignored paths, one file per line (!! marks ignored)
git status --porcelain --ignored=matching | grep '^!!' | cut -c4-
 
# Trace which rule ignored a specific path
git check-ignore -v public/content/articles/en/agents/foo.html
# → .gitignore:12:public/content/	public/content/articles/en/agents/foo.html

git check-ignore -v tells you the file and line number of the rule that matched. That output is how I finally found a stale exclusion sitting in .git/info/exclude rather than .gitignore — somewhere I would not have thought to look.

For a batch of paths, feed them through stdin:

# Pass the agent-touched file list, keep only the ignored ones
printf '%s\n' "${TOUCHED[@]}" | git check-ignore --stdin --verbose

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
Listing exactly the agent-written files Git refuses to track, using git status --porcelain --ignored=matching
A 60-line pre-commit gate that exits 1 on ignored build output, with an allowlist escape hatch
The order to fix .gitignore in so false positives settle around 10% instead of drowning the signal
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

Agents & Manager2026-06-29
When Your Antigravity Agent Opens a PR That Just Says "Update files" — and a Gate That Forces a Reviewable Summary
Pull requests opened automatically by an Antigravity agent tend to carry empty descriptions like "Update files." Here is a validation gate, with working code, that estimates risk from the diff and rejects vacuous descriptions so a human can actually review them.
Agents & Manager2026-06-21
Keeping Unattended Agent Run Logs Long Enough to Debug — Without Filling the Disk
A scheduled agent is only fixable if you can reconstruct why it failed. Here is how to keep run logs around without filling the disk — tiered retention, schema-versioned records, and a compaction job — drawn from running four sites on autopilot as an indie developer.
Agents & Manager2026-06-20
Don't Lose Failed Agent Jobs: Designing a Dead-Letter and Requeue Path
Scheduled agents fail silently overnight and the work simply vanishes. Here is how to catch those failures with a dead-letter store and a staged requeue, drawn from running four sites on autopilot as an indie developer.
📚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 →