Skip to content
BENIBIX Learn

Setup Hook

AI⌨️ Claude CodeConfiguration

Also known as Setup

An event that fires only on a set-up run.

Think of it like

It is like you set up a tent once. You do it before the camp starts.

Example

Lucy's CI job runs claude --init-only before the real work. Her Setup hook installs the packages once.

Why it matters

It keeps slow, one-off setup out of the hooks that run every session.

Definition

Setup is the hook event that fires only on a set-up run. That is a start with --init-only, or a -p run with --init or --maintenance. It never fires on a normal start. The matcher is init or maintenance. Use it for one-time jobs, such as installing packages in CI. Keep those apart from the hooks that run each session.

Example code

json
{
  "hooks": {
    "Setup": [
      { "matcher": "init", "hooks": [{ "type": "command", "command": "npm ci" }] }
    ]
  }
}
Install packages on an init run only.

Common mistake

Expecting it to run when you just type claude. It only runs with those flags.

Key takeaways

  1. 1
    Only with flags. --init and more.
  2. 2
    Two kinds. init, maintenance.
  3. 3
    Cannot block. Runs and moves on.

Compare