Available in
Marketplaces, most starred first
Tags
Add to README
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
By johnlindquistv1.0.0MIT
Build your own Claude Code session-hook plugin by forking this template and editing its hook scripts. The bundled hooks fire on every prompt and tool call as shipped.
Trending plugins
7-day copy clicks
Run automatically on Claude Code events. Claude doesn't decide.
1 critical · 2 cautions to review before installing
A hook runs before every tool call and can block or approve it
A hook runs when Claude uses the Bash tool
A hook runs when Claude writes or edits files
Static checks of hooks, mods, MCP servers and commands. Not a security audit.
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
A template for creating Claude Code session hook plugins. Fork this repo to build your own custom session behaviors.
Claude Code plugins can hook into various session events to:
This template provides ready-to-use hook scripts for all major hook types with extensive documentation and examples.
Fork/Clone this template
# Clone the template
git clone https://github.com/johnlindquist/claude-session-hooks-template.git my-plugin
cd my-plugin
# Install dependencies
bun install
Customize the plugin
package.json and .claude-plugin/plugin.json with your plugin namescripts/ for your use caseSTATE_FILE_PREFIX in src/state.tsInstall and test
# Install as local plugin
claude plugin install . --scope local
# Test your changes
claude # Start a session and try your hooks
| Hook | File | When It Fires |
|---|---|---|
| SessionStart | scripts/SessionStart.ts | When a session begins |
| UserPromptSubmit | scripts/UserPromptSubmit.ts | On every user prompt |
| Stop | scripts/Stop.ts | When Claude tries to stop |
| PreToolUse | scripts/PreToolUse.ts | Before any tool executes |
| PostToolUse | scripts/PostToolUse.ts | After a tool completes |
┌──────────────────────────────────────────────────────────────┐
│ Claude Code Session │
├──────────────────────────────────────────────────────────────┤
│ │
│ SessionStart ─────► User types prompt │
│ │ │
│ ▼ │
│ UserPromptSubmit ◄───── Inject context? │
│ │ │
│ ▼ │
│ Claude processes... │
│ │ │
│ ┌───────┴───────┐ │
│ ▼ ▼ │
│ PreToolUse (No tools) │
│ │ │ │
│ ▼ │ │
│ Tool executes │ │
│ │ │ │
│ ▼ │ │
│ PostToolUse │ │
│ │ │ │
│ └───────┬───────┘ │
│ ▼ │
│ Stop ◄───── Block? Allow? │
│ │
└──────────────────────────────────────────────────────────────┘
File: scripts/SessionStart.ts
Fires when a Claude Code session begins. Use it to:
Input fields:
session_id - Unique session identifiersource - Why session started: "startup" | "resume" | "clear" | "compact"cwd - Current working directoryOutput options:
additionalContext - Text to inject into the conversationFile: scripts/UserPromptSubmit.ts
Fires on every user prompt. Use it to:
Input fields:
session_id - Unique session identifierprompt - The user's prompt textcwd - Current working directoryOutput options:
additionalContext - Text to inject after the promptFile: scripts/Stop.ts
Fires when Claude attempts to stop. Use it to:
Input fields:
session_id - Unique session identifierstop_hook_active - True if another hook already blocked this stopOutput options:
decision - "block" to prevent stopping, undefined to allowreason - Message explaining why stop is blockedImportant: Always check stop_hook_active and implement a safety valve (max denials) to prevent infinite loops.
File: scripts/PreToolUse.ts
Built from public signals: copy clicks on this site, GitHub stars and activity, the README and the manifest. Not a security audit or an endorsement.
Generated from the plugin's indexed repository (johnlindquist/claude-session-hooks-template) — no native marketplace selected
npx claudepluginhub p/johnlindquist-session-hooks-templatePlugins from other owners that cover similar ground