◉ANTIGRAVITY LABJP
Articles/Antigravity Basics
◉ Antigravity Basics/2026-04-26Intermediate

Mastering Antigravity's `.antigravityignore` — Designing What You Let the AI See

The `.antigravityignore` file controls which files Antigravity's AI agents and indexer can read. This guide walks through how it differs from `.gitignore`, the baseline patterns to start with, and the design decisions that make the agent both faster and safer.

Antigravity377.antigravityignoreFile ExclusionProject SetupSecurity9AI Development7

import { Callout } from '@/components/ui/callout';

Open a project in Antigravity, work with it for a few minutes, and you will notice something: the AI agent is willing to look at every file in the repo. node_modules/, build artifacts, and yes, even .env.local.

The mechanism for steering this is the .antigravityignore file. It looks like a cousin of .gitignore, but its purpose and behavior diverge in important ways. This article shares the patterns I have actually used across several projects, and the design choices behind them.

How It Differs from .gitignore

The two share syntax but serve different roles.

.gitignore keeps files out of Git history. .antigravityignore keeps files away from Antigravity's agents and indexer. There are surprisingly common cases where you want to commit a file but not let the AI read it — and the inverse, files you exclude from Git but expect the agent to consume (auto-generated schemas, for instance).

I keep them as separate files in my projects. Copying .gitignore straight across is convenient on day one, but maintaining the two with their own logic pays off long term.

A Baseline Template to Start From

This is the minimum I would set on any new project.

# .antigravityignore — baseline
 
# Dependencies — too large, wastes context
node_modules/
.pnpm-store/
__pycache__/
.venv/
 
# Build artifacts — the source is enough
dist/
build/
.next/
.nuxt/
out/
 
# Secrets — never expose to the AI
.env
.env.local
.env.*.local
*.pem
*.key
secrets/
credentials.json
 
# Test artifacts — large, low signal
coverage/
__snapshots__/
test-results/
playwright-report/
 
# AI-generated outputs — avoid self-reference
.claude/
.antigravity/cache/

Two reasons this is worth doing immediately: a clean context improves answer quality, and excluding secrets reduces the risk of credentials leaking into prompts.

Layering on Project-Specific Rules

Beyond the baseline, the right additions depend on the project type.

Monorepos

When you are working in one package out of many, you generally want the agent's attention focused on the active workspace.

packages/*/dist/
packages/*/.cache/
apps/*/dist/
.turbo/
.nx/cache/

Next.js + Cloudflare Workers

The Next.js + Cloudflare Workers stack I run for sites like Antigravity Lab generates a lot of intermediate output.

.next/
.open-next/
.wrangler/
public/cf-cache/
worker-bundle.js
 
# Auto-generated types and content data — touching these breaks invariants
src/generated/
public/content/

src/generated/ is particularly important. It contains TypeScript types derived from MDX frontmatter, and you do not want the agent editing them as if they were source files.

iOS / Android Apps

# iOS
*.xcuserstate
DerivedData/
Pods/
*.xcworkspace/xcuserdata/
 
# Android
.gradle/
build/
*.keystore
local.properties

local.properties often holds API keys, so treat it as a secret.

The Risk of Excluding Too Much

The opposite mistake matters too. Early on I excluded docs/ entirely, reasoning that the agent could lean on README.md. The result was that it stopped understanding the intent behind features and started rewriting business logic in ways that broke product expectations.

So I now intentionally keep "the documents that exist to convey intent" inside the agent's reach.

# ✅ Re-include living architecture docs
# !docs/architecture/
# !docs/api-spec/
 
# ❌ But stale drafts add noise
docs/drafts/
docs/*.bak

Re-inclusion with ! is order-sensitive, so audit carefully when you use it.

Verifying the Configuration

After editing .antigravityignore, check that the rules took effect. Antigravity's Mission Control panel surfaces the files currently in the agent's context, so you can confirm exclusions visually.

If something seems off, walk through this list:

  • Is .antigravityignore at the project root?
  • Are line endings LF? (CRLF on Windows can misbehave)
  • Is there a nested .antigravityignore in a subfolder that overrides things?
  • Did you restart the agent session after editing? (Existing sessions sometimes hold the old state)

How I Think About This Day to Day

I run multiple side projects in parallel as a solo developer, so context efficiency matters a lot. Even with a generous context window, noise still degrades answers.

My rule of thumb is one question:

"Could I summarize this content in a single line if I had to explain it to the AI?"

If yes, you do not need the file in context. A 10,000-line lockfile compresses to "dependency lock" and that is enough. Files that resist summarization — design docs, ADRs, API contracts — are the ones worth keeping in.

Next Step

Drop the baseline template into .antigravityignore and ship. The build artifacts and secrets exclusions alone make the agent feel measurably faster and safer. From there, prune project-specific noise as you notice it during real sessions.

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 →

If you found this article helpful, a small tip ($1.50) would mean a lot to us. Your support helps keep this site ad-free and covers server and hosting costs.

Related Articles

◉ Antigravity2026-09-13
When You Cannot Decide Between Rules and Skills: Rethinking Where Instructions Live
Rules and Skills load at different moments in Antigravity. Rules go in full on every turn; Skills lead with a heading and load the rest on demand. After the same note drifted apart in two places on a client site, here are the questions I use to place an instruction, plus a small script to measure what you carry each turn.
◉ Antigravity2026-09-02
Why Filename Search Misses Every Error String in Your Repo
Antigravity 2.12 improved partial filename search. Measuring name lookups against full-text search across a 2,088-file repository, the reading cost differed by 67x and error strings hit filenames only 4.5% of the time. Here is where the line actually falls.
◉ Antigravity2026-08-10
Guarding the Turn Boundary in Non-Interactive Runs: A Command Table and a Fail-Closed Gate
A scheduled job meant only to record usage was calling the model on every run. Here is how I split commands into ones that start a turn and ones that do not, built a gate that refuses anything unclassified, and measured it against real scripts.
📚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