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.
npx skills add VersoXBT/claude-initial-setup --skill pre-post-hooksgit clone --depth 1 https://github.com/VersoXBT/claude-initial-setupWrote 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.
[](https://agentmods.dev/skills/versoxbt/claude-initial-setup/pre-post-hooks)<a href="https://agentmods.dev/skills/versoxbt/claude-initial-setup/pre-post-hooks"><img src="https://agentmods.dev/badge/skills/versoxbt/claude-initial-setup/pre-post-hooks/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/versoxbt/claude-initial-setup/pre-post-hooks"><img src="https://agentmods.dev/badge/skills/versoxbt/claude-initial-setup/pre-post-hooks.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00060 | $0.01269 |
| Opus 5.5 | $0.00024 | $0.00508 |
| Sonnet 5.5 | $0.00012 | $0.00254 |
| Haiku 4.5 | $0.00006 | $0.00127 |
Grade B, and why
pre-post-hooks scanned grade B 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 2mo 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.
Reads agent configuration directoriesmediumAgent snooping
.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.
Hooks live in `~/.claude/settings.json` under the `hooks` key: How it starts
The opening of the file, as written. The whole thing — 177 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Pre/Post Hooks
Claude Code hooks are shell commands that execute automatically in response to tool events. They enable validation, formatting, and guardrails without manual intervention.
When to Use
- User wants to run a command before or after a tool executes
- User asks about PreToolUse, PostToolUse, or Stop hooks
- User wants to add validation gates or blockers
- User needs to configure hooks in settings.json
- User mentions auto-running commands on file edit, git push, or session end
Core Patterns
Hook Types and Lifecycle
PreToolUse --> Tool Executes --> PostToolUse
|
(session ends)
|
Stop
- PreToolUse: Runs before a tool call. Can block execution by returning a non-zero exit code.
- PostToolUse: Runs after a tool call completes. Used for side effects like formatting or checks.
- Stop: Runs when the agent session ends. Used for final audits or cleanup.
Hook Configuration in settings.json
Hooks live in ~/.claude/settings.json under the hooks key:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Write|Edit",
"command": "echo 'About to write a file'",
"description": "Log before file writes"
}
],
"PostToolUse": [
{
"matcher": "Edit",
"command": "npx prettier --write \"$CLAUDE_FILE_PATH\"",
"description": "Auto-format after editing JS/TS files"
}
],
"Stop": [
{
"command": "echo 'Session ended'",
"description": "Log session end"
}
]
}
}
Matcher Patterns
The matcher field filters which tool triggers the hook. It matches against tool names:
{
"matcher": "Edit",
"command": "..."
}
Common tool names to match:
Write— file creationEdit— file modificationBash— shell command executionRead— file readingGlob— file searchGrep— content search
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.
- 2mo ago First seen · 177 lines · 60 tokens per session scan B 745ed4594396
pre-post-hooks is a skill published in the GitHub repository VersoXBT/claude-initial-setup (4 stars, last pushed 6mo ago), licensed MIT. It adds 60 tokens to every session and 1,269 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it B with 1 finding (reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.
pre-post-hooks compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| pre-post-hooksVersoXBT/claude-initial-setup | Skill | 4 | 6mo ago | MIT | B | 60 | Claude Code |
| find-plugin-fileclosedloop-ai/claude-plugins | Skill | 122 | today | Apache-2.0 | B | 70 | Claude Code |
| timeboxed-iteratingav/skills | Skill | 29 | 20d ago | MIT | A | 239 | Claude Code, Codex |
| call-a-person23blocks-OS/ai-maestro-plugins | Skill | 11 | today | MIT | A | 86 | Claude Code |
| xlsxsmith-network-solutions/threadknot | Skill | 9 | 12d ago | Apache-2.0 | A | 84 | Claude Code, Codex |
| pdfsmith-network-solutions/threadknot | Skill | 9 | 12d ago | Apache-2.0 | A | 88 | Claude Code, Codex |
| retroberekvolgyipeter/dotclaude | Skill | 2 | 2d ago | MIT | A | 106 | Claude Code |