dotharness/dotcraft/create-hooks

Claude Code and agent skill by dotharness/dotcraft

Trust tier 3
  • community
  • ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Source check pending

Checking that the SKILL.md file is still in the repository.

Create and configure DotCraft lifecycle hooks (hooks.json) for workspaces. Use when the user wants to add hooks, create hook scripts, set up security guards, auto-formatting, logging, notifications, or any shell-based automation triggered by DotCraft agent lifecycle events.

Install

npx vskill@latest install dotharness/dotcraft/create-hooks

Semi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard

SKILL.md

Create DotCraft Hooks

Overview

DotCraft hooks are lifecycle event triggers that run external shell commands at key agent execution points. Hooks are configured in hooks.json and can observe, log, or block agent actions.

Workflow

  1. Establish the goal (security guard, auto-format, logging, notification, etc.), asking only if the request leaves it ambiguous
  2. Determine which lifecycle event(s) to use
  3. Determine scope: workspace (.craft/hooks.json), global (~/.craft/hooks.json), or plugin (<plugin-root>/hooks/hooks.json)
  4. Generate the hooks.json config and any helper scripts
  5. Place scripts in .craft/hooks/, the user's chosen global hooks directory, or the plugin's hooks/ directory

Config File Locations

ScopePathPurpose
Global~/.craft/hooks.jsonShared across all workspaces
Workspace<workspace>/.craft/hooks.jsonCurrent workspace only
Plugin<plugin-root>/hooks/hooks.jsonContributed by an installed and enabled plugin

Global hooks load first, workspace hooks are appended, and enabled plugin hooks run after config hooks. Plugin hooks are additive and read-only from Desktop; Desktop manages only user state.

Config Format

json
{
"hooks": {
"<EventName>": [
{
"matcher": "<regex for tool names>",
"hooks": [
{
"type": "command",
"command": "<shell command>",
"timeout": 30
}
]
}
]
}
}
Fields
FieldTypeDescription
matcherstringRegex matching tool names. Empty string = match all. Only applies to tool-related events
typestringAlways "command"
commandstringShell command. Linux/macOS: /bin/bash -c; Windows: pwsh when installed, otherwise Windows PowerShell, then cmd
timeoutnumberSeconds before kill, default 30

Trust and User State

DotCraft stores per-hook user state in global ~/.craft/config.json under Hooks.State.

json
{
"Hooks": {
"State": {
"<hook-key>": {
"Enabled": false,
"TrustedHash": "sha256:..."
}
}
}
}
  • Enabled: false disables one hook without editing hooks.json.
  • TrustedHash records the normalized hook definition the user approved.
  • Config and plugin hooks must be trusted before they run. Modified hooks need trust again.
  • Do not write trust state into workspace .craft/config.json; it is personal user state.

For plugin hooks, commands may use ${DOTCRAFT_PLUGIN_ROOT} and ${DOTCRAFT_PLUGIN_DATA}. DotCraft expands these variables in the command and also injects them as environment variables.

Lifecycle Events

EventTriggerCan Block?stdin JSON Fields
SessionStartFirst usable turn for a sessionNosessionId/session_id, cwd, hook_event_name
UserPromptSubmitUser prompt submitted before prompt assemblyYessessionId/session_id, turnId/turn_id, prompt, cwd
PrePromptDotCraft compatibility event before assembled prompt is sentYessessionId/session_id, turnId/turn_id, prompt, cwd
PreToolUseBefore tool executesYestoolName/tool_name, toolArgs/tool_args, tool_input
PermissionRequestBefore permission is requestedYespermission context when available
PostToolUseAfter tool succeedsNotoolName/tool_name, tool_input, toolResult/tool_result
PostToolUseFailureAfter tool failsNotoolName/tool_name, tool_input, error
PreCompact / PostCompactAround context compactionPre can blockcompaction context when available
SubagentStart / SubagentStopAround subagent lifecycleNosubagent context when available
StopAfter assistant responseRewake onlylast_assistant_message, stop_hook_active
StopFailureAfter Stop handling failsNofailure context when available

DotCraft emits both camelCase and snake_case field names. Prefer snake_case in portable scripts.

Exit Codes

