skills/codex/cc-hooks-creator/SKILL.md
<!-- AUTO-GENERATED by export-skills.py — DO NOT EDIT --> --- name: cc-hooks-creator description: Create, configure, and debug Claude Code hooks -- shell commands that execute at lifecycle events (PreToolUse, PostToolUse, Stop, SessionStart, etc.). Use when building file protection, code formatting, notifications, context loading, or any automation triggered by Claude Code events. Covers inline commands, Python scripts, JSON output, state management, and security. --- > **Platform Note:** This
npx skillsauth add frank-luongt/faos-skills-marketplace skills/codex/cc-hooks-creatorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Platform Note: This skill was designed for multi-agent execution. In Codex, treat sub-agent instructions as sequential steps to complete thoroughly within a single agent context.
Create effective Claude Code hooks -- shell commands that execute automatically at specific lifecycle points, enabling deterministic control over Claude's behavior.
| Event | When It Runs | Common Use Cases |
|---|---|---|
| PreToolUse | Before tool executes | Block operations, validate inputs, auto-approve |
| PostToolUse | After tool completes | Format files, log operations, validate output |
| Stop | When Claude finishes | Remind to store learnings, validate completion |
| SubagentStop | When subagent completes | Validate subagent output |
| UserPromptSubmit | When user submits prompt | Add context, validate prompts |
| SessionStart | Session begins | Load context, set environment |
| SessionEnd | Session ends | Cleanup, logging |
| PreCompact | Before context compact | Save important context |
Input (JSON via stdin):
{
"session_id": "abc123",
"transcript_path": "/path/to/transcript.jsonl",
"cwd": "/current/directory",
"hook_event_name": "EventName",
"tool_name": "Write",
"tool_input": {"file_path": "/path/to/file"}
}
Output (exit codes):
Advanced JSON output (exit 0):
{
"decision": "block",
"reason": "Explanation for Claude",
"hookSpecificOutput": {
"hookEventName": "PreToolUse",
"permissionDecision": "allow|deny|ask"
}
}
Inline command (simple):
{
"hooks": {
"PreToolUse": [{
"matcher": "Bash",
"hooks": [{
"type": "command",
"command": "jq -r '.tool_input.command' >> ~/.claude/bash-log.txt"
}]
}]
}
}
Python script (complex):
#!/usr/bin/env python3
import json, sys
def main():
input_data = json.load(sys.stdin)
tool_name = input_data.get("tool_name", "")
tool_input = input_data.get("tool_input", {})
# Your logic here...
sys.exit(0) # Allow
# print("Error message", file=sys.stderr); sys.exit(2) # Block
if __name__ == "__main__":
main()
Add to ~/.claude/settings.json (user) or .claude/settings.json (project):
{
"hooks": {
"EventName": [{
"matcher": "ToolPattern",
"hooks": [{
"type": "command",
"command": "/path/to/hook-script.py",
"timeout": 30
}]
}]
}
}
Matcher patterns: Exact ("Write"), Regex ("Edit|Write"), All ("*" or "")
#!/usr/bin/env python3
import json, sys
PROTECTED = ['.env', 'package-lock.json', '.git/', 'credentials']
input_data = json.load(sys.stdin)
file_path = input_data.get('tool_input', {}).get('file_path', '')
if any(p in file_path for p in PROTECTED):
print(f"Protected file: {file_path}", file=sys.stderr)
sys.exit(2)
sys.exit(0)
#!/usr/bin/env python3
import json, sys, subprocess
input_data = json.load(sys.stdin)
file_path = input_data.get('tool_input', {}).get('file_path', '')
if file_path.endswith('.py'):
subprocess.run(['black', file_path], capture_output=True)
elif file_path.endswith(('.ts', '.tsx', '.js', '.jsx')):
subprocess.run(['npx', 'prettier', '--write', file_path], capture_output=True)
sys.exit(0)
#!/usr/bin/env python3
import json, sys, os
result = os.popen('git log --oneline -5 2>/dev/null').read()
output = {
"hookSpecificOutput": {
"hookEventName": "SessionStart",
"additionalContext": f"Recent commits:\n{result}"
}
}
print(json.dumps(output))
sys.exit(0)
For hooks tracking state across invocations:
import json, os
from datetime import datetime
STATE_FILE = os.path.expanduser("~/.claude/hook_state.json")
def load_state():
if os.path.exists(STATE_FILE):
with open(STATE_FILE) as f:
return json.load(f)
return {"invocations": 0, "last_run": None}
def save_state(state):
with open(STATE_FILE, 'w') as f:
json.dump(state, f)
chmod +x /path/to/hook.pyecho '{"tool_name":"Write"}' | /path/to/hook.pyclaude --debugCtrl+O in Claude Code"$VAR" not $VAR..)| Avoid | Why | Instead |
|---|---|---|
| Inline commands for complex logic | Hard to debug, no error handling | Use Python/Bash scripts |
| Missing timeout | Hook can hang indefinitely | Set "timeout": 30 |
| No exit code handling | Unclear success/failure | Use 0 (allow), 2 (block) |
| Modifying tool input without reason | Confuses Claude | Only modify when necessary, document why |
| Missing try/except | JSON parse errors crash hook | Wrap in try/except |
development
<!-- AUTO-GENERATED by export-skills.py — DO NOT EDIT --> --- name: grpo-rl-training description: GRPO reinforcement learning training with TRL. Use when applying Group Relative Policy Optimization for reasoning and task-specific model training. --- # GRPO/RL Training with TRL Expert-level guidance for implementing Group Relative Policy Optimization (GRPO) using the Transformer Reinforcement Learning (TRL) library. This skill provides battle-tested patterns, critical insights, and production-r
tools
<!-- AUTO-GENERATED by export-skills.py — DO NOT EDIT --> --- name: graphql-architect description: Master modern GraphQL with federation, performance optimization, --- ## Use this skill when - Working on graphql architect tasks or workflows - Needing guidance, best practices, or checklists for graphql architect ## Do not use this skill when - The task is unrelated to graphql architect - You need a different domain or tool outside this scope ## Instructions - Clarify goals, constraints, and
development
<!-- AUTO-GENERATED by export-skills.py — DO NOT EDIT --> --- name: grafana-dashboards description: Create and manage production Grafana dashboards for real-time visualization of system and application metrics. Use when building monitoring dashboards, visualizing metrics, or creating operational observability interfaces. --- # Grafana Dashboards Create and manage production-ready Grafana dashboards for comprehensive system observability. ## Do not use this skill when - The task is unrelated
development
<!-- AUTO-GENERATED by export-skills.py — DO NOT EDIT --> --- name: gptq description: GPTQ post-training quantization for generative models. Use when quantizing large models to 4-bit with calibration-based weight compression. --- # GPTQ (Generative Pre-trained Transformer Quantization) Post-training quantization method that compresses LLMs to 4-bit with minimal accuracy loss using group-wise quantization. ## When to use GPTQ **Use GPTQ when:** - Need to fit large models (70B+) on limited GPU