onepageai
      Tips
      tips
      productivity
      AI tools
      best practices
      efficiency

      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...

      By onepageai AIOctober 23, 202610 min read2 views

      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. Autocomplete has become agentic editing, chat windows have become multi-file refactors, and the question is no longer whether you use AI in your workflow but how well you use it. The developers pulling ahead aren't the ones with the fanciest models; they're the ones who've learned to structure prompts, scope agent tasks, and measure the results.

      Who This Article Is For

      This guide is for intermediate to advanced developers who already use AI tools daily but suspect they're leaving productivity on the table. If you've ever accepted a suggestion, watched it fail to compile, and then spent ten minutes explaining your codebase to a chatbot, this is for you.

      What You'll Learn

      Ten concrete techniques across three areas: prompt design (Tips 1, 2, 4, 5, 6, 8), Google Antigravity workflows (Tips 3, 7, 9), and measurable efficiency gains (Tip 10 and the before/after benchmarks throughout).

      How to Read This Guide

      Each tip follows the same structure: the technique, a real prompt, a code snippet, why it works, and a before/after comparison. The numbers come from a sample of 50 representative tasks run by a small product team—treat them as directional, not gospel.


      Tip 1: Write Prompts Like Specifications, Not Wishes

      The Technique

      Vague prompts ("fix my code") force the model to guess at intent, and guessing is where round-trips come from. Instead, use a four-part frame: Role → Context → Task → Output contract.

      • Role: who the model should act as ("senior TypeScript reviewer")
      • Context: what codebase, conventions, and constraints apply
      • Task: the specific transformation you want
      • Output contract: the exact shape of the result (diff, file, JSON)

      Prompt Example

      Vague:

      fix my code
      

      Structured:

      Role: You are a senior TypeScript engineer reviewing production code.
      Context: This function lives in a payment service. We use strict
      null checks, no `any`, and prefer small pure helpers over long
      procedures. Max function length in this repo is ~25 lines.
      Task: Refactor the function below. Extract validation and
      formatting into named helpers. Preserve behavior exactly.
      Output contract: Return the full refactored file, then a
      bulleted list of behavioral risks, if any.
      

      Code Snippet

      Input (excerpt of a 60-line processPayment function):

      function processPayment(order: any) {
        if (!order || !order.items || order.items.length === 0) {
          throw new Error("bad order");
        }
        let total = 0;
        for (const i of order.items) {
          if (i.price < 0) throw new Error("bad price");
          total += i.price * i.qty;
        }
        // ...40 more lines of mixed validation, logging, and formatting
      }
      

      AI output (excerpt):

      function validateOrder(order: Order): void {
        if (!order?.items?.length) throw new OrderError("empty order");
      }
      
      function computeTotal(items: OrderItem[]): number {
        return items.reduce((sum, i) => {
          if (i.price < 0) throw new OrderError("negative price");
          return sum + i.price * i.qty;
        }, 0);
      }
      

      Why It Improves Workflow

      The output contract eliminates the "is this what you wanted?" loop. The context block prevents style drift. The role primes the model toward review-quality reasoning rather than quick fixes.

      Before/After Productivity

      Before: ~4 prompt iterations per task. After: ~1.3 iterations across the 50-task sample—a 3x reduction in back-and-forth.


      Tip 2: Feed the Model Your Codebase Context Deliberately

      The Technique

      Isolated snippets invite hallucinated APIs. Instead, attach the target file, its interface dependencies, and two style exemplar functions from the same module. Many tools also support project rules files (e.g., .cursorrules, AGENTS.md) and README excerpts to anchor conventions globally.

      Prompt Example

      Here is the file to modify: [attached: userService.ts]
      Here is the interface it depends on: [attached: types.ts]
      Here are two functions from the same module that represent
      our house style: [attached: exemplars.ts]
      
      Task: Add a `getUserWithRoles` function following the same
      patterns. Do not invent any methods not present in types.ts.
      

      Code Snippet

      // types.ts (attached)
      export interface UserRepo {
        findById(id: string): Promise<User | null>;
        findRoles(userId: string): Promise<Role[]>;
      }
      
      // exemplars.ts (attached) — style anchor
      export async function getUser(repo: UserRepo, id: string) {
        const user = await repo.findById(id);
        if (!user) throw new NotFoundError("user", id);
        return user;
      }
      

      Why It Improves Workflow

      Models are excellent pattern-matchers and terrible mind-readers. Given real interfaces, they stop inventing repo.getUserRoles() and start calling repo.findRoles(). Style exemplars do the same for naming and error handling.

      Before/After Productivity

      Before: 30–40% of generated code needed manual API fixes. After: under 10%.


      Tip 3: Use Google Antigravity's Agent Mode for Multi-File Tasks

      The Technique

      Chat mode leaves file traversal and edit application to you. Agent mode in Google Antigravity—like similar agentic surfaces in other tools—takes a task brief, plans across files, applies edits, and reports back. Use it for cross-cutting changes: renames, interface migrations, test backfills. Always define the task boundary and acceptance criteria before launching.

      Prompt Example

      Task: Migrate all callers of `fetchUser` to `getUser` with the
      new options object signature.
      Scope: src/** only. Do not touch node_modules, migrations, or
      unrelated modules.
      Acceptance criteria:
      1. No remaining references to `fetchUser` in src/.
      2. All call sites pass `{ includeRoles: boolean }`.
      3. Existing tests updated and passing.
      4. Report a summary of every file changed.
      

      Code Snippet

      Agent-produced diff (abridged):

      --- a/src/api/profile.ts
      +++ b/src/api/profile.ts
      -const user = await fetchUser(id);
      +const user = await getUser(id, { includeRoles: true });
      
      --- a/src/api/admin.ts
      +++ b/src/api/admin.ts
      -const user = await fetchUser(id);
      +const user = await getUser(id, { includeRoles: true });
      
      --- a/src/api/__tests__/profile.test.ts
      +++ b/src/api/__tests__/profile.test.ts
      -  fetchUser.mockResolvedValue(mockUser);
      +  getUser.mockResolvedValue(mockUser);
      

      Why It Improves Workflow

      Agents absorb the mechanical overhead—grepping call sites, opening files, applying consistent edits—while you review a coherent diff instead of orchestrating twenty small ones.

      Before/After Productivity

      Before: ~45 minutes of manual rename plus test updates. After: ~8 minutes reviewing agent output.


      Tip 4: Constrain Output Format to Match Your Toolchain

      The Technique

      Demand machine-consumable outputs: unified diffs, JSON conforming to a schema, conventional commit messages, or test scaffolds. Pair every format constraint with a validation step—git apply --check, tsc --noEmit, eslint, or a test run.

      Prompt Example

      Return only a unified diff. No prose, no markdown fences.
      The diff must apply cleanly to the attached file at HEAD.
      Do not reformat untouched lines.
      

      Code Snippet

      # Save the model's response, then verify before applying
      git apply --check fix.patch && git apply fix.patch
      

      Why It Improves Workflow

      Diffs remove copy-paste friction entirely and make AI output scriptable—you can pipe it through CI, review it like a human PR, or batch-apply it across branches.

      Before/After Productivity

      Before: manual re-typing of edits from chat windows. After: patch applied and verified in seconds.


      Tip 5: Ask for Tests First, Implementation Second

      The Technique

      Test-driven prompting: stage one generates failing tests from your behavioral spec; you review them; stage two asks for an implementation that satisfies them. This reframes the AI as a spec-checker instead of an optimistic code generator.

      Prompt Example

      Stage 1: Write failing Vitest tests for this behavior spec:
      - `applyDiscount(cart, code)` applies 10% off when code is "TEN".
      - Throws `InvalidCodeError` for unknown codes.
      - Never reduces total below zero.
      Do not write the implementation yet.
      
      Stage 2 (after review): Now implement `applyDiscount` until
      all tests pass. Do not modify the tests.
      

      Code Snippet

      // Generated test
      it("never reduces total below zero", () => {
        const cart = { total: 5, items: [] };
        expect(applyDiscount(cart, "TEN").total).toBe(0);
      });
      
      // Generated implementation
      export function applyDiscount(cart: Cart, code: string): Cart {
        if (code !== "TEN") throw new InvalidCodeError(code);
        return { ...cart, total: Math.max(0, cart.total * 0.9) };
      }
      

      Why It Improves Workflow

      Misinterpretations surface at the cheapest possible moment—before implementation exists. The tests then become durable regression protection, not throwaway scaffolding.

      Before/After Productivity

      Before: bugs found in code review or QA. After: ~60% of logic errors caught at generation time (team metric).


      Tip 6: Build a Reusable Prompt Library for Recurring Tasks

      The Technique

      Codify your best prompts for repeatable jobs: PR descriptions, migration scripts, error-handling reviews, changelog entries. Store them in the repo (e.g., prompts/ or a rules file) so the whole team benefits.

      Prompt Example

      # prompts/pr-description.md
      Given the staged diff, write a PR description with:
      - Summary (2 sentences)
      - Changes (bulleted, grouped by module)
      - Risk assessment (what could break, and why)
      - Test plan (how a reviewer verifies this)
      Tone: terse, technical. No marketing language.
      

      Why It Improves Workflow

      A prompt library turns tribal knowledge into infrastructure. New team members get the same output quality on day one, and improvements compound instead of evaporating in chat history.

      Before/After Productivity

      Before: 10–15 minutes writing PR descriptions from scratch. After: under 2 minutes with a consistent template.


      Tip 7: Scope Agent Runs with Explicit Boundaries

      The Technique

      Antigravity's agent mode is powerful precisely because it touches many files—which means an unscoped task can sprawl. Always specify in-scope paths, out-of-scope paths, and a stop condition ("stop and ask if a change would require modifying a public API").

      Prompt Example

      Scope: src/features/billing/** only.
      Out of scope: shared/, migrations/, any file exporting
      from index.ts.
      Stop condition: if a required change falls outside scope,
      halt and list the files you would need to touch.
      

      Why It Improves Workflow

      Boundaries convert "hope it did the right thing" into a reviewable contract. The stop condition prevents silent scope creep—the most common agent failure mode.

      Before/After Productivity

      Before: frequent cleanup of unintended edits. After: near-zero scope violations in agent runs.


      Tip 8: Iterate on the Prompt, Not the Code

      The Technique

      When output disappoints, resist the urge to hand-edit the result. Instead, diagnose which prompt component failed—role, context, task, or contract—and fix that. Hand-editing teaches the model nothing; prompt iteration compounds.

      Prompt Example

      The previous output used `any` in two places, violating the
      context constraint. Re-run with strict typing. If a type is
      genuinely unknown, define an interface and note the assumption.
      

      Why It Improves Workflow

      Each prompt fix improves every future use of that prompt. Over a week, you build a personal library of high-yield prompts rather than a pile of half-edited AI output.

      Before/After Productivity

      Before: repeated manual fixes for the same class of error. After: error classes eliminated at the prompt level.


      Tip 9: Review Agent Output Like a Human PR

      The Technique

      Treat agent output as a junior engineer's pull request: read the diff, check tests, verify no unrelated changes, and run the full suite locally before merging.

      Prompt Example

      Before finishing, produce a self-review:
      - Files changed and why
      - Any assumptions made
      - Anything you were unsure about
      - Tests run and their results
      

      Why It Improves Workflow

      Agents are fast but not infallible. A structured self-review surfaces uncertainty, and a consistent review checklist keeps quality high without slowing you down.

      Before/After Productivity

      Before: occasional regressions from rubber-stamped agent output. After: zero regressions across the last 30 agent runs (team metric).


      Tip 10: Measure Your AI Workflow—Don't Just Feel It

      The Technique

      Track a few simple metrics per task: prompt iterations, first-pass acceptance rate, time to merge, and bugs caught at generation vs. review. A spreadsheet is enough.

      Prompt Example

      After completing this task, summarize:
      - Number of prompt iterations
      - Whether the first output was accepted
      - Any manual fixes required
      

      Why It Improves Workflow

      What gets measured gets improved. Metrics reveal which tips actually pay off for your codebase—maybe agent mode shines on migrations but underperforms on UI work.

      Before/After Productivity

      Before: vague sense of "AI helps." After: a 40% reduction in time-to-merge on refactor tasks, with data to prove it.


      Conclusion

      AI coding tools have crossed the threshold from novelty to infrastructure. The ten tips above share one theme: treat the model like a capable colleague, not a magic box. Give it specifications, context, and boundaries. Constrain its output to your toolchain. Let agents handle mechanical work while you review like a senior engineer. Then measure the results so improvements compound.

      Start with Tip 1 and Tip 2—they deliver the biggest immediate gains. Add agent workflows (Tips 3, 7, 9) once your prompts are disciplined. Build your prompt library as you go, and let the metrics tell you where to invest next. The developers who win with AI won't be the ones with the best models; they'll be the ones with the best workflows.

      Related Articles

      Tips

      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...

      November 10, 20268 min
      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