Hooks inject the context every session must read, and the read gate denies work until the agent has read it.
Settings: Settings § Context system; per-session switches: Permissions § Approvals.
Three hooks inject context; the read gate makes reading it binding.
| Hook | Runs on | Does |
|---|---|---|
| cmd/globalcontext | SessionStart, SubagentStart (wired in settings.json) | Injects always-read global content: what every session needs that belongs neither in AGENTS.md nor in a skill's acdsl-context: declaration. |
| cmd/skillcontext | A skill invocation | Injects an entry's body once per agent; a repeat invocation or an overlapping skill gets only ids, from the context records the hook keeps in the agent's read ledger. |
| cmd/readgate | PreToolUse; its ledger fills on PostToolUse | Denies gated calls until the required reading is done, making the injection files binding. |
| cmd/planmodecontext | UserPromptSubmit and after every tool call | Injects the plan-format rules while in plan mode. |
~/.claude/context/global/*.md, then <cwd>/<context-dir>/global/*.md (company facts, for example); the hook is silent when both are absent or empty. Context entries with Reach: always are the authored source of machine-global content: cmd/rules pack, the install engine's context component and every context deploy render them into ~/.claude/context/global/always-context.md.
Claude Code caps hook output at 10,000 characters and passes only a 2KB preview of anything longer, so content over 9,000 bytes goes to ~/.claude/context-required/<session>/global.md behind an injected pointer. The skill-context hook writes large skill context to the same dir as <skill>[--<slice>]--<agent>.md, appended per invocation.
On PreToolUse it denies Bash, Read and Write class calls (the tool classes of the toolpolicy section of ~/.claude/hooks/config.json) until the agent has read in full everything it owes; other tools pass.
| Owed | When |
|---|---|
| Language guides | Every guide whose glob matches a file the call touches. |
| Required reading | Under context-required/<session>/: every agent, root or subagent, owes global.md plus its own injection files of the skills it invoked (a typed /<skill> prompt for the root, a Skill call for any agent). |
| Review manifests | A review lane's manifest files. |
| Rule | Detail |
|---|---|
| A denied guide stays owed | A guide denial leaves a guide record in the agent's ledger: the guide is then owed on every gated call, whatever it touches, and only Reads of the agent's required readings pass until it is read in full. |
| Ledger | Per agent under ~/.claude/read-gate-state/ (internal/readledger), filled on PostToolUse from what the harness actually returned: a Read cut short by the token cap owes the rest. |
| Chunking | Deny and pointer Read lines are chunked to the 55 KB budget that rules validate (so make audit) enforces on every language guide and the always pack. |
| Compaction, /clear | The next SessionStart drops the root's read records, pending guides and inline context records, so everything is owed again; invocations and context records with an injection file stay. |
Plan mode is switched on in the UI; the tool-policy gate denies EnterPlanMode. While it is on, cmd/planmodecontext writes the plan-format rules of the repo's context index to ~/.claude/context-required/<session>/planmode.md and injects a pointer once per plan-mode stretch; the root agent owes that file to the read gate. The first event outside plan mode removes it.
Every hook reads its section of ~/.claude/hooks/config.json, rendered by the install from the context.* settings (caps, budgets, banners, pointer texts, patterns): set them on the Config page's Smine tab or with smine-rules settings set context.<key> <value>.
The context dir, context.context_dir, is unset by default. Unset, each hook falls back and names the setting in one line:
| Hook | Without a context dir |
|---|---|
| globalcontext | Injects only ~/.claude/context/global/*.md, appending the line. |
| planmodecontext | Injects nothing; answers the line in plan mode. |
| skillcontext | Answers the line instead of a skill's context, unless SKILL_CONTEXT_INDEX names an index. |
| readgate | Owes nothing, allows every call, logs the line at session start. |
SKILL_CONTEXT_INDEX and SKILL_CONTEXT_MAP stay process environment (eval arms set them), in skillcontext and skillinvokegate alike.
For every session, park the hook group on the Hooks tab (hooks.disabled.json); the Context page's global-context toggle parks and unparks the two global-context groups. There are no env-file kill switches.
For one session, touching no file, type #disable <word…>: off from the next hook event; #enable turns it back, #reset clears every switch.
| Word | Switches off |
|---|---|
| inject:global, inject:skill, inject:plan, inject:acdsl, inject:env | The injections; inject:env also the skillenv check of an invoked skill's required repo values. |
| rgate:global, rgate:invoked, rgate:plan, rgate:<ext|guide> | What the read gate owes: rgate:go drops every guide covering .go files, rgate:go_test that guide alone. |
| skill:invokegate | The skill invoke gate. |
| rgate (a bare group word) | Every member of the group. |
Full grammar: Permissions § Approvals; /smine-help prints the full list.
ACDSL (Agentic Context Domain Specific Linter) makes repo conventions machine-verifiable; its rules live in acdsl/rules.acdsl.
| Piece | Rule |
|---|---|
| Delivery | In a session the Read hook delivers a governed file's rules as additional context; the file on disk is never touched. |
| Projection | acdsl project -file writes the same rules as a header block for consumers outside Claude; make audit, the pre-commit guard and acdsl check strip or refuse such blocks. |
| Fixtures | 44 of the 48 rules carry pass/fail fixtures, run in make audit and make test. |
| Red rates | Every gate run logs to ~/.claude/acdsl/verdicts.jsonl; the config server's context page shows each rule's red rate per delivery arm (delivered or gate-only). |
| Deploy | When a context sync writes to a target repo with "sync acdsl" on, the deploy engine ships the reach-covered gate slice (rules, registry subset, policy, prebuilt bin/acdsl + verifier binaries); the deployed read hook activates it automatically. |
The gate, its commands and the loop around it: Context Linting. The full specification: acdsl-spec.pdf.