In the previous post on Rules, we hit a hard boundary: all always-on rules share a 20,000-token budget, and any single file over 24 KB is silently truncated. One rule of thumb bears repeating: do not dump multi-step SOPs like release checks, database migrations, or incident runbooks into AGENTS.md.

The reason is straightforward. When you tweak a line of UI copy, you have no use for a 200-line database rollback procedure. Yet if it lives in always-on rules, every new session injects it verbatim into context—burning your budget and diluting the coding constraints that actually matter.

Antigravity separates these “rarely needed day-to-day, fixed multi-step workflow when invoked” procedures into a dedicated mechanism: Skills. Combining the official skills and json_configs docs with hands-on inspection of agy v1.5.19 on my workstation, this guide breaks down how Skills save tokens, how discovery works, how to author reliable ones, and the pitfalls to watch out for.

Three-tier progressive disclosure and 5-level discovery precedence for Skills


1. Why Rules Aren’t Enough—and Why Skills Exist

Because Rules, Skills, and Plugins all involve writing Markdown instructions for an Agent, newcomers to Antigravity often hesitate over which mechanism to pick.

Put side by side, their boundaries are crisp:

Type Typical Path Loading Mechanism Best For
Rules AGENTS.md / .agents/rules/*.md Always-on or path/condition-triggered; counts toward the 20k Rules budget Standing constraints, code style, and module boundaries that apply continuously
Skills skills/<name>/SKILL.md Three-tier progressive disclosure; exposes 1–2 summary lines at idle and loads on demand Multi-step operational runbooks (troubleshooting, releases, migrations)
Plugins plugins/<name>/plugin.json Enabled, disabled, and distributed as a single bundle Packaging related Skills + Rules + Hooks + MCP servers for cross-repo reuse

In one sentence:

  • A Rule is a standing policy: regardless of the task, entering a directory or touching matching files requires following it (e.g., “never modify historical migrations” or “reply in Chinese by default”).
  • A Skill is an operational runbook: it stays tucked away off your desk until the user asks to cut a release, review a PR, or run a database migration—only then does the agent open the manual, run its scripts, consult reference tables, and verify the outcome.

2. Progressive Disclosure: Hundreds of Lines Reduced to One or Two

The single highest-leverage design behind Skills is Progressive Disclosure. Rather than stuffing every playbook into the System Prompt upfront, Antigravity splits skill invocation into three on-demand layers:

  1. Tier 1 (Always-on summary): At session startup, Antigravity injects only a compact manifest containing each mounted Skill’s name, description, and absolute SKILL.md path—never reading the body. Even if a Skill and its reference docs total hundreds of KB, it takes just 1–2 lines (a few dozen tokens) in idle context.
  2. Tier 2 (On-demand expansion): Only when you explicitly type /<skill-name>, or when the model matches your request against a Skill’s description, does it call read_file to load the full SKILL.md.
  3. Tier 3 (Deep on-demand): Large protocol docs live in references/, complex commands in scripts/, templates in resources/, and sample code in examples/. The model follows links to read sub-documents or run scripts only when a specific step in SKILL.md requires them—unvisited branches add zero bytes to context.

Measured locally with wc -l -c against the built-in agy-customizations Skill in agy v1.5.19:

  • Always-on startup injection (name + description + path): ~280 bytes;
  • Entry file SKILL.md read upon match: 109 lines / 5,598 bytes;
  • Its 6 bundled sub-documents (hooks.md 15.5 KB, json_configs.md 4.9 KB, plugins.md 4.7 KB, mcp_servers.md 3.4 KB, skills.md 2.6 KB, rules.md 1.8 KB) total 32,954 bytes.

If you only ask “how do I author a Skill?”, the model reads the 5.6 KB SKILL.md and pulls only the 2.6 KB skills.md—never touching the 15.5 KB hooks.md. On sessions unrelated to customization, that entire 38 KB bundle consumes just 280 bytes of metadata, cutting context overhead by over 99%.

Here is the full trigger and on-demand expansion flow:


3. Standard Directory Layout & SKILL.md Frontmatter Spec

A compliant Skill must live in its own directory under skills/:

1
2
3
4
5
6
skills/<skill_name>/
├── SKILL.md # Required: main instructions and YAML frontmatter
├── scripts/ # Optional: executable helper scripts (Shell / Python, etc.)
├── references/ # Optional: large reference docs, error code tables, checklists
├── examples/ # Optional: example configs or reference implementations
└── resources/ # Optional: templates and static assets

SKILL.md must begin with YAML frontmatter, and its core schema is intentionally minimal:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
---
name: release-preflight
description: >-
Run pre-release checks before cutting a production tag or deploying a service.
Use when the user asks to prepare a release, verify changelog/version bumps,
or run pre-deploy verification. Do not use for routine local commits or draft PRs.
metadata:
icon: verified
---

# Release Preflight Runbook

1. Run the environment and workspace verification script: [verify.sh](./scripts/verify.sh)
2. If env vars or database changes are involved, read [checklist.md](./references/checklist.md) on demand

Three details that commonly trip people up:

  1. name (required): A globally unique identifier in lowercase kebab-case. Keep it identical to the directory name so slash commands and conflict troubleshooting map 1:1.
  2. description (required, highest leverage): The model decides whether to open this runbook entirely from this field. Official guidance recommends writing in the third person and covering three things: what it does + when to trigger + when NOT to use it. Skip vague blurbs like “a useful release helper”—spell out concrete trigger cues and negative boundaries.
  3. metadata (optional) & relative links: UI-facing Skills can declare a metadata block—for instance, the built-in mcp-app-development/SKILL.md sets metadata.icon: handyman. Reference bundled scripts or docs using standard relative Markdown links (such as [prepare.sh](./scripts/prepare.sh)). Because the model receives the absolute path to SKILL.md, it resolves relative targets accurately.

4. Discovery Paths, 5-Tier Precedence & Local Inspection

Antigravity discovers Skills using the same hierarchy as Rules, with one extra rule: built-in Skills are mounted explicitly rather than scanned blindly. When two Skills share the same name (for example, both the project and global directories define code-review), higher precedence overrides lower precedence.

Per the official agy-customizations docs, the 5-tier precedence order from highest to lowest is:

Priority Source Tier Discovery Path / Config Notes
P1 Workspace upward traversal .agents/skills/*/SKILL.md from CWD → ... → .git Closer to CWD wins; also supports .agent/, _agents/, _agent/
P2 Workspace declarative config .agents/skills.json Explicitly mounts non-default directories; supports entries, inherits, and filters
P3 Global directory discovery ~/.gemini/config/skills/ (plus ~/.agents/skills/ compatibility) Applies to all local workspaces; also loads skills/ from enabled plugins
P4 Built-in Skills ~/.gemini/antigravity-cli/builtin/skills/ Shipped with the client; explicitly mounted per Agent config, not blind-scanned
P5 Global declarative config ~/.gemini/config/skills.json Mounts custom machine-wide shared directories; lowest priority

