Hooks & Pre-Write Checks
How Septum's pre-write hook and Git pre-commit check validate imports before edits land.
septum init can scaffold editor/agent pre-write hooks and a Git pre-commit hook (septum check --staged) while preserving your existing unrelated hooks.
Pre-Write Hook (septum hook pre-write)
septum hook pre-write reads a JSON edit payload from stdin, reconstructs the proposed file content, extracts its imports, and checks them against the module rules stored in .septum/septum.db.
- Supported payload formats: Full file content (
content/CodeContent), targeted string replacements (old_string/TargetContent), multi-chunk edits (edits/ReplacementChunks), and Codexapply_patchdiffs. - Exit codes & client modes:
- Policy violations exit with code
1(or2when passed--exit-code-2,--claude,--cursor,--codex, or--opencode). - Default mode prints
{"decision": "deny", "reason": "..."}tostdout; client flags (--claude,--cursor,--codex,--opencode) write the reason tostderrsostdoutstays clean. - If
.septum/septum.dbdoes not exist or the file is outside any mapped module, the hook exits0without blocking.
- Policy violations exit with code
- Scope limits: The pre-write hook checks proposed import rules only—not full dependency cycles or runtime behavior. Use
septum_boundaryorseptum check --stagedfor full audits.
Git Pre-Commit Check
The generated Git pre-commit hook runs:
septum check --staged
- In
warnmode (default),septum checkreports violations and exits0(advisory). - In
strictmode (septum check --staged --strict), violations, unresolved imports, or unindexed workspaces exit1and block the commit.
Index Freshness & Watcher
While the MCP server is running, Septum's built-in file watcher keeps .septum/septum.db updated in-process—so default harness configs do not need a separate PostToolUse shell hook. For CLI-only workflows, septum-post-write.sh is still available and coalesces bursts using .septum/sync.lock.