Back to paths

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.

intermediate~25 min#agentic-ai#coding-agents#hooks#skills#plugins
Chapter 3Coding agentsLesson 2 of 4Show

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.

MechanismWhat it isWhen it actsWhat it guarantees
Guidance in a Markdown fileIn context always, or when its trigger matchesThe agent sees it, not that it obeys
A command the agent's program runsOn every matching event, such as before a tool callIt runs, whatever the model decides
A folder of know-how headed by SKILL.mdWhen a task matches its descriptionIt loads when matched, then guides
A delegated agent with its own instructionsWhen the agent delegates a task to itIts own context, model and tool list
A package of the othersWhen a developer installs itEveryone 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:

TriggerWhen the rule is in context
always_onOn every turn
globWhen the agent works on files matching its pattern
model_decisionIts description is always there; the model reads the rest when it judges the rule relevant
manualWhen 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 typeCan it change data?Can it block?Use it for
InspectNo, read-onlyNo; runs without delaying the agentLogging and monitoring, such as PostToolCallHook
DecideNo (a tool-call allow may sanitise the arguments)Yes: it returns allow or denyPolicy and permission checks, such as PreToolCallDecideHook or PreTurnHook
TransformYes, and returns the modified dataYes: the agent waits for it, and if it fails the operation fails closedSanitising 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.

Simulation: customization-guarantees-flow

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 with agy plugin install <name>@antigravity-plugins-official, from a GitHub URL or from a local path. agy plugin import converts plugins from other agents, including Claude Code.
  • Claude Code: a plugin is a directory with a manifest at .claude-plugin/plugin.json and 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 add and 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 PreToolUse hook can block a tool call; a PostToolUse hook 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
SourcePublisherWhat it supports
Antigravity Hook Architecture (opens in a new tab)github.comGoogle, Antigravity SDK for PythonInspect 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.googleAntigravity documentationAGENTS.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)(.agents/hooks.json and ~/.gemini/config/hooks.json; events SessionStart, PreToolUse, PostToolUse, PreInvocation, PostInvocation, Stop; JSON on stdin and stdout; PreToolUse decisions allow, auto_approve, deny "hard blocks execution immediately", ask, force_ask, deny_unless_prior_grant; PostToolUse fires after a tool completes and returns an empty object). Antigravity changelog v2.12.0: a failing hook no longer ends the sessionantigravity.googleAntigravity documentation
Subagents (opens in a new tab)antigravity.googleAntigravity 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.googleAntigravity documentationbundle 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)code.claude.comClaude Code documentationCLAUDE.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)and code.claude.com/docs/en/hooks (opens in a new tab)code.claude.comClaude Code documentationdeterministic 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)code.claude.comClaude Code documentationown context window; .claude/agents/; frontmatter name, description, tools, model
"Create plugins" and "Discover and install plugins" (opens in a new tab)and code.claude.com/docs/en/discover-plugins (opens in a new tab)code.claude.comClaude 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)docs.cloud.google.comGoogle Cloudrepository 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)(retrieved 2026-12-02: standalone skills in Agent Registry are generally available; skill security scanning and governance in Agent Registry are available). The Skill Registry overview, docs.cloud.google.com/gemini-enterprise-agent-platform/build/skill-registry (opens in a new tab), is still marked Preview and notes that standalone skills can be managed centrally in Agent Registrydocs.cloud.google.comGoogle Cloud
I/O 26 news for agent developers on Google Cloud (opens in a new tab)19 May 2026cloud.google.comGoogle Cloud BlogSkill 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

Review

Flashcards1 / 5

What does a rule guarantee?

Check yourself

Quick exam1 / 9 · 0 correct

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

Your notes on this lesson