Customising coding agents: rules, hooks, skills, subagents and plugins
Pick the right customisation for each team requirement. Rules and skills guide the agent, hooks run on every matching event, subagents give a focused role its own context, and plugins and Skill Registry share the result across a team or an organisation.
Chapter 3Coding agentsLesson 2 of 4ShowHide
Chapter 3 of 7 in Google Cloud Professional Agentic Architect
- Customising coding agents: rules, hooks, skills, subagents and pluginsYou're here
Prerequisites: Configuring coding agents with MCP and skills
Each mechanism comes with a different guarantee
Configuring coding agents gave a coding agent additional tools through MCP and know-how through skills. Teams soon want more: house conventions followed, checks that always run, focused helpers, and a way to give all of it to every developer. Coding agents offer five mechanisms for this, and the difference that matters is what each one guarantees.
| Mechanism | What it is | When it acts | What it guarantees |
|---|---|---|---|
| Guidance in a Markdown file | In context always, or when its trigger matches | The agent sees it, not that it obeys | |
| A command the agent's program runs | On every matching event, such as before a tool call | It runs, whatever the model decides | |
A folder of know-how headed by SKILL.md | When a task matches its description | It loads when matched, then guides | |
| A delegated agent with its own instructions | When the agent delegates a task to it | Its own context, model and tool list | |
| A package of the others | When a developer installs it | Everyone gets the same versioned set |
The rest of this lesson works through each row. In short, if something must happen every time, use a hook; if it is guidance, use a rule or a skill.
Rules guide, and the model decides
A rule is persistent guidance in the agent's context. In Claude Code, CLAUDE.md
is always loaded, and files in .claude/rules/ can take a paths field so they
load only when the agent works on matching files. In Antigravity, AGENTS.md or
GEMINI.md is always on, and each file in .agents/rules/ takes a trigger:
| Trigger | When the rule is in context |
|---|---|
always_on | On every turn |
glob | When the agent works on files matching its pattern |
model_decision | Its description is always there; the model reads the rest when it judges the rule relevant |
manual | When you @-mention it in the app |
Scope rules so they appear only where they apply. A convention for migration
files belongs in a rule scoped to migrations/, not in the always-on file
where it spends context on every task.
What a rule cannot do is enforce. Claude Code's documentation says so directly: its instruction files are "context, not enforced configuration". The model reads a rule and decides what to do. A long, vague or conflicting rule is followed less reliably, and text the agent reads in a file or web page can talk it out of one.
Skills load on demand, then guide
A skill, from Configuring coding agents, loads only when a task matches its description or you invoke it. Once loaded, it is guidance like a rule, so a skill that describes a lint procedure still leaves the model to decide whether to follow it. Use a skill for know-how that some tasks need, such as a release procedure with a helper script, and a rule for conventions that apply always or to certain files.
Hooks run every time
A hook is a command that the agent harness (the program around the model that runs tools and manages the session) executes on a lifecycle event, a fixed moment in the session. The model does not decide whether a hook runs. Both products offer these core events:
SessionStart, when a session begins.PreToolUse, before a tool call runs. The hook can block the call.PostToolUse, after a tool call (in Claude Code, only after one that succeeds). The tool has already run, so the hook can only act afterwards; in Claude Code it can also report back to the model.Stop, when the agent finishes its turn.
Take one requirement: every TypeScript file the agent edits must pass the
linter. In Claude Code, a PostToolUse hook in the project's
.claude/settings.json does it. The command reads the edited file's path and,
for .ts or .tsx files, runs ESLint, exiting with code 2 if it fails:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "f=$(jq -r '.tool_input.file_path'); case \"$f\" in *.ts|*.tsx) npx eslint \"$f\" >&2 || exit 2;; esac"
}
]
}
]
}
}The hook receives the tool call as JSON on standard input (the command needs
jq, and ESLint installed in the project). Exit code 2, rather than any other
failure code, tells Claude Code to show the hook's error output to the model,
which then fixes the file. The matcher covers the Edit and Write tools; a file
the agent rewrites with a shell command does not trigger it.
To stop an action rather than react to it, use PreToolUse. A hook on file
reads that sees a path ending in .env returns a decision of deny, as JSON on
standard output, and that read never happens (a shell command such as
cat .env needs its own check, or a permission deny rule). In Claude Code, a deny from a
PreToolUse hook holds in every permission mode, including modes set to run
tools without asking for approval. Antigravity's hooks live in
.agents/hooks.json, with a different file layout but the same idea: a
PreToolUse hook gets the call as JSON and can return deny, which "hard
blocks execution immediately", or decisions such as ask or allow. By
default a hook that crashes or times out does not block: Claude Code lets the
call go ahead unless the hook is set to block on failure, and Antigravity
reports the error and carries on. Write a policy hook so that it denies
explicitly.
Matching command text is easy to get around: a hook that looks for
git push --force misses -f, a + refspec or an alias. For a hard rule on
commands, pair the hook with a permission deny rule or a server-side protection
such as a protected branch.
If you build your own agent on the Antigravity SDK (see Configuring coding agents), its hooks are
named after lifecycle events (such as PreToolCall, PostToolCall and
OnToolError), and each one also belongs to one of three types, set by what it
may do:
| SDK hook type | Can it change data? | Can it block? | Use it for |
|---|---|---|---|
| Inspect | No, read-only | No; runs without delaying the agent | Logging and monitoring, such as PostToolCallHook |
| Decide | No (a tool-call allow may sanitise the arguments) | Yes: it returns allow or deny | Policy and permission checks, such as PreToolCallDecideHook or PreTurnHook |
| Transform | Yes, and returns the modified data | Yes: the agent waits for it, and if it fails the operation fails closed | Sanitising data and recovering from errors, such as OnToolErrorHook |
On a tool call, Decide hooks run first and Inspect hooks after the tool has
run, so a check cannot pass on data that changes before the tool runs, and the
log records what actually ran. The Antigravity app's hooks.json uses its own
event names, such as PreToolUse.
In the Antigravity SDK, what can Inspect, Decide and Transform hooks each do?
Subagents give a focused role its own context
A subagent is a delegated agent with its own instructions. Its key property is context isolation: a custom subagent starts without the parent's conversation, does its work in its own context, and returns only a result. A security review that reads hundreds of files leaves the main session with a list of findings instead of hundreds of file listings.
Both products define subagents as Markdown files whose frontmatter names the
subagent and describes when to use it, and whose body is its system prompt:
.claude/agents/<name>.md in Claude Code, .agents/agents/<name>.md in
Antigravity. The frontmatter can also set a model and a tool list. In Claude
Code:
---
name: security-reviewer
description: Reviews changed code for security issues. Use before a pull request is opened.
tools: Read, Grep, Glob
model: inherit
---
You review code for injection, secrets in source, unsafe deserialisation and
missing authorisation checks. Report each finding with file, line and a fix.
Do not change any files.Antigravity uses the same shape, but tools is a YAML list of its own tool
names (such as read_file, edit_file, write_file and run_command), and
model takes inherit, flash or pro. Check each name against the
documentation: Antigravity lists a known issue where an unmapped or misspelled
tool name can make the subagent hang.
The tool list is where a subagent's guarantee comes from. This reviewer has only read and search tools, so it cannot edit a file even if a file it reads tells it to. The last line of the body is guidance; the tool list is enforcement.
One requirement, five ways
Put the mechanisms side by side on the requirement from the hooks section: every edited TypeScript file passes the linter. Predict first whether the linter still runs when the model ignores the rule, then step one edit request through the agent and watch where each mechanism sits.
A hook enforces on one developer's machine, in one agent, for the edits its matcher covers. A developer can edit files by hand or turn the hook off, so keep the same check in CI as the final gate before merge.
Share customisations with plugins and Skill Registry
A plugin packages customisations so a team installs and updates them together.
- Antigravity: a plugin bundles skills, MCP servers, subagents, rules and
hooks "into a single versioned unit", described by a
plugin.json. Developers install one from the official marketplace withagy plugin install <name>@antigravity-plugins-official, from a GitHub URL or from a local path.agy plugin importconverts plugins from other agents, including Claude Code. - Claude Code: a plugin is a directory with a manifest at
.claude-plugin/plugin.jsonand skills, subagents, hooks and MCP servers (instructions go in a skill, not a rules file). Teams publish plugins in a marketplace, a catalogue that is often a Git repository, which developers add once with/plugin marketplace addand then install from with/plugin install <plugin>@<marketplace>.
A plugin adds no guarantee of its own. It ships the mechanisms inside it, each with the guarantee it already had.
shares skills at the platform
level. It is a Gemini Enterprise Agent Platform feature in public Preview. You
upload a skill as a zip that contains its SKILL.md (with YAML frontmatter;
keeping it at the top of the archive is a sensible layout), and the registry stores it
in your Google Cloud project, keeping each revision as a fixed version. Agents
reach it through the Managed Agents API, the Agent Platform SDK and ADK (the
Agent Development Kit), whose SkillToolset gives an agent tools to search the
registry and load a skill.
So use a plugin to put skills into developers' coding agents, and Skill Registry for skills that the agents you build and deploy should load. Google's documentation does not describe Antigravity or Claude Code reading Skill Registry natively.
Recap
- A rule puts guidance in context, always or when its trigger matches; the model decides whether to follow it. Scope rules to the files they apply to.
- A skill loads when a task matches, then guides like a rule.
- A hook is run by the agent harness on every matching event. A
PreToolUsehook can block a tool call; aPostToolUsehook runs after it and cannot undo it. Keep the same checks in CI. - A subagent works in its own context and returns a result; its tool list is what enforces its limits.
- A plugin ships a coding agent's skills, hooks, subagents and MCP servers (and, in Antigravity, rules) as one versioned package. Skill Registry, in Preview, stores versioned skills on Agent Platform for the agents you build.
Sources
Show 12 sourcesHide sources
| Source | Publisher | What it supports |
|---|---|---|
| Antigravity Hook Architecture (opens in a new tab) | Google, Antigravity SDK for Python | Inspect hooks read-only and non-blocking; Decide hooks return allow or deny; Transform hooks modify data and fail closed; decisions run before the tool, inspections after |
| Rules (opens in a new tab) | Antigravity documentation | AGENTS.md and GEMINI.md always on; .agents/rules/*.md with trigger always_on, model_decision, glob or manual; 24,000 bytes per file; 20,000-token budget shared by global and always-on rules; manual rules are mentioned in the app, not the CLI |
| Hooks (opens in a new tab) | Antigravity documentation | |
| Subagents (opens in a new tab) | Antigravity documentation | .agents/agents/ with one Markdown file per subagent; frontmatter name, description, tools, model (inherit, flash or pro), commandExecutionPolicy, mcpServers, skills; tools is a list of Antigravity tool names, for example read_file, edit_file, write_file and run_command, and a known issue warns that an unmapped or misspelled tool name may cause the subagent process to hang, rechecked 2026-12-02; a subagent does not inherit the parent's conversation history |
| Plugins (opens in a new tab) | Antigravity documentation | bundle skills, MCP servers, agents, rules and hooks into a single versioned unit; plugin.json; agy plugin install; agy plugin import from Gemini CLI extensions and Claude Code plugins |
| How Claude remembers your project (opens in a new tab) | Claude Code documentation | CLAUDE.md and rules are "context, not enforced configuration"; .claude/rules/ with paths frontmatter; use a PreToolUse hook to block an action |
| "Automate workflows with hooks" and "Hooks reference" (opens in a new tab) | Claude Code documentation | deterministic control; PostToolUse with an Edit|Write matcher in .claude/settings.json; exit code 2 blocks PreToolUse and shows stderr to Claude for PostToolUse; a PreToolUse deny holds in every permission mode; for command patterns, the hooks reference recommends the permission system for a hard allow or deny |
| Create custom subagents (opens in a new tab) | Claude Code documentation | own context window; .claude/agents/; frontmatter name, description, tools, model |
| "Create plugins" and "Discover and install plugins" (opens in a new tab) | Claude Code documentation | .claude-plugin/plugin.json; skills, agents, hooks, MCP servers; Claude Code does not load a CLAUDE.md at the plugin root, so instructions go in a skill; /plugin marketplace add; /plugin install plugin@marketplace |
| Skill Registry overview (opens in a new tab) | Google Cloud | repository for managing agent skills; versioned revisions; zip containing a SKILL.md file with YAML frontmatter is validated on upload; standalone skills can be managed within Agent Registry |
| Agent Registry release notes (opens in a new tab) | Google Cloud | |
| I/O 26 news for agent developers on Google Cloud (opens in a new tab) | Google Cloud Blog | Skill Registry public preview; accessible via the Managed Agents API, Agent Platform SDK and ADK via SkillToolset; will be part of Agent Registry |
Suggested videos
Show 2 videosHide videos
One tool to rule them all: Extending and customizing the Gemini CLI (opens YouTube in a new tab)
Next '26 session on bundling MCP servers, context files, skills, hooks and subagents to customize Gemini CLI: almost every mechanism in the lesson.
Note: 37 minutes with no chapters, and about Gemini CLI rather than Antigravity.
Inside Google Antigravity 2.0: The complete developer guide | The Agent Factory (opens YouTube in a new tab)
Antigravity 2.0 developer guide showing skills and customizations in Google's own coding agent.
Note: A long conversation; hook types such as Transform and Inspect aren't covered.
Review
What does a rule guarantee?
Check yourself
A team requires every Python file the agent edits to be formatted with black. Which customisation makes the formatter run after every edit the agent makes with its edit tools, whatever the model decides?
Go deeper
Hands-on lab: Practical Harness Engineering with Google Antigravity →
Sandboxing, PreToolUse classifier hooks, human-in-the-loop notifications and steering. About 46 min. Codelab, runs in your own Google Cloud project with billing on.
LinkHands-on lab: CodeMender Skills & Hooks for Antigravity →
Load skills and add a pre-push security hook: guidance versus an enforced check. Codelab, runs in your own Google Cloud project with billing on.