CodeMeaningBehavior
0SuccessContinue
2Block / feedbackBlock supported events, or request follow-up feedback for asyncRewake hooks
OtherErrorFail-open: warning logged, execution continues

JSON Output

Hooks may print plain text or JSON. Plain text becomes additional context for context-capable events. JSON output can use:

json
{
"hookSpecificOutput": {
"hookEventName": "PostToolUse",
"additionalContext": "Model-visible guidance"
},
"decision": "block",
"reason": "Why the action should stop or continue with feedback",
"systemMessage": "Optional user-visible status"
}

Use hookSpecificOutput.additionalContext for guidance that should be shown to the model without leaking raw JSON.

Built-in Tool Names (for matcher)

ToolDescription
ExecShell command execution
ReadFileRead file contents (also lists directory when path is a directory)
WriteFileWrite file
EditFileEdit file (partial replace)
GrepFilesSearch file contents
FindFilesFind files by name pattern
WebFetchFetch web page
WebSearchSearch web
SpawnAgentSpawn a subagent child thread for background tasks

Matcher is case-insensitive regex. Examples: "" (all), "WriteFile|EditFile" (write ops), ".*File" (all file ops), "Exec" (shell only).

The optional if field supports portable conditions such as Bash(git commit:*). DotCraft maps common tool aliases: shell execution to Bash, full-file writes to Write, and search/replace edits to Edit.

Platform Differences

  • Linux/macOS: Commands run via /bin/bash -c '<command>'. Use standard bash syntax, jq for JSON parsing.
  • Windows: PowerShell commands run via pwsh when installed, otherwise Windows PowerShell, with -File <temp.ps1>. Use PowerShell syntax and ConvertFrom-Json for JSON parsing. If neither is available, the default is cmd; set shell to powershell or pwsh when the hook requires PowerShell.
Windows (PowerShell) stdin reading pattern
powershell
$input_data = [Console]::In.ReadToEnd() | ConvertFrom-Json
$toolName = $input_data.toolName
$toolArgs = $input_data.toolArgs
Windows blocking pattern (exit 2)
powershell
$input_data = [Console]::In.ReadToEnd() | ConvertFrom-Json
# ... check logic ...
if ($shouldBlock) {
[Console]::Error.WriteLine("Block reason here")
exit 2
}
exit 0
Linux/macOS stdin reading pattern
bash
INPUT=$(cat)
TOOL_NAME=$(echo "$INPUT" | jq -r '.toolName // empty')
TOOL_ARGS=$(echo "$INPUT" | jq -c '.toolArgs')

Best Practices

  1. Always consume stdin — even if unused, read it (cat > /dev/null or [Console]::In.ReadToEnd() | Out-Null) to avoid broken pipe errors
  2. Use `jq` (bash) or `ConvertFrom-Json` (PowerShell) for JSON parsing
  3. Append `|| true` (bash) or `try/catch` (PowerShell) inside helper scripts for non-critical work
  4. Set reasonable timeouts — default is 30s, increase for slow operations
  5. Use `exit 2` intentionally — reserve it for blocking events or for asyncRewake feedback
  6. Write block reasons to stderr — echo "reason" >&2 (bash) or [Console]::Error.WriteLine("reason") (PowerShell)
  7. No interactive commands — hooks run in background without user input
  8. Place complex logic in script files — store in .craft/hooks/ and reference from hooks.json

Generation Rules

When generating hooks for the user:

  1. Read the shell from workspace context — use its syntax, or explicitly set shell when the hook requires PowerShell; use bash on Linux/macOS
  2. For complex hooks, create script files in the selected hooks directory and reference them in the command field
  3. Merge with existing config — if .craft/hooks.json already exists, read it first and merge new hooks into the existing config rather than overwriting
  4. Validate event names — use an event name from the Lifecycle Events table above
  5. Ensure hooks are enabled — check that config.json does not have "Hooks": { "Enabled": false }
  6. Leave trust to the user — mention that new or modified hooks must be trusted through Desktop Hooks settings or hooks/setState

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

Popularity

7-day trend score
0

Not refreshed yet.

Extension points

  • hookPre/post lifecycle hooks

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
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/dotharness/dotcraft/create-hooks/badge)](https://verified-skill.com/skills/dotharness/dotcraft/create-hooks)

Something wrong with this skill or its page? Tell us.