Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Antigravity IDE — Complete Setup & Token Optimization Guide

Who this is for: Anyone starting a new project or adding a new feature in Antigravity IDE. Goal: Set up Antigravity correctly before writing a single line of code so the AI agent works precisely, wastes zero tokens, and produces correct output on the first attempt.


Table of Contents

  1. Why Token Optimization Matters
  2. How Antigravity Consumes Tokens
  3. The Two Scenarios
    • 3A. Starting a Brand New Project
    • 3B. Adding a Feature to an Existing Project
  4. Step-by-Step Setup — New Project
    • Step 1: Create the Folder Structure
    • Step 2: Write gemini.md (Project Identity)
    • Step 3: Add Rules
    • Step 4: Add Workflows
    • Step 5: Add Skills
    • Step 6: Add .antigravityignore
    • Step 7: Connect MCP Servers
    • Step 8: Select the Right Model
    • Step 9: Write Your First Prompt
  5. Step-by-Step Setup — Existing Project / New Task
    • Step 1: Update gemini.md
    • Step 2: Check Rules Still Apply
    • Step 3: Use the Right Workflow
    • Step 4: Plan in ChatGPT or Claude First
    • Step 5: Write a Scoped Prompt
  6. Deep Dive: Each Tool Explained
    • gemini.md
    • Rules
    • Workflows
    • Skills
    • MCP Servers
    • .antigravityignore
  7. Model Selection Guide
  8. Prompt Writing Guide
  9. Token Usage by Activity
  10. When Quota Runs Out
  11. Quick Reference Cheatsheet

1. Why Token Optimization Matters

Antigravity IDE is free during preview but has a weekly token quota. Each model has a different rate of token consumption:

Model Token Speed Use Case
Gemini Flash Slow burn Simple tasks, 1–2 files
Gemini 3 Pro Fast burn Complex tasks, multi-file
Claude Sonnet Medium burn Logic-heavy tasks

A single unoptimized prompt like "build me a login page" can burn 200,000–400,000 tokens because:

  • The agent reads every file in your project to understand context
  • It makes 30–50 tool calls exploring your codebase
  • It retries when it gets things wrong
  • It re-reads the full conversation history on every follow-up

A properly optimized setup reduces this to 30,000–60,000 tokens for the same task — a 6–10x reduction.

The setup steps in this guide happen BEFORE you start prompting. They are a one-time investment that pays back on every single prompt forever.


2. How Antigravity Consumes Tokens

Understanding where tokens go helps you stop wasting them.

2.1 System Prompt Injection (Every Prompt)

Every time you send a message, Antigravity automatically injects:

  • Your gemini.md file (project identity)
  • All active Rules
  • Tool definitions

If your gemini.md is 8,000 tokens, that's 8,000 tokens burned before you type a single word. Over a 20-message session that's 160,000 tokens just for the system prompt.

✅ Fix: Keep gemini.md under 1,500 tokens. Use references instead of pasting full content.

2.2 Context Accumulation (Every Follow-Up)

Each follow-up message re-sends the entire conversation history. By message 15 in a session, even a short reply costs 50,000+ tokens because the model processes everything said before it.

✅ Fix: Start a new conversation for each new task. Never continue a long thread for an unrelated feature.

2.3 Tool Call Overhead

When the agent reads a file, runs a terminal command, or queries a database — each action costs tokens. A vague prompt like "review my project" triggers 30–50 tool calls as the agent explores everything it can find.

✅ Fix: Tell the agent exactly which files to read. Precise prompts = precise tool calls.

2.4 Background Indexing

Antigravity continuously indexes your project files for autocomplete — including node_modules, bin, obj, and lock files. These never need AI context but burn tokens constantly.

✅ Fix: Add .antigravityignore to block junk from being indexed.

2.5 Planning Without Direction

When the agent has no script to follow, it enters "planning mode" — generating thousands of hidden reasoning tokens before producing any output. Without a Workflow, every task starts from scratch.

✅ Fix: Use Workflows so the agent follows a script instead of planning from scratch.


3. The Two Scenarios

