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.

Antigravity321.antigravityignoreFile ExclusionProject SetupSecurity8AI 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 $10 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-07-04
Point Real-Browser Self-Debug at a Throwaway Preview, Not Localhost or Production
Antigravity 2.0's real-browser self-debug is genuinely useful, but aim it at the wrong place and it touches production data. Here is a practical way to confine it to a per-branch throwaway preview and neutralize email, billing, and webhook side effects.
Antigravity2026-07-01
Don't Build Your Own Peak: Time-Spreading Background Agent Schedules
Antigravity 2.0's desktop auto-schedules tasks in the background. Convenient, but cluster them at round hours and you build your own peak, and the late-night jobs fail together. Here is a design that spreads times and bans overlap, with real results.
Antigravity2026-07-01
When Your MCP Servers Vanish From the Chat App in Antigravity 2.0
After Antigravity 2.0 split into an IDE and a separate chat-style agent app, an MCP server I had set up in the IDE stopped showing up on the chat side. Here is why the settings scopes are separate, and how to fix it by making a single workspace-level source of truth that both apps read.
📚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 →