Platform engineering wants Antigravity to refuse any rm -rf or production deploy command before it runs, whatever the prompt says. What enforces this?
- Exam domain
- Using coding agents for application development~17% of the exam
- Difficulty
- Hard
- In this mock
- 10 questions on this domainPractise this domain
Why the exam asks this
Customizing coding agents for enterprise workflows.
Objective in the exam guide: Creating skills, plugins, extensions hooks, rules, and subagents using Antigravity.
Hooks are the enforcement point for coding agent policy.
Why C is the answer
A PreToolUse hook that returns deny for any matching command
A PreToolUse hook runs before a tool executes, and a deny decision hard-blocks the call. Rules are instructions the model may not follow.
Remember: Enforce with PreToolUse hooks, not with rules.
How it works
A PreToolUse hook runs before a tool call and can deny it.
A PostToolUse hook runs after the call, so it can observe or log but cannot stop it.
Clues in the question
The words that point to the answer, and what each one tells you.
- before it runs
- PreToolUse.
- whatever the prompt says
- Code that enforces, not an instruction.
In detail
- PreToolUse can allow, ask, deny or rewrite tool arguments.
- PostToolUse hooks observe only, and Stop hooks run at the end of the loop.
- Workspace hooks live in .agents/hooks.json, and global hooks in the user's config folder.
Side by side with look-alikes
| Mechanism | Runs | Can block? |
|---|---|---|
| PreToolUse hook | Before the call | Yes |
| PostToolUse hook | After the call | No |
| Rule in AGENTS.md | In the prompt | No |
Every option, checked
Knowing why each wrong option fails is how you rule it out on exam day.
A. A PostToolUse hook that logs each command after it runsWrong
PostToolUse runs after the damage is done.
B. A rule in AGENTS.md that tells the agent never to do itWrongMost tempting
A rule is advice to the model, not a hard block.
Why it tempts: A rule guides the model; a hook enforces the decision in code.
C. A PreToolUse hook that returns deny for any matching commandRight
Enforce with PreToolUse hooks, not with rules.
D. A Stop hook that reviews the session when it endsWrong
A Stop hook runs when the loop ends, too late to stop a command.
Use case
An illustrative scenario, not a real incident.
Illustrative: a workspace hooks.json denies kubectl commands against production contexts. A developer's prompt to "just deploy it" is blocked before the shell runs.
See it in different ways
sequenceDiagram participant P0 as Agent participant P1 as PreToolUse hook participant P2 as Shell P0->>P1: tool call rm -rf build P1-->>P0: decision deny P0->>P1: tool call npm test P1->>P2: allow, run command
How to read this chart
- 1. Agent sends "tool call rm -rf build" to PreToolUse hook.
- 2. Agent gets a reply from PreToolUse hook: "decision deny".
- 3. Agent sends "tool call npm test" to PreToolUse hook.
- 4. PreToolUse hook sends "allow, run command" to Shell.
flowchart TD
Q{"When must it act?"}
Q -->|"Before a tool runs"| A0["PreToolUse, can deny"]
Q -->|"After a tool runs"| A1["PostToolUse, observe only"]
Q -->|"When the loop ends"| A2["Stop"]How to read this chart
- At "When must it act?": if "Before a tool runs", go to "PreToolUse, can deny"; if "After a tool runs", go to "PostToolUse, observe only"; if "When the loop ends", go to "Stop".