All skills
Skillintermediate

refactor: Adopt anchored confidence, validation gate, and mode-aware precision in ce-code-review

Port the ce-doc-review anchored-confidence pattern into ce-code-review and add three code-review-specific precision controls inspired by Anthropic's official `code-review` plugin: a per-finding validation stage before externalization, mode-aware false-positive policy, and an explicit lint-ignore suppression rule. Also add a PR-mode-only skip-condition pre-check (closed/draft/trivial/already-review

Claude Code Knowledge Pack7/10/2026

Overview

refactor: Adopt anchored confidence, validation gate, and mode-aware precision in ce-code-review

Overview

Port the ce-doc-review anchored-confidence pattern into ce-code-review and add three code-review-specific precision controls inspired by Anthropic's official code-review plugin: a per-finding validation stage before externalization, mode-aware false-positive policy, and an explicit lint-ignore suppression rule. Also add a PR-mode-only skip-condition pre-check (closed/draft/trivial/already-reviewed) to avoid wasted review cycles.

The goal is to make ce-code-review's externalizing modes (autofix, headless, future PR-comment) materially higher-precision while preserving interactive mode's broader review surface.

Problem Frame

ce-code-review currently uses a continuous confidence: 0.0-1.0 field with a 0.60 suppress gate, a 0.50+ P0 exception, and a +0.10 cross-reviewer agreement boost. The same false-precision problem ce-doc-review just fixed applies here: personas anchor on round numbers (0.65, 0.72, 0.85), the gate boundary creates a coin-flip band, and the additive boost hides what the score actually measures.

Reviewing Anthropic's official code-review plugin (anthropics/claude-plugins-official/plugins/code-review/commands/code-review.md) surfaced four additional precision techniques worth adopting:

  1. Anchored 0/25/50/75/100 rubric — discrete buckets tied to behavioral criteria reduce model-fabricated precision. ce-doc-review already proved this works (commit 6caf3303); ce-code-review was deferred at the time.
  2. Per-finding validation subagent — Anthropic's actual command relies on a binary validated/not-validated gate more than on the numeric score. Independent validation catches false positives that confident-sounding personas produce. We rely on cross-reviewer agreement, which only fires when 2+ reviewers happen to converge — many real findings only fire once.
  3. Skip-condition pre-check — Anthropic skips closed, draft, trivial, or already-reviewed PRs before doing any work. We have no equivalent; PR-mode invocations spend full review effort on PRs that should not be reviewed.
  4. Lint-ignore suppression — code carrying an explicit eslint-disable, rubocop:disable, etc. for the rule a reviewer is about to flag should suppress the finding. Not currently in our false-positive catalog.

The right framing for ce-code-review's broader surface is not "narrow to Anthropic's 4-agent shape" but "tier the precision bar by mode": externalizing modes (PR-comment, autofix, headless) need narrow Anthropic-style precision; interactive mode is allowed broader findings as long as weak general-quality concerns route to soft buckets (advisory / residual_risks / testing_gaps) rather than primary findings.

Independent validation as a Stage 5b gate (drop rejected findings, keep approved ones) is the right framing. An earlier draft of this plan added a validated: boolean field to every finding — that field was YAGNI and is removed. The validator's effect is on the population of surviving findings, not on per-finding metadata.

Requirements Trace

  • R1. Replace continuous confidence field with 5 discrete anchor points (0, 25, 50, 75, 100) and a behavioral rubric per anchor. Mirror ce-doc-review's pattern.
  • R2. Update Stage 5 synthesis to consume anchor values: >= 75 filter threshold (P0 exception at 50+), one-anchor cross-reviewer promotion (replaces +0.10), anchor-descending sort.
  • R3. Add a new Stage 5b validation pass that spawns one validator subagent per surviving finding before externalization. Scope: required for autofix/headless externalization and downstream-resolver handoff; skipped for interactive terminal display where the human is the validator. Validation is process logic — findings the validator rejects are dropped; no metadata field is added to surviving findings.
  • R4. Make the false-positive policy mode-aware in synthesis. Headless and autofix apply the narrow Anthropic-style filter (concrete bugs, compile/parse failures, traceable security, explicit standards violations only). Interactive demotes weak general-quality concerns to advisory / residual_risks / testing_gaps rather than suppressing them.
  • R5. Add an explicit lint-ignore suppression rule to the subagent template's false-positive catalog: if the code carries a lint disable comment for the rule the reviewer is about to flag, suppress unless the suppression itself violates project standards.
  • R6. Add a PR-mode-only skip-condition pre-check (closed, draft, trivial automated, or already-reviewed by Claude). Skip cleanly without dispatching reviewers. Standalone branch and base: modes are unaffected.
  • R7. Update all persona files for hardcoded float confidence references and mode-aware suppression hints where applicable.
  • R8. Update test fixtures and contract tests in tests/review-skill-contract.test.ts and any related fixtures.
  • R9. Document the migration in docs/solutions/skill-design/ extending the existing ce-doc-review note, including the rationale for ce-code-review's specific threshold and the validation-stage scoping decision.

