cursor-hook-authoring

cursor-hook-authoring is a skill for Claude Code, Codex from philtzjp/startingpoint. It costs 87 tokens per session (1,196 once invoked), scanned A, original, MIT.

A reference for creating and debugging Cursor Hooks, scripts that run when events such as shell commands, tool calls, or file edits occur. It documents their configuration, input and output data, and exit-code behavior.

In plain words
What is it for?
Use it when adding or changing .cursor/hooks.json or scripts in .cursor/hooks/. It covers command checks, MCP-call checks, audit logging, formatting, linting, and stop-event follow-ups.
Why use it?
It helps hooks follow Cursor's required file locations and configuration format, reducing errors in checks, logging, and automated follow-up actions.

Skill for Claude CodeCodex

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 skills/philtzjp/startingpoint/cursor-hook-authoring
Any agent
npx skills add philtzjp/startingpoint --skill cursor-hook-authoring
Clone the repo
git clone --depth 1 https://github.com/philtzjp/startingpoint

Made for: Claude Code, Codex.

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 cursor-hook-authoring

README.md
[![agentmods](https://agentmods.dev/badge/skills/philtzjp/startingpoint/cursor-hook-authoring.svg)](https://agentmods.dev/skills/philtzjp/startingpoint/cursor-hook-authoring)
Your own site
<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>
Per session 87 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,196 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. 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.00087 $0.01196
Opus 5 $0.00044 $0.00598
Sonnet 5 $0.00017 $0.00239
Haiku 4.5 $0.00009 $0.00120

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

Security

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.

templates/cursor/.agents/skills/cursor-hook-authoring/SKILL.md · 72 lines

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 の作成規約

配置

  1. MUST: プロジェクト用 Hook 設定は <project-root>/.cursor/hooks.json に置く(ユーザーグローバルは ~/.cursor/hooks.json
  2. MUST: Hook スクリプトは .cursor/hooks/ 配下に置き、実行権限(chmod +x)を付与する
  3. MUST: hooks.jsoncommand はプロジェクトルートからの相対パス(./.cursor/hooks/<name>.sh)で書く

hooks.json スキーマ

{
  "version": 1,
  "hooks": {
    "<eventName>": [
      {
        "type": "command",
        "command": "./.cursor/hooks/script.sh",
        "matcher": "正規表現",
        "timeout": 10,
        "failClosed": false
      }
    ]
  }
}
  • beforeShellExecution / afterShellExecutionmatcher はシェルコマンド全文に対する正規表現
  • preToolUse / postToolUsematcher はツール種別(Shell, Read, Write, Task, MCP:<tool>

主なイベント

イベント 用途
beforeShellExecution シェルコマンド実行前の検査・ブロック・確認(Git ガード等)
afterShellExecution 実行結果の記録・監査
beforeMCPExecution MCP ツール呼び出し前の検査
afterFileEdit ファイル編集後のフォーマット・lint
beforeSubmitPrompt プロンプト送信前の検査
stop エージェント停止時のフォローアップ(followup_message

ペイロードとレスポンス

  1. Hook は stdin から JSON を受け取る。beforeShellExecution の主要フィールドは command(コマンド全文)、cwdhook_event_nameworkspace_rootsbeforeMCPExecutiontool_nametool_input(オブジェクトではなく JSON 文字列で渡される場合があるため両対応する)。共通フィールドの model には Auto モードでも解決済みの実モデル名が入るため、モデル依存の判定・メッセージに利用できる
  2. stdout に単一の JSON を出力する。permissionallow / deny / ask:
    • deny: ブロックし、user_message をユーザーに通知、agent_message をエージェントに返す(自己修正を促す指示を書く)
    • ask: 実行前にユーザーへ確認ダイアログを表示する
  3. MUST: レスポンスのメッセージキーは snake_case(user_message / agent_message)と camelCase(userMessage / agentMessage)の両方を出力する(公式ドキュメントと実装記事で表記が揺れており、両方出せばどちらのバージョンでも動く)
  4. exit code: 0 = stdout の JSON を採用、2 = 強制ブロック、その他 = fail-open(許可)。ブロック必須の Hook は failClosed: true を設定する

設計規約

  1. MUST: 判定不能(stdin 解析失敗・依存コマンド欠如・リポジトリ外)の場合は fail-open で {"permission":"allow"} を返し、エージェントの作業を止めない
  2. MUST: JSON 解析は jqpython3 の順にフォールバックする
  3. MUST: メッセージに変数を埋め込む場合は JSON エスケープする
  4. NEVER: git rev-parse --git-dir の相対パス(.git)をそのまま使用しない; MUST: --absolute-git-dir を使用する(Hook のカレントディレクトリと対象リポジトリは一致しない)
  5. NEVER: stdout に JSON 以外(デバッグ出力等)を混ぜない; デバッグは stderr またはファイルに出す

Read the full file on GitHub · 72 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. 5d ago First seen · 72 lines · 87 tokens per session scan A e535199efa8a

Subscribe to this mod's changes

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.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

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…

microsoft/ai-agents-for-beginners · 200 tokens

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…

vercel/next.js · 95 tokens

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…

vercel/next.js · 170 tokens

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…

vercel/next.js · 103 tokens

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…

microsoft/vscode · 72 tokens