Scenario A — Starting a Brand New Project

You have an empty folder. No code yet. You need to set up Antigravity before writing anything.

→ Follow Section 4 completely.

Scenario B — Existing Project, Adding a New Feature or Task

You already have code running. You want to add a feature, fix a bug, or implement a task.

→ Follow Section 5 for the lighter setup process.


4. Step-by-Step Setup — New Project

Do these steps before sending your first prompt to the agent.


Step 1: Create the Folder Structure

Create this exact structure in your project root:

your-project/
├── .agents/
│   ├── rules/
│   │   ├── backend.md
│   │   ├── frontend.md
│   │   └── database.md
│   ├── workflows/
│   │   ├── new-endpoint.md
│   │   ├── new-component.md
│   │   └── db-migrate.md
│   └── skills/
│       ├── feature-name/
│       │   └── SKILL.md
│       └── another-feature/
│           └── SKILL.md
├── .antigravityignore
├── gemini.md
├── GUIDELINES.md
└── INSTRUCTIONS.md

Why .agents/ and not .antigravity/? Newer versions of Antigravity IDE read from .agents/. If you see both folders, use .agents/ — it's the current standard.

Open the correct folder in Antigravity: File → Open Folder → select your-project/ (not a parent folder above it)

Antigravity auto-reads gemini.md, all files in .agents/rules/, and .antigravityignore the moment you open the folder. No manual loading needed.


Step 2: Write gemini.md (Project Identity)

gemini.md is loaded on every single prompt. It tells the agent who it is, what the project is, and where to find things.

Rules for writing gemini.md:

  • Keep it under 1,500 tokens (roughly 1,200 words)
  • Never paste full documentation — reference file paths instead
  • Only include things the agent needs to know on every prompt

Template:

# Project Name — Identity

## What this project is
One sentence describing the project purpose.

## Tech Stack
- Frontend: React 18, TypeScript, Tailwind CSS, React Query
- Backend: ASP.NET Web API (.NET 8), C#
- Database: SQL Server (via EF Core)
- Architecture: Clean Architecture

## Project Structure
/frontend         → React app
/backend
  /Project.Domain          → Entities, enums, exceptions
  /Project.Application     → Commands, queries, handlers, validators
  /Project.Infrastructure  → EF Core, repositories, migrations
  /Project.API             → Controllers, middleware, DI

## Key File References (read only when needed)
- Domain entities: /backend/Project.Domain/Entities/
- DB context: /backend/Project.Infrastructure/Persistence/AppDbContext.cs
- Controllers: /backend/Project.API/Controllers/
- React components: /frontend/src/components/
- API hooks: /frontend/src/hooks/

## Naming Conventions
- C# classes/methods: PascalCase
- React components: PascalCase
- React hooks: camelCase with `use` prefix
- TypeScript interfaces: prefix with I (ITransaction)
- SQL tables: PascalCase, plural (Transactions)
- API routes: kebab-case (/api/liquidity-transfers)

What NOT to include in gemini.md:

  • Full API documentation (reference the file path instead)
  • Database schema details (agent reads from MCP)
  • Long lists of business rules (put those in Rules files)
  • Code examples (put those in Skills)

Step 3: Add Rules

Rules are always-on guardrails. They prevent the agent from making mistakes that cause retry loops — and retry loops are the biggest token waster.

How to add Rules in Antigravity UI

  1. Click the Agent icon in left sidebar
  2. Click Customizations
  3. Click Rules tab
  4. Click + Workspace
  5. Set Activation Mode to Always On
  6. Paste the rule content and save

Repeat for each rule set.

OR use file-based rules (recommended for teams)

Create .agents/rules/backend.md, .agents/rules/frontend.md, .agents/rules/database.md with your rules. Antigravity reads these automatically. Files are committed to Git so the whole team shares them.

What to put in Rules

Rules should be short, direct, and cover things that must NEVER be violated.

Backend Rules Example:

- NEVER put business logic in Controllers
- NEVER reference Infrastructure from Domain or Application
- Use Result<T> for all Application service return types
- Soft delete only — never hard delete (use IsDeleted)
- All money columns: decimal(18,2) — never float
- Always add indexes on foreign keys
- Validate inputs via FluentValidation in Application layer
- Never expose internal exception messages in API responses

Frontend Rules Example:

- NEVER use `any` type — use `unknown` and narrow it
- All components must be functional — no class components
- Named exports only — no default exports
- Never fetch data in useEffect — always use React Query
- All forms use React Hook Form + Zod validation
- ALWAYS format currency using Intl.NumberFormat
- Tailwind CSS only — no inline styles

Database Rules Example:

- All tables: Id (uniqueidentifier), CreatedAt, UpdatedAt, IsDeleted
- All money columns: decimal(18,2)
- Use Fluent API — never data annotations on domain entities
- Never call SaveChanges() inside a loop
- Use AsNoTracking() for all read-only queries
- Migration name format: Add_Entity_Detail
- Always review migration SQL before applying

Activation Mode — What to choose

Mode When to use
Always On Rules that apply to every single prompt (architecture, code style, security)
Model Decision Rules the agent should load only when relevant (specific feature rules)
Manual Rules you want to toggle yourself depending on the task
Glob Rules for specific file types (e.g. only apply when editing *.cs files)

For the 3 core rule files (backend, frontend, database) → always use Always On.


Step 4: Add Workflows

Workflows are reusable step-by-step scripts triggered by /command. Instead of the agent planning from scratch (burning reasoning tokens), it follows your pre-written script.

How to add Workflows in Antigravity UI

  1. Click Customizations
  2. Click Workflows tab
  3. Click + Workspace
  4. Set a trigger (e.g. /new-endpoint)
  5. Write the steps and save

OR use file-based workflows

Create .agents/workflows/new-endpoint.md with trigger defined in the file header. Antigravity reads these automatically.

Essential Workflows for any project

1. /new-endpoint — Create a full API endpoint

trigger: /new-endpoint

When triggered:
1. Ask: Entity name? Operation? Special business rules?
2. Create Domain entity if it doesn't exist
3. Create Application Command/Query + Handler + Validator + DTO
4. Create Infrastructure EntityTypeConfiguration
5. Create API Controller endpoint with ProducesResponseType attributes
6. Create Frontend API function + React Query hook
7. Run dotnet build → verify 0 errors

2. /new-component — Create a React component

trigger: /new-component

When triggered:
1. Ask: Component name? What does it display? Data fetching or props only?
2. Create component with TypeScript interface for props
3. If data fetching: create React Query hook
4. Apply project color system (online=blue, offline=amber, expense=red, income=green)
5. Run npx tsc --noEmit → verify 0 errors

3. /db-migrate — Safe database migration

trigger: /db-migrate

When triggered:
1. Ask: What schema change is needed?
2. Read affected entity and configuration files
3. Run: dotnet ef migrations add {Name} --startup-project ../Project.API
4. Read generated Up() and Down() methods — verify correctness
5. Verify money columns are decimal(18,2), FK columns have indexes
6. Run: dotnet ef database update --startup-project ../Project.API
7. Confirm migration in __EFMigrationsHistory

Why Workflows save tokens:

  • Agent skips planning phase (saves 5,000–15,000 reasoning tokens per task)
  • Agent asks specific questions instead of exploring everything
  • Consistent output means fewer corrections and retries

Step 5: Add Skills

Skills are specialist knowledge modules loaded only when the agent detects relevance in your prompt. Unlike Rules (always loaded), Skills stay out of context until needed — saving tokens.

How Skills work

Each Skill is a folder with a SKILL.md file. The file has a YAML header with a description. Antigravity reads the description and loads the Skill only when your prompt matches.

.agents/skills/
  liquidity-transfer/
    SKILL.md         ← loaded when you mention "transfer", "wallet", "balance"
  clean-arch-scaffold/
    SKILL.md         ← loaded when you mention "entity", "scaffold", "feature"
  db-migration/
    SKILL.md         ← loaded when you mention "migration", "ef core", "column"