Local verification of P4 built-in Skills: Running ls ~/.gemini/antigravity-cli/builtin/skills/ on agy v1.5.19 reveals 16 built-in Skills (agy-customizations, antigravity_guide, automation, conversations, generative_ui, mcp-app-development, migrate-agent-settings, migrate-workflows, native_swarm, permissioned-github, plugin, run-workflow, swarm_monitor, swarm_narrator, swarm_pane, ui-plugin-navigation). In a standard terminal session, however, the system prompt does not inject all 16—it mounts only the subset required by the active Agent config (such as agy-customizations, antigravity-guide, conversations, and run-workflow). This confirms the documented “mounted by name rather than blind directory scanning” behavior.

Here is the actual Skills directory layout active on my Linux workstation:

Local inspection of built-in and custom Skills directories and SKILL.md structure

All four sources stay cleanly separated without interfering with one another:

  • Built-in (16): Located under ~/.gemini/antigravity-cli/builtin/skills/, covering customization docs, workflow orchestration, MCP App development, and multi-agent Swarm coordination.
  • Personal global custom: Located at ~/.gemini/config/skills/browser-tab-group/, containing a lean 34-line SKILL.md (2,642 bytes) that delegates session title lookup and browser extension redirect URL generation to scripts/session-tab-url.py—a textbook “thin instructions + heavy script” design.
  • Cross-tool compatible directory: Under ~/.agents/skills/, code-review (29 lines), debug-root-cause (30 lines), and git-commit (25 lines) each sit at 1.2–1.7 KB, adding virtually zero overhead.
  • Plugin-bundled Skills: Once the local abc plugin is enabled, its four skills under ~/.gemini/config/plugins/abc/skills/ (accept, config, connect, copy) are merged into the available list automatically with no manual copying.

