> ## Documentation Index
> Fetch the complete documentation index at: https://docs.driftless.icu/llms.txt
> Use this file to discover all available pages before exploring further.

# Auto-pull (experimental)

> A deterministic Claude Code hook that injects reviewed context before every edit: the gate paying off.

The skill *asks* the agent to pull context before editing (UC1). **Auto-pull** makes it deterministic: a Claude Code **PreToolUse hook** injects the team's **reviewed System context** for a file *before every edit*, so no one has to remember.

<Note>
  Experimental, and **Claude Code only** (hooks are a Claude Code feature). Off by default.
</Note>

## How it works

```text theme={"theme":"github-light"}
1. You go to edit src/billing/refund.ts
2. Claude Code fires the PreToolUse hook → driftless hook pre-edit   (always, deterministic)
3. The glue checks the workspace toggle. Off → no-op, exits.
4. On → it matches topics for the file and injects ONLY reviewed
   System context (gotchas / invariants / decisions) as additionalContext
5. The agent edits already knowing the team's rules, not blind
```

The agent never *chose* to pull. The editor did it. That's the difference between a skill (the agent *should*) and a hook (it *happens*).

## Two switches, by design

The hook is **installed locally** but **controlled remotely**:

* **Installed** by `driftless install-skill` into the repo's `.claude/settings.json`. It stays there, inert.
* **Activated** by a workspace admin at **Settings → Automations**, a single toggle (`settings.auto_pull_context`). The glue reads it on each run (cached \~60s), so flipping it off makes the hook a no-op for the **whole workspace**, without anyone touching a local file.

To remove the hook from a machine entirely, run `driftless hooks disable` there.

<Note>
  `hook` and `hooks` are two different commands, not a typo. `driftless hook` is the runtime glue Claude Code invokes (`pre-edit`, `post-edit`, `stop`, `sync`); you never run it by hand. `driftless hooks` is the management command (`enable` / `disable`) that installs or removes the hook entries in `.claude/settings.json`.
</Note>

## Why it's the payoff of governance

Only Knowledge (`reviewed`) topics auto-inject. A Note is a hint, not the team's truth, so it never reaches the agent automatically. This is why **adding a note to knowledge is literally what makes your agents start coding with it.** The owner/admin decision and the hook are the same loop: review → merge (by an owner/admin, or an agent they ask) → the hook delivers it → the agent gets it right.

## Cost & safety

Built so it can't run away with your tokens or block your editor:

* **Reviewed + System only.** Drafts and early-stage notes never inject.
* **Deduped per session.** Edit the same area five times → its context injects once, not five.
* **Size-capped.** A signal-first brief under a fixed \~2k-token budget: every matched topic's invariants and gotchas come before any topic's decisions, drawn round-robin so one verbose topic can't crowd out the rest. Never the whole topic.
* **No-op on miss or slowness.** No matching reviewed topic, or a slow API → nothing injected.
* **Never blocks.** The hook always exits cleanly; a failure can't stop your edit.

Combined with prompt caching (the injected prefix is cheap to re-send), a deduped brief costs cents over a session, not dollars.

## Turn it on

```bash theme={"theme":"github-light"}
driftless install-skill         # installs the hook (inert)
# then: dashboard → Settings → Automations → toggle ON
driftless hooks disable         # remove the hook from this machine entirely
```
