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.

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

Related Articles

Agents & Manager2026-07-29
A Typo in agent.md Quietly Widened My Permissions — Writing a Strict Frontmatter Lint
Misspelled keys in agent.md frontmatter do not raise errors. They fall back to defaults, and for permission fields that fallback points the wrong way. Here is the failure I hit, the lint I wrote to catch it, and what the measurements showed.
Agents & Manager2026-07-10
Tracing Why an Agent Wrote That Line Six Months Ago — Commit Granularity and Provenance Trailers
When an agent packs 14 files and 800 lines into a single commit, git blame tells you nothing six months later. Here is how I split commits at intent boundaries, recorded provenance as machine-readable Git trailers, and built a one-command path from a blamed line back to the design decision behind it.
Agents & Manager2026-07-16
When to Hand Your Agent the Next Instruction: Waiting, Interrupting, and Queuing, Measured
Antigravity v2.3.0 added message queuing and Send Now. I measured waiting, interrupting, and queuing against the same yardstick, found that 41% of queued instructions arrive stale, and cut rework from 22% to 9% with a twenty-line stamp.
📚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 →