Context system

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.

Global context and the read gate

Three hooks inject context; the read gate makes reading it binding.

HookRuns onDoes
cmd/globalcontextSessionStart, 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/skillcontextA skill invocationInjects 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/readgatePreToolUse; its ledger fills on PostToolUseDenies gated calls until the required reading is done, making the injection files binding.
cmd/planmodecontextUserPromptSubmit and after every tool callInjects the plan-format rules while in plan mode.

Global content

~/.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.

Large injections

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.

The read gate

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.

OwedWhen
Language guidesEvery guide whose glob matches a file the call touches.
Required readingUnder 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 manifestsA review lane's manifest files.
RuleDetail
A denied guide stays owedA 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.
LedgerPer 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.
ChunkingDeny 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, /clearThe 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 context

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.

Configuration

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:

HookWithout a context dir
globalcontextInjects only ~/.claude/context/global/*.md, appending the line.
planmodecontextInjects nothing; answers the line in plan mode.
skillcontextAnswers the line instead of a skill's context, unless SKILL_CONTEXT_INDEX names an index.
readgateOwes 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.

Switching hooks off

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.

WordSwitches off
inject:global, inject:skill, inject:plan, inject:acdsl, inject:envThe 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:invokegateThe skill invoke gate.
rgate (a bare group word)Every member of the group.

Full grammar: Permissions § Approvals; /smine-help prints the full list.

Context Linting

ACDSL (Agentic Context Domain Specific Linter) makes repo conventions machine-verifiable; its rules live in acdsl/rules.acdsl.

PieceRule
DeliveryIn a session the Read hook delivers a governed file's rules as additional context; the file on disk is never touched.
Projectionacdsl 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.
Fixtures44 of the 48 rules carry pass/fail fixtures, run in make audit and make test.
Red ratesEvery 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).
DeployWhen 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.