Scope Boundaries

  • No change to persona-specific domain logic (what each persona looks for). Only confidence rubric, validation flow, mode-aware policy, and skip-conditions change.
  • No change to severity taxonomy (P0 | P1 | P2 | P3).
  • No change to autofix_class or owner enums.
  • No collapse of the 17-persona architecture to Anthropic's 4-agent shape. ce-code-review's broader surface is intentional.
  • No change to the standalone / branch / PR / base: scope-resolution paths in Stage 1.

Deferred to Separate Tasks

  • PR inline comment posting mode: Anthropic's --comment flag posts findings as inline GitHub PR comments via mcp__github_inline_comment__create_inline_comment with full-SHA link discipline and committable suggestion blocks for small fixes. We have no PR-comment mode at all today. This is a substantial new mode (link format, suggestion-block handling, deduplication semantics, tracker integration overlap). Worth its own plan; this refactor sets the precision foundation it would build on.
  • Haiku-tier orchestrator-side checks: Anthropic uses haiku for the skip-condition probe and CLAUDE.md path discovery. We currently use sonnet for everything; pushing cheap checks to haiku is a separate cost-optimization task.
  • Re-evaluating which always-on personas earn their noise: Anthropic's HIGH-SIGNAL philosophy raises the question of whether testing and maintainability should remain always-on. Out of scope here — handled by the mode-aware soft-bucket routing in this plan, but a deeper re-think is its own conversation.

Context & Research

Relevant Code and Patterns

Direct port targets (ce-doc-review prior art):

  • plugins/compound-engineering/skills/ce-doc-review/references/findings-schema.json — anchored integer enum precedent
  • plugins/compound-engineering/skills/ce-doc-review/references/subagent-template.md — verbatim rubric + consolidated false-positive catalog
  • plugins/compound-engineering/skills/ce-doc-review/references/synthesis-and-presentation.md — anchor gate, one-anchor promotion, anchor-descending sort
  • Commit 6caf3303 — the migration diff is the canonical reference for what to change in this skill

Files this plan modifies:

  • plugins/compound-engineering/skills/ce-code-review/SKILL.md — Stage 1 (skip-condition gate), Stage 5 (anchor gate, promotion), new Stage 5b (validation), Stage 6 (mode-aware false-positive policy)
  • plugins/compound-engineering/skills/ce-code-review/references/findings-schema.json — confidence enum, threshold table in _meta
  • plugins/compound-engineering/skills/ce-code-review/references/subagent-template.md — anchored rubric, expanded false-positive catalog with lint-ignore rule, mode-aware suppression hints
  • plugins/compound-engineering/skills/ce-code-review/references/persona-catalog.md — verify no float references remain (no behavioral changes needed)
  • plugins/compound-engineering/skills/ce-code-review/references/review-output-template.md — anchor-as-integer rendering in confidence column
  • plugins/compound-engineering/skills/ce-code-review/references/walkthrough.md — anchor display in per-finding block
  • plugins/compound-engineering/skills/ce-code-review/references/bulk-preview.md — anchor rendering if confidence appears
  • plugins/compound-engineering/agents/ce-*-reviewer.agent.md — sweep for hardcoded float references
  • tests/review-skill-contract.test.ts — anchor enum assertions, validation-stage assertions, skip-condition assertions
  • tests/fixtures/ — any seeded review fixtures with embedded confidence values
  • docs/solutions/skill-design/confidence-anchored-scoring-2026-04-21.md — extend with ce-code-review section

Institutional Learnings

  • docs/solutions/skill-design/confidence-anchored-scoring-2026-04-21.md — the canonical writeup of the anchored-rubric pattern. Establishes the ce-doc-review threshold of >= 50 and explicitly anticipates ce-code-review's threshold of >= 75 due to opposite economics (linter backstop, PR-comment cost, ground-truth verifiability of code claims).
  • docs/plans/2026-04-21-001-refactor-ce-doc-review-anchored-confidence-scoring-plan.md — the ce-doc-review plan, particularly its "Deferred to Separate Tasks" entry naming this exact follow-up. Sequencing rationale ("do ce-doc-review first, observe, then plan ce-code-review") was honored.

