claude-session-hooks-template AGENTS.md

claude-session-hooks-template AGENTS.md is an instructions file for Codex, OpenCode from johnlindquist/claude-session-hooks-template. It costs 1,453 tokens per session, scanned C, original, MIT.

A starter repository for building Claude Code session-hook plugins. Hooks are TypeScript scripts that receive JSON, run when events such as prompts or tool calls occur, and return JSON.

In plain words
What is it for?
For creating actions at session start, after prompts, before or after tools run, or when a session stops.
Why use it?
It provides the event scripts, shared utilities, state storage, and configuration needed to add custom behavior to coding-agent sessions. Without this structure, each plugin would need to set up these pieces itself.

Instructions file for CodexOpenCode

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/johnlindquist/claude-session-hooks-template/agents-md
Clone the repo
git clone --depth 1 https://github.com/johnlindquist/claude-session-hooks-template

Made for: Codex, OpenCode.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for claude-session-hooks-template AGENTS.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/johnlindquist/claude-session-hooks-template/agents-md.svg)](https://agentmods.dev/instructions/johnlindquist/claude-session-hooks-template/agents-md)
Your own site
<a href="https://agentmods.dev/instructions/johnlindquist/claude-session-hooks-template/agents-md"><img src="https://agentmods.dev/badge/instructions/johnlindquist/claude-session-hooks-template/agents-md.svg" alt="Measured on agentmods" height="20"></a>
Per session 1,453 This file is loaded in full into every session.
When invoked 1,453 The same file — it is already loaded in full.
Security scan C 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.01453 $0.01453
Opus 5 $0.00727 $0.00727
Sonnet 5 $0.00291 $0.00291
Haiku 4.5 $0.00145 $0.00145

Measured 4d ago against content hash 3d2ece17b180, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade C, and why

claude-session-hooks-template AGENTS.md scanned grade C with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

Example: "Block Bash commands containing 'rm -rf'"
AGENTS.md · 226 lines

How it starts

The opening of the file, as written. The whole thing — 226 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AI Agent Instructions

This is a template repository for building Claude Code session hook plugins. When working with this codebase, your goal is to help users create custom session behaviors.

Understanding This Template

What This Template Provides

  1. Five hook scripts in scripts/:

    • SessionStart.ts - Fires when a session begins
    • UserPromptSubmit.ts - Fires on every user prompt
    • Stop.ts - Fires when Claude tries to stop
    • PreToolUse.ts - Fires before any tool executes
    • PostToolUse.ts - Fires after a tool completes
  2. Utilities in src/:

    • state.ts - Persist data across hook invocations
    • utils.ts - Common helper functions
  3. Configuration in hooks/hooks.json and .claude-plugin/plugin.json

How Hooks Work

Hooks are TypeScript scripts that:

  1. Receive JSON input via stdin
  2. Process the input
  3. Output JSON to stdout

Each hook has access to:

  • session_id - Unique identifier for the session
  • cwd - Current working directory
  • Hook-specific data (prompt text, tool name, etc.)

Common User Requests

"I want to [action] when the user [trigger]"

Pattern: Use UserPromptSubmit hook

Example: "Remind the agent to run tests when the user mentions 'deploy'"

// In scripts/UserPromptSubmit.ts
if (prompt.toLowerCase().includes('deploy')) {
  contextMessages.push('<reminder>Run tests before deploying!</reminder>');
}

"I want to block [tool] when [condition]"

Pattern: Use PreToolUse hook

Example: "Block Bash commands containing 'rm -rf'"

// In scripts/PreToolUse.ts
if (tool_name === 'Bash') {
  const command = (tool_input as { command?: string }).command || '';
  if (command.includes('rm -rf')) {
    return denyTool('Dangerous command blocked');
  }
}

"I want to require [condition] before completing"

Pattern: Use Stop hook

Example: "Require tests to pass before allowing stop"

// In scripts/Stop.ts
const state = await getState<MyState>(session_id);
if (state?.testsRequired && !state.testsPassed) {
  return blockStop('Tests must pass before completing');
}

Read the full file on GitHub · 226 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 226 lines · 1,453 tokens per session scan C 3d2ece17b180

Subscribe to this mod's changes

claude-session-hooks-template AGENTS.md is an instructions file published in the GitHub repository johnlindquist/claude-session-hooks-template (5 stars, last pushed 7mo ago), licensed MIT. It adds 1,453 tokens to every session, about $0.0073 per session on Opus 5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.