agent-hooks

A set of four lifecycle checks for coding agents: starting a session, preparing delegation, reviewing delegated work, and closing a session.

In plain words
What is it for?
Use it for session startup checks, delegation pre-flight, post-delegation reviews and CI checks, checkpointing incomplete work, and session logging.
Why use it?
It helps agents resume prior work, verify issue and file ownership information, run checks after delegation, and record session health and failures.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/monkilabs/opencastle/agent-hooks
Any agent
npx skills add monkilabs/opencastle --skill agent-hooks
Clone the repo
git clone --depth 1 https://github.com/monkilabs/opencastle

Made for: Claude Code, Codex.

Per session 122 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 886 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00122 $0.00886
Opus 5 $0.00061 $0.00443
Sonnet 5 $0.00024 $0.00177
Haiku 4.5 $0.00012 $0.00089

Measured 3d ago against content hash ff4a5127b780, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

agent-hooks scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

src/orchestrator/skills/agent-hooks/SKILL.md · 79 lines

How it starts

The opening of the file, as written. The whole thing — 79 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Agent Lifecycle Hooks

Conventions (not auto-triggers) agents execute at specific lifecycle points. Team Lead includes hook reminders in delegation prompts; specialists follow them in their own workflow.

on-session-start → [work loop] → on-session-end
                        ↓   ↑
               on-pre-delegate → on-post-delegate

on-session-start

# Action
1 rg -n "keyword" .opencastle/LESSONS-LEARNED.md
2 cat .opencastle/SESSION-CHECKPOINT.md (resume if exists)
3 rg -n "ERROR|FAIL" .opencastle/AGENT-FAILURES.md || true
4 cat .opencastle/agents/skill-matrix.json | jq '.bindings' — load domain skills

See HOOKS-REFERENCE.md for extended startup checks (approval polling, skill-matrix verification).


on-session-end

HARD GATE — every session gets a record in .opencastle/logs/events.ndjson, written before you yield, one per task, never batched retrospectively. Load observability-logging for the Pre-Response Quality Gate.

# Action
1 opencastle doctor
2 opencastle log --type session ...
3 Write .opencastle/SESSION-CHECKPOINT.md if work is incomplete
4 Flag for memory merge if 5+ new lessons

on-pre-delegate — Team Lead only

# Check
1 Tracker issue exists (gh issue view TAS-XX)
2 File partition clean (comm -12 <(sort agent1-files) <(sort agent2-files) = empty)
3 Upstream deps Done (gh issue view TAS-XX --json state -q '.state' = CLOSED)
4 Prompt has exact file paths + acceptance criteria
5 Prompt includes "Read LESSONS-LEARNED.md first"
6 5+ files → load context-map skill

All 6 must pass before the sub-agent is dispatched. See HOOKS-REFERENCE.md for example commands per check.

on-post-delegate — Team Lead only

# Action
1 opencastle log --type=delegation --issue=TAS-XX --status=complete
2 Run fast-review skill
3 Lint, typecheck, and test (commands via the codebase-tool slot)
4 gh issue view TAS-XX --json body -q '.body' — verify each AC met
5 If agent retried → verify lesson added via self-improvement
6 Move to Done or re-delegate; 3rd failure → .opencastle/AGENT-FAILURES.md

Read the full file on GitHub · 79 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 79 lines · 122 tokens per session scan A ff4a5127b780

Subscribe to this mod's changes

agent-hooks is a skill published in the GitHub repository monkilabs/opencastle (61 stars, last pushed 5d ago), licensed MIT. It adds 122 tokens to every session and 886 once invoked, about $0.0006 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

product-architect

Complete product development system with 64 agents and 35 frameworks. Use when the user wants to build a product, write a PRD, plan an MVP or roadmap, design an app, research a market or check whether a feature already exists or is novel, do competitive analysis, run a security audit, build a financial model, plan…

ankitjha67/product-architect · 211 tokens

codex-delegation

Use when a coding task would benefit from delegating work to Codex in the background — a deep independent second opinion, security or architecture analysis, or a parallel implementation running while the session continues. Lets Claude drive the codex companion itself (task, review, status --wait, result) without the…

zebbern/agent-collab · 74 tokens

cursor-delegation

Use when a coding task would benefit from delegating work to Cursor in the background — fast parallel implementation, scaffolding, or an everyday review running while the session continues. Lets Claude drive the cursor companion itself (task, review, status --wait, result) without the user typing /cursor: commands.

zebbern/agent-collab · 66 tokens

cursor-cli-runtime

Internal helper contract for calling the cursor-companion runtime from Claude Code.

zebbern/agent-collab · 17 tokens

cursor-prompting

Internal guidance for composing cursor-agent prompts and picking models for coding, review, diagnosis, and research tasks inside the Cursor Claude Code plugin.

zebbern/agent-collab · 31 tokens

goal-runner

Use when the user asks to advance, continue, or work on the project's long-horizon goal (or to set one up) — the policy for goal-driven increments driven through the goal companion, one increment at a time, delegated via the codex/cursor delegation skills, honestly recorded.

zebbern/agent-collab · 62 tokens