Agent skill

Crush Hook Writer

by charmbracelet in charmbracelet/crush

Helps write, debug and configure Crush hooks in crush.json that block, approve or rewrite tool calls before they run.

Custom licenceAuto-check passedAgent Workflows

Install Crush Hook Writer

skills CLI
$ npx skills add charmbracelet/crush --skill crush-hooks -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install charmbracelet/crush crush-hooks --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/charmbracelet/crush.git skills-src && mkdir -p .claude/skills && cp -r skills-src/internal/skills/builtin/crush-hooks .claude/skills/crush-hooks && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
crush-hooks
GitHub stars
29k
Token cost
~1.8k tokens
SKILL.md length
677 words
Files
1
Skills in repo
5
Repo updated
First seen
Licence
Custom licence

At a glance

Helps write, debug and configure Crush hooks in crush.json that block, approve or rewrite tool calls before they run.

  • Works in 5 steps: Add #!/usr/bin/env bash and set -euo… → chmod +x the script. → Add the entry under hooks.PreToolUse in… → …
  • Blocking dangerous shell commands before Crush runs them
  • SKILL.md covers Supported Events, Configuration, Language and Input, plus 6 more sections
  • Calls jq, node and python3

What it does

Hooks in Crush are user-defined commands set in crush.json that fire at set points during execution and give deterministic control over tool behavior. They run before permission checks and only on the top-level agent's tool calls. Work done by sub-agents, such as the task tool, is not intercepted, though the call that starts the sub-agent is. Only the PreToolUse event is supported today, and event names are case-insensitive.

The skill explains the configuration layout (project hooks take precedence over global ones, and matching hooks are deduplicated by command, run in parallel and combined in config order), the inputs a hook receives as environment variables such as CRUSH_TOOL_NAME and as JSON on stdin, and the outputs. Exit code 0 means success with JSON on stdout, 2 blocks the call with the reason on stderr, and 49 halts the whole turn. Because the command is a shell command, hooks can be written in any language.

When your agent uses it

  • Blocking dangerous shell commands before Crush runs them
  • Approving or rewriting tool input before it executes
  • Injecting extra context into a tool result
  • Debugging a hook in crush.json that does not fire or misbehaves

Example prompts

  • “Write a Crush hook that blocks any bash command containing rm -rf.”
  • “My PreToolUse hook in crush.json never fires. Help me debug it.”
  • “Add a hook that rewrites file paths in tool input so they stay inside the project directory.”

Requirements

  • Crush with a crush.json configuration

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Add #!/usr/bin/env bash and set -euo pipefail (for shell scripts).
  2. chmod +x the script.
  3. Add the entry under hooks.PreToolUse in crush.json with the right matcher.
  4. Decide intent: inject context (omit decision), auto-approve ("allow"),
  5. If rewriting input, remember updated_input is a shallow merge — only

What it can do on your machine

Read from SKILL.md and the folder at commit 6e026b1. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • jq
    • node
    • python3

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Crush Hook Writer loads about 1.8k tokens when it runs. Until then it costs about 63 tokens; SKILL.md has 677 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~63
When it runs · the whole SKILL.md, loaded when a task matches
~1.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

Its licence (Custom licence) doesn't allow us to republish the file, so here is its outline and opening line. It has 677 words (~1,818 tokens).

“Hooks are user-defined commands in crush.json that fire at specific points during execution, giving deterministic control over tool behavior. They run before permission checks and only on the top-level agent's tool calls — sub-agent calls (task tool, agentic_fetch, etc.) are…”

— opening of SKILL.md by charmbracelet, Custom licence
name
crush-hooks

Read the full SKILL.md on GitHub

Files

Just SKILL.md in internal/skills/builtin/crush-hooks of charmbracelet/crush.

Open the folder on GitHubat commit 6e026b1

Compare with similar skills

Crush Hook Writer next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Crush Hook Writer compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Crush Hook Writer this skillcharmbracelet/crush29k—~1.8kAutomated safety check: PassCustom licence
Hook Development for Claude Code Pluginsanthropics/claude-plugins-official38k10 repos~4.1kAutomated safety check: NotesApache-2.0
Claude Code Agent Developmentanthropics/claude-plugins-official38k7 repos~2.8kAutomated safety check: PassApache-2.0
Claude Code Skill Developer Guidediet103/claude-code-infrastructure-showcase10k11 repos~3.5kAutomated safety check: PassMIT
Plugin Settings Patternanthropics/claude-plugins-official38k7 repos~3kAutomated safety check: PassApache-2.0
MCP Integration for Pluginsanthropics/claude-plugins-official38k11 repos~3.1kAutomated safety check: PassApache-2.0

