Bỏ qua để đến nội dung

Trình đơn

Antigravity

Vị trí cần đặt quy tắc, skill, plugin và MCP để được tải

Bảng tra cứu các thư mục Antigravity đọc để tìm quy tắc, skill, tác nhân tùy chỉnh, plugin, hook và MCP, cùng các bước kiểm tra khi tệp đặt đúng chỗ vẫn không được tải.

phút đọc
12
Cấp độ
Trung cấp
Xác minh lần cuối

Antigravity does not crawl your whole repository looking for rules. It reads a handful of agreed locations, and a file in the wrong place usually fails silently. This page is a lookup map. After reading it you can decide where a rule, a skill, an MCP configuration, a plugin, or a hook belongs, and you can work through the checks in order when a correctly placed file still isn’t loaded.

This page covers where things go and how they are discovered, not how to write their contents. The examples here were not run; they were only checked against the official pages for directory structure and field names. Where the official pages don’t settle a behavior (for example, whether mcp_config.json is also picked up from the repository root when you start in a subfolder), the page says so and defers to the official page.

The official Customization discovery page says Antigravity reads customizations from two scopes:

Scope Location Good for
Workspace The .agents/ folder in your project, plus AGENTS.md and GEMINI.md Rules and workflows shared with the team and committed with the repository
Personal ~/.gemini/config/ in your home directory, plus ~/.gemini/AGENTS.md and ~/.gemini/GEMINI.md Preferences that belong to you and apply to every project

Personal customizations apply in both the Antigravity App and the Antigravity CLI. Both scopes use the same layout: each path in the table below can live under .agents/ or under ~/.gemini/config/.

The official page adds that Antigravity also recognizes folders named .agent/, _agents/, and _agent/, but recommends .agents/ for new projects.

Paths below are relative to .agents/ or ~/.gemini/config/.

