hook-authoring

hook-authoring is a skill for Claude Code from kouroshez/coding-os. It costs 105 tokens per session (2,940 once invoked), scanned A, original, Apache-2.0.

Project guidance for creating coding-agent hooks: scripts that run when particular agent events occur. It covers Bash hooks, Python helpers, registration, environment variables, and event matching.

In plain words
What is it for?
Use it when adding or changing hook scripts, hook helper programs, hook registrations, or adapter hook capabilities.
Why use it?
It helps hooks work across different coding agents and projects instead of relying on one agent's private folder layout. Consistent registration also reduces the risk of breaking several projects at once.

Skill for Claude Code

Written for Claude Code: PreToolUse hook event. Also seen: positional $N argument; mentions Codex.

Needs its repository: it runs a file that does not travel with it, so clone the repository first. The line is bash src/core/hooks/write-state.sh "$COS_AGENT_DIR/.thinking_os-gate" "COMPLICATED 3".

Good fit Use it when adding or changing hook scripts, hook helper programs, hook registrations, or adapter hook capabilities.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/kouroshez/coding-os
agentmods
npx agentmods add skills/kouroshez/coding-os/hook-authoring

Made for: Claude Code.

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/kouroshez/coding-os/hook-authoring/github.svg)](https://agentmods.dev/skills/kouroshez/coding-os/hook-authoring)
Your own site
<a href="https://agentmods.dev/skills/kouroshez/coding-os/hook-authoring"><img src="https://agentmods.dev/badge/skills/kouroshez/coding-os/hook-authoring/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.

agentmods 80×15 button for hook-authoring

Your own site · 80×15
<a href="https://agentmods.dev/skills/kouroshez/coding-os/hook-authoring"><img src="https://agentmods.dev/badge/skills/kouroshez/coding-os/hook-authoring.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 105 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,940 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00105 $0.02940
Opus 5 $0.00053 $0.01470
Sonnet 5 $0.00021 $0.00588
Haiku 4.5 $0.00011 $0.00294

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

Security

Grade A, and why

hook-authoring scanned grade A 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 5d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/new_hook.sh), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

proc = subprocess.run(
src/templates/meta/skills/hook-authoring/SKILL.md · 293 lines

How it starts

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

hook-authoring

Purpose: Every hook in src/core/hooks/ propagates via live symlinks to every consumer project that registers any adapter. A buggy hook breaks N projects at once. The same shape, every time, keeps the ~50 hooks coherent.

Read when: editing files matching:

  • src/core/hooks/*.sh — hook scripts.
  • src/core/hooks/_helpers/*.py — Python helpers invoked by hooks.
  • src/core/hooks/registry.yaml — the SSOT for hook registration.
  • src/adapters/<id>/adapter.yaml (hook_capabilities block) — runtime capability filter.

Skip when: editing hook tests, runtime presence files in .coding-os/, generated adapter templates.

The Three Hard Contracts

Every hook MUST satisfy:

1. Source cos-env.sh (Rule 3)

The first non-comment lines of every hook:

#!/usr/bin/env bash
# What this hook does, one line.
set -euo pipefail

source "$(dirname "$0")/cos-env.sh" 2>/dev/null || true

cos-env.sh exports $COS_STATE_DIR, $COS_AGENT, $COS_AGENT_DIR, $COS_DB_PATH, etc. Without it, the hook will reach for hardcoded .claude/ paths and break on Codex/Cursor.

2. Never hardcode .claude/ (Rule 1, P2)

# WRONG
state_file=".claude/state/something"

# RIGHT
state_file="$COS_AGENT_DIR/something"
# or, if it's session-shared across agents:
state_file="$COS_STATE_DIR/something"

The block-hardcoded-literals.sh hook audits the diff and blocks .claude/ literals in src/core/**.

3. Register in registry.yaml (Rule 10, SSOT)

A new hook file is invisible until registered. Add an entry to src/core/hooks/registry.yaml:

- id: my-new-hook
  script: my-new-hook.sh
  event: PreToolUse        # PreToolUse | PostToolUse | UserPromptSubmit | Stop | SessionStart | PostToolUseFailure | SubagentStart | SubagentStop
  matcher: "Write|Edit"    # tool matcher (event-specific) — empty = match-all where allowed
  phase: gate              # gate | observation | enforcement | telemetry
  category: governance     # documentation | governance | safety | telemetry | task | skill | graph | ...
  description: "One line — what the hook does."
  blocking: true           # exit 2 blocks the tool call; false = soft warn only
  adapters: ["claude", "codex", "cursor"]  # which adapters to render this hook into

Read the full file on GitHub · 293 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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 · 293 lines · 105 tokens per session scan A fbe1ef3853db

Subscribe to this mod's changes

hook-authoring is a skill published in the GitHub repository kouroshez/coding-os (6 stars, last pushed yesterday), licensed Apache-2.0. It adds 105 tokens to every session and 2,940 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

potpie-graph

Use when the task can read or write the project-memory graph through the potpie CLI: discover the contract with graph catalog, read named views with graph read, resolve entity identity with graph search-entities, create validated plans with graph propose, commit plans with graph commit --verify, inspect quality with…

potpie-ai/potpie · 94 tokens

potpie-source-ingestion

Use when the user explicitly asks to ingest, refresh, or deeply understand a repository, PR, issue, ticket, runbook, incident report, document, or web link into Potpie. The harness performs todo-driven discovery, uses local/GitHub/integration tools and read-only subagents when available, builds evidence-backed…

potpie-ai/potpie · 82 tokens

potpie-repo-baseline

Use when establishing, refreshing, or deeply understanding a repository's baseline memory in Potpie: purpose, application type, features, services/modules, environments, deploy shape, dependencies, API contracts, datastores, integrations, ownership, and explicit preferences. The harness reads authored and…

potpie-ai/potpie · 75 tokens

graph-mutation-plan

Cookbook for composing an applygraphmutations plan — stable entitykey patterns, the canonical label/edge vocabulary, evidence/invalidation/confidence discipline, and a worked example. Load this when building a non-trivial mutation plan.

potpie-ai/potpie · 51 tokens

potpie-cli

Use when the task is centered on running, explaining, configuring, or troubleshooting the potpie command: doctor, login, pot management, source registration, search, graph workbench reads/writes, and pot scope behavior.

potpie-ai/potpie · 50 tokens

potpie-change-timeline

Use when an agent needs recent or historical change context: what changed recently, regressions, merged PRs, tickets, docs, incidents, deployments, releases, and source-history ingestion.

potpie-ai/potpie · 43 tokens