Google Antigravity Rules: Complete Guide
Rules in Google Antigravity guide the AI agent's behavior when generating code, tests, and documentation. This comprehensive guide covers everything you need to know about creating effective rules.
What are Antigravity Rules?
Rules are guidelines that tell Google Antigravity's AI agent how to write code for your project. They're like persistent instructions that the agent follows automatically every time it generates code.
Think of rules as a combination of coding standards, style guides, and architectural preferences that ensure consistency across your entire project.
Types of Rules
🌍Global Rules (GEMINI.md)
Global rules apply across ALL your workspaces. They're stored in a GEMINI.md file in the ~/.gemini/ folder.
Best for: Personal coding preferences, universal standards you want everywhere (e.g., "always use TypeScript", "prefer functional components").
📁Project Rules (.antigravity)
Project rules are specific to a single project. They're stored in .antigravity/rules/ directory or a .antigravity file in your project root.
Best for: Project-specific conventions, team standards, framework-specific rules (e.g., Next.js App Router patterns).
⚡Workflows (Saved Prompts)
Workflows are saved prompts triggered on-demand with / slash commands. Unlike rules (which are automatic), workflows are user-triggered.
Best for: Common tasks you repeat often (e.g., "/create-component", "/add-tests", "/refactor").
How to Create Rules
Method 1: Via Antigravity UI
- Click the
...menu in the top right corner of the agent chat - Select Customizations
- Choose Rules or Workflows
- Click + Global for global rules or + Project for project rules
- Write your rules in the editor
Method 2: Manual File Creation
# For global rules:
~/.gemini/GEMINI.md# For project rules:
your-project/.antigravity/rules/my-rules.mdExample Rules
Next.js Project Rules
# Next.js 15 Project Rules ## Code Style - Use TypeScript for all files - Prefer Server Components by default - Only add "use client" when necessary - Use the App Router, not Pages Router ## Naming Conventions - Components: PascalCase (e.g., UserProfile.tsx) - Utilities: camelCase (e.g., formatDate.ts) - Folders: kebab-case (e.g., user-profile/) ## Architecture - Keep components small and focused - Extract shared logic into custom hooks - Use Zod for form validation - Prefer server actions over API routes ## Testing - Write tests for all utility functions - Use React Testing Library for components - Mock external APIs in tests
Best Practices
Keep Rules Concise
Individual rule files are limited to 6,000 characters. Focus on the most important guidelines. Less is more - overly detailed rules can confuse the agent.
Be Specific, Not Vague
Instead of "write clean code", say "use descriptive variable names with auxiliary verbs (isLoading, hasError)". Specific rules produce consistent results.
Include Examples
Show the agent what good code looks like. Include short code snippets demonstrating your preferred patterns.
Organize with Sections
Use markdown headers (##) to organize rules into categories like "Code Style", "Architecture", "Testing", etc.
Browse Pre-Made Rules
Don't start from scratch! We have 130+ curated rules and prompts for Next.js, React, Python, TypeScript, and more. Copy any prompt directly to your .antigravity file.
Frequently Asked Questions
What's the difference between rules and workflows?
Rules are always-on guidelines that the agent follows automatically. Workflows are saved prompts you trigger manually with slash commands. Think of rules as "system instructions" and workflows as "reusable prompts."
Can I use .cursorrules files with Antigravity?
Yes! Google Antigravity automatically detects and reads .cursorrules files in your project. However, we recommend migrating to the native .antigravity format for better compatibility with Antigravity-specific features.
How do I share rules with my team?
Simply commit your .antigravity/ folder to your Git repository. Project rules are designed to be version-controlled and shared. Each team member will get the same rules when they clone the repo.
What happens if global and project rules conflict?
Project rules take priority over global rules when they conflict. The total combined limit for all rules is 12,000 characters. If you exceed this, global rules take priority, then project rules, with excess truncated.