5. Building a Project Skill Step by Step (Monorepo Sharing & /learn)

Specs alone rarely stick until you ship one. Below is a production-ready db-migration-check Skill you can drop straight into an application repository to automate pre-merge and pre-deploy database migration checks.

1. Directory Layout

1
2
3
4
5
6
.agents/skills/db-migration-check/
├── SKILL.md
├── scripts/
│ └── verify.sh
└── references/
└── checklist.md

2. Main File SKILL.md (Lean Entrypoint + Explicit Acceptance Criteria)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
---
name: db-migration-check
description: >-
Review and verify SQL database migration files before merging or deploying.
Use when the user creates, edits, or audits files under migrations/, asks to
check schema changes, or prepares a release involving DB changes. Do not use
for read-only SQL queries or ORM model refactors with no migration diff.
---

# Database Migration Check

## Steps

1. Run the static checker against changed migration files:
[verify.sh](./scripts/verify.sh)
- If the script exits non-zero, stop and inspect every reported file and line.
2. Check rollback safety and lock impact:
- For high-risk operations (`ALTER TABLE` on core tables, index builds, column drops),
read [checklist.md](./references/checklist.md) before approving.
3. Verify locally:
- Run the project's migration dry-run / up-and-down test against a local test DB,
confirming zero errors and clean `git status`.

## Done Criteria

- Report exact command output from `verify.sh` and the local dry-run.
- Classify findings as Blocker / Warning with `file:line` references.
- Never claim safe if `verify.sh` or dry-run was skipped.

3. Encapsulated Script scripts/verify.sh (Never Hardcode CWD)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env bash
set -euo pipefail

# Anchor to repo root so invocations from subdirectories never break paths
REPO_ROOT="$(git rev-parse --show-toplevel)"
MIG_DIR="${REPO_ROOT}/migrations"

if [ ! -d "$MIG_DIR" ]; then
echo "ERROR: migrations/ directory not found at ${MIG_DIR}" >&2
exit 2
fi

CHANGED="$(git -C "$REPO_ROOT" diff --name-only -- migrations/ || true)"
if [ -z "$CHANGED" ]; then
echo "OK: no modified migration files in working tree."
exit 0
fi

FAIL=0
while IFS= read -r relpath; do
[ -f "${REPO_ROOT}/${relpath}" ] || continue
if grep -Ein 'DROP[[:space:]]+(TABLE|COLUMN)|TRUNCATE[[:space:]]+TABLE' "${REPO_ROOT}/${relpath}"; then
echo "BLOCKER: destructive DDL detected in ${relpath}" >&2
FAIL=1
fi
done <<< "$CHANGED"

exit "$FAIL"

4. Offloading Heavy Details to references/checklist.md

Put lock-severity matrices, dual-write steps for adding columns to large tables, and online DDL compatibility notes across database versions into references/checklist.md. For routine new tables or small changes, the model runs verify.sh and wraps up without ever reading a multi-hundred-line reference sheet. Only when high-risk DDL shows up does Step 2 pull it into context.

Measured against the four best practices in the official docs, this template hits every mark:

  • Progressive disclosure: The entrypoint stays under 35 lines; heavy docs live in references/.
  • Script-encapsulated commands: scripts/verify.sh locks down the exact checks so the model does not hand-craft fragile, escape-prone regex pipelines on the fly.
  • Explicit verification criteria: Non-zero exit handling, local dry-run checks, and a strict “never claim safe if skipped” reporting contract.
  • Zero filler: No lectures explaining what SQL is or how git diff works—only your team’s concrete quality gate.

