.antigravity File Complete Reference
The .antigravity file is the heart of your Google Antigravity configuration. Learn how to use rules, workflows, and settings to customize AI behavior for your project.
What is a .antigravity File?
A .antigravity file is a configuration file that contains rules and instructions for Google Antigravity's AI agents. Think of it as a "coding constitution" that tells the AI:
- →How to write code (style, patterns, conventions)
- →What technologies and libraries to use
- →Project architecture and file structure
- →Testing requirements and documentation standards
Key Concept: The agent reads your .antigravity file on every interaction, treating it as trusted instructions that guide all code generation.
File Locations
Project Rules (Recommended)
your-project/
├── .antigravity # Single file approach
└── ...
# OR
your-project/
├── .antigravity/
│ ├── rules.md # Main rules
│ ├── styling.md # CSS/styling rules
│ ├── testing.md # Testing rules
│ └── api.md # API conventions
└── ...Global Rules
~/.gemini/
├── antigravity/
│ ├── GEMINI.md # Global rules for all projects
│ └── browserAllowlist.txt
└── ...Global rules apply to all projects. Project rules take precedence over global rules.
Basic Syntax
Rules are written in Markdown format. Here's a basic structure:
# Project Rules
## Code Style
- Use TypeScript for all new files
- Prefer functional components over class components
- Use async/await instead of .then() chains
- Maximum line length: 100 characters
## Architecture
- Follow the feature-based folder structure
- Keep components in /src/components
- API routes go in /src/app/api
## Naming Conventions
- Components: PascalCase (Button.tsx)
- Utilities: camelCase (formatDate.ts)
- Constants: UPPER_SNAKE_CASE
## Testing
- Write unit tests for all utility functions
- Use React Testing Library for component tests
- Minimum 80% code coverage
## Documentation
- Add JSDoc comments to exported functions
- Include usage examples in complex componentsRule Types
1. Style Rules
Define code formatting and style preferences:
## Style
- Use 2 spaces for indentation
- Always use semicolons
- Prefer single quotes for strings
- Use trailing commas in multiline arrays/objects2. Technology Rules
Specify frameworks, libraries, and versions:
## Technology Stack
- Framework: Next.js 15 with App Router
- Styling: Tailwind CSS (no CSS modules)
- State: React Query for server state, Zustand for client
- Database: Supabase with Drizzle ORM
- Testing: Vitest + React Testing Library3. Architecture Rules
Define project structure and patterns:
## Architecture
- Use feature-based folder structure
- Shared components in /src/components/ui
- Feature components in /src/features/[feature]/components
- All API calls through /src/lib/api
- No direct fetch() calls in components4. Workflow Rules
Guide the agent's behavior and process:
## Workflow
- Always create a plan before implementing
- Run tests after making changes
- Update documentation when adding features
- Ask for clarification if requirements are unclearExample Configurations
Next.js Project
# Next.js 15 Project Rules
## Framework
- Next.js 15 with App Router
- TypeScript strict mode enabled
- Server Components by default
- Use 'use client' only when necessary
## Styling
- Tailwind CSS for all styling
- Use CSS variables for theming
- Mobile-first responsive design
- Use cn() helper for conditional classes
## Components
- Functional components only
- Props interface above component
- Export default for page components
- Named exports for shared components
## Data Fetching
- Server Components for initial data
- React Query for client-side fetching
- Implement proper loading states
- Handle errors gracefully
## File Structure
src/
├── app/ # Next.js App Router
├── components/ # Shared components
│ └── ui/ # Base UI components
├── lib/ # Utilities and helpers
├── hooks/ # Custom React hooks
└── types/ # TypeScript typesPython FastAPI Project
# FastAPI Project Rules
## Framework
- FastAPI with Pydantic v2
- Python 3.11+
- Async/await for all I/O operations
- SQLAlchemy 2.0 with async sessions
## Code Style
- Type hints for all functions
- Docstrings for public functions
- Black formatting (line length 88)
- isort for import sorting
## API Design
- RESTful conventions
- Versioned endpoints (/api/v1/)
- Consistent error responses
- OpenAPI documentation
## Architecture
app/
├── api/ # Route handlers
├── core/ # Config and security
├── models/ # SQLAlchemy models
├── schemas/ # Pydantic schemas
├── services/ # Business logic
└── utils/ # HelpersBest Practices
Do
- ✓ Be specific and clear
- ✓ Include examples
- ✓ Organize rules by category
- ✓ Update as project evolves
- ✓ Keep rules actionable
Don't
- ✗ Write vague instructions
- ✗ Include sensitive data
- ✗ Make rules too restrictive
- ✗ Contradict yourself
- ✗ Forget to test rules
For comprehensive best practices, see our Best Practices guide.
Advanced Configuration
Exclude Patterns
Prevent the AI from reading or modifying certain files:
## Exclude Patterns
exclude_patterns:
- node_modules/**
- .git/**
- dist/**
- coverage/**
- *.log
- .env*
- secrets/**This improves performance and prevents accidental exposure of sensitive data.
MCP Server Integration
Configure MCP servers in your .antigravity file:
## MCP Servers
Use the following MCP servers:
- @supabase/mcp for database operations
- @github/mcp for repository management
- @stripe/mcp for payment integration
Configure in .antigravity/mcp.jsonBrowse available MCP servers in our MCP directory.
Agent Mode Configuration
Configure Agent Mode behavior:
## Agent Mode Settings
When using Agent Mode:
- Always create a plan before implementation
- Ask for confirmation before destructive operations
- Run tests after making changes
- Provide progress updates during long tasks
- Stop and ask if encountering unexpected errors⚡ Workflow Integration
Your .antigravity file works seamlessly with Antigravity's built-in workflows:
🔧 Troubleshooting
If your .antigravity rules aren't being applied:
- 1.Check file location - Must be in project root or ~/.gemini/
- 2.Reload the agent - Rules are loaded on startup
- 3.Check syntax - Use valid Markdown formatting
- 4.Verify file name - Must be .antigravity or in .antigravity/ folder
Still having issues? Check our Troubleshooting Guide for more solutions.