Rules vs. Skills: Why Separating Invariants From Runbooks Cuts Token Bloat

Developers building agentic repositories frequently dump every playbook—database migration steps, release checklists, API docs, and formatting rules—into one giant GEMINI.md. Every conversation then pays thousands of unnecessary input tokens before a single question is asked.

Antigravity cleanly separates the two concerns. Keep persistent constraints and invariants ('always validate schemas', 'use PowerShell semi-colons', 'never modify production fixtures') inside Rules. Move specialized multi-step procedures ('how to deploy release X', 'how to audit SEO pages') into Skills under .agents/skills/<name>/SKILL.md, where progressive disclosure keeps the full body unloaded until relevant.

Architecture diagram of Antigravity precedence hierarchy covering Rules, Progressive Skills, Hooks, and MCP servers
Loading hierarchy: Separating always-active Rules from progressively disclosed SKILL.md folders and deterministic hooks.json checks.
Customization TypeStandard PathToken Loading BehaviorIdeal Purpose
RulesGEMINI.md, AGENTS.md, .agents/rules/*.mdCumulative (always_on or model_decision)Hard code style, test gates, forbidden edits
Skills.agents/skills/<name>/SKILL.mdProgressive (name + description until triggered)Multi-step runbooks, scripts/, examples/
Hooks.agents/hooks.json or ~/.gemini/config/hooks.jsonZero prompt tokens (lifecycle script execution)Deterministic formatters, linters, pre-commit blocks
Plugins.agents/plugins/<name>/plugin.jsonBundled unit toggleable in Plugin ManagerDistributing team rules + skills + MCP together
MCP Serversmcp_config.jsonTool schemas loaded when registeredLive DB queries, browser/SaaS APIs, observability

Directory Precedence & Two Subtle Discovery Pitfalls

Antigravity evaluates customizations cumulatively by walking upward from your current working directory (CWD) to the repository root (.git), and resolves naming conflicts strictly in priority order: Workspace .agents/ overrides declared skills.json/plugins.json, which override global ~/.gemini/config/ and built-in skills.

Two real-world pitfalls trip up teams configuring custom rules: first, Antigravity uses flat scanning inside .agents/rules/, meaning nested paths like .agents/rules/frontend/react.md are ignored unless explicitly registered in .agents/rules.json; second, subfolders *below* your workspace folder do not inject rules automatically.

  • Keep .agents/rules/*.md flat at one level deep (e.g., .agents/rules/python-style.md).
  • Global always-active rules live in ~/.gemini/AGENTS.md or ~/.gemini/GEMINI.md, while modular global rules require YAML frontmatter inside ~/.gemini/config/rules/*.md.
  • Verify active hooks anytime inside Antigravity CLI with /hooks or in Antigravity IDE via ... -> Customizations -> Hooks.

Deterministic Guardrails via .agents/hooks.json

Prompt instructions alone can still slip during long multi-file refactors. Lifecycle hooks solve reliability at the runtime boundary by firing deterministic shell commands immediately before or after tool invocations—such as running your linter or schema validator cleanly inside PostToolUse.

Unlike IDE keybindings, the same .agents/hooks.json format executes across Antigravity App, Antigravity IDE, and Antigravity CLI (hooks.json inside ~/.gemini/antigravity-cli/settings.json is intentionally ignored so lifecycle hooks stay centralized in hooks.json).

json
{
  "python-lint-after-edit": {
    "PostToolUse": [
      {
        "matcher": "write_file|edit_file",
        "hooks": [
          {
            "type": "command",
            "command": "python -m py_compile scripts/editorial_ceo.py scripts/build_blog.py"
          }
        ]
      }
    ]
  }
}

Scaling Across Teams With Plugins & MCP Configs

Once a repository accumulates three or more custom skills alongside domain MCP tool servers (such as Postgres read-only introspection, Sentry trace lookup, or WordPress staging helpers), package them together inside a plugin bundle under .agents/plugins/<plugin-name>/plugin.json rather than leaving scattered files around individual workstations.

Plugins bundle skills, rules, hooks.json, and mcp_config.json into a single toggleable unit across Antigravity IDE, CLI, and Antigravity 2.0. Whenever a project uses non-standard directory paths, register explicit locations inside skills.json or plugins.json so discovery stays deterministic without duplicating files.

  • Keep mcp_config.json focused on active data tools you call daily; excessive unused MCP tools bloat input tool declarations.
  • Use model_decision rules sparingly alongside clear trigger descriptions so unrelated conversations ignore heavyweight guidelines.
  • Audit loaded rules and hooks after onboarding new repositories so workspace overrides behave predictably.