用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/SocketDev/action --skill creating-guards命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Propagate a wheelhouse template change across fleet repos: worktrees, push/PR fallback, cleanup.
Run this repo's GitHub Actions locally with Agent-CI before pushing CI-sensitive changes.
Audit package exports for dead, internal-only, or weakly-consumed subpaths before pruning.
基于 SOC 职业分类
正在显示 SKILL.md
| name | creating-guards |
| description | Author or convert fleet hooks to the uniform check plus runGuard contract used by the dispatcher. |
| model | claude-haiku-4-5 |
| context | fork |
| user-invocable | false |
| allowed-tools | Read, Edit, Write, Grep, Glob, Bash |
| metadata | {"internal":true} |
Rule: a guard is a pure function that RETURNS a verdict — it never calls process.exit and never runs logic at import top level beyond one runGuard(check). That contract is what lets the per-event dispatcher (_shared/dispatch.mts) import every guard for an event into ONE node process (one @socketsecurity/lib-stable import) instead of paying a node cold-start + lib import per guard on every tool call.
_shared/guard.mts)import { block, notify, bashGuard, runGuard } from '../_shared/guard.mts'
// editGuard for Edit/Write/MultiEdit hooks; both if it handles both.
export const check = bashGuard((command, payload) => {
if (<not applicable>) { return undefined } // allow, silent
if (<bypass present>) { return undefined }
return block(`[my-guard] Blocked: …\n Fix: …`) // or notify(…)
})
await runGuard(check)
Three verdicts — pick by intended behavior:
block(message) — prints message to stderr and sets exitCode 2 (Claude Code blocks the tool call). Use for a -guard.notify(message) — prints to stderr, exit 0, the tool call proceeds. Use for a -nudge / -nudge.undefined — allow, silent.export const check = bashGuard((command, payload) => …)export const check = editGuard((filePath, content, payload) => …)export const check = (payload) => … (no adapter; read payload.transcript_path etc.)await runGuard(check).socket/guard-contract)process.exit(...) — a hard exit in a shared dispatcher kills the loop and silently skips every later guard.process.argv[1] entrypoint gates — they misfire when the dispatcher imports the module.process.stdin reader — read the payload only through the harness / readPayload.export const check + one await runGuard(check). Unit tests import check and call it directly (no spawning).A pure side-effect hook (output transformer, installer, sweeper) with no block and no user-facing message does NOT fit the verdict contract — leave it as its own spawned command and skip the conversion.
Registration is generated: node scripts/fleet/gen/hook-dispatch.mts classifies every guard and moves contract-conformant ones into _shared/dispatch-manifest.json (dispatched) — non-conformant ones stay spawned. Run it after adding/converting a guard; --check (in check --all) fails when the wiring is stale.