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/philtzjp/startingpoint/cursor-hook-authoringnpx skills add philtzjp/startingpoint --skill cursor-hook-authoringgit clone --depth 1 https://github.com/philtzjp/startingpointWrote 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/philtzjp/startingpoint/cursor-hook-authoring)<a href="https://agentmods.dev/skills/philtzjp/startingpoint/cursor-hook-authoring"><img src="https://agentmods.dev/badge/skills/philtzjp/startingpoint/cursor-hook-authoring.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.00087 | $0.01196 |
| Opus 5 | $0.00044 | $0.00598 |
| Sonnet 5 | $0.00017 | $0.00239 |
| Haiku 4.5 | $0.00009 | $0.00120 |
Grade A, and why
cursor-hook-authoring scanned grade A with 0 findings 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 5d 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.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 72 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Cursor Hook の作成規約
配置
- MUST: プロジェクト用 Hook 設定は
<project-root>/.cursor/hooks.jsonに置く(ユーザーグローバルは~/.cursor/hooks.json) - MUST: Hook スクリプトは
.cursor/hooks/配下に置き、実行権限(chmod +x)を付与する - MUST:
hooks.jsonのcommandはプロジェクトルートからの相対パス(./.cursor/hooks/<name>.sh)で書く
hooks.json スキーマ
{
"version": 1,
"hooks": {
"<eventName>": [
{
"type": "command",
"command": "./.cursor/hooks/script.sh",
"matcher": "正規表現",
"timeout": 10,
"failClosed": false
}
]
}
}
beforeShellExecution/afterShellExecutionのmatcherはシェルコマンド全文に対する正規表現preToolUse/postToolUseのmatcherはツール種別(Shell,Read,Write,Task,MCP:<tool>)
主なイベント
| イベント | 用途 |
|---|---|
beforeShellExecution |
シェルコマンド実行前の検査・ブロック・確認(Git ガード等) |
afterShellExecution |
実行結果の記録・監査 |
beforeMCPExecution |
MCP ツール呼び出し前の検査 |
afterFileEdit |
ファイル編集後のフォーマット・lint |
beforeSubmitPrompt |
プロンプト送信前の検査 |
stop |
エージェント停止時のフォローアップ(followup_message) |
ペイロードとレスポンス
- Hook は stdin から JSON を受け取る。
beforeShellExecutionの主要フィールドはcommand(コマンド全文)、cwd、hook_event_name、workspace_roots。beforeMCPExecutionはtool_nameとtool_input(オブジェクトではなく JSON 文字列で渡される場合があるため両対応する)。共通フィールドのmodelには Auto モードでも解決済みの実モデル名が入るため、モデル依存の判定・メッセージに利用できる - stdout に単一の JSON を出力する。
permissionはallow/deny/ask:deny: ブロックし、user_messageをユーザーに通知、agent_messageをエージェントに返す(自己修正を促す指示を書く)ask: 実行前にユーザーへ確認ダイアログを表示する
- MUST: レスポンスのメッセージキーは snake_case(
user_message/agent_message)と camelCase(userMessage/agentMessage)の両方を出力する(公式ドキュメントと実装記事で表記が揺れており、両方出せばどちらのバージョンでも動く) - exit code:
0= stdout の JSON を採用、2= 強制ブロック、その他 = fail-open(許可)。ブロック必須の Hook はfailClosed: trueを設定する
設計規約
- MUST: 判定不能(stdin 解析失敗・依存コマンド欠如・リポジトリ外)の場合は fail-open で
{"permission":"allow"}を返し、エージェントの作業を止めない - MUST: JSON 解析は
jq→python3の順にフォールバックする - MUST: メッセージに変数を埋め込む場合は JSON エスケープする
- NEVER:
git rev-parse --git-dirの相対パス(.git)をそのまま使用しない; MUST:--absolute-git-dirを使用する(Hook のカレントディレクトリと対象リポジトリは一致しない) - NEVER: stdout に JSON 以外(デバッグ出力等)を混ぜない; デバッグは stderr またはファイルに出す
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.
- 5d ago First seen · 72 lines · 87 tokens per session scan A e535199efa8a
cursor-hook-authoring is a skill published in the GitHub repository philtzjp/startingpoint (2 stars, last pushed 15d ago), licensed MIT. It adds 87 tokens to every session and 1,196 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other skills, from other repositories
systematic-debugging
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.
local-ai-agents
Build local-first AI agents that run entirely on a developer workstation with Microsoft Foundry Local and Qwen function-calling models. Covers Small Language Models (SLMs), the OpenAI-compatible local endpoint, sandboxed local tools, local RAG with Chroma, local MCP servers, hybrid cloud/local routing, and the…
next-cache-components-adoption
Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt, or migrate to Cache Components, flip the cacheComponents flag, work through a flood of blocking-prerender / instant validation errors, run the cache-components-instant-false codemod, or…
next-cache-components-optimizer
Drive a Next.js route to instant navigation by setting up an agentic loop, under Cache Components / PPR, on initial load (hard navigation) and client-side navigation (soft navigation). Encode the goal as a failing @next/playwright instant() e2e and work it to green, one verified route at a time; the shipped test then…
next-partial-prefetching-adoption
Turn on Partial Prefetching in a Next.js app and work through the insights it surfaces. Use when the user wants to enable or adopt Partial Prefetching, flip the partialPrefetching flag, opt routes in with export const prefetch = 'partial', audit Link prefetch={true} behavior, preserve existing prefetched UI with…
chronicle
Analyze Copilot session history for standup reports, usage tips, session search, and session reindexing. Use when the user asks for a standup, daily summary, usage tips, workflow recommendations, wants to search or find past sessions by keyword/file/PR, wants to reindex their session store, or asks about deleting…