Hook framework for AI agents

AI agents that
don't cut corners

One manifest of TypeScript hooks installed across Claude Code, Cursor, Gemini CLI, and Codex CLI. The same rules enforce the same discipline — before tools run, after they complete, and before a session is allowed to stop.

$ bun install && bun link
Read the docs →
107
Hooks
TypeScript scripts sharing a common utility layer
12
Event types
Every moment in the agent loop is covered
4
Agents
Claude, Cursor, Gemini CLI, Codex CLI
0
Compromises
Rules apply to every agent, every time
The agent loop

Hooks fire at every stage

swiz intercepts the agent loop at four key moments. Hooks can inject context, block tool calls, validate results, and refuse to let the session end until every quality gate passes.

Trigger
User prompt
Inject git state, active tasks, and session context before the agent reads the message
Pre-tool
Before tool use
Block dangerous operations — secret commits, lint bypasses, force pushes, task-free edits
Post-tool
After tool use
Validate results, run tests, remind about failing CI, track task progress
Gate
Stop
The last line of defence — blocks the session until uncommitted changes, failing CI, and open tasks are resolved
Core capabilities

Built-in disciplines agents forget

Hooks enforce standards that agents consistently skip when left to their own judgment.

🛑
Stop hooks that mean it
24 stop hooks audit uncommitted changes, failing CI, unresolved tasks, stale branches, open PRs with review requests, and secrets in diffs — and block until every issue is resolved.
🔒
Pre-tool gatekeeping
Block @ts-ignore, eslint-disable, force pushes, credential leaks, and workflow permission escalations before they ever execute.
🌐
Cross-agent, one manifest
Tool names, event names, and config formats differ across agents. swiz translates automatically at install time. Write once, enforce everywhere.
Task-driven enforcement
Agents must create tasks before editing code, keep them updated every ten tool calls, and supply real evidence before marking anything complete. No faking done.
🔁
Self-directed loop
swiz idea and swiz continue together create a closed loop — the agent's own outputs become the next inputs, expanding the project without external prompts.
Daemon-backed dispatch
A long-lived Bun server handles hook dispatch, git state caching, CI polling, and issue sync simultaneously across projects — hooks respond in milliseconds.
107 hooks

What gets enforced

Every hook is TypeScript, shares utilities from a common layer, and produces polyglot JSON that every supported agent understands.

Stop (24)
last line of defence
  • Uncommitted changes & unpushed commits
  • Failing or in-progress GitHub Actions CI
  • Secrets in staged diffs
  • Open PRs with change requests
  • Incomplete tasks without evidence
  • TODO / FIXME in new code
  • Lockfile drift after package.json edits
  • CLAUDE.md / MEMORY.md over threshold
PreToolUse (44)
block before execute
  • No tasks before editing files
  • Secret / credential patterns
  • eslint-disable & @ts-ignore
  • Force push to main
  • Workflow permission escalations
  • Offensive language patterns
  • Repeated lint / test runs
  • Commit without /commit skill
PostToolUse (24)
validate after execute
  • Test failure detection
  • Auto-steer on drift
  • Task output streaming
  • Narrator TTS for assistant text
  • JSON file validation
  • Git status context injection
UserPromptSubmit (6)
context injection
  • Git status & branch state
  • Active task list
  • Memory size warnings
  • Session context summary
SessionStart (4)
session bootstrap
  • Prior session task recovery
  • Daemon startup check
  • Environment validation
PreCompact + others (5)
lifecycle
  • Compaction guard
  • Subagent convention injection
  • Notification routing
Agent support

Every agent, same rules

swiz translates tool names and event names at install time. Hook scripts never need to know which agent triggered them.

Claude Code
Nested matcher groups in ~/.claude/settings.json. Full support across all 5 event types.
Full
Cursor IDE
Flat list format in ~/.cursor/hooks.json (version 1). All events fire in the IDE.
Full
Gemini CLI
Nested matcher groups in ~/.gemini/settings.json. Full support across all 5 event types.
Full
Codex CLI
Tool mappings fully tracked. Ready to activate when Codex ships user-configurable hook support.
Ready
Autonomous operation

The self-directed loop

When swiz idea and swiz continue are used together, the agent's own outputs feed back as the next inputs — creating a closed loop that expands the project without external prompts.

Agent completes work
swiz stop hooks audit
swiz idea generates next step
swiz continue resumes
Agent works again
Hooks enforce quality at every turn. The loop only advances when the previous step is actually done.
Get started in two commands
Requires Bun. After install, run swiz install to write hooks into your agents, and swiz status to verify.
# clone and link globally $ bun install $ bun link # install hooks into your agents $ swiz install $ swiz status