What Is Inline Chat?
Antigravity's inline chat (Cmd+I on Mac, Ctrl+I on Windows/Linux) lets you give AI instructions directly inside the editor — right where your cursor is. Unlike the side panel chat, inline chat operates on the exact code you're looking at, making pinpoint edits without the copy-paste dance.
Think of it this way: the side chat is great for conversations and broad changes, but inline chat is your scalpel — fast, precise, and designed for quick surgical edits. This guide walks you through the techniques that will make inline chat a natural part of your daily workflow.
Getting Started with Inline Chat
Basic Workflow
Using inline chat is refreshingly simple.
// Step 1: Place your cursor anywhere (or select a range of code)
// Step 2: Press Cmd+I (Mac) or Ctrl+I (Windows/Linux)
// Step 3: Type your instruction in the text box that appears
// Step 4: Press Enter → AI generates or modifies your code
// Example: Place your cursor on this function, press Cmd+I,
// then type "add error handling"
function fetchUser(id: string) {
const response = await fetch(`/api/users/${id}`);
return response.json();
}
// Expected output:
async function fetchUser(id: string): Promise<User | null> {
try {
const response = await fetch(`/api/users/${id}`);
if (!response.ok) {
throw new Error(`HTTP error: ${response.status}`);
}
return await response.json();
} catch (error) {
console.error(`Failed to fetch user ${id}:`, error);
return null;
}
}When to Use Inline Chat vs. Side Chat
Each has its sweet spot.
Inline chat (Cmd+I) works best for:
- Function-level or block-level edits
- Renaming variables and refactoring
- Adding comments or documentation
- Fixing type definitions
- Quick bug fixes
Side chat (Cmd+L) works best for:
- Creating new files from scratch
- Multi-file changes
- Architecture discussions
- Investigating error root causes
A good rule of thumb: if the change is localized and you can point to exactly where it should happen, reach for inline chat.
Practical Techniques for Power Users
Technique 1: Select Before You Ask
The precision of inline chat depends heavily on your selection. Without a selection, the AI guesses based on cursor context. With an explicit selection, it knows exactly what to work with.
// ❌ Cursor-only + "add types" → ambiguous scope
// ✅ Select the entire function + "add parameter and return types" → precise result
// Select the full function below, then press Cmd+I
function processOrder(order, user) {
const total = order.items.reduce((sum, item) => sum + item.price, 0);
const discount = user.isPremium ? total * 0.1 : 0;
return { total: total - discount, discount };
}
// Expected output:
interface OrderItem {
name: string;
price: number;
quantity: number;
}
interface Order {
items: OrderItem[];
}
interface User {
isPremium: boolean;
}
interface OrderResult {
total: number;
discount: number;
}
function processOrder(order: Order, user: User): OrderResult {
const total = order.items.reduce((sum, item) => sum + item.price, 0);
const discount = user.isPremium ? total * 0.1 : 0;
return { total: total - discount, discount };
}Technique 2: Be Specific in Your Instructions
Vague prompts produce vague results. The more specific you are, the closer the output matches your intent.
# ❌ Vague instructions
"improve this function"
"make it better"
"fix the bug"
# ✅ Specific instructions
"add a null check — return early if id is undefined"
"convert the forEach to map and return the new array"
"rewrite using async/await with try-catch that logs errors"
"refactor into a pure function by removing all side effects"Technique 3: Build Up Iteratively
You don't need to get everything perfect in one shot. Inline chat shines when used repeatedly to layer improvements.
// Step 1: Generate the basic structure
// Cmd+I → "create an auth middleware function"
export function authMiddleware(req, res, next) {
const token = req.headers.authorization;
if (!token) return res.status(401).json({ error: 'Unauthorized' });
next();
}
// Step 2: Add types
// Select the function → Cmd+I → "add Express types"
import { Request, Response, NextFunction } from 'express';
export function authMiddleware(
req: Request,
res: Response,
next: NextFunction
): void {
const token = req.headers.authorization;
if (!token) {
res.status(401).json({ error: 'Unauthorized' });
return;
}
next();
}
// Step 3: Add JWT verification
// Select the function body → Cmd+I →
// "verify the JWT token and attach the decoded payload to req.user"Technique 4: Instant Test Generation
Select a function and ask for tests — it's one of the fastest ways to build coverage.
// Select the function below → Cmd+I →
// "write Jest tests including happy path and edge cases"
function calculateShipping(weight: number, distance: number): number {
if (weight <= 0 || distance <= 0) throw new Error('Invalid input');
const baseRate = 500;
const weightRate = weight * 10;
const distanceRate = distance * 2;
return baseRate + weightRate + distanceRate;
}
// AI-generated tests:
describe('calculateShipping', () => {
test('calculates shipping for valid inputs', () => {
expect(calculateShipping(5, 100)).toBe(500 + 50 + 200);
});
test('throws when weight is zero or negative', () => {
expect(() => calculateShipping(0, 100)).toThrow('Invalid input');
});
test('throws when distance is zero or negative', () => {
expect(() => calculateShipping(5, 0)).toThrow('Invalid input');
});
test('handles large weight and distance values', () => {
expect(calculateShipping(100, 500)).toBe(500 + 1000 + 1000);
});
});Advanced Patterns Worth Knowing
Pattern 1: Generate Code from Comments
Write a comment describing what you want, select it, and let inline chat implement it.
// Select the comment block below → Cmd+I → "implement this"
// Rate-limiting middleware:
// - Allow 60 requests per minute
// - Limit by IP address
// - Return 429 status when exceeded
// - Include X-RateLimit-Remaining headerPattern 2: Paste Error Messages for Context-Aware Fixes
Copy an error from your terminal, select the offending code, and paste the error into inline chat. The AI uses both the code context and error message to produce a targeted fix.
# Example inline chat prompt:
"fix this error: TypeError: Cannot read property 'map' of undefined"Pattern 3: Batch-Generate Documentation
Select multiple functions (or an entire file) and add JSDoc/TSDoc in one pass.
// Select all public functions → Cmd+I →
// "add JSDoc comments to every public function
// with @param and @returns tags"Wrapping Up
Inline chat (Cmd+I) hits a sweet spot that other AI features don't quite reach. It's lighter than opening a full chat conversation but more intentional than auto-complete — the perfect tool for precise, everyday edits.
The key takeaways: always select the code you want to change, write specific instructions, and don't hesitate to iterate. Start with routine tasks like adding types or error handling, and you'll quickly find that inline chat becomes second nature.
If you're still getting familiar with the editor itself, our Antigravity Editor View guide covers all the fundamentals.