Your Antigravity completions were spot-on at 50,000 lines of code. Then the project crossed 100,000 lines, and suddenly the suggestions became irrelevant. Sound familiar? The culprit is almost certainly context window saturation.
An AI coding assistant's effectiveness is not just about model intelligence. What you feed into the context matters even more. Antigravity automatically includes open files, project structure, and recent edit history in its context, but as your project grows, this automatic collection can backfire.
Recognizing Context Window Saturation
Context problems creep in gradually, making them hard to spot. If two or more of these symptoms are present, it is time to rethink your context management:
- Completion candidates suggest code from modules unrelated to your current file
- Type inference fails more frequently, returning
anyor undefined types - Inline chat responses start retreating to "generally, best practice recommends..."
- Answer quality for the same question varies wildly between attempts
The third symptom is the easiest to miss. When Antigravity starts answering with generic advice instead of project-specific code suggestions, it signals that your project's unique context is not making it into the window.
Eliminating Noise with .antigravityignore
The first step is excluding files that do not need to be in the context. .antigravityignore uses the same syntax as .gitignore and prevents specific paths from being collected for AI context:
# .antigravityignore
# Build artifacts (the biggest source of context pollution)
dist/
build/
.next/
out/
# Auto-generated files (not human-written code)
*.generated.ts
*.d.ts
prisma/migrations/
# Test snapshots (massive text that eats context space)
**/__snapshots__/
**/*.snap
# Large config files
package-lock.json
yarn.lock
pnpm-lock.yaml
# Documentation and assets (irrelevant for coding)
docs/
*.md
\!README.md
public/images/
In my experience, this configuration alone improves effective context utilization by 40 to 60 percent. Excluding package-lock.json (which can run to tens of thousands of lines) and __snapshots__/ delivers the biggest gains.
One caveat: excluding *.d.ts can prevent Antigravity from referencing library type definitions. It is safer to exclude only project-specific .d.ts files (like env.d.ts) and let Antigravity's default handling manage node_modules type definitions:
# Safer type definition exclusion
src/**/*.generated.d.ts
\!src/env.d.ts
Manual References: Telling the AI What to See
If .antigravityignore controls what you hide, manual references control what you show. Using @file in Antigravity's chat panel explicitly adds specific files to the context.
Effective reference patterns:
# Pattern 1: Type definition → Implementation
@types/api.ts Write a new endpoint handler based on this type
# Pattern 2: Test → Implementation (reverse order)
@__tests__/auth.test.ts Implement the auth middleware so this test passes
# Pattern 3: Design doc → Implementation
@docs/architecture.md Add a caching layer following this design
Pattern 2, the "test-first reference," is particularly powerful. Test code is the most precise expression of a specification, and it tells Antigravity exactly what needs to be achieved.
Workspace Splitting Strategy
For large projects, you can limit Antigravity's workspace to a subdirectory. Instead of opening an entire monorepo, open only the package you are actively working on:
# ❌ Opening the entire monorepo (context gets diluted)
antigravity open /path/to/monorepo
# ✅ Opening only the active package
antigravity open /path/to/monorepo/packages/apiThe downside is losing access to type definitions and interfaces from other packages, which makes this approach impractical when inter-package dependencies are strong.
My solution is creating a "context bridge file":
// packages/api/CONTEXT_BRIDGE.ts
// This file exists for Antigravity context only. Not used at runtime.
// Re-export important types from shared packages
export type { User, Session, Permission } from '@monorepo/shared';
export type { APIResponse, PaginatedResult } from '@monorepo/shared/api';
// Document touchpoints with other packages
// Web package depends on /api/auth/* endpoints
// Worker package subscribes to Redis pub/sub channel "events:*"Including this file in your workspace gives Antigravity awareness of cross-package interfaces while keeping the workspace focused. It has zero build impact but dramatically improves AI suggestion quality.
Session Management: Refreshing Context
During long work sessions, context accumulates stale information. Files you touched in the morning can linger in the context and interfere with afternoon work on a completely different feature.
The fix is straightforward. Reset your chat session when switching between major tasks:
1. Complete Feature A → Clear chat
2. Start Feature B → Re-reference only the files you need with @file
This might feel tedious, but it saves more time than working with contaminated context. After adopting a routine of refreshing sessions every two hours, the "completions get worse in the afternoon" problem essentially disappeared for me.
Microservice Architecture in Practice
Microservice architectures often have each service in its own repository. Context optimization here requires a different approach than single-repository projects:
# .antigravity/context.yaml (place at project root)
external_references:
- name: "user-service"
openapi: "https://internal-docs.example.com/user-service/openapi.json"
- name: "payment-service"
proto: "./proto/payment.proto"
priority_files:
- "src/config/services.ts" # Inter-service communication config
- "src/middleware/auth.ts" # Auth logic
- "src/types/events.ts" # Event type definitionsUse external_references to make other services' API specs available, and priority_files to specify files that should always be included in context. Event type definitions like events.ts are especially critical — whether they are present in context or not can dramatically change the quality of code suggestions.
Your Next Move
Start with creating a .antigravityignore file. Just excluding build artifacts and lock files delivers a noticeable improvement. From there, introduce workspace splitting and context bridge files as your workflow evolves.