Similar skills

  • Hook Development for Claude Code Plugins

    anthropics/claude-plugins-official

    Official

    Explains how to write Claude Code plugin hooks, both prompt-based checks and bash commands, for events such as PreToolUse, Stop and SessionStart.

    38k GitHub starsUsed in 10 repos~4.1k tokens
    Agent WorkflowsAuto-check: notes
  • Claude Code Agent Development

    anthropics/claude-plugins-official

    Official

    Explains how to write agents for Claude Code plugins: the markdown file with YAML frontmatter, trigger descriptions, model and color settings, and system prompt design.

    38k GitHub starsUsed in 7 repos~2.8k tokens
    Agent WorkflowsAuto-check passed
  • Claude Code Skill Developer Guide

    diet103/claude-code-infrastructure-showcase

    A guide to creating and managing Claude Code skills with auto-activation: skill-rules.json triggers, hooks, enforcement levels, YAML frontmatter and progressive disclosure.

    10k GitHub starsUsed in 11 repos~3.5k tokens
    Agent WorkflowsAuto-check passed
  • Plugin Settings Pattern

    anthropics/claude-plugins-official

    Official

    Shows how Claude Code plugins keep per-project settings and state in .claude/plugin-name.local.md files with YAML frontmatter and a markdown body.

    38k GitHub starsUsed in 7 repos~3k tokens
    Agent WorkflowsAuto-check passed
  • MCP Integration for Plugins

    anthropics/claude-plugins-official

    Official

    Explains how to bundle Model Context Protocol servers in a Claude Code plugin, covering config files, stdio, SSE, HTTP and WebSocket server types, and authentication.

    38k GitHub starsUsed in 11 repos~3.1k tokens
    Agent WorkflowsAuto-check passed
  • Claude Code Command Development

    anthropics/claude-plugins-official

    Official

    Explains how to write Claude Code slash commands: Markdown files with YAML frontmatter, arguments, file references, bash context and interactive prompts.

    38k GitHub starsUsed in 10 repos~4.8k tokens
    Agent WorkflowsAuto-check passed

More from charmbracelet/crush

  • Crush Configuration

    charmbracelet/crush

    Explains how to configure the Crush coding agent with crushrc or crush.json, covering providers, models, LSPs, MCP servers, hooks, permissions and config precedence.

    29k GitHub stars~3.7k tokensUpdated today
    Auto-check passed
  • JSON Processing with jq

    charmbracelet/crush

    Explains the jq command built into Crush for querying, filtering and reshaping JSON, including its supported flags and where it differs from standard jq.

    29k GitHub stars~746 tokensUpdated today
    Auto-check passed
  • Crush Shell Builtins

    charmbracelet/crush

    Explains how to add a new in-process builtin command to Crush's embedded POSIX shell, so it is intercepted before reaching the OS, with context polling and exit-status rules.

    29k GitHub stars~790 tokensUpdated today
    Auto-check passed
  • Crush Builtin Skills

    charmbracelet/crush

    Explains how the Crush coding agent embeds builtin skills in its binary and how to add or edit one, including the discovery test and build commands.

    29k GitHub stars~466 tokensUpdated today
    Auto-check passed

Categories

Questions about Crush Hook Writer

What does Crush Hook Writer do?

Helps write, debug and configure Crush hooks in crush.json that block, approve or rewrite tool calls before they run. json that fire at set points during execution and give deterministic control over tool behavior. They run before permission checks and only on the top-level agent's tool calls.

When should I use Crush Hook Writer?

Crush Hook Writer fits situations like: blocking dangerous shell commands before Crush runs them; approving or rewriting tool input before it executes; injecting extra context into a tool result; debugging a hook in crush.json that does not fire or misbehaves.

How do I install Crush Hook Writer in Claude Code?

Run `npx skills add charmbracelet/crush --skill crush-hooks -a claude-code`. Or copy the skill folder (internal/skills/builtin/crush-hooks in charmbracelet/crush) into .claude/skills/crush-hooks in your project. Claude Code loads it when a task matches its description.

How do I install Crush Hook Writer in Codex?

Run `npx skills add charmbracelet/crush --skill crush-hooks -a codex`. Or copy the skill folder (internal/skills/builtin/crush-hooks in charmbracelet/crush) into .agents/skills/crush-hooks in your project. Codex loads it when a task matches its description.

Can I use Crush Hook Writer in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add charmbracelet/crush --skill crush-hooks -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/crush-hooks, .gemini/skills/crush-hooks, .github/skills/crush-hooks and .opencode/skills/crush-hooks in your project.

What does Crush Hook Writer need to run?

Going by SKILL.md and its folder, Crush Hook Writer needs the command-line tools its instructions call (jq, node and python3). Our summary lists: Crush with a crush.json configuration.

Does Crush Hook Writer access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Crush Hook Writer safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Crush Hook Writer use?

Crush Hook Writer has a licence file (the repository's licence) that doesn't match a standard licence. Read it on GitHub before reusing the skill.

How many tokens does Crush Hook Writer use?

About 1.8k tokens (SKILL.md is roughly 7.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Crush Hook Writer?

Skills that share tags, products or a category with Crush Hook Writer: Hook Development for Claude Code Plugins (anthropics/claude-plugins-official, 38k stars), Claude Code Agent Development (anthropics/claude-plugins-official, 38k stars), Claude Code Skill Developer Guide (diet103/claude-code-infrastructure-showcase, 10k stars) and Plugin Settings Pattern (anthropics/claude-plugins-official, 38k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Crush Hook Writer?

charmbracelet (a GitHub organization) maintains it in charmbracelet/crush, which has 28,557 GitHub stars. The repository holds 5 skills in this directory. The repository was last updated on October 9, 2026.

Source: charmbracelet/crush on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.