crush-hooks
यह क्या करती है
यह स्किल आपको Crush, एक कोडिंग टूल, के लिए हुक लिखने में मदद करती है। हुक तय बिंदुओं पर, जैसे टूल कॉल से पहले, आपके अपने कमांड चलाते हैं, ताकि कॉल को अनुमति दें, रोकें या बदलें। यह उन उपयोगकर्ताओं के लिए है जो टूल क्या कर सकता है इस पर पक्के नियम चाहते हैं।
कब इस्तेमाल करें
- ✓जब आप Crush में कुछ टूल कॉल को रोकना या अनुमति देना चाहें।
- ✓जब आप टूल चलने से पहले उसका इनपुट बदलना चाहें, या टूल के नतीजों में संदर्भ जोड़ना चाहें।
- ✓जब कोई Crush हुक अपेक्षा के अनुसार न चल रहा हो और उसे ठीक करना हो।
Skill का लिंक
https://github.com/charmbracelet/crush/blob/main/internal/skills/builtin/crush-hooks/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“Crush के लिए ऐसा हुक लिखिए जो मेरे प्रोजेक्ट फ़ोल्डर के बाहर फ़ाइलें मिटाने वाले किसी भी shell कमांड को रोके।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
एजेंट सही इवेंट, जैसे PreToolUse, के लिए crush.json में हुक लिखता है। हुक अनुमति जांच से पहले चलते हैं, और सिर्फ़ मुख्य एजेंट की टूल कॉल के लिए, सब-एजेंट की कॉल के लिए नहीं।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Crush Hooks
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 not intercepted, though
the sub-agent tool call itself is.
For the full reference, see docs/hooks/README.md. This skill covers what you
need to author correct hooks.
Supported Events
Crush supports 13 hook events: PreToolUse, PostToolUse,
PostToolUseFailure, PermissionRequest, PermissionResult,
SessionStart, SessionEnd, TurnStart, TurnEnd, StopFailure,
Interrupt, PreCompact, PostCompact. Event names are case-insensitive
and accept snake_case (PreToolUse, pretooluse, pre_tool_use all work);
an unknown name is a config error. The five events that carry a tool call
(PreToolUse, PostToolUse, PostToolUseFailure, PermissionRequest,
PermissionResult) accept matcher; the rest run every configured hook and
reject matcher.
Only PreToolUse (allow/deny/halt/rewrite/context), PostToolUse
(halt/replace output/context/feedback), PostToolUseFailure
(halt/context), and PreCompact (block) honor output. The rest are
observe-only. Turn and tool events fire only for the top-level agent, never
for sub-agents (agentic_fetch, the task tool), so a TurnEnd hook runs
once per user prompt.
Per-event payload extras: PostToolUse has tool_response (the output
string), PostToolUseFailure and StopFailure have error, TurnEnd has
last_assistant_message, PermissionResult has decision
(granted/denied/cancelled), SessionStart has source
(startup/resume), SessionEnd has reason, and the compaction events
have trigger (auto/manual). Payloads also carry hook_event_name and
tool_use_id, and hooks see CLAUDE_PROJECT_DIR, so scripts written for
Claude Code usually work unchanged.
Configuration
{
"hooks": {
"PreToolUse": [
{
"matcher": "^bash$", // regex against tool name (optional; omit to match all)
"command": "./hooks/my-hook.sh", // required: shell command to run
"timeout": 10 // optional: seconds, default 30
}
]
}
}
Project-level hooks take precedence over global. Matching hooks are deduped by
command, run in parallel, and aggregated in config order (not finish order).
Language
command is a shell command, so hooks can be written in any language by
invoking the interpreter: node ./hooks/h.js, python3 ./hooks/h.py,
./hooks/h.sh, inline echo '…', etc. The rest of this skill shows bash, but
the input/output contract is identical regardless of language.
Input
Environment variables:
| Variable | Description |
|---|---|
CRUSH_EVENT |
Event name (e.g. PreToolUse) |
CRUSH_TOOL_NAME |
Tool being called (e.g. bash) |
CRUSH_SESSION_ID |
Current session ID |
CRUSH_CWD |
Working directory |
CRUSH_PROJECT_DIR |
Project root directory |
CLAUDE_PROJECT_DIR |
Same value, for Claude Code scripts |
CRUSH_TOOL_INPUT_COMMAND |
For bash calls: the shell command |
CRUSH_TOOL_INPUT_FILE_PATH |
For file tools: the target file path |
The CRUSH_TOOL_* variables are only set on events that carry a tool call.
JSON on stdin:
{
"event": "PreToolUse",
"hook_event_name": "PreToolUse",
"session_id": "313909e",
"cwd": "/home/user/project",
"tool_name": "bash",
"tool_input": {"command": "rm -rf /"},
"tool_use_id": "call_01"
}
Output
Communicate back via exit code (+ stderr) or JSON on stdout.
| Exit Code | Meaning |
|---|---|
| 0 | Success. Stdout is parsed as the JSON envelope below. |
| 2 | Block this tool call. Stderr becomes the deny reason. |
| 49 | Halt the whole turn. Stderr becomes the halt reason. |
| Other | Non-blocking error unless stdout holds a JSON object. |
Exit 2 blocks one tool call (agent sees the rea
अक्सर पूछे जाने वाले सवाल
कौन से इवेंट हुक इस्तेमाल कर सकते हैं?
Crush 13 इवेंट सपोर्ट करता है, जैसे PreToolUse, PostToolUse और SessionStart।
क्या हुक सब-एजेंट के लिए चलते हैं?
नहीं। हुक सिर्फ़ मुख्य एजेंट की टूल कॉल के लिए चलते हैं, सब-एजेंट कॉल के लिए नहीं।
हुक कहाँ सेट होते हैं?
हुक crush.json फ़ाइल में सेट किए जाते हैं।
जानकारी
लेखक का मूल विवरण
Use when the user wants to add, write, debug, or configure a Crush hook — gating or blocking tool calls, approving or rewriting tool input before execution, injecting context into tool results, or troubleshooting hook behavior in crush.json.
repo: charmbracelet/crush
लोकप्रियता
- GitHub स्टार
- 29k
- रैंकिंग में स्थान
- #9766
- लाइसेंस
- —
- अपडेट की गई
- 2/11/2026
कमेंट
- …
इस repository की और skills
crush-config
29kयह आपके एजेंट को Crush सेट करने में मदद करती है, उसकी crushrc या crush.json कॉन्फ़िग फ़ाइल लिखकर, जिसमें प्रोवाइडर, मॉडल, MCP सर्वर, हुक और अनुमतियाँ शामिल हैं।
jq
29kयह आपके एजेंट को JSON डेटा खंगालने और उसका रूप बदलने में मदद करती है, जैसे API जवाब, कॉन्फ़िग फ़ाइलें या लॉग, अंतर्निहित jq कमांड से।
मिलती-जुलती skills
diffs
394kयह आपके एजेंट को बदलावों का असली diff बनाने देती है, जिसे व्यूअर लिंक या इमेज फ़ाइल के रूप में साझा किया जा सकता है, हाथ से लिखे सारांश के बजाय।
coding-agent
394kयह आपके एजेंट को बड़े कोडिंग काम Codex, Claude Code या OpenCode को बैकग्राउंड वर्कर के रूप में सौंपने, फिर उसकी प्रगति जांचने में मदद करती है।
gh-issues
394kयह आपके एजेंट को GitHub issues खोजने, उनमें से काम करने लायक चुनने, और सुधार के साथ pull requests खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।