External References

  • anthropics/claude-plugins-official/plugins/code-review/commands/code-review.md — canonical source for the four code-review-specific patterns (anchored rubric, validation step, skip-conditions, lint-ignore). Note: the README describes a 0/25/50/75/100 scale with threshold 80, but the actual command prompt relies more heavily on the binary validated/not-validated gate (their Step 5) than on the numeric score. We model this faithfully by adopting both the anchored rubric and the validation gate, recognizing the validation gate is the load-bearing precision mechanism.
  • Two-model comparative analysis (this conversation, 2026-04-21) — original reflection plus second-model critique that surfaced (a) validation gate is more important than the numeric score in the upstream design, (b) false-positive policy should be mode-aware, (c) confidence and validation should be decoupled fields. All three insights are R-traced above.

Slack Context

Slack tools detected. Ask me to search Slack for organizational context at any point, or include it in your next prompt.

Key Technical Decisions

  • Threshold >= 75, not >= 80: Matches ce-doc-review's stylistic choice of using the anchor itself as the threshold (no awkward >= 80 middle-bucket gap that effectively means "100 only" under the discrete scale). At >= 75, anchor 75 ("real, will hit in practice") and anchor 100 ("evidence directly confirms") survive; anchors 0 / 25 / 50 are dropped. P0 exception at 50+ preserves the current escape hatch for critical-but-uncertain issues.
  • Validation is process logic, not a metadata field: An earlier draft of this plan added a validated: boolean field to every finding. Removed: rejected findings are dropped, so surviving findings post-validation are validated by definition; in modes where validation does not run, no consumer needs a per-finding flag because the run's mode already tells them whether validation ran. A field that is constant within any mode does no work and the name implies a truth claim it does not carry. Validation stays as a Stage 5b gate; no schema change.
  • Validation is scoped to externalization, not universal: Validating every finding roughly doubles agent calls. The cost is justified when findings will be posted to GitHub, applied automatically, or handed off to downstream automation — places where false positives have real cost. For interactive terminal display, the user provides the validation by reviewing.
  • One validator subagent per finding, not batched: Independence is the product. A single batched validator looking at all findings together pattern-matches across them and effectively becomes an opinionated re-reviewer, recreating the persona-bias problem we are escaping. Per-finding parallel dispatch keeps fresh context per call. Per-file batching is a plausible future optimization for reviews with many findings clustered in few files, but not needed today (typical reviews surface 3-8 findings post-gate).
  • Validator dispatch budget cap: To bound worst-case cost when a review surfaces an unusually large finding set, cap parallel validator dispatch at 15. If more findings survive Stage 5, validate the highest-severity 15 in parallel and queue the rest for a second wave. This is a safety bound; typical reviews never hit it.
  • Mode-aware false-positive policy uses existing soft buckets, not a new schema field: Weak general-quality findings already have well-defined homes (residual_risks for "noticed but couldn't confirm," testing_gaps for missing coverage, advisory autofix_class for "report-only"). Mode-aware demotion routes weak findings into these buckets in interactive mode and suppresses them in headless/autofix. No new schema needed.
  • One-anchor cross-reviewer promotion replaces +0.10 boost: Mirrors ce-doc-review. Cleaner than additive math and semantically meaningful (independent corroboration moves a "real but minor" finding to "real, will hit in practice").
  • Skip-condition gate is PR-mode only: Standalone, branch, and base: modes always run. The closed/draft/trivial/already-reviewed checks only make sense when there's a PR. Already-reviewed detection uses gh pr view --comments filtering for prior Claude-authored comments; the same pattern Anthropic uses.
  • Lint-ignore suppression has a project-standards exception: If a finding is about a CLAUDE.md/AGENTS.md rule violation and the code uses a lint disable to suppress that specific rule, the suppression itself may violate project standards (e.g., "do not use eslint-disable-next-line for security rules"). The rule is "suppress the finding unless the suppression itself is the violation."
  • No haiku-tier downgrade in this plan: The skip-condition pre-check is a natural haiku candidate, but model-tier choices are out of scope here. Use the same mid-tier (sonnet) the rest of the skill uses; haiku is its own optimization plan.

Open Questions

Resolved During Planning

  • Threshold value (>= 75 vs >= 80)? Resolved: >= 75. Matches ce-doc-review's use of the anchor as the threshold and avoids the ">= 80 collapses to anchor 100 only" gotcha under a discrete scale.
  • **Add a validated field on findings or keep val