What is a hook, and how do I give Irene a house rule?

A hook is a house rule that runs by itself at a set moment: when a chat begins, every time you send a message, before or after a tool runs, when a turn ends, and more. It's a small script on your computer (or a quick model check) that can add a reminder, rewrite a tool's inputs, block a call, or answer an approval for you. It never depends on the agent remembering to follow it. Irene's hooks use the same format as Claude Code's, so the hooks you already have work as they are.

What makes it different

what it does the primitive behind it what that buys you
Rules that don't rely on memory A hook is wired to a moment in the run (a tool about to run, a message arriving), not written into a prompt A rule in a prompt is a request the model can forget halfway through a long job. A hook runs every time
No model, no cost A command hook is a plain script on your computer A rule that fires on every turn costs nothing in usage. It only costs whatever text it adds to the conversation
Steers the call, not just the chat Before a tool runs, a hook sees the tool's name and exact inputs and can allow, deny, ask, or rewrite them You can refuse rm -rf on every agent, or pin every search to one site, without touching a single prompt
Claude Code compatible Same events, same settings shape, same JSON in and out, same exit codes Copy a hook you already use; plugins built for Claude Code bring their hooks along
Scoped per agent Each hook can apply to all agents or only the ones you pick A coding rule doesn't fire on your Slides agent
Can't break a chat A hook that crashes, can't start or takes too long is skipped A broken rule costs you the rule, never the turn
Nothing runs unseen Capabilities → Hooks lists every hook with its exact command You can see everything that runs on your computer, and where it came from

How it works

The moments a hook can fire on

event label in the app fires… what a hook can do there
SessionStart Every time a chat begins on the first turn of a new chat add context the agent sees from the start
UserPromptSubmit Every time you send a message before your message reaches the agent add context, or refuse the message
PreToolUse Before a tool runs after the inputs are ready, before the approval gate allow, ask or deny the call, or rewrite its inputs
PostToolUse After a tool runs after a call succeeds replace or add to what the tool returned, or raise a notice
PostToolUseFailure When a tool fails when a call errors react to the failure
Stop When Irene finishes a turn at the end of a turn that said something raise a notice
SubagentStart · SubagentStop When a subagent starts / finishes around every helper Irene sends out; the stop carries a short piece of its result log, check or react to delegated work
PreCompact · PostCompact Before / after the context is compacted around compaction save something before it's folded away; re-add it after
Notification When Irene notifies you whenever Irene raises a notification forward it anywhere you like
SessionEnd When a chat ends when a chat is deleted, or Irene shuts down clean up

Why a fixed set of moments: a rule belongs at one seam in the work. "Never run this command" belongs before the tool runs; "remind it about my style guide" belongs when a message arrives. Picking the moment is what makes the rule automatic.

What a hook is

A hook lives in a settings file, under the event it listens to:

{
  "hooks": {
    "PreToolUse": [
      { "matcher": "shell",
        "hooks": [ { "type": "command",
                     "command": "python3 ~/.irene/hooks/guard_shell.py",
                     "timeout": 10 } ] }
    ]
  }
}
  • matcher picks which tools it fires for: "" or * means every tool, shell|file means either, anything else is a pattern.
  • if narrows it further by the call's main input, for example shell(git push*).
  • type:
    • command: a script on your computer. No model.
    • prompt: one small model question about the event; the answer is added as context.
    • agent: hands the event to an agent and adds what it says.
  • timeout: seconds before it's given up on; 60 by default.

Where hooks are read from, in this order, all added together: 1. Irene's own (empty: nothing fires by default) 2. ~/.irene/settings.json, which holds yours, plus every plugin's 3. .irene/settings.json in the project folder 4. .irene/settings.local.json in the project folder, for rules only you use

"disableAllHooks": true in any of them turns every hook off.

What it receives and how it answers

The script gets the event as JSON on its input: the event name, the chat, the agent, and for tool events the tool's name and exact inputs (plus its result, after it runs). It answers through its exit code and what it prints:

the script… result
exits 0 and prints plain text that text is added to what the agent sees
exits 0 and prints nothing no effect
exits 0 and prints {"additionalContext": "…"} context added
prints {"hookSpecificOutput": {"permissionDecision": "deny", "permissionDecisionReason": "…"}} the call is refused, and the agent is told why
prints "permissionDecision": "allow" the call skips your approval (see Approvals)
prints {"hookSpecificOutput": {"updatedInput": {…}}} the tool runs with the rewritten inputs
prints {"continue": false} the turn stops
exits 2 blocked, with what it printed as an error as the reason
crashes, can't start, or times out skipped; the turn carries on

When several hooks match, they run in order. A rewrite from the first is what the second sees. Deny beats ask, and ask beats allow.

Why a refused tool call doesn't end the turn: the agent is told the call was refused and why, so it can choose another way. Ending the whole turn would throw away the work around it.

Why "fail open": a hook runs on every matching moment of every chat. If a broken one could stop turns, one typo would freeze Irene everywhere. Blocking always has to be a deliberate answer from the script.

