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.
| Customization Type | Standard Path | Token Loading Behavior | Ideal Purpose |
|---|---|---|---|
| Rules | GEMINI.md, AGENTS.md, .agents/rules/*.md | Cumulative (always_on or model_decision) | Hard code style, test gates, forbidden edits |
| Skills | .agents/skills/<name>/SKILL.md | Progressive (name + description until triggered) | Multi-step runbooks, scripts/, examples/ |
| Hooks | .agents/hooks.json or ~/.gemini/config/hooks.json | Zero prompt tokens (lifecycle script execution) | Deterministic formatters, linters, pre-commit blocks |
| Plugins | .agents/plugins/<name>/plugin.json | Bundled unit toggleable in Plugin Manager | Distributing team rules + skills + MCP together |
| MCP Servers | mcp_config.json | Tool schemas loaded when registered | Live 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/*.mdflat at one level deep (e.g.,.agents/rules/python-style.md). - Global always-active rules live in
~/.gemini/AGENTS.mdor~/.gemini/GEMINI.md, while modular global rules require YAML frontmatter inside~/.gemini/config/rules/*.md. - Verify active hooks anytime inside Antigravity CLI with
/hooksor 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).
{
"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.jsonfocused on active data tools you call daily; excessive unused MCP tools bloat input tool declarations. - Use
model_decisionrules 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.