Skill file format

---
name: skill-name
description: >
  Use this skill when the user asks about X, Y, Z.
  Triggers on: "keyword1", "keyword2", "keyword3".
---

# Skill Title

## What this skill covers
Detailed instructions, templates, code patterns, business rules
specific to this feature area.

What to put in Skills (not Rules)

Put in Rules Put in Skills
Short universal guardrails Long domain-specific logic
Code style standards Feature-specific templates
Architecture constraints Business rule calculations
Security requirements Code patterns with examples

Token impact of Skills vs Rules

  • A 500-line Skill loaded always = 500 lines × 20 sessions = 10,000 lines of tokens wasted
  • A 500-line Skill loaded on Model Decision = 500 lines × 3 relevant sessions = 1,500 lines

Always put large knowledge blocks in Skills, not Rules.


Step 6: Add .antigravityignore

This is one of the highest-impact token savings with zero effort. Antigravity indexes your entire project in the background for autocomplete. Without an ignore file, it indexes node_modules (100,000+ files), bin/, obj/, lock files — all of which are useless for AI context.

Create .antigravityignore in your project root:

# JavaScript/Node
node_modules/
dist/
build/
.next/
.vite/
coverage/
*.lock
package-lock.json
yarn.lock

# .NET
**/bin/
**/obj/
**/.vs/
**/TestResults/

