Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/n4m3z-buildhook
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: writing
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/buildhook
What's inside
- Skill name
BuildHook- Description
- Create and validate module hooks. USE WHEN create hook, new hook, write hook, scaffold hook, validate hook, check hook, hook conventions, hook events, hook structure.
- License
- EUPL-1.2
- Instructions
- 226 lines in SKILL.md · view on GitHub
Agent Skills spec issues
- name: only lowercase letters, digits and single hyphens allowed
Files (1)
- SKILL.md
SKILL.md (first lines)
# BuildHook
Create and validate hook scripts for forge modules. Hooks are bash scripts triggered by Claude Code events, routed through the `dispatch` binary.
## Workflow Routing
| Workflow | Trigger | Section |
|--------------|-----------------------------------------------|------------------------------------------|
| **Create** | "create hook", "new hook", "scaffold hook" | [Create Workflow](#create-workflow) |
| **Validate** | "validate hook", "check hook" | [Validate Workflow](#validate-workflow) |
## Hook Conventions
### Design Principles
Hooks must block or inject, never advise. A hook that "reminds" or "nudges" is a rule or skill in disguise. Before proposing a hook, check whether Claude Code already injects this context: rules are always loaded, skills are auto-discovered; don't duplicate what the runtime provides. Kill test: if a hook breaks silently and nobody notices for a month, it wasn't worth shipping. See [ARCH-0011](../../docs/decisions/ARCH-0011 Hook Design Principles.md) for the full design criteria.
### Events and Output Modes
Every hook handles one of 9 Claude Code events. Each event has a fixed output mode that determines how module output is handled:
| Event | Mode | Behaviour |
|--------------------|-------------|--------------------------------------------------------|
| `SessionStart` | Concatenate | All module outputs combined and emitted to AI context |
| `PreCompact` | Concatenate | All module outputs combined and emitted to AI context |
| `PreToolUse` | Gate | Exit 2 blocks the tool call; exit 0 allows |
| `Stop` | Gate | Exit 2 blocks session exit; exit 0 allows |
| `SubagentStop` | Gate | Exit 2 blocks subagent exit; exit 0 allows |
| `PostToolUse` | Passive | Output discarded; runs for side effects only |
| `SessionEnd` | Passive | Output discarded; runs for side effects only |
| `UserPromptSubmit` | Passive | Output discarded; runs for side effects only |
| `Notification` | Passive | Output discarded; runs for side effects only |
### Output Mode Decision Table
Use this when choosing which event to hook:
| Goal | Event | Mode | Notes |
|---------------------------------------|------------------|-------------|----------------------------------------|
| Inject context at session start | `SessionStart` | Concatenate | Emit markdown to stdout |
| Block a tool call (access control) | `PreToolUse` | Gate | Exit 2 to block, 0 to allow |
| Enforce rules before exit | `Stop` | Gate | Exit 2 to block, 0 to allow |
| React to a tool result | `PostToolUse` | Passive | Side effects only, output discarded |
| Clean up after session | `SessionEnd` | Passive | Side effects only, output discarded |
| Inject context before compaction | `PreCompact` | Passive | Emit markdown to stdout |
### File Naming
Hook scripts use **PascalCase** matching the event name:
| Event | Filename |
|------------------|-------------------------|
| `SessionStart` | `hooks/SessionStart.sh` |
| `PreToolUse` | `hooks/PreToolUse.sh` |
| `PostToolUse` | `hooks/PostToolUse.sh` |
| `Stop` | `hooks/Stop.sh` |
| `PreCompact` | `hooks/PreCompact.sh` |
### Dual-Mode Preamble
Every hook script starts with this template. It resolves the module root from either forge-core dispatch or standalone plugin context:
```bash
#!/usr/bin/env bash
set -euo pipefail
MODULE_ROOT="${FORGE_MODULE_ROOT:-${CLAUDE_PLUGIN_ROOT:-$(command cd "$(dirname "$0")/.." && pwd)}}"
```
### Stdin JSON
Claude Code pipes a JSON payload to hook scripts on stdin. The schema varies by event:
- **PreToolUse / PostToolUse**: `{"tool_name":"...", "tool_input":{...}}`
- **Stop**: `{"stop_reason":"...", ...}`
- **SessionStart**: empty or `{}`
Read stdin once: `INPUT=$(cat)`. Parse with `yq -p json` or a compiled binary.
### Windows
Claude Code on Windows requires Git for Windows, which provides Git Bash. Plugin hooks run in Git Bash, not PowerShell or cmd. Write hooks as standard bash scripts; they work cross-platform without `.cmd` or `.ps1` wrappers. Platform detection inside a hook when needed: `$OS == "Windows_NT"`.
### Registration Chain
For dispatch to find a hook:
1. Hook file exists at `hooks/<EventName>.sh` and is executable
2. `module.yaml` lists the event in `events:` (Tier 1 check)
3. Module is listed in project `defaults.yaml` under `modules:` (Tier 0)
The 3-tier event check: `config.yaml` override (authoritative) > `module.yaml` events > hook file existence (fallback).
### Exit Code and Output Contract
Claude Code distinguishes three exit classes ([hooks reference][CCHOOKS]): exit 0 (success; stdout is parsed for JSON control fields), exit 2 (blocking error; stdout is ignored, stderr is fed back, and whether it blocks depends on the event), and any other code (non-blocking error; the action proceeds). The trap: `exit 1` blocks nothing despite being the conventional Unix failure code.
Forge hooks block via exit 0 plus stdout JSON rather than exit 2: a structured decision carries its reason through the documented protocol and cannot be confused with an infrastructure failure.
- Empty stdout = allow
- `{"decision":"block","reason":"..."}` = block
- `{"hookSpecificOutput":{"additionalContext":"..."}}` = context injection
Guard files use `$PPID` or `$SESSION_ID` scoping to prevent repeat firing within a session. Hooks that cannot build or run must exit 0 (graceful degradation: never block Claude on infrastructure failure).
[CCHOOKS]: https://code.claude.com/docs/en/hooks
---
## Create Workflow
### Step 1: Determine event and output mode
Ask the user:
1. What should trigger this hook? (Use the Output Mode Decision Table above)
2. What should the hook do? (Inject context, block an action, or run a side effect?)
### Step 2: Scaffold the hook scriptFrom N4M3Z/forge-core, EUPL-1.2.
More from N4M3Z/forge-core
- 0.520score
LocalModel
N4M3Z
Run prompts against a local LLM backend (LM Studio, Ollama, or MLX) with privacy-preserving output guardrails — drop reasoning_content, enforce structured…
SkillCFreshness: C★ 4Claude Code +9 - 0.520score
ForgeSkill
N4M3Z
Create, validate, evaluate, and iterate skills for forge modules.
SkillCFreshness: C★ 4Claude Code +9 - 0.515score
Brainstorming
N4M3Z
Collaborative ideation before implementation — explore context, clarify intent, propose approaches.
SkillCFreshness: C★ 4Claude Code +9 - 0.515score
BuildAgent
N4M3Z
Create, validate, or audit agent definitions.
SkillCFreshness: C★ 4Claude Code +9 - 0.515score
BuildModule
N4M3Z
Design, build, and validate forge modules.
SkillCFreshness: C★ 4Claude Code +9 - 0.515score
BuildPlugin
N4M3Z
Create, validate, and publish Claude Code plugins from forge modules.
SkillCFreshness: C★ 4Claude Code +9 - 0.515score
BuildRule
N4M3Z
Create, validate, or place behavioral rules in forge modules.
SkillCFreshness: C★ 4Claude Code +9 - 0.515score
BuildSkill
N4M3Z
Create and validate skills for forge modules.
SkillCFreshness: C★ 4Claude Code +9 - 0.515score
DesignFrontend
N4M3Z
Build distinctive, production-grade frontend interfaces that avoid generic AI aesthetics.
SkillCFreshness: C★ 4Claude Code +9 - 0.515score
DesignSpec
N4M3Z
Write a formal design spec from brainstorming output or requirements.
SkillCFreshness: C★ 4Claude Code +9 - 0.515score
ExecutePlan
N4M3Z
Execute an implementation plan inline — task by task in a single session — then finish the work: verify, present integration options (merge, PR, keep…
SkillCFreshness: C★ 4Claude Code +9 - 0.515score
GuardRails
N4M3Z
Safety guardrails: runtime overrides for AI-safety plugin blocks, and per-language security review for python, javascript/typescript, and go.
SkillCFreshness: C★ 4Claude Code +9
Signals
- Stars
- 4
- Forks
- 3
- Open issues
- 8
- Last commit (this folder)
- Jun 16, 2026 (4 months ago)
- Last release
- Apr 16, 2026 (6 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- EUPL-1.2
- Repository
- github.com/N4M3Z/forge-core
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from N4M3Z
- 0.520score
LocalModel
N4M3Z
Run prompts against a local LLM backend (LM Studio, Ollama, or MLX) with privacy-preserving output guardrails — drop reasoning_content, enforce structured…
SkillCFreshness: C★ 4Claude Code +9 - 0.520score
ForgeSkill
N4M3Z
Create, validate, evaluate, and iterate skills for forge modules.
SkillCFreshness: C★ 4Claude Code +9 - 0.515score
HtmlPlayground
N4M3Z
Generate single-file HTML demos comparing techniques side-by-side.
SkillCFreshness: C★ 4Claude Code +9 - 0.515score
BuildAgent
N4M3Z
Create, validate, or audit agent definitions.
SkillCFreshness: C★ 4Claude Code +9 - 0.515score
BuildModule
N4M3Z
Design, build, and validate forge modules.
SkillCFreshness: C★ 4Claude Code +9 - 0.515score
Brainstorming
N4M3Z
Collaborative ideation before implementation — explore context, clarify intent, propose approaches.
SkillCFreshness: C★ 4Claude Code +9
Cite this page
BuildHook skill. Agent Mart. https://agentmart.dev/skills/n4m3z-buildhook (last updated 2026-10-24)