Customization Path CLI vs. App
Rules rules/*.md, AGENTS.md, GEMINI.md Both read them; rules with the manual trigger load through an @ mention in the App, and the CLI doesn’t support rule mentions
Skills skills/<name>/SKILL.md The CLI also reads ~/.gemini/antigravity-cli/skills/ and ~/.gemini/skills/; the App doesn’t
Custom agents agents/<name>.md or agents/<name>/agent.md Both read them
Plugins plugins/<plugin-folder>/ Both read them; plugins installed in the App also show up in the CLI’s installed list
Hooks hooks.json Both read them; hooks written in the CLI’s settings.json are not loaded
MCP servers mcp_config.json Both read them; the CLI’s global file is ~/.gemini/config/mcp_config.json and its workspace file is <workspace>/.agents/mcp_config.json

A few details that are easy to miss:

  • AGENTS.md and GEMINI.md can sit in the workspace folder itself or inside .agents/. The personal scope also accepts ~/.gemini/config/AGENTS.md and ~/.gemini/config/GEMINI.md.
  • A plugin folder needs a plugin.json, either in the folder or in its .antigravity-plugin/ or .gemini-plugin/ subfolder. A plugin can bundle its own skills, rules, custom agents, hooks, and MCP servers, which load while the plugin is enabled. A plugin’s skills are named <plugin>:<skill>, so they never collide with your own.
  • Every .md file in rules/ must start with YAML frontmatter that declares a valid trigger (always_on, model_decision, glob, or manual). A missing frontmatter block, or a camelCase value such as alwaysOn, causes the rule to be silently discarded. AGENTS.md and GEMINI.md use no frontmatter and are always active.
  • A skill’s SKILL.md also needs frontmatter, and its description is required.

What counts as the “workspace folder” depends on the surface:

  • App: each folder you add to a project.
  • CLI: the folder where you start agy, plus any folder you add with --add-dir or /add-dir.

Antigravity checks the workspace folder and each parent folder up to the repository root (for example, the folder that contains .git). At each level it reads AGENTS.md, GEMINI.md, and the .agents/ folder. If you start the CLI in services/api/, it loads services/api/.agents/ and the .agents/ folder at the repository root.

Two boundaries apply:

  • The search stops at the repository root. If the workspace folder isn’t in a repository, only the workspace folder is checked.
  • It does not search the subfolders below the workspace folder. If you open the repository root, src/routes/AGENTS.md is not loaded, even while the agent reads and edits files in that folder.

In practice: put a rule at the repository root if it should apply everywhere, and start the client in a subfolder if the rule should apply only to that sub-project. Don’t expect the agent to discover a rule by walking into a subfolder.

Bẫy độ sâu một cấp và manifest khám phá

Phần tiêu đề “Bẫy độ sâu một cấp và manifest khám phá”

Antigravity scans each customization folder one level deep. A skill folder must sit directly inside skills/, and a rule file directly inside rules/. Custom agents follow the same rule: agents/<name>.md and agents/<name>/agent.md load, and deeper ones don’t.

skills/
├── add-endpoint/SKILL.md loaded
└── database/
└── migrate-schema/SKILL.md skipped: nested one level too deep
rules/
├── api-conventions.md loaded
└── security/
└── api-keys.md skipped: nested one level too deep

There are two fixes: move the item up one level, or name it in a discovery manifest. A manifest is a JSON file that lists customizations stored outside the standard folders or nested deeper than the scan reaches. Manifests add to the standard folders; they don’t replace them.

Manifest file Covers
skills.json Skills
rules.json Rules
agents.json Custom agents
plugins.json Plugins

A manifest can live in one project’s .agents/ folder, or in ~/.gemini/config/ for all your projects. Antigravity reads the manifests in every .agents/ folder between the workspace folder and the repository root. The top-level fields are entries, inherits, and exclude; each item in entries and inherits has path (required), include_only, and exclude.

{
"entries": [
{ "path": ".agents/skills", "include_only": ["database/migrate-schema"] }
]
}

Rules from the official page to keep in mind when writing a manifest:

  • In a project manifest, a relative path starts at the folder that contains .agents/; if it isn’t found there, Antigravity tries the repository root. In a personal manifest, relative paths in entries start at ~/.gemini/config/.
  • ~ is not expanded, so write paths in your home directory as absolute paths.
  • include_only and exclude match by name or relative path (for example load-test, api-keys.md, or database/migrate-schema). Wildcards are not supported; load-* does not match load-test.
  • A rule listed in rules.json keeps its own frontmatter, so its trigger still applies.
  • The official page also describes a .gemini/config.json file at the repository root whose personal_customization_dir setting lets each person load customizations from their own folder inside the repository; see the official page for details.

When names collide: rules don’t replace each other, and every rule found is loaded. For two skills or two custom agents with the same name, only one is kept, in this priority order: your personal folder inside the repository (if the repository sets one up), the workspace, your personal ~/.gemini/config/, and built-in items. The CLI is the exception: skills in ~/.gemini/antigravity-cli/skills/ and ~/.gemini/skills/ take priority over all of these, and a manifest exclude list can’t hide them.

Mối quan hệ giữa GEMINI.md, AGENTS.md và .agents/rules/

Phần tiêu đề “Mối quan hệ giữa GEMINI.md, AGENTS.md và .agents/rules/”

All three are “rules” and are loaded the same way. The official Rules page says rules are cumulative: Antigravity combines everything it finds into the prompt rather than replacing one with another. They differ in format and in how they are triggered:

Location Frontmatter Trigger Good for
AGENTS.md, GEMINI.md Not used Always active (always_on) Repository-wide invariants, acceptance commands, stop conditions
.agents/rules/*.md Required, with a valid trigger One of always_on, model_decision, glob, manual Per-module details that should load conditionally

The Rules page lists these discovery locations: <dir>/AGENTS.md or <dir>/GEMINI.md, <dir>/.agents/AGENTS.md or <dir>/.agents/GEMINI.md, and <dir>/.agents/rules/*.md, where <dir> is the workspace folder and each of its parent folders.

For choosing between them, the official Rules page suggests putting always-active content that needs no frontmatter directly in AGENTS.md. The page describes GEMINI.md the same way as AGENTS.md (no frontmatter, always active), so a project that already uses GEMINI.md, or a repository migrated from Gemini CLI, doesn’t need to rename it. Don’t write the same constraint into both AGENTS.md and GEMINI.md: both are loaded, and you will update one and forget the other. For content and examples, see GEMINI.md project context.

Two more limits apply; take the exact numbers from the official Rules page. A single rule file over the size limit is truncated, and all active global rules share one token budget, so when the total is exceeded the largest rule files are demoted to a “path plus description” pointer that the agent reads on demand.

Item CLI App
Workspace folders The folder where you start agy, plus folders from --add-dir and /add-dir Each folder added to the project
Personal skills Reads ~/.gemini/config/skills/, and also ~/.gemini/antigravity-cli/skills/ and ~/.gemini/skills/ Reads only ~/.gemini/config/skills/
A personal skill usable in both Put it in ~/.gemini/config/skills/ Put it in ~/.gemini/config/skills/
Checking what loaded /skills, /agents, /hooks, /mcp, /plugin The Customizations section in project Settings, or Customizations > Installed in the sidebar
Rules list The official pages list no command for it; check the start folder and file paths Filter by type in the interfaces above
manual rules Rule mentions aren’t supported Load with an @ mention

This is the usual reason a repository works in the App but is missing something in the CLI, or the other way around. Reads in the Antigravity IDE and editor extensions differ slightly from the above; follow the official pages.

Ví dụ tối thiểu: một dự án được cố ý đặt quá sâu

Phần tiêu đề “Ví dụ tối thiểu: một dự án được cố ý đặt quá sâu”

The synthetic project demo-notes has a .git at its root. The goal is to make three things load. You may change only .agents/ and the rule files at the project root.

Initial layout (all three items are misplaced):

demo-notes/
├── .git/
├── AGENTS.md
├── .agents/
│ ├── rules/
│ │ ├── style.md
│ │ └── docs/
│ │ └── citations.md
│ └── skills/
│ └── docs/
│ └── check-links/
│ └── SKILL.md
└── notes/
└── drafts/
└── GEMINI.md

Assume rules/style.md and citations.md both have valid frontmatter. After starting agy in demo-notes/, the official rules predict this result:

File Loaded Why
AGENTS.md Yes It’s in the workspace folder itself
.agents/rules/style.md Yes It sits directly inside rules/
.agents/rules/docs/citations.md No Nested one level too deep
.agents/skills/docs/check-links/ No Nested one level too deep
notes/drafts/GEMINI.md No It’s below the workspace folder, and Antigravity doesn’t search downward

This is an expected failure that checks your understanding of discovery. Ask the agent to restate the rules it sees (without modifying files), then run /skills; check-links should not appear.

The fixes use a different approach for each of the three:

  1. Move the rule up one level: move citations.md to .agents/rules/citations.md.

  2. Name the skill in a manifest and leave the folders where they are. Create .agents/skills.json:

    {
    "entries": [
    { "path": ".agents/skills", "include_only": ["docs/check-links"] }
    ]
    }
  3. A GEMINI.md in a subfolder is not discovered automatically: merge its content into a rule at the repository root. If it only matters while drafting, use .agents/rules/drafts.md with trigger: model_decision and a one-line description, so the agent reads it on demand when a task matches.

Verify again after fixing: rules are reread before each turn. In the CLI, run /skills reload or start a new conversation, then run /skills to confirm check-links appears and check the path it shows.

When changes take effect. The official page says Antigravity rereads rules and skills before each turn, so a new or edited file applies to your next message without a restart. In the CLI, the /skills list and the slash commands update only after /skills reload or a new conversation. The App refreshes its lists when you open Settings or the Customizations page.

If something doesn’t load, check in this order (taken from the official checklist):

  1. Location: the file is in one of the folders listed above, in the workspace folder or a parent folder, without crossing the repository root.
  2. Depth: the item sits one level inside its folder, or a manifest names it.
  3. File name: skills use SKILL.md; rules and custom agents end in .md; MCP configs use mcp_config.json; each plugin has a plugin.json.
  4. Frontmatter: SKILL.md and every file in rules/ has frontmatter, and each rule’s trigger is valid.
  5. Manifest: the JSON is valid, paths are absolute or relative to the right folder, no exclude matches the item, and no wildcard is used.
  6. Name conflicts: no other skill or custom agent with the same name has higher priority, especially in the CLI’s two dedicated skill folders.

How to verify. In the CLI, use /skills, /agents, /hooks, /mcp, and /plugin to check each category. In the App, look in the Customizations section of Settings, and hover over a Global badge under Installed to see where an item came from. Rules have no CLI list command, so ask the agent to restate one distinctive, low-risk rule and tell you which file it came from.

MCP and hooks. What this page can confirm is their file names and scope locations. How mcp_config.json is resolved between the repository root and a subfolder you started in isn’t spelled out: the official MCP page only names <workspace>/.agents/mcp_config.json, so follow the official page and use /mcp to see whether the server actually appears. For whether hooks need a restart after editing, see Run automatic checks before and after tool calls with hooks.

Safety boundary. The .agents/ folder, hooks.json, and mcp_config.json in a project are shared with the repository, and the scripts and servers they name run as you. After cloning an unfamiliar repository, review these files before starting an agent in it. Don’t put secrets in mcp_config.json or rule files; use YOUR_API_KEY in examples.