5. Sharing Across a Team Monorepo with .agents/skills.json

In large monorepos, teams typically centralize shared skills under a top-level tools/agents/skills/ directory rather than duplicating folders into every service. Declare them in .agents/skills.json:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
"inherits": [
{
"path": "../platform-standards/skills.json",
"include_only": ["db-migration-check", "release-preflight"],
"exclude": ["legacy-deploy"]
}
],
"entries": [
{
"path": "tools/agents/skills",
"exclude": ["experimental-.*"]
}
]
}

Three path rules worth noting (from docs/json_configs.md):

  • Directories listed in entries are scanned only one level deep (<entry>/<skill_name>/SKILL.md), not recursively.
  • path supports absolute paths (leading /), home-relative paths (leading ~/), and relative paths (resolved relative to the declaring dot-directory first, falling back to the repository root).
  • When starting a session inside a subdirectory, every .agents/skills.json along the path from CWD up to the repository root takes effect—teammates get them immediately after git pull.

6. Don’t Want to Write from Scratch? Capture Workflows with /learn

The fastest way to author a strong Skill is rarely writing one from a blank page. Instead, solve a complex task end-to-end once, then distill it into a Skill with /learn.

Suppose you spend half an hour guiding the Agent through “build Docker image → push to staging registry → inspect K8s Pod logs → verify health endpoint,” hitting two environment-variable pitfalls and tweaking a startup flag along the way. Before closing the session, run /learn to extract the verified steps and edge cases into .agents/skills/<name>/SKILL.md (and pull recurring commands into scripts/). Lightly polish the generated description and acceptance criteria, and anyone on the team can replay that entire release-troubleshooting flow with a single prompt.


6. Five Common Pitfalls When Authoring Skills

  1. Writing a description that is too broad or too vague
    Describing a Skill as “helps developers write better code and fix bugs” causes false triggers on ordinary chats, wasting tokens reading the body. Conversely, overly academic phrasing that omits the words developers actually type (like PR, diff, migration, or release) prevents the model from ever matching it. Fix: Use third person, include 2–3 concrete trigger phrases, and add a Do not use for ... clause to draw a sharp negative boundary.
  2. Stuffing all documentation into one giant SKILL.md
    Pasting error-code catalogs, past incident writeups, and API field tables directly into the main file bloats it past 600 lines and defeats progressive disclosure. Fix: Treat SKILL.md as a table of contents plus step skeleton (aim for under 100 lines), and push any reference longer than half a screen into references/ via on-demand links.
  3. Hardcoding CWD-relative paths inside scripts
    A ./migrations or ./scripts/helper.py path that passes at the repo root immediately fails with No such file or directory when someone launches agy inside services/order/. Fix: Locate bundled assets with SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" and locate the repo root with git rev-parse --show-toplevel.
  4. Specifying “how to run” without “how to verify” or “when to abort”
    With only 1-2-3 execution steps and no verification signal, a model encountering a mid-run error often assumes “looks fine” and wraps up early. Fix: Pair every critical step with a machine-verifiable check (stop on non-zero exit code, grep for expected log markers, run a dry-run) and explicit abort/rollback conditions.
  5. Copying raw Skill directories across repos when you also need MCP and Hooks
    When a workflow requires a Skill for step-by-step instructions, a dedicated MCP server for external APIs, and a PreToolUse Hook to block mistakes, distributing .agents/skills/ alone makes team alignment fragile. That combination belongs in a Plugin bundle—which we will unpack in Part 9 of this series.

Permission boundary reminder: Just like Rules, Skills are prompt-layer guidance, not a security firewall. If a script performs destructive actions—deleting resources, pushing to production branches, or mutating production databases—do not rely on writing “please ask the user first” in SKILL.md. Use hooks.json (covered in the next post) to enforce hard pre-execution blocks before the tool ever runs.


Series Navigation