From claude-optimize
Use when running /optimize:hooks to analyze existing hooks for health issues, detect missing hooks based on project type, and recommend new hooks with implementations. Triggers on hook analysis, hook creation for optimization, or hook health checking. Do NOT trigger on general hook development or coding tasks.
npx claudepluginhub btcdlabs/btcd-cc-marketplace --plugin claude-optimizeThis skill uses the workspace's default tool permissions.
Analyzes Claude Code hook configuration for health, coverage gaps, and improvement opportunities. Powers `/optimize:hooks` and the hook health dimension of `/optimize:audit`.
Compares coding agents like Claude Code and Aider on custom YAML-defined codebase tasks using git worktrees, measuring pass rate, cost, time, and consistency.
Designs and optimizes AI agent action spaces, tool definitions, observation formats, error recovery, and context for higher task completion rates.
Designs, implements, and audits WCAG 2.2 AA accessible UIs for Web (ARIA/HTML5), iOS (SwiftUI traits), and Android (Compose semantics). Audits code for compliance gaps.
Analyzes Claude Code hook configuration for health, coverage gaps, and improvement opportunities. Powers /optimize:hooks and the hook health dimension of /optimize:audit.
ALWAYS use the bundled scripts. Do NOT manually read .claude/settings.json, parse hook JSON, check shebangs/permissions, run bash -n, or use any ad-hoc shell commands like for loops.
# Inventory all hooks (project, personal, plugin)
python3 ${CLAUDE_PLUGIN_ROOT}/scripts/env_inventory.py --component hooks --json
# Validate all hook scripts for health issues
python3 ${CLAUDE_PLUGIN_ROOT}/scripts/hook_validator.py --settings .claude/settings.json --json
The env_inventory discovers hooks from .claude/settings.json, .claude/settings.local.json, and installed plugins. For each hook it returns: event type, matcher, command/script path, and timeout.
The hook_validator checks all hook scripts for: missing shebang, missing set -euo pipefail, unquoted variables (injection risk), missing executable permissions, references to non-existent files, syntax errors (via bash -n), and stdin handling.
Review the validator output for timeout risks:
Based on detected project type (from codebase-analyzer), identify missing hooks:
Reference: ${CLAUDE_PLUGIN_ROOT}/skills/hook-recommender/references/hook-patterns.md
| Hook | Event | Purpose |
|---|---|---|
| Sensitive file protection | PreToolUse (Write|Edit) | Block writes to .env, .key, credential files |
| Dangerous command blocker | PreToolUse (Bash) | Block rm -rf /, chmod 777, etc. |
| Detected | Hook | Event | Purpose |
|---|---|---|---|
| TypeScript/JS | Auto-format | PostToolUse (Write|Edit) | Run prettier/eslint --fix |
| Python | Auto-format | PostToolUse (Write|Edit) | Run black/ruff format |
| Rust | Auto-format | PostToolUse (Write|Edit) | Run cargo fmt |
| Go | Auto-format | PostToolUse (Write|Edit) | Run gofmt |
| Any with tests | Test runner | PostToolUse (Write|Edit) | Run relevant tests |
| Hook | Event | Purpose |
|---|---|---|
| PreCompact context saver | PreCompact | Preserve critical info during compaction |
| Commit message enforcer | PreToolUse (Bash) | Enforce conventional commits |
| Branch protection | PreToolUse (Bash) | Prevent direct commits to main |
If session logs are available, use the session-analyzer skill output (provided by the calling command) to identify hook opportunities. Do NOT manually parse JSONL session files or use grep/awk/for loops.
Look for these patterns in the session analyzer output:
## Hook Health Report
**Overall Grade**: [A-F] ([score]/100)
### Existing Hooks ([count])
| # | Event | Matcher | Timeout | Health |
|---|-------|---------|---------|--------|
| 1 | PreToolUse | Write | 10s | OK |
| 2 | PostToolUse | Bash | none | Warning |
### Health Issues
| Hook | Issue | Severity | Fix |
|------|-------|----------|-----|
| [#] | [description] | [level] | [action] |
### Missing Hooks (Recommended)
| Hook | Event | Priority | Rationale |
|------|-------|----------|-----------|
| .env protection | PreToolUse | Critical | No credential file protection |
| Auto-format | PostToolUse | High | [formatter] detected but no hook |
### Recommended Implementations
[For each missing hook, provide ready-to-use JSON config and script]
### Automation Opportunities (from session analysis)
| Pattern | Frequency | Suggested Hook |
|---------|-----------|---------------|
| [pattern] | [count] | [hook type] |
Hook health dimension (10% of total score):