Prompting and instructions
Section titled “Prompting and instructions”Good prompting is clear technical writing. State the goal, constraints, and definition of done up front. The model then spends its reasoning budget solving the real problem instead of guessing what you meant.
For model-level guidance beyond coding agents, see Prompt design strategies and Introduction to prompt design in Vertex AI.
Four parts of an effective prompt
Section titled “Four parts of an effective prompt”You do not need a rigid template for every message. Strong task prompts usually answer four questions:
| Element | What it tells the agent | Example |
|---|---|---|
| Goal | The exact outcome you want. | Add rate limiting to the /api/export endpoint. |
| Scope and inputs | Which files, modules, or logs matter. | Edit src/routes/export.ts and reuse the helper in src/lib/limiter.ts. |
| Constraints | Boundaries, libraries to avoid, or style rules. | Do not add new npm dependencies. Keep responses JSON-formatted. |
| Verification | How to prove the work is done. | Add unit tests for burst and window reset behavior, then run npm test. |
Vague prompt vs. concrete specification
Section titled “Vague prompt vs. concrete specification”Vague prompts force the agent to guess architecture, file paths, and edge cases:
Fix the search page so it works better on mobile.
A concrete specification narrows the blast radius and adds a check the agent can run itself:
Fix horizontal overflow on the search results table below 480px in src/styles/search.scss without changing desktop column widths, then verify at 390px viewport width with /browser.
Try a self-contained prompt that works in any repository:
Inspect this repository's build scripts, test runner, and code style config, then draft a concise AGENTS.md with our real commands and conventions without editing any other files.
Layer your instructions
Section titled “Layer your instructions”Repeating project conventions in every prompt wastes time and context. Place each instruction at the right layer so Antigravity loads it automatically:
- Workspace rules (
AGENTS.md,GEMINI.md, or.agents/rules/*.md): Team conventions, test commands, banned dependencies, and architecture notes. Antigravity loads these from your workspace folder and parent folders up to the repository root. See Rules. - Global rules (
~/.gemini/AGENTS.md,~/.gemini/GEMINI.md,~/.gemini/config/AGENTS.md,~/.gemini/config/GEMINI.md, or~/.gemini/config/rules/*.md): Personal preferences that follow you across every project. - Rule activation modes: Standalone
AGENTS.mdandGEMINI.mdfiles stay always on. Modular files inrules/*.mduse YAML frontmatter with atriggerkey. Choosealways_on(every turn),glob(matching file patterns),model_decision(loaded from itsdescription), ormanual(@-mentioned in the Antigravity App). - Reusable skills (
SKILL.md): Step-by-step procedures that load on demand when a task matches, or run explicitly via/<skill-name>. See Skills. - Capture session fixes with
/learn: After correcting the agent or solving a tricky setup, run/learn. Antigravity drafts a reviewable proposal to save the lesson as a rule or skill. - Turn prompt: The specific goal, target files, and acceptance criteria for the task in front of you.
Write constraints and feedback loops
Section titled “Write constraints and feedback loops”Four habits catch ambiguity before the agent writes the wrong diff:
- State negative constraints explicitly. Tell the agent what to leave untouched, such as keeping database migrations unchanged or preserving public function signatures.
- Show one concrete example for custom formats. Include a short JSON schema, log line, or layout snippet instead of describing the format in prose.
- End prompts with a runnable check. Include
npm test,pytest, or/browserso the agent catches and fixes its own mistakes before reporting back. - Course-correct early. Stop a drifting turn rather than waiting for it to
finish. In the Antigravity CLI, press Esc and run
/rewind. In the Antigravity App, click Stop and click Revert on an earlier prompt.
Prompt failure modes
Section titled “Prompt failure modes”| Symptom | Likely gap | Fix |
|---|---|---|
| Agent edits unrelated files | Missing scope or negative constraints | Name exact target files and list what to leave untouched. |
| Agent guesses library APIs or flags | Missing primary-source grounding | Point to workspace manifests (package.json, pyproject.toml) or docs via MCP. |
| Agent reports done while broken | Missing verification step | End the prompt with a runnable test command or /browser check. |
| You repeat the same correction | Standing convention stuck in chat | Move it to AGENTS.md or run /learn to save it. |
Next steps
Section titled “Next steps”See how prompt size, file mentions, and long sessions affect accuracy and speed.
Store persistent workspace and global instructions in AGENTS.md and rule files.
See how a well-scoped single prompt coordinates four parallel agents.