Skip to content
Apothem
リファレンス

フック

SessionStart、PreToolUse、Stop で発火するツールイベントハンドラ。git 隔離と計画規律を強制するメッセージコンテキストを読み込みます。

フックはツールイベントで発火し、アシスタントが追加のシステムプロンプトとして扱う メッセージコンテキストを読み込みます。配線は Claude Code の settings.json フックブロック、 Codex の hooks.json フックファイル、Qwen Code の settings.json フックマップに 存在します。

イベントタイムアウト目的
SessionStart30 秒メモリの読み取り、計画状態の確認、準備完了の報告
PreCompact30 秒圧縮前に状態が外部化されていることを検証
PostCompact30 秒圧縮後に作業状態を復元
Stop60 秒セッション終了時の外部化
PreToolUse (Bash)10 秒Bash の検証 — git 成果物の隔離
PreToolUse (Write/Edit/NotebookEdit/apply_patch)10 秒計画参照の隔離、frontmatter のチェック

ディスパッチャ

インストールされたフックエントリは、絶対スクリプトパスでディスパッチャを呼び出します。 設定テンプレートは ${HARNESS_ROOT} トークンを保持し—— python "${HARNESS_ROOT}/apothem/hooks/dispatch.py" <event> [<message-name>] ——インストーラはインストール時にこれを harness ルートの実パスへとレンダリングします (Claude Code と Qwen Code はディスパッチャを <harness-root>/apothem/hooks/ の下に、 Codex は <harness-root>/hooks/ の下に具現化します)。ディスパッチャは自己完結型の 標準ライブラリスクリプトです。自身の sys.path をブートストラップするため、 ホスト上にインポート可能な apothem パッケージは不要です。ソースチェックアウトからは、 モジュール形式 python -m apothem.hooks.dispatch <event>PYTHONPATH=src 付き)が 開発用に同じコードを実行します。ディスパッチャはエコシステムルートの解決のために hooks/lib/resolve_root.py を読み込み、hooks/emit_hook_context.py および hooks/session_start_bootstrap.py に委譲します。

メッセージコンテキスト

イベントごとの Markdown コンテキストは src/apothem/hooks/messages/ の下に存在します。

  • postcompact.mdprecompact.mdstop.md
  • pretooluse-bash.mdpretooluse-write.mdpretooluse-edit.mdpretooluse-notebookedit.md

各コンテキストファイルは、そのイベントが発火し、そのコンテキスト引数が設定ファイルに 登録されているときに、ディスパッチャによって読み込まれます。

生成されたフックメッセージのインベントリ

NameDescriptionSource
postcompactPost-compaction Blind Bootstrap (CM-24 §6.2). Restore working state from durable files; conversation context is now compressed.src/apothem/hooks/messages/postcompact.md
posttooluse-proactive-compactionProactive-compaction tracker for PostToolUse tool calls.src/apothem/hooks/messages/posttooluse-proactive-compaction.md
precompactPre-compaction protocol (CM-24 §2.3). Externalize all in-conversation state BEFORE the harness compresses context.src/apothem/hooks/messages/precompact.md
pretooluse-askuserquestion-recommendedCall-time (Recommended)-marker guard for AskUserQuestion tool calls.src/apothem/hooks/messages/pretooluse-askuserquestion-recommended.md
pretooluse-bash-plan-guardPlans-Discipline write guard for Bash tool calls (companion to pretooluse-write-plan-guard.md).src/apothem/hooks/messages/pretooluse-bash-plan-guard.md
pretooluse-bashCM-7 git-artifact isolation + M12 numeric-prefix discipline + M15 human-only authorship.src/apothem/hooks/messages/pretooluse-bash.md
pretooluse-conformity> Advisory: this hook reports; it does not block. Mechanical enforcement runs in CI.src/apothem/hooks/messages/pretooluse-conformity.md
pretooluse-dependency-guardDependency-manifest supply-chain guard (advisory).src/apothem/hooks/messages/pretooluse-dependency-guard.md
pretooluse-edit-header-guardSPDX-header inject guard for Edit tool calls.src/apothem/hooks/messages/pretooluse-edit-header-guard.md
pretooluse-editCodebase isolation (Edit scope).src/apothem/hooks/messages/pretooluse-edit.md
pretooluse-eval-guardDynamic-eval / unsafe-deserialization guard — advisory prompt-injection defense.src/apothem/hooks/messages/pretooluse-eval-guard.md
pretooluse-notebookeditCodebase isolation (notebook scope).src/apothem/hooks/messages/pretooluse-notebookedit.md
pretooluse-write-header-guardSPDX-header inject guard for Write tool calls.src/apothem/hooks/messages/pretooluse-write-header-guard.md
pretooluse-write-plan-guardPlans-Discipline write guard for Write / Edit / NotebookEdit tool calls.src/apothem/hooks/messages/pretooluse-write-plan-guard.md
pretooluse-writeCodebase isolation + frontmatter compliance.src/apothem/hooks/messages/pretooluse-write.md
sessionstartSession-start conformity posture.src/apothem/hooks/messages/sessionstart.md
stopSession-end protocol (CM-14 + CM-24 §2.5 + CM-26 + CM-22 §2/§4).src/apothem/hooks/messages/stop.md

On this page