lewibs/dark-factory/declare-hooks-in-md-frontmatter
Claude Code and agent skill by lewibs/dark-factory
- community
Checking that the SKILL.md file is still in the repository.
Users can declare Claude Code hooks (PreToolUse, PostToolUse, Stop, SubagentStop, PreCompact) in YAML frontmatter of any .md file; running /dark-factory:gen-hooks activates them in .claude/settings.json.
Install
npx vskill@latest install lewibs/dark-factory/declare-hooks-in-md-frontmatterSKILL.md
The same SKILL.md was published earlier as lewibs/dark-factory/declare-hooks-in-md-frontmatter.
When to use
Any time you need to attach a shell script to a Claude Code hook event (PreToolUse, PostToolUse, Stop, SubagentStop, PreCompact) and want the declaration to live alongside the skill, agent, or command file that owns it — rather than editing .claude/settings.json directly.
Also use this skill when explaining to users how to register their own hook scripts without touching plugin internals.
Steps
- In the YAML frontmatter of any
.mdfile (skill, agent, command, or any project markdown), add a key matching one of the supported hook event names with the script path as the value:
```yaml
name: my-skill PreToolUse: ./hooks/pre-use.sh PostToolUse: ./hooks/post-use.sh
```
- Multiple hooks of the same type are supported — declare them as a YAML list:
```yaml
name: my-skill PreToolUse:
- ./hooks/first.sh
- ./hooks/second.sh
```
Note: YAML does not support duplicate keys in a single mapping. Use a list for multiple values under the same event type.
- Run
/dark-factory:gen-hooksfrom the project root. The command scans all.mdfiles recursively and merges any discovered hook declarations into.claude/settings.jsonunder thehookskey.
- Verify by inspecting
.claude/settings.json— each declared hook appears as:
``json { "matcher": "", "hooks": [{ "type": "command", "command": "bash ./hooks/pre-use.sh" }] } ` The matcher defaults to ""` (matches all tools/events).
Notes
- The
gen-hookscommand is additive: it never deletes existing hooks insettings.json. Re-running it after adding new declarations is safe. - Deduplication is by exact command string (
bash <path>). Runninggen-hookstwice does not add duplicate entries. - This mechanism writes to the user-local
.claude/settings.json(project-level settings). It is distinct from the plugin-levelhooks/hooks.jsonmechanism (seeskills/register-plugin-hooks-in-hooks-json/SKILL.md), which ships hooks with the installed plugin. - The supported hook event names are exactly:
PreToolUse,PostToolUse,Stop,SubagentStop,PreCompact. Any other frontmatter key is ignored bygen-hooks. - The backing implementation is
scripts/gen_hooks.py. The slash command iscommands/gen-hooks.md.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/declare-hooks-in-md-frontmatter/SKILL.md
Popularity
- Repository forks
- 1
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/lewibs/dark-factory/declare-hooks-in-md-frontmatter)