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 agentmods add skills/versoxbt/claude-initial-setup/pre-post-hooksnpx 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.svg" alt="Measured on agentmods" 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 | $0.00060 | $0.01269 |
| Opus 5 | $0.00030 | $0.00634 |
| Sonnet 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 yesterday.
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.
- yesterday 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 3mo ago), licensed MIT. It adds 60 tokens to every session and 1,269 once invoked, about $0.0003 per session on Opus 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.
Other skills, from other repositories
expertise-exchange
Team expertise billboard via adept exchange: ask teammates for expertise and stack responses. Apply when the user wants a colleague's input, mentions the exchange, or when you start using adept — sample open requests and offer to answer ones the user knows about.
release
Cut a versioned release and publish everos to PyPI via the tag-triggered workflow.
cao-session-management
Interact with CAO (CLI Agent Orchestrator) — launch multi-agent sessions, check status, send follow-up instructions, unblock stuck terminals, or shut down sessions. Use when working with CAO sessions in any capacity.
cog-braindump-capture
Capture raw thoughts with automatic domain classification and vault routing.
cog-knowledge-consolidation
Build structured knowledge frameworks from scattered vault notes with source attribution.
keyboard-shortcuts
Reference for keyboard shortcut implementation, keybinding registration, shortcut parity with vim and other TUI tools, and the complete shortcut assignment table across all sidecar plugins. Use when adding or modifying keyboard shortcuts, checking shortcut assignments, resolving key conflicts, or assessing alignment…