PLUGIN brewtools / Skills
On this page
Agent Deadline Setup
sonnet opt-in project | globalClaude Code has no wall-clock timeout for subagents. An agent that hits maxTurns returns a partial result and loses any analysis it hasn’t written down. These hooks add a soft elapsed-time budget that nudges the agent to finalize. They kill nothing.
Quick reference
| Field | Value |
|---|---|
| Command | /brewtools:agent-deadline-setup |
| Args | [prompt] [status|install|upgrade|enable|disable|uninstall|purge] [project|global] [minutes] [--unattended] |
| Model | sonnet |
| Defaults | no args = status; budget 20 min; ABSENT config = DISABLED (enabled must be exactly true) |
| Output | 2 hook files, 2 settings.json entries, agent-deadline.json |
Modes
| Mode | Does |
|---|---|
status | Report installed scopes, wiring, governing config (default) |
install | Copy hooks, merge settings, write config |
upgrade | Re-emit hooks from the current plugin, budget kept |
enable | Set enabled: true |
disable | Set enabled: false, files stay |
uninstall | Unwire and delete hooks, keep config |
purge | Uninstall and delete config |
Under --unattended, upgrade covers one scope and skips with nothing written unless the prompt names exactly one of project or global; it also skips when that scope has an orphan config, is not installed, uses a custom launcher or has an invalid settings.json. A config kept by uninstall is not an install: the note is not installed (uninstalled, config kept) and the hooks are not wired again. See how the flag works.
Example
/brewtools:agent-deadline-setup install project 20
The skill prints its plan (2 hook files into .claude/hooks/, config with defaultMinutes: 20, 2 settings entries), asks only for confirmation and re-prints status: guard=yes cleanup=yes guard_refs=1 cleanup_refs=1 enabled=true.
How it works
| Elapsed | Action |
|---|---|
| 80% of budget | Non-blocking notice: finish the step, prepare the final report |
| 100% | Every tool outside the finalization set is denied |
hardStopRatio x budget (default 2x) | Only Write, Edit, SubagentHandback pass |
The finalization set is Read, Write, Edit, NotebookEdit, TodoWrite, TaskUpdate, SubagentHandback.
- Status first
Both scopes are checked before anything changes.
- Plan, then questions
The plan is printed; scope and budget are asked only if missing.
- Delegated file work
One
brewcode:hook-creatorspawn per scope copies hooks and merges settings. See Delegation. - Live status
Wiring and config changes apply to the running session; no restart,
/hooksconfirms.
Technical details
The two hooks #
| Hook | Event | Behavior |
|---|---|---|
agent-deadline-guard.mjs | PreToolUse on .* | Tracks elapsed time per agent_id; warns at 80%; past 100% denies tools outside the finalization set; past hardStopRatio x budget allows only Write, Edit, SubagentHandback (deny reason starts Time budget far exceeded) |
agent-deadline-cleanup.mjs | SubagentStop | Stamps the stop on the agent’s state file, never deletes it, prunes old state. A call under 5 minutes after the stop continues the original clock; later gets a fresh window |
SubagentHandback stays allowed at every stage: in auto mode it is how a subagent reports. AskUserQuestion is denied past the deadline: a subagent parked on a human answer is the unbounded wait this guard stops. Read-only agent types (readOnlyAgentTypes) are told to return what they have instead of saving a file.
Installation targets and config discovery #
| Scope | Hooks dir | settings.json | Config |
|---|---|---|---|
| Project | <repo>/.claude/hooks/ | <repo>/.claude/settings.json | <repo>/.claude/agent-deadline.json |
| Global | <config dir>/hooks/ | <config dir>/settings.json | <config dir>/agent-deadline.json |
<config dir> is $CLAUDE_CONFIG_DIR when set, else ~/.claude. State lives in the OS temp dir under brewtools-agent-deadline/<session_id>/, never under the config dir.
The guard reads the nearest valid project config first (a JSON object in .claude/agent-deadline.json, walking up from the subagent’s working directory, at most 16 levels), then the global one; a malformed project config is skipped. Global writes go through Bash only, because the config dir is a protected path for Write/Edit.
Config shape #
Example: {"enabled": true, "defaultMinutes": 20, "byAgentType": {}, "hardStopRatio": 2} plus the provenance keys below.
| Key | Meaning |
|---|---|
enabled | Exactly true; anything else turns enforcement off |
defaultMinutes | Budget for every agent type; default 20 |
byAgentType | Per-type overrides, e.g. {"Explore": 10}; empty = one limit |
hardStopRatio | Optional, default 2, must be > 1 |
readOnlyAgentTypes | Optional, default ["Explore", "Plan"]; a list replaces the default, add it by hand |
version / content_version / generated_by / last_updated | Provenance; freshness is judged by content_version (header of agent-deadline-guard.mjs) |
Budget is byAgentType[agent_type] ?? defaultMinutes. upgrade keeps defaultMinutes, byAgentType, hardStopRatio and enabled; a disabled setup stays disabled. One scope per run.
enabled is opt-in: absent or not true means OFF, unlike agent-router-setup and brewdoc:docsync-setup.
Governing config after uninstall project #
uninstall project keeps .claude/agent-deadline.json. While the global scope still registers the guard, that file keeps governing it: the project enabled and budget override global. The uninstall prints WARNING: kept <cfg> still GOVERNS ... and offers purge project.
status prints governing_config=<path> governing_scope=project|global|none orphan_config=yes|no; orphan_config=yes means a project config governs while the project has no registrations and global has some. upgrade is never offered for it, because it would re-wire the project and undo the uninstall.
| Goal | Run |
|---|---|
| Hand control back to global | /brewtools:agent-deadline-setup purge project |
| Keep the project config | Nothing; the warning is informational |
uninstall and purge remove only the state recorded for this scope’s config, plus files untouched for 24 h.
Limits: read before trusting it #
- Not a timeout. Time is sampled only at tool-call boundaries; cap long commands separately with
BASH_MAX_TIMEOUT_MS. - The clock starts at the first tool call, not at spawn. A stop does not reset it (see the cleanup hook above), so an over-budget agent blocked once by another guard can only finalize.
agent_typefor plugin agents is unverified (brewcode:skill-creatorvsskill-creator). A non-matchingbyAgentTypekey silently falls back todefaultMinutes.- Fail-open: any hook error lets the call through.
- Cost on every tool call, main session included. The matcher is
.*because the guard must seeSubagentHandback. Measured on one Apple M-series machine (Node v24.1.0, 30 runs): median 58.3 ms, p90 62.5 ms. A global install charges this in every session; re-measure before relying on it.
Provenance keys and version checks: see Artifact metadata.
Related
Brewtools overview
All brewtools skills and agents.
Agent Return Setup
Size budget for subagent final returns; installs side by side with this skill.
Setup Status
Dashboard across every -setup skill; upgrade brings the stale ones current.
GitHub source
SKILL.md, the install runbook and both hook scripts.
Update: /brewtools:plugin-update, /reload-plugins, then /brewcode:setup-status upgrade - FAQ