# Setup  -  Enforcement hooks (Step 8) and stack plugins (Step 9)

> Loaded by `setup/SKILL.md` Steps 8 and 9. The SKILL keeps what is offered and the commands; this file carries the merge rules for the hooks template and how the stack answer is read. Read it before Step 8.

## Step 8  -  Hook merge rules

The template carries three blocking `PreToolUse` gates (secret scan, agent-guard, read-size), non-blocking hooks on `PreCompact`, `SessionEnd`, `SessionStart` and `PostToolUse`, and a `Stop` hook (`run-stop-guard.sh`) that holds a session from stopping mid-run. What each does: `$HOME/.claude/multi-agent-refs/picker-contract.md`. Copilot CLI gets no hook: it discards `postToolUse` output as of 1.0.45.

- Ask (picker): "Install the pipeline's hooks into `~/.claude/settings.json`?" Default Yes.
- On Yes, deep-merge EVERY event in the template's `hooks` object (merging `PreToolUse` alone drops the capture hooks); keep existing hooks, never duplicate a matcher calling the same script.
- Say only the three gates are hookable (no run-specific arguments); the rest are phase-enforced.
- Say the read-size gate stays inert until `prefs.global.bulkRead.mode` is set; recommend `observe` first (why, and the Phase 3 exemption: `picker-contract.md`).

## Step 9  -  Reading the stack answer

Ask the detector, then derive. No marker list here: a second list is a second
answer, and it drifts from the detector.

Report `MA_STACK_WHY` with the result. `ai-common-toolkit` and
`ai-analyst-toolkit` are in every answer, the empty one included: neither is
stack-specific. **No marker matched is an answer** - those two, not a guess.
A name the marketplace does not carry is dropped with `dropped[]` naming it,
so a toolkit that was never shipped is caught before it fails to load.

The marketplace repo name (`multi-agent-plugins`) is generic; a different org points `{owner}` at its own fork, and nothing in the pipeline is coupled to a specific account.