# Generated files
**/Migrations/*.Designer.cs

# Logs
*.log
logs/

# Secrets — NEVER index these
appsettings.Production.json
appsettings.Staging.json
.env.local
.env.production
secrets.json

Token savings: Prevents background indexing of thousands of irrelevant files. Estimated saving: 10,000–50,000 background tokens per session depending on project size.


Step 7: Connect MCP Servers

MCP (Model Context Protocol) gives the agent "hands" to reach external tools. Instead of you pasting large amounts of data into the chat, the agent fetches exactly what it needs.

How to configure MCP in Antigravity

Open Settings (Ctrl + ,) → search for MCP → click Edit in settings.json

Or directly open:

C:\Users\{YourName}\AppData\Roaming\Antigravity\settings.json

SQL Server MCP (Windows Authentication)

{
  "mcpServers": {
    "sqlserver": {
      "command": "npx",
      "args": ["-y", "mssql-mcp@latest"],
      "env": {
        "DB_SERVER": "YOUR-SERVER-NAME",
        "DB_DATABASE": "YourDatabase",
        "DB_TRUSTED_CONNECTION": "true",
        "DB_TRUST_SERVER_CERTIFICATE": "true",
        "DB_ENCRYPT": "false"
      }
    }
  }
}

SQL Server MCP (SQL Authentication)

{
  "mcpServers": {
    "sqlserver": {
      "command": "npx",
      "args": ["-y", "mssql-mcp@latest"],
      "env": {
        "DB_SERVER": "YOUR-SERVER-NAME",
        "DB_DATABASE": "YourDatabase",
        "DB_USER": "sa",
        "DB_PASSWORD": "your-password",
        "DB_TRUST_SERVER_CERTIFICATE": "true",
        "DB_ENCRYPT": "false"
      }
    }
  }
}

After adding MCP config

  1. Save settings.json
  2. Restart Antigravity IDE completely
  3. Test with: "Connect to the database and list all tables"

Why MCP saves tokens

Without MCP:

You paste 200 lines of schema description into chat → 200 lines × every relevant session = thousands of wasted tokens

With MCP:

Agent calls mssql_list_schema_objects and gets precise schema in one tool call → agent only reads what it needs


Step 8: Select the Right Model

Before sending any prompt, select the correct model from the dropdown in Antigravity.

Model Selection Table

Task Model Mode
Full project scaffold (first prompt) Gemini 3 Pro Planning
New feature end-to-end (3+ files) Gemini 3 Pro Planning
Complex business logic Gemini 3 Pro Planning
Single file refactor Gemini Flash Fast
New React component (simple) Gemini Flash Fast
Database migration Gemini Flash Fast
Fix a specific bug Gemini Flash Fast
Write tests Gemini Flash Fast
Architecture question Gemini 3 Pro Planning
Token quota running low Gemini Flash Fast

Mode Selection

Mode When to use Token cost
Fast Simple, well-defined tasks Low
Planning New features, complex tasks requiring reasoning first High

Rule: Use Planning mode only when the task genuinely needs the agent to reason before acting. For everything else: Fast mode.


Step 9: Write Your First Prompt

Your first prompt sets the tone for the entire project. A well-written first prompt means zero retries on the foundation.

Template for a first project prompt

Set up the complete project structure for [Project Name].

Backend ([Tech Stack]):
- [List exactly what to create with exact names]
- [File paths, class names, package names]
- [What NOT to do yet]

Frontend ([Tech Stack]):
- [List exactly what to create]
- [Folder structure, file names]
- [What NOT to do yet]

Do NOT add business logic yet. Structure and boilerplate only.
After completing, run [build command] and confirm 0 errors.

The golden rule of prompts

Every prompt must answer 3 questions:

  1. What — exact entity/file/function name
  2. Where — exact file path
  3. Done when — what success looks like (0 errors, specific behavior)
❌ Bad prompt ✅ Good prompt
"add login" "Create POST /api/auth/login in AuthController. Use LoginCommand + Handler in Application layer. Return JWT token in LoginResponseDto. Run dotnet build → 0 errors."
"make a component" "Create WalletCard component in /src/components/Dashboard/WalletCard.tsx. Props: label (string), balance (number), type ('online'|'offline'|'total'). Display balance using formatCurrency(). Run npx tsc --noEmit → 0 errors."
"fix the bug" "In TransactionRepository.cs line 47, the GetByUserId query is missing AsNoTracking(). Add it and run dotnet build."

5. Step-by-Step Setup — Existing Project / New Task

When your project is already running and you want to add a new feature or fix something, you don't need to redo all of Section 4. Follow this lighter process instead.


Step 1: Update gemini.md if Needed

Before starting a new task, check if gemini.md needs updating:

  • Did you add a new entity? Add its file path reference.
  • Did you change the folder structure? Update it.
  • Did you add a new library? Add it to the tech stack line.

Do NOT add the full feature description to gemini.md. It loads on every prompt — keep it lean.


Step 2: Check Rules Still Apply

If you are working on a completely different area (e.g. you were building backend, now you're adding a frontend feature), verify the relevant rules are still set to Always On in the Customizations panel.

No changes needed if rules were set up in Section 4.


Step 3: Use the Right Workflow

Before typing a custom prompt, check: does a workflow exist for this task?

Task Use workflow
New API endpoint /new-endpoint
New React component /new-component
Database migration /db-migrate
Domain-specific feature /your-custom-workflow

If a workflow exists → use it. The workflow gives the agent a script, saving planning tokens.

If no workflow exists for your task → create one before prompting. It takes 5 minutes and saves tokens on every future occurrence of that task type.


Step 4: Plan in ChatGPT or Claude First (for complex tasks)

For any task that touches 3+ files or involves non-trivial business logic, plan it in ChatGPT or Claude before coming to Antigravity. Both are free to use and have no Antigravity token quota — so all planning work costs you nothing.

Why plan outside Antigravity?

When you send a vague or complex prompt directly to Antigravity, the agent spends thousands of tokens:

  • Exploring your codebase to understand the context
  • Deliberating on how to approach the task
  • Retrying when it guesses wrong

If you bring a finished, detailed plan to Antigravity instead, the agent skips all of that and only executes — saving 60–80% of tokens on complex tasks.

Which tool to use for planning

Planning Tool Best for How to access
ChatGPT Architecture decisions, step-by-step plans, SQL schema design chat.openai.com
Claude Complex logic reasoning, code review, business rule clarification claude.ai

Both are free. Use whichever you prefer — the output is the same: a finished plan you paste into Antigravity.

Planning process — step by step

Step 1 — Open ChatGPT (chat.openai.com) or Claude (claude.ai)

Step 2 — Paste your relevant context

Copy and paste the files that are relevant to the task:

  • The affected entity or model
  • The current controller or service
  • The current component (if frontend)
  • The DB schema for the affected table

Step 3 — Ask for an implementation plan

Use this prompt template in ChatGPT or Claude:

I'm building a [project type] using [tech stack].
Here are my relevant files: [paste files]

I want to add: [describe the feature]

Give me a step-by-step implementation plan with:
- Exact file paths for each file to create or modify
- Exact class/method/component names
- What each file should contain
- Business rules to enforce
- What "done" looks like (build command + expected result)

Step 4 — Copy the output plan

ChatGPT or Claude will return a structured, detailed plan. Copy the entire output.

Step 5 — Paste into Antigravity as your prompt

Open a new Antigravity conversation, select the right model, and paste the plan directly. The agent now has a complete script to follow — no exploration, no guessing.

Example

Without planning (token-wasteful):

Add a dashboard summary page to my project

→ Agent reads 40+ files, guesses the structure, retries 3 times = ~300,000 tokens

With ChatGPT/Claude planning first:

Create /src/pages/DashboardPage.tsx.
Fetches from GET /api/dashboard/summary using useQuery with QUERY_KEYS.DASHBOARD.
Shows 3 cards: OnlineBalance (blue), OfflineBalance (amber), TotalFund (gray).
Each card uses formatCurrency() from /src/utils/formatCurrency.ts.
Loading state: animate-pulse skeleton. Error state: red error message.
Done when: npx tsc --noEmit → 0 errors.

→ Agent executes directly = ~30,000 tokens ✅

Token saving: ~270,000 tokens on one task.


Step 5: Write a Scoped Prompt

For an existing project, always scope your prompt to the minimum necessary context.

Scoping techniques

Name the exact files:

In /backend/Project.Application/Features/Transactions/Create/
CreateTransactionCommandHandler.cs — the handler is missing the UserId filter.
Add: .Where(t => t.UserId == request.UserId) to the query on line 23.
Run dotnet build → 0 errors.

Tell the agent what NOT to read:

Do not read any frontend files.
Focus only on: TransactionRepository.cs and ITransactionRepository.cs

Set a clear done condition:

Done when: dotnet build shows 0 errors and 0 warnings.

Start a new conversation for each task: Never continue a 20-message thread for a new unrelated feature. The full history re-sends on every message. Start fresh — paste only the context the new task needs.


6. Deep Dive: Each Tool Explained

6.1 gemini.md

What it is: The project identity file. Loaded automatically on every single prompt.

Token impact: HIGH — directly multiplied by every message in every session.

Optimization rules:

  • Hard limit: 1,500 tokens (≈ 1,200 words)
  • Use file path references instead of pasting content: "API docs: /docs/api.md — read when needed"
  • Include only: tech stack, folder structure, naming conventions, core domain terms
  • Never include: full business rules, code examples, long lists

Location: Project root /gemini.md


6.2 Rules

What it is: Always-on guardrails that prevent the agent from making mistakes.

Token impact: MEDIUM — loaded on every prompt but kept short.

Optimization rules:

  • Each rule file should be under 100 lines
  • Write rules as short imperative statements, not paragraphs
  • Use Always On for universal constraints (architecture, style, security)
  • Use Model Decision for feature-specific rules
  • Split by layer: backend.md, frontend.md, database.md

Token saving mechanism: Rules prevent wrong-direction code → fewer retries → fewer tokens.


6.3 Workflows

What it is: Reusable step-by-step scripts triggered by /command.

Token impact: HIGH SAVINGS — eliminates planning phase for repeated task types.

Optimization rules:

  • Create a Workflow for any task you do more than once
  • Workflows should ask clarifying questions at the start (not mid-task)
  • Include a verification step at the end (build/typecheck command)
  • Keep Workflow steps numbered and sequential — no ambiguity

Token saving mechanism: Agent follows a script instead of planning → saves 5,000–15,000 reasoning tokens per task.


6.4 Skills

What it is: Specialist knowledge modules loaded only when the agent detects relevance.

Token impact: HIGH SAVINGS — large knowledge blocks loaded only when needed.

Optimization rules:

  • Put long domain logic, code templates, and business rules in Skills (not Rules or gemini.md)
  • Write clear, specific trigger keywords in the description header
  • Each Skill should be self-contained — don't reference other Skills
  • Skills can be 200–500 lines — that's fine because they're not always loaded

Token saving mechanism: 500-line Skill costs zero tokens when you're working on an unrelated feature.


6.5 MCP Servers

What it is: Persistent connections to external tools (databases, GitHub, etc.).

Token impact: HIGH SAVINGS — gives agent precise data without you pasting large contexts.

Optimization rules:

  • Always prefer MCP over pasting content into chat
  • For database tasks: let MCP read the schema instead of describing it
  • For file tasks: let MCP read the file instead of copying it into the prompt
  • Restart Antigravity after changing MCP config

Useful MCP servers for development projects:

  • mssql-mcp — SQL Server (read/write queries, schema inspection)
  • @modelcontextprotocol/server-github — GitHub (branches, PRs, issues)
  • @modelcontextprotocol/server-filesystem — file system operations
  • @modelcontextprotocol/server-memory — cross-conversation memory

6.6 .antigravityignore

What it is: Tells Antigravity what NOT to index for background autocomplete.

Token impact: MEDIUM SAVINGS — prevents constant background token drain.

What to always ignore:

node_modules/     ← 100,000+ files, never relevant
**/bin/           ← .NET build output
**/obj/           ← .NET intermediate output
dist/             ← frontend build output
*.lock            ← package lock files
**/*.Designer.cs  ← EF Core migration designer files
*.log             ← log files

What to never ignore:

  • Your source code files
  • Configuration files (appsettings.json, .env.example)
  • Your .agents/ folder

7. Model Selection Guide

When to use Gemini 3 Pro

  • First project scaffold
  • New feature touching 3+ files across layers
  • Complex business logic (calculations, domain rules)
  • Architecture or design decisions
  • Debugging a complex issue with unknown root cause

When to use Gemini Flash

  • Adding a single field to an existing entity
  • Creating a simple React component
  • Running a database migration
  • Writing unit tests
  • Fixing a specific known bug
  • Renaming, refactoring, moving files

When to use Claude Sonnet

  • Tasks requiring precise logical reasoning
  • Complex validation rules
  • Algorithm implementation
  • When Gemini Pro is giving inconsistent results

Mode selection

  • Planning mode: Use when the task needs reasoning before acting. Costs more tokens but produces better output for complex tasks.
  • Fast mode: Use for everything else. Direct execution, no deliberation.

8. Prompt Writing Guide

The 3-Part Formula

Every good prompt has:

[WHAT] + [WHERE] + [DONE WHEN]

Example:

[WHAT]      Create CreateTransactionCommand + Handler + Validator in Application layer.
[WHERE]     File: /backend/Project.Application/Features/Transactions/Create/
[DONE WHEN] Run dotnet build → 0 errors before finishing.

Prompt Templates by Task Type

New feature (multi-file)

/new-endpoint

Entity: {EntityName}
Operation: {Create/Read/Update/Delete/List}
Business rules:
- {rule 1}
- {rule 2}
Files to create:
- /backend/.../Command.cs
- /backend/.../Handler.cs
- /frontend/src/api/{entity}.api.ts
Done when: dotnet build + npx tsc --noEmit both show 0 errors.

Bug fix

File: {exact file path}
Problem: {describe exactly what is wrong, include line number if known}
Fix: {describe exactly what the correct behavior should be}
Do NOT change any other files.
Done when: {specific behavior or build result}

Database change

/db-migrate

Change: Add {ColumnName} ({type}) to {TableName} table.
Reason: {why this column is needed}
Constraints: {not null / default value / index needed?}
Done when: Migration applied, dotnet build 0 errors.

React component

/new-component

Name: {ComponentName}
Location: /frontend/src/components/{Category}/{ComponentName}.tsx
Displays: {exactly what it shows}
Props: {propName: type, propName: type}
Data fetching: {yes/no — if yes, from which endpoint}
Done when: npx tsc --noEmit 0 errors, component renders without console errors.

Things to always include in prompts

  • Exact file paths (not vague directory names)
  • Exact class/function/component names
  • A build/typecheck command as the done condition
  • What NOT to change (prevent scope creep)

Things to never put in prompts

  • Vague descriptions ("make it better", "fix the issue")
  • Multiple unrelated tasks in one prompt
  • Requests to "review the whole project"
  • Open-ended exploration ("see what you can find")

9. Token Usage by Activity

This table shows approximate token usage for common activities, with and without optimization.

Activity Unoptimized Optimized Savings
New feature (3 files) 300,000 60,000 80%
Single component 80,000 15,000 81%
Bug fix 60,000 8,000 87%
DB migration 40,000 10,000 75%
Project scaffold 500,000 120,000 76%
Code review 200,000 25,000 88%

The biggest token wasters (ranked)

  1. Bloated gemini.md — multiplied by every message
  2. No .antigravityignore — constant background drain
  3. Vague prompts — agent explores everything, retries often
  4. Long conversation threads — history re-sent on every reply
  5. No Workflows — agent plans from scratch every time
  6. Pasting content that MCP could fetch — unnecessary context

10. When Quota Runs Out

Option A: Wait for weekly reset

Free quota resets every week. No action needed.

Option B: Use your own API key (recommended)

  1. Go to aistudio.google.com
  2. Sign in → click Get API KeyCreate API key
  3. Copy the key (looks like AIzaSyXXXXXXXXX)
  4. In Antigravity: Settings (Ctrl + ,)Models → paste your key
  5. Your own key uses Google AI Studio free quota which resets daily

Option C: Switch to a cheaper model

Switch from Gemini 3 Pro to Gemini Flash for remaining tasks. Flash uses significantly fewer tokens per request.

Option D: Use ChatGPT or Claude for planning

Do all planning and architecture decisions in ChatGPT (chat.openai.com) or Claude (claude.ai) — both free, no Antigravity quota used. Only come to Antigravity for actual code execution.


11. Quick Reference Cheatsheet

Before starting ANY session

  • Open the correct project folder (not a parent folder)
  • Check gemini.md is up to date and under 1,500 tokens
  • Verify rules are active (Customizations → Rules)
  • Select correct model for the task
  • Start a NEW conversation (don't continue old threads)

Before starting a NEW PROJECT

  • Create .agents/rules/backend.md
  • Create .agents/rules/frontend.md
  • Create .agents/rules/database.md
  • Create .agents/workflows/new-endpoint.md
  • Create .agents/workflows/new-component.md
  • Create .agents/workflows/db-migrate.md
  • Create skills for domain-specific logic
  • Write gemini.md (under 1,500 tokens)
  • Add .antigravityignore
  • Configure MCP servers in settings.json
  • Restart Antigravity after MCP config

Before starting a NEW TASK on existing project

  • Does a workflow exist for this task? → use it
  • Is this a complex task (3+ files)? → plan in ChatGPT or Claude first
  • Start a new conversation
  • Select correct model (Flash for simple, Pro for complex)
  • Write prompt with: What + Where + Done When

Prompt quality check

  • Does the prompt name specific files/classes?
  • Does it say where things should go?
  • Does it have a build/typecheck done condition?
  • Is it one task only (not multiple unrelated things)?

Model quick pick

1-2 files, known task    → Gemini Flash, Fast mode
3+ files, new feature    → Gemini 3 Pro, Planning mode
Complex logic/debugging  → Gemini 3 Pro, Planning mode
Running low on quota     → Gemini Flash, Fast mode

This guide covers Antigravity IDE as of July 2026. Folder conventions (.agents/ vs .antigravity/) may vary by version — check which folder your version reads by opening Customizations and seeing which rules are detected.

About

A practical GitHub repo for optimizing Antigravity IDE usage, reducing token waste, and improving prompt efficiency for faster, cheaper AI-assisted development.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages