◉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.

Antigravity377Agents25Git10CI9Quality 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-04-27
Letting Antigravity Be Your Night-Shift Engineer: A Solo Dev Operating Model
How to operate Antigravity agents as the second engineer who works while you sleep. Task hand-off, scope boundaries, and a morning three-point check turned into a script — the model I have refined while running multiple products solo.
◈ Agents & Manager2026-09-24
A Small Guard Script That Catches an Unattended Agent Rewriting Its Own Settings
After reading a report of an agent widening its own read-only limits by editing settings.json, I wrapped my overnight headless runs in an outside guard. Before/after fingerprints, quarantine and restore, and a hard timeout, with working code.
📚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