一键导入
hooks-worker
Hook system optimization — async conversion, consolidation, deduplication, new hook events
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Hook system optimization — async conversion, consolidation, deduplication, new hook events
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Agent frontmatter enhancements — disallowedTools, mcpServers scoping, fork_eligible field
Context management — pre-compact persistence, threshold alignment, microcompact/circuit breaker detection
Hook enhancements — updatedInput for bash safety prefixes, suppressOutput for verbose blocks, denial-based routing feedback
Memory index discipline — cap enforcement, pruning, archival, health reporting
Prompt assembler optimization — sorting, memoization, cache-break detection, integration tests
Compresses and merges CLAUDE.md and rules files to fit under the 40K character cap
基于 SOC 职业分类
| name | hooks-worker |
| description | Hook system optimization — async conversion, consolidation, deduplication, new hook events |
NOTE: Startup and cleanup are handled by worker-base. This skill defines the WORK PROCEDURE.
Features that modify .claude/settings.json hook registrations, create new hook scripts, consolidate existing hooks, or add new hook event categories.
Read the feature description carefully. Understand exactly which hooks to modify, what safety classification to respect, and what the expected settings.json structure should be.
Baseline snapshot. Before ANY changes, read .claude/settings.json and record:
Write tests first (red). Create test file at tests/hooks/<descriptive-name>.test.cjs. Tests should verify:
Implement changes.
'use strict', project-root.cjs, safeParseJSON, formatResult(). Security hooks exit 2 to block; advisory hooks exit 0.Run tests (green). All tests pass. Fix any failures.
Validate settings.json.
node -e "JSON.parse(require('fs').readFileSync('.claude/settings.json','utf8'))"
Run lint and format.
pnpm lint
pnpm format:check
Manual verification. For new hooks, run them manually with sample input to verify behavior. For settings.json changes, diff against baseline to confirm only intended changes were made.
{
"salientSummary": "Converted 22 advisory hooks to async:true in settings.json. Zero security hooks affected. Added timeout_ms to 40 hooks that were missing it. settings.json valid JSON with all 7 event categories preserved. Created tests/hooks/hook-async-classification.test.cjs (15 tests).",
"whatWasImplemented": "Parsed settings.json, classified each hook by reading its source (exit 2 = blocking/sync, exit 0 = advisory/async candidate). Added async:true to 22 advisory hooks across UserPromptSubmit, PostToolUse, PostToolUseFailure. Left all 18 security/blocking hooks as sync. Added timeout_ms to 40 hooks: 5000ms for simple advisory, 10000ms for monitoring, 15000ms for file-scanning, 30000ms for cleanup.",
"whatWasLeftUndone": "",
"verification": {
"commandsRun": [
{
"command": "node --test tests/hooks/hook-async-classification.test.cjs",
"exitCode": 0,
"observation": "15 tests passing"
},
{
"command": "node -e \"JSON.parse(require('fs').readFileSync('.claude/settings.json','utf8'))\"",
"exitCode": 0,
"observation": "Valid JSON"
},
{
"command": "pnpm lint",
"exitCode": 0,
"observation": "0 errors"
}
]
},
"tests": {
"added": [
{
"file": "tests/hooks/hook-async-classification.test.cjs",
"cases": [
{ "name": "advisory hooks have async:true", "verifies": "VAL-HO-003" },
{ "name": "security hooks do NOT have async:true", "verifies": "VAL-HO-002" },
{ "name": "all hooks have timeout_ms", "verifies": "VAL-HO-004" }
]
}
]
},
"discoveredIssues": []
}