installskill

Skills / anthropics/claude-plugins-official

hook-development

Guide to writing Claude Code plugin hooks, with a focus on prompt-based hooks and hook events.

Pinned commit
0fbfda5a91f4Committed 2026-11-25
Files
1163 KB
License
Apache-2.0
Snapshot taken
2026-11-28
Description from the skill
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.

This is the text your agent reads to decide when to use the skill.

Install

Choose your agent. Pinned commands install exactly the commit this page describes.

Skill directory .claude/skills/Claude Code · Official docs

Does not read the shared .agents/skills directory. A skill must land in .claude/skills, or arrive inside a plugin.

GitHub CLIpinned

$ gh skill install anthropics/claude-plugins-official plugins/plugin-dev/skills/hook-development --agent claude-code --pin 0fbfda5a91f4adc311daca25acc99132f40f0b6e

gh picks the directory for the agent, names the folder after the source directory (hook-development), and writes source metadata into the SKILL.md frontmatter, so the content hash below will not match. Check the github-tree-sha it records instead: it should read 7feae717de16415b31b61bb721106aefaa4c5ba2.

skills CLIpinned

$ npx skills add anthropics/claude-plugins-official@0fbfda5a91f4adc311daca25acc99132f40f0b6e --skill hook-development -a claude-code --copy

Downloads and runs the skills package from npm. --copy writes real files instead of symlinks. The CLI sends anonymous telemetry unless DISABLE_TELEMETRY=1 is set, and that setting also turns off its audit lookups.

Claude Code pluginnot pinnedrun inside the agent

> /plugin marketplace add anthropics/claude-plugins-official
> /plugin install plugin-dev@claude-plugins-official

Not pinned: installs whatever the marketplace currently serves. The plugin bundles 6 other skills with this one. It also installs things this page does not cover: slash commands, subagents. Plugin scope is chosen in the /plugin dialog.

Plain gitpinned

$ tmp=$(mktemp -d)
$ git clone --quiet https://github.com/anthropics/claude-plugins-official.git "$tmp"
$ git -C "$tmp" checkout --quiet 0fbfda5a91f4adc311daca25acc99132f40f0b6e
$ mkdir -p .claude/skills
$ cp -R "$tmp/plugins/plugin-dev/skills/hook-development" .claude/skills/hook-development

No extra tooling. Files land byte for byte as published in .claude/skills/hook-development, so the content hash below can be checked directly.

Check what landed

Run this after installing. It prints one SHA-256 for the whole directory. If your installer reported a different directory, cd there instead.

$ cd .claude/skills/hook-development && find . -type f -print0 | LC_ALL=C sort -z | xargs -0 shasum -a 256 | shasum -a 256

Expectedffd15883f5820304a69714eeeb893f94699f5d49e6c01134e3a5c3b858f0d9e1

It matches only when the files are byte for byte as published. A difference means something changed: by the installer, by you, or upstream.

What is inside

Pattern matches in the files, each linked to its line. A match is a place to read, not a verdict, and no match is not proof of absence.

Scripts · 6Docs · 4SKILL.md · 1

Runs commands50

Code that spawns other processes, or shell code blocks in the instructions.

0 in scripts · 50 in docs and other text files

Network access1

Calls that fetch from or send to a remote host.

0 in scripts · 1 in docs and other text files

Installs packages1

Commands that pull and run third-party packages at use time.

0 in scripts · 1 in docs and other text files

Reads env or credentialsNo match

References to environment variables, tokens, keys or credential files.

Privileged or destructive10

sudo, recursive deletes, permission changes and similar commands.

3 in scripts · 7 in docs and other text files

Dynamic or encoded code3

eval, exec, base64 decoding and remote-script piping, which hide what runs.

0 in scripts · 3 in docs and other text files

Outside hosts mentioned

Hostnames of every URL in the text files.

  • docs.claude.com×1

Entries worth a second look

No symlinks, submodules, hidden files, archives, compiled files or unscanned files.

File manifest

Every file in the skill directory at the pinned commit.

Content hash
ffd15883f5820304a69714eeeb893f94699f5d49e6c01134e3a5c3b858f0d9e1
Git tree SHA
7feae717de16415b31b61bb721106aefaa4c5ba2
PathKindSizeSHA-256
SKILL.mdSKILL.md16 KBf47e2d42f6360294…
examples/load-context.shScripts · executable1.7 KB0d614599e711c087…
examples/validate-bash.shScripts · executable1.3 KB348c58f4cf38a2e7…
examples/validate-write.shScripts · executable1.2 KB89a8ef9bb7508e48…
references/advanced.mdDocs9.9 KB5b139ceeb6a3ef16…
references/migration.mdDocs8.1 KB7f8e7a795829837f…
references/patterns.mdDocs7.0 KBcb607fca192bfa89…
scripts/README.mdDocs3.6 KB08a28b12ffa9fcb1…
scripts/hook-linter.shScripts · executable4.1 KB85a7d55488f8f38f…
scripts/test-hook.shScripts · executable5.2 KBded642e811b4731f…
scripts/validate-hook-schema.shScripts · executable5.0 KBe7785d6c61d368f5…

Spec and portability

Checked against the Agent Skills specification.

Frontmatter
Parses as YAML
Name matches directory
Yes
Name uses lowercase letters, digits and hyphens
Yes
Description length
525limit 1,024 characters
SKILL.md body
708 linesthe spec suggests under 500 lines
Fields outside the spec
versionAgents that do not know these fields ignore them, and uploading to claude.ai or the Skills API can fail on them.
License field
None declared
License file
None declared
Repository license
LICENSE (Apache-2.0)
Claude Code plugin
plugin-dev@claude-plugins-official

Change history

No changes recorded since the first snapshot on 2026-11-28.

Follow changes to this skill in a feed reader: Atom feed · all skills

Get an email when this skill changes

Email alerts are not built yet. Leave your address and we will write to you once, when they are. The feed above works today.

We store your address, the name of this skill and the date. It is used for nothing else.