What a hook runs with

  • Your computer's permissions. A command hook is a program you run. Irene strips its API keys and secrets from the environment, but the script can still read your files and reach the internet. Only add hooks you'd run yourself.
  • What it sees can include your messages, a tool's inputs and its results. A hook that sends these somewhere sends your conversation there.
  • The variables IRENE_SESSION_ID, the agent and the event are set for it. The CLAUDE_… ones are set too, so Claude Code scripts find what they expect.

How hooks are added

way how
Ask Irene "Make it a rule: never push to main without asking me." Irene writes the script, tests it by hand on a sample event, then adds it to ~/.irene/settings.json, keeping every hook already there
Dreaming offers one When you've corrected the same behaviour more than once in a chat, dreaming may offer a hook instead of a skill or recipe. Why only then: one correction is a preference for this job; two is a rule. A hook is the only shape that enforces it
A plugin brings one Installing a plugin with hooks always asks "These scripts run on your machine — who do they apply to?", and Install stays off until you choose the agents
By hand Edit ~/.irene/settings.json (or a project's .irene/settings.json). Hooks from Claude Code paste in as they are

Before writing a hook, Irene reads its built-in skill building-hooks: the events, the in-and-out contract, a worked "guard destructive shell" example, and five golden rules. You can read it in Capabilities → Skills. The golden rules: 1. It runs every time, so keep it fast and free of side effects. 2. Match narrowly: name the tool you mean. 3. Read before you write: a settings file that's overwritten or broken stops every hook. 4. Prove it first by feeding it a sample event by hand. 5. A rule you can't remove isn't finished.

To remove a hook, ask Irene, or take it out of the settings file. Plugin hooks are removed by uninstalling the plugin.

Real ones, and why Irene turns its own off

Irene puts its hook scripts in ~/.irene/hooks/ and turns none of them on. Two, one shipped and one retired, show what a good hook looks like, and why the bar is high:

building-a-site/announce.sh (start of a chat, 10-second limit). It reminds the agent that it can publish a static site to a real address, that it should render a page and look at it before saying it works, and that a site reviewer should check it before it goes live. Why it exists: an agent that doesn't know it can publish hands back a folder of files instead of a link, and nothing errors. You just get less.

writing-tools/notice-repetition.py (after a tool runs, shell commands only; retired from Irene's set in September 2026): - it reduces each command to its shape (git log -n 5 and git log -n 50 are the same work) and counts them for the chat - on the third time, it tells the agent once that a tool "usually pays for itself" there, and points it at the skills for building one, adding "skip this if the repetition was incidental" - it never blocks, speaks once per command per chat, and stays silent on any error - why only shell: repeating read_file means nothing, but repeating git log --oneline | head means a tool is missing. Watching every tool would cry wolf, "and a hook that cries wolf gets turned off"

Why they're off by default: a hook taxes every turn of every chat. The tool-building reminder cost 194 tokens at the top of every chat to say what four skills already say when they're read. The repetition nudge ran on every shell command and wasn't worth it, so it was retired. So Irene comes with no hooks firing, and you turn one on only when it's worth its cost: ask Irene to "turn on the site-publishing reminder".

Approvals

  • Adding, changing or removing a hook always asks you, even in auto mode. Irene's settings are in the class auto mode can never open. Why: a hook can approve things for you, so an agent that could write hooks could hand itself permissions. Irene can never change its own permissions.
  • Installing a plugin with hooks asks which agents they apply to before anything installs.
  • A hook that answers "allow" skips your approval card, but never past the floor: payments, keys leaving your computer and the other always-held actions still come to you. Workflows never take a hook's "allow".
  • You can switch this off per chat. /permissions lists, under Skipping the gate without you asking, each plugin that can approve tools for you ("The superpowers plugin can approve tools before you are asked"). Stop it turns that off for the chat, and it stays off after a restart.
  • A hook's "deny" always wins, even over things you've trusted. Why: a house rule should hold even when you've said "always allow" to a tool.

→ Approvals & auto mode

Where you see it

Capabilities → Hooks shows every hook, grouped by when it fires ("Before a tool runs", "Every time you send a message"…):

  • the exact command, "so nothing runs on your machine unseen"
  • where it came from: Irene, yours, or the plugin's name
  • its matcher, and a warning if a script it points to is missing
  • who it applies to: All agents ▾ opens a list of your agents to narrow it

With none, it reads: "No hooks yet — Irene comes with none, and a hook is added when a plugin brings one or one is written by hand."

The tab is for seeing and scoping. Adding and removing happen through Irene, a plugin, or the file.

What it costs

hook type cost
command nothing: it runs on your computer. Text it adds becomes part of the conversation, like anything else the agent reads
prompt one small model call each time it fires, at what we pay + 20%
agent a helper run each time it fires

No plan gate. Every hook adds a little time to the moment it fires on, which is why fast scripts and narrow matchers matter.

Limits

  • Hooks run on your computer, in the app. They don't travel with an agent deployed to the cloud, or inside a share bundle.
  • A hook that fires before a tool runs can't undo one that already ran. After a tool runs, a hook can change what the agent reads back, not what happened.
  • "Block" at the end of a turn only raises a notice; the turn has already happened.
  • Up to 100 items of any list in a tool's inputs or result are passed to a hook.
  • Only command, prompt and agent hooks run. Claude Code's http and mcp_tool hook types are skipped.

[Ask Irene about this]

Updated