用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/srid/emanote --skill code-police命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Run /be's review gauntlet SERIALLY — /lens-debate (lowy ⇄ hickey), then /codex-debate, then /simplify, then code-police, each editing and committing on the live branch in turn. Use from /be §4, or when the user asks to "run the review gauntlet". Requires Claude Code's Skill tool.
Modern, interactive alternative to `/do` — clarify intent up front, then take a task end-to-end with a serial AI review gauntlet (lens debate (lowy ⇄ hickey) → codex debate → simplify → code-police, each editing the branch in turn) → CI → evidence. ONLY invoke when the user explicitly types `/be` or `$be`; never auto-select from a natural-language request.
Reference for the `odu` runner — how to invoke a full pipeline, a single recipe, or a platform-pinned node, and how to attach to a live run, from a project whose CI odu runs. Trigger when the user asks to "run CI", "run the pipeline", "re-run a check", to run named lanes or recipes (e.g. "run fmt and nix", "just the e2e lane", bare selectors like `fmt`/`nix`/`e2e`), or names a recipe by `<recipe>@<platform>`. This skill — not a repo's local `just ci` / `just <recipe>` — is how an odu-run request is served.
基于 SOC 职业分类
正在显示 SKILL.md
| name | code-police |
| description | Review code for quality, simplicity, and common mistakes before declaring work complete. |
| context | fork |
| model | sonnet |
| argument-hint | [--no-elegance] |
Review the current changes (scoped to the current branch/PR) against the rules below plus any additional rules from the project. The three passes — rule checklist, fact-check, elegance — run as parallel sub-agents on fresh contexts; the implementer's main context just wrote the diff and is biased to rationalize it, so reviewing inline laundered violations through. Sub-agents start cold, which is the point. After they return, the orchestrator stitches their findings into a single summary.
--no-elegance — skip Pass 3 (elegance) entirely. Pass 1 (rules) and Pass 2 (fact-check) still run. Use this when the elegance pass would be redundant because /simplify already ran over this same tree — e.g. a caller that invokes /simplify standalone and then /code-police. Without it, Pass 3 re-invokes /simplify on an already-simplified tree, paying a full skill invocation (agent spawn, diff re-read, model tokens) to re-derive a near-guaranteed no-op. When the flag is set, report Pass 3 as Elegance | – | Skipped (--no-elegance) in the summary.
Before spawning the pass sub-agents, read .agency/code-police.md if it exists. Treat any rules declared there — whether inline or as a pointer to another file (See ./code-police-rules.md) — as additions to the built-in rules below. They appear as separate rows in the Pass 1 checklist with the project's chosen rule IDs.
If .agency/code-police.md is missing, proceed with only the built-in rules. The file is project-defined and free-form (Markdown, no required frontmatter).
These apply to every pass — Pass 1, Pass 2, Pass 3 alike. Each sub-agent's prompt restates them, but the burden also sits on the orchestrator: if a sub-agent comes back with prose that violates these, push it back rather than launder its dismissal through the summary.
Two similar instances are fine — don't abstract prematurely. Three is the threshold for extraction. But identical content that must stay in sync (same HTML, same version string) should be deduplicated immediately regardless of count. Versions, ports, paths — define once, reference everywhere.
Before hand-rolling a utility (string tokenizer, quoted-string parser, date helper, semver comparator, URL builder, CLI arg parser, tree walker, regex-based matcher, path normalizer, etc.), check whether a focused library solves the same problem. If one exists with a matching scope and a reasonable bundle cost, prefer it — even if it's a new dependency. Hand-rolling is only justified when the library would add capabilities you actively don't want (tagging, env expansion, i18n layers, etc. you'd have to ignore), or when the hand-roll is genuinely a handful of lines with no branching.
Rationale: "Zero deps" is an easiness judgment dressed as a simplicity judgment. Code you don't own is genuinely simpler than code you do own — it doesn't accumulate private test fixtures, it doesn't bitrot when requirements shift, and its edge cases are someone else's problem to fix. Hand-rolled utilities routinely grow past the library they displaced as new edge cases surface. A small focused library with a single exported function is the same complexity to your reader as a one-line utility import, and less complexity than a 40-line loop with state variables.
How to apply: When you're about to write a loop with nested state-machine variables, a tokenizer, a parser, a semver comparator, a date math helper, a quoted-string handler, or a path normalizer — stop and search for the focused library first. Only fall back to hand-roll after seeing a concrete library and judging that its scope genuinely exceeds what you need.
Anti-patterns in this rule's application:
Use discriminated unions, not booleans or stringly-typed fields. If two fields can't both be undefined at the same time, model that in the type.
Aggressively remove unused code. No commented-out blocks, no "just in case" leftovers.
Never silently swallow errors. Empty catch {} blocks, bare catch: pass, and || true hide failures. At minimum, log the error. If the catch is intentional (best-effort operation), add a comment explaining why the error is safe to ignore.
Rationale: Silent swallowing masks bugs — failures disappear without a trace, making debugging impossible.
Collections, buffers, and listeners that grow with usage must have a bound or a cleanup path. Common violations:
fs.watch, resize, scroll, mousemove, WebSocket onmessage, or any event that can fire many times per second. Each invocation that does non-trivial work (I/O, parsing, DOM mutation, allocation) needs a debounce or throttle. A bare handler is only acceptable if the work is O(1) and allocation-free.Rationale: LLM-generated code defaults to the simplest correct implementation, which is often O(n) in session lifetime. These patterns silently degrade performance over hours/days and surface as "the app got slow" with no obvious cause. The fix is almost always straightforward (cap, debounce, stream, share) but must be applied at write time — it's rarely caught in review because the code is functionally correct.
Write a comment when a reader who didn't write the code can't tell, at first glance, what it does or why it's structured this way. The comment supplies whichever is missing — design intent (why this shape over the conventional one), control-flow semantics (what the cascade actually dispatches), or a hidden constraint the type system doesn't carry.
This is a positive prompt, applied per block: at every non-trivial declaration or block, ask the question. A "obvious to me because I just wrote it" reflex is the failure mode — reviewers and writers both pattern-match on what they already understand and skip the question.
Spawn Pass 1 and Pass 2 as two parallel sub-agents via the harness's agent tool. On Claude Code this is the Agent tool with subagent_type: "Explore" (Pass 1 and Pass 2 are read-only audits — no edits). On opencode this is the task tool. On Codex, the sub-agent spawning tool. Emit both Agent tool_use blocks in a single response so they run concurrently — sequential spawning halves the parallelism.
Each sub-agent inherits no context from the implementer's main thread; the prompts below are self-contained and reference the rules-of-record by file path so a single source of truth stays in this skill.
Pass 3 runs after Pass 1 and Pass 2 return. It applies fixes (via /simplify) and would race against Pass 1/2's grep-and-read work if run in parallel; sequential is the safer ordering. See "Pass 3: Elegance" below. If --no-elegance was passed, skip Pass 3 — only Pass 1 and Pass 2 run.
Once all three pass outputs are in hand, stitch them into the summary table in the Output section.
Sub-agent prompt:
You are Pass 1 (rule checklist) of the
/code-policeskill on this repo's current diff.Read the "Reviewing principles" and "Rules" sections of
.apm/skills/code-police/SKILL.mdfor the built-in rule set. Also read.agency/code-police.mdif it exists — its rules are additions to the built-in list (separate rows in the table, project-chosen rule IDs).Scope: the current diff against the merge base — run
git diff origin/HEAD...HEAD(or the appropriate base-branch ref iforigin/HEADis unset).Produce a single table with every rule (built-in + project):
Rule ID Violation found? What was identified Action taken Every "No" requires a
Checked by:field whose content is one of:
- For purely-negative rules (e.g.
no-dead-code,no-silent-error-swallowing): the grep that confirmed absence — "grep'd forhead,tail,fromJust,(!!),Map.!,error,undefined; zero matches."- For bidirectional rules (e.g.
comment-the-non-obvious,prefer-focused-library): the enumeration of positive candidates ruled out — "enumeratedam,keep, guard branches,G.stars/G.reachablecalls; for each, named why a fresh reader decodes the why from code alone."A "No" without
Checked by:is malformed and must be rewritten. Every rule must appear in the table — no skipping. Apply the "Reviewing principles" verbatim — do not rationalize a violation away because the diff "needs" it.Return only the table plus any per-finding rationale beneath it. Do not apply fixes; the orchestrator will route them.
Sub-agent prompt:
You are Pass 2 (fact-check) of the
/code-policeskill on this repo's current diff.Read the "Reviewing principles" section of
.apm/skills/code-police/SKILL.mdand apply them verbatim. This is not a style review — it is a logic review. Find places where the code lies to itself.Scope: the current diff against the merge base — run
git diff origin/HEAD...HEAD(or the appropriate base-branch ref iforigin/HEADis unset).Flag:
- Silent error swallowing — bare
try/catch: pass, emptycatch {},|| true, errors caught but not propagated,Result/Optionsilently defaulted.- Inaccurate fallbacks — defaults masking misconfiguration, "sensible defaults" that aren't sensible for the failure case, fallback paths that silently degrade correctness.
- Wishful thinking — assumptions about input shape without validation at boundaries, code that "can't fail" but actually can, race conditions papered over with comments.
- Logic errors — always-true/false conditions, off-by-one, wrong operators, shadowed variables.
- Slow leaks — collections that grow without bound, event handlers doing heavy work on every fire without debounce, watchers/listeners registered per-caller instead of shared, buffers sized to the full input when streaming would work.
Operating principles:
- Fail loud over fail silent: Code should scream when something is wrong, not quietly do the wrong thing.
- Fallbacks must be justified: Every default/fallback needs a reason why that value is correct for the failure case, not just convenient.
- Precision over coverage: Better to catch 3 real issues than flag 20 maybes.
For each finding: file, line, one-line risk, concrete fix. If no issues, say so — don't invent problems. Do not apply fixes; the orchestrator will route them.
Skip if --no-elegance was passed. Do not run this pass and do not invoke /simplify; report Elegance | – | Skipped (--no-elegance) in the summary. The caller asserted /simplify already ran over this tree, so a second run is redundant. Pass 1 and Pass 2 are unaffected.
Skip on tiny diffs. Run git diff origin/HEAD...HEAD --shortstat (or the appropriate base-branch ref). If the diff is under 10 lines, skip this pass and report Elegance | 0 | Skipped (tiny diff) in the summary. The elegance pass's three-lens fan-out has overhead that's disproportionate to a few-line change; Pass 1 and Pass 2 still run. If the diff exceeds the threshold, proceed below.
Review the changes for elegance and simplicity.
If running under Claude Code (the Skill tool is available): invoke the bundled /simplify skill via the Skill tool. It runs three parallel lenses — reuse, quality, efficiency — over the current diff and applies fixes. Prefer this path.
On other harnesses (no /simplify available), run the inline loop instead. For each iteration (run 3 iterations):
Principles:
The "Reviewing principles" (prosecutor stance, no talk-out-of-findings) apply here too — /simplify and the inline loop both bind to them.
Stitch the three pass outputs into a single combined summary:
| Pass | Issues found | Details |
|---|---|---|
| Rules | N | Brief summary or "Clean" |
| Fact-check | N | Brief summary or "Clean" |
| Elegance | N | Brief summary or "Clean" |
Below the table, reproduce each sub-agent's full findings (the Pass 1 rule table, Pass 2's per-finding list, Pass 3's /simplify log) verbatim so the orchestrator (/do's police step) can commit each violation as its own fix.
If ANY pass found issues, clearly state: "Violations or issues found" so the workflow can route to a fix step.
If all passes are clean, state: "All clear".
Simple means not interleaved. Each module does one thing. Data flows through arguments and return values, not shared mutable state or indirection.
# above the recipe name).Group code by rate of change, not by technical layer. Things that change together live together; things that change independently get separate modules.