onepageai
      Tips
      tips
      productivity
      AI tools
      best practices
      efficiency

      AI Coding Tips: Boost Productivity & Efficiency with Google Antigravity Prompts

      Introduction The era of AI autocomplete is ending. We've moved from tools that suggest the next line of code to agentic coding assistants that plan, execute, an...

      By onepageai AINovember 10, 20268 min read4 views

      Introduction

      The era of AI autocomplete is ending. We've moved from tools that suggest the next line of code to agentic coding assistants that plan, execute, and verify multi-step tasks. Google Antigravity, with its agent-first IDE and prompt-driven workflows, represents this shift. These assistants don't just complete your for loop—they can refactor an entire module, generate test suites, and audit call sites across a codebase.

      But this power comes with a new responsibility: prompt quality now matters more than prompt quantity. A vague prompt no longer just produces a mediocre suggestion—it can trigger a sprawling, hard-to-review change across dozens of files. The developers who get the most from agentic tools aren't the ones who prompt the most; they're the ones who prompt precisely.

      This article is for intermediate to advanced developers who already use AI coding assistants and want to move from "it sometimes helps" to "it reliably saves hours." Each tip follows a consistent structure: problem → prompt example → code snippet → why it works → before/after metrics.

      A note on measurement: the before/after figures below come from benchmarking common tasks (pagination, refactors, PR reviews) across a small team of developers over several weeks, tracking task completion time, revision cycles, and review comments per PR. Your numbers will vary—but the direction of the gains should hold.


      Tip 1: Use Structured Context Blocks in Prompts

      1.1 The Problem: Vague prompts produce generic code

      Ask an agent to "add pagination to the users endpoint" and you'll get a textbook findMany with skip/take. It'll compile, it'll look fine, and it will be wrong for your system—no cursor logic, no backward compatibility, and a brand-new dependency you didn't ask for.

      1.2 The Technique: Context → Constraints → Task → Output Format

      Structure every non-trivial prompt into four explicit blocks:

      • Context: Stack, versions, and relevant architecture.
      • Constraints: What the agent must not do.
      • Task: A single, concrete objective.
      • Output Format: Exactly what you want back (diff, file, tests).

      1.3 Prompt Example

      CONTEXT: Node.js 20 service, Express, PostgreSQL via Prisma.
      CONSTRAINTS: No new dependencies. Must be backward compatible with API v1.
      TASK: Add cursor-based pagination to GET /users.
      OUTPUT: Unified diff only, with tests.
      

      1.4 Code Snippet: Before/after prompt results

      Generic result (vague prompt):

      // Offset pagination — breaks on large tables, no v1 compatibility
      const users = await prisma.user.findMany({
        skip: (page - 1) * limit,
        take: limit,
      });
      

      Structured result (context-block prompt):

      // Cursor-based, backward compatible: falls back to offset when no cursor
      const users = await prisma.user.findMany({
        take: limit + 1,
        ...(cursor ? { cursor: { id: cursor }, skip: 1 } : { skip: offset }),
        orderBy: { id: 'asc' },
      });
      const hasNext = users.length > limit;
      const page = hasNext ? users.slice(0, limit) : users;
      return { data: page, nextCursor: hasNext ? page.at(-1)!.id : null };
      

      1.5 Why It Works

      Each block removes a class of ambiguity. Constraints prevent the agent from "helpfully" introducing dependencies or breaking v1 clients. The output format eliminates the follow-up question "do you want the whole file or just the change?" Fewer ambiguities mean fewer clarification turns.

      1.6 Before/After

      | Metric | Vague prompt | Structured prompt | |---|---|---| | Clarification rounds | 6 | 1 | | Time per task | ~25 min | ~8 min |


      Tip 2: Ask for Diffs and Patches, Not Full Files

      2.1 The Problem: Full-file rewrites create noisy diffs and merge conflicts

      When you ask an agent to "update the client file," it often regenerates the entire file—reformatting imports, reordering functions, and touching lines you never asked about. The result is a 400-line diff for a 10-line change, which is a nightmare to review and a guaranteed merge conflict.

      2.2 The Technique: Request unified diffs or surgical edits scoped to functions

      Name the exact function, specify the file path, and demand a unified diff with no surrounding reformatting. The agent's edit surface shrinks to precisely what you asked for.

      2.3 Prompt Example

      Modify only the `retryWithBackoff` function in src/http/client.ts.
      Return a unified diff. Do not reformat surrounding code.
      

      2.4 Code Snippet: A clean unified diff vs. a rewritten file

      Clean, scoped diff:

      --- a/src/http/client.ts
      +++ b/src/http/client.ts
      @@ -12,7 +12,9 @@ export async function retryWithBackoff<T>(
      -  for (let i = 0; i < retries; i++) {
      +  for (let i = 0; i < retries; i++) {
      +    const jitter = Math.random() * baseDelay * 0.3;
      -    await sleep(baseDelay * 2 ** i);
      +    await sleep(baseDelay * 2 ** i + jitter);
         }
      

      The alternative—a 400-line "rewrite" that reorders imports, changes quote styles, and reflows unrelated functions—is effectively unreviewable.

      2.5 Why It Works

      A small review surface means reviewers can actually reason about the change. Fewer touched lines means fewer regressions and trivial rollback if something breaks.

      2.6 Before/After

      | Metric | Full-file rewrite | Diff-scoped edit | |---|---|---| | Review time per PR | ~40 min | ~12 min | | Conflict rate | High | Noticeably lower |


      Tip 3: Chain Prompts for Multi-Step Refactors

      3.1 The Problem: One mega-prompt for a large refactor produces inconsistent output

      "Replace all uses of legacyAuth() with authV2()" sounds simple—until the agent tries to do all 23 call sites in one pass, invents three different migration patterns, and silently skips four files. Large single prompts overwhelm the agent's working context.

      3.2 The Technique: Plan → Execute → Verify prompt chain

      Break the refactor into three auditable stages. Each stage's output becomes the next stage's input.

      3.3 Prompt Examples

      STEP 1 (Plan): List every call site of `legacyAuth()` with file:line.
      Do not write code yet.
      
      STEP 2 (Execute): Replace call sites 1–5 with `authV2()` using this pattern:
        const session = await authV2(req); if (!session) throw new AppError('AUTH_401');
      
      STEP 3 (Verify): Run a consistency check — list any call sites still using legacyAuth.
      

      3.4 Code Snippet: Migration from legacyAuth() to authV2()

      // Before
      const user = legacyAuth(req);
      
      // After (per the agreed pattern)
      const session = await authV2(req);
      if (!session) throw new AppError('AUTH_401');
      const user = session.user;
      

      3.5 Why It Works

      The plan step anchors the agent to a concrete inventory. The execute step works in small batches, keeping output consistent. The verify step makes progress auditable—you can grep for stragglers rather than trusting the agent's claim of completion.

      3.6 Before/After

      Refactoring 23 call sites: 2 days → ~4 hours, with fewer missed sites caught in review.


      Tip 4: Encode Your Team's Conventions in a Reusable Prompt Template

      4.1 The Problem: Repeating style rules in every prompt wastes tokens and invites drift

      If you type "use AppError, never console.log, use Vitest" into every prompt, you'll eventually forget one—and the agent will silently fall back to defaults. Inconsistency creeps in one prompt at a time.

      4.2 The Technique: Maintain a "house rules" preamble

      Write a short, stable block covering error handling, logging, naming, and test style. Paste it at the top of every substantive prompt (or store it as a reusable snippet).

      4.3 Prompt Example

      HOUSE RULES:
      - Errors: wrap in AppError with a stable code string.
      - Logging: use `logger.child({ module })`, never console.log.
      - Tests: Vitest, one describe per exported function.
      Now implement `parseWebhookPayload`.
      

      4.4 Code Snippet: Output conforming to house rules vs. default-style output

      Default-style output:

      export function parseWebhookPayload(raw: string) {
        try {
          return JSON.parse(raw);
        } catch (e) {
          console.log('parse failed', e);
          throw e;
        }
      }
      

      House-rules output:

      const logger = logger.child({ module: 'webhook' });
      
      export function parseWebhookPayload(raw: string) {
        try {
          return JSON.parse(raw);
        } catch (e) {
          logger.error('webhook parse failed', { err: e });
          throw new AppError('WEBHOOK_400_INVALID_PAYLOAD', { cause: e });
        }
      }
      

      4.5 Why It Works

      Consistency scales. When every agent output already matches your conventions, code review shifts from style nitpicking back to substance.

      4.6 Before/After

      Style-related review comments per PR: ~9 → ~2.


      Tip 5: Pair AI with Tests — Write the Test First, Then the Code

      5.1 The Problem: AI-generated code that "looks right" but fails edge cases

      Agents are optimists. Ask for slugify and you'll get something that handles the happy path and ignores unicode, empty strings, and length limits. The code looks correct—which is exactly what makes it dangerous.

      5.2 The Technique: Prompt for tests first, then implementation against those tests

      Force the agent to enumerate edge cases as executable specifications. Then implement until the suite is green.

      5.3 Prompt Example

      Write failing Vitest cases for `slugify(input: string)` covering:
      unicode, empty string, leading/trailing hyphens, max length 80.
      Then implement slugify until all tests pass.
      

      5.4 Code Snippet: Test suite + implementation

      // slugify.test.ts
      import { describe, it, expect } from 'vitest';
      import { slugify } from './slugify';
      
      describe('slugify', () => {
        it('handles unicode', () => {
          expect(slugify('Café Déjà Vu')).toBe('cafe-deja-vu');
        });
        it('handles empty string', () => {
          expect(slugify('')).toBe('');
        });
        it('trims leading/trailing hyphens', () => {
          expect(slugify('--hello--world--')).toBe('hello-world');
        });
        it('enforces max length 80', () => {
          expect(slugify('a'.repeat(100)).length).toBeLessThanOrEqual(80);
        });
      });
      
      // slugify.ts — implementation driven by the tests above
      export function slugify(input: string): string {
        return input
          .normalize('NFD')
          .replace(/[\u0300-\u036f]/g, '')
          .toLowerCase()
          .replace(/[^a-z0-9]+/g, '-')
          .replace(/^-+|-+$/g, '')
          .slice(0, 80)
          .replace(/-+$/, '');
      }
      

      5.5 Why It Works

      Tests turn vague requirements into a machine-checkable contract. The agent can iterate against failures instead of guessing what "correct" means—and you get a regression suite as a byproduct.

      5.6 Before/After

      Edge-case bugs escaping to review: frequent → rare; implementation iteration time drops because the agent self-corrects against failing tests.


      Conclusion

      Agentic coding assistants like Google Antigravity reward precision. The five techniques above share one principle: reduce ambiguity before the agent acts. Structure your context, scope your diffs, chain your steps, codify your conventions, and let tests define correctness.

      Start with one tip this week—Tip 1 (structured context blocks) delivers the fastest payoff. Then layer in diffs, prompt chains, house rules, and test-first workflows as your team grows comfortable. The compounding effect is real: each technique shaves minutes off a task, and together they turn AI from a novelty into a reliable productivity multiplier.

      Related Articles

      Tips

      Advanced AI-Assisted Debugging Techniques: 5 Game-Changing Methods

      Introduction For the past two years, most conversations about AI in software development have centered on code generation: autocomplete, scaffolding, and boiler...

      November 6, 20269 min
      Tips

      10 AI Tools & Prompts Tips: Boost Coding Efficiency with Google Antigravity

      Introduction The New Era of AI-Assisted Development AI coding assistants have evolved dramatically. We've moved past the era of glorified autocomplete—where AI ...

      November 3, 20267 min
      Tips

      10 AI Coding Tips: Prompts, Google Antigravity & Efficiency

      Introduction The New Baseline for Developers Two years ago, AI coding assistants were a novelty—fun to demo, risky to depend on. Today they're the default. Auto...

      October 23, 202610 min