Best for
- When to Use This Skill
- When NOT to Use
- FORBIDDEN INVOCATION PATTERNS
MichelKerkmeester/opencode--skilled-agent-loops-with-spec-kit-memory/.opencode/skills/system-deep-loop/deep-review/SKILL.md
Autonomous iterative code-review loop with externalized state, convergence detection, P0/P1/P2 findings, fresh context per pass.
Decision brief
Iterative code review and quality auditing protocol with fresh context per iteration, externalized state, convergence detection, and severity-weighted findings (P0/P1/P2).
Compatibility matrix
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Not declared | No explicit evidence | Portability before use |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/MichelKerkmeester/opencode--skilled-agent-loops-with-spec-kit-memory --skill ".opencode/skills/system-deep-loop/deep-review"Inspect the Agent Skill "deep-review" from https://github.com/MichelKerkmeester/opencode--skilled-agent-loops-with-spec-kit-memory/blob/6f0b93906be829894c38e580010885d54199067f/.opencode/skills/system-deep-loop/deep-review/SKILL.md at commit 6f0b93906be829894c38e580010885d54199067f. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
RESOURCEMAP = { "REVIEWSETUP": [ "references/protocol/loop-protocol.md", "references/state/state-format.md", "references/state/state-outputs.md", "references/state/state-reducer-registry.md", "assets/deep-review-strategy.md", "references/state/state-jsonl.md", ], "REVIEWITERATIO…
Detect the current review phase from dispatch context to load appropriate resources:
The four primary review dimensions (configured in assets/review-mode-contract.yaml):
Use this skill when: - Code quality audit requiring multiple rounds across different review dimensions - Spec folder validation requiring cross-reference checks between docs and implementation - Release readiness check before shipping a feature or component - Finding misalignmen…
Use this skill when: - Code quality audit requiring multiple rounds across different review dimensions - Spec folder validation requiring cross-reference checks between docs and implementation - Release readiness check before shipping a feature or component - Finding misalignmen…
Permission review
The documentation asks the agent to run terminal commands or scripts.
Invoke cli-opencode / cli-claude-code directly in a loop to simulate iterationsEvidence record
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 95/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 32 | Source | Repository attention, not individual Skill quality |
| Compatibility | 0 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Iterative code review and quality auditing protocol with fresh context per iteration, externalized state, convergence detection, and severity-weighted findings (P0/P1/P2).
Runtime path resolution:
.opencode/agents/*.md.claude/agents/*.mdConvergence threshold semantics and sibling-parity notes (deep-review 0.10 vs deep-research 0.05 vs deep-ai-council 0.20) live in references/convergence/convergence.md §1 under "Threshold Semantics and Sibling Parity".
Use this skill when:
sk-code's code-review mode instead)sk-code or /speckit:implement)This skill is invoked EXCLUSIVELY through the /deep:review command. The command's YAML workflow owns state, dispatch, and convergence.
NEVER:
/tmp and dispatch them via copilot -p@deep-review LEAF agent via the Task tool for iteration loops (the agent is LEAF, a single iteration, and MUST be driven by the command's workflow)deep-review-state.jsonl, deep-review-config.json, deltas/, prompts/, logs/{spec_folder}/review/COMMAND-DRIVEN FAN-OUT IS SUPPORTED: use --executor/--executors/--concurrency flags on /deep:review. The command's YAML step_fanout_spawn owns multi-lineage dispatch; fanout-merge.cjs applies strongest-restriction (any lineage active P0 → merged FAIL). This is not ad-hoc shell dispatch — it is the canonical fan-out path. Intra-lineage wave orchestration remains deferred.
ALWAYS:
/deep:review :auto or /deep:review :confirm.opencode/commands/deep/assets/deep-review-auto.yaml)scripts/reduce-state.cjs be the SINGLE state writerresolveArtifactRoot(specFolder, 'review') from .opencode/skills/system-spec-kit/shared/review-research-paths.cjs to locate the canonical review rootdeep review, convergence review, iterative review, review loop, release readiness, spec folder review, convergence detection, quality audit, find misalignments, verify cross-references, pre-release review, audit spec folder
| Level | When to Load | Resources |
|---|---|---|
| ALWAYS | Every skill invocation | references/protocol/quick-reference.md |
| CONDITIONAL | If intent signals match | Loop protocol, convergence, state format, review contract |
| ON_DEMAND | Only on explicit request | Full protocol docs, detailed specifications |
discover_markdown_resources() recursively inventories references/ and assets/.load_if_available() guards markdown paths, checks inventory, and uses seen.get_routing_key() derives the review phase from dispatch context.UNKNOWN_FALLBACK returns review disambiguation and missing phases return a "no review resources" notice.from pathlib import Path
SKILL_ROOT = Path(__file__).resolve().parent
RESOURCE_BASES = (SKILL_ROOT / "references", SKILL_ROOT / "assets")
DEFAULT_RESOURCE = "references/protocol/quick-reference.md"
INTENT_SIGNALS = {
"REVIEW_SETUP": {"weight": 4, "keywords": ["deep review", "review mode", "convergence review", "iterative review", ":review", "audit spec"]},
"REVIEW_ITERATION": {"weight": 4, "keywords": ["review iteration", "dimension review", "review findings", "P0", "P1", "P2"]},
"REVIEW_CONVERGENCE": {"weight": 3, "keywords": ["review convergence", "coverage gate", "verdict", "binary gate", "all dimensions"]},
"REVIEW_REPORT": {"weight": 3, "keywords": ["review report", "remediation", "verdict", "release readiness", "planning packet"]},
}
NOISY_SYNONYMS = {
"REVIEW_SETUP": {"audit code": 2.0, "review spec folder": 1.8, "release readiness": 1.5, "pre-release": 1.5},
"REVIEW_ITERATION": {"review dimension": 1.5, "check correctness": 1.4, "check security": 1.4, "check alignment": 1.4},
"REVIEW_CONVERGENCE": {"all dimensions covered": 1.6, "coverage complete": 1.5, "stop review": 1.4},
"REVIEW_REPORT": {"review results": 1.5, "what to fix": 1.4, "ship decision": 1.6, "final report": 1.5},
}
# RESOURCE_MAP: local markdown assets + local review-specific protocol docs
RESOURCE_MAP = {
"REVIEW_SETUP": [
"references/protocol/loop-protocol.md",
"references/state/state-format.md",
"references/state/state-outputs.md",
"references/state/state-reducer-registry.md",
"assets/deep-review-strategy.md",
"references/state/state-jsonl.md",
],
"REVIEW_ITERATION": [
"references/protocol/loop-protocol.md",
"references/convergence/convergence.md",
"references/convergence/convergence-signals.md",
],
"REVIEW_CONVERGENCE": [
"references/convergence/convergence.md",
"references/convergence/convergence-signals.md",
"references/state/state-outputs.md",
"references/protocol/completion-criteria.md",
"references/protocol/loop-state-and-gates.md",
"references/convergence/convergence-recovery.md",
],
"REVIEW_REPORT": [
"references/state/state-format.md",
"references/state/state-outputs.md",
"references/state/state-reducer-registry.md",
"assets/deep-review-dashboard.md",
],
}
LOADING_LEVELS = {
"ALWAYS": [DEFAULT_RESOURCE],
"ON_DEMAND_KEYWORDS": ["full protocol", "all templates", "complete reference", "resume deep review", "deep-review wave", "review artifact", "release-readiness audit", "convergence-tracked", "same session lineage", "P0"],
"ON_DEMAND": [
"references/protocol/loop-protocol.md",
"references/state/state-format.md",
"references/convergence/convergence.md",
"references/convergence/convergence-signals.md",
"references/state/state-outputs.md",
"references/state/state-reducer-registry.md",
],
}
PHASE_RESOURCE_MAP = {
"init": ["references/protocol/loop-protocol.md", "references/state/state-format.md", "references/state/state-outputs.md"],
"iteration": ["references/protocol/loop-protocol.md", "references/convergence/convergence.md", "references/convergence/convergence-signals.md"],
"stuck": ["references/convergence/convergence.md", "references/convergence/convergence-signals.md", "references/protocol/loop-protocol.md", "references/state/state-reducer-registry.md"],
"synthesis": ["references/state/state-format.md", "references/state/state-outputs.md", "references/state/state-reducer-registry.md", "assets/deep-review-dashboard.md"],
}
NON_MARKDOWN_REFERENCES = {
"review_contract": "assets/review-mode-contract.yaml",
}
UNKNOWN_FALLBACK_CHECKLIST = [
"Confirm the review target or spec folder",
"Confirm the review phase",
"Provide one concrete file, diff range, or expected finding class",
"Confirm the verification command set before final review",
]
def _guard_in_skill(relative_path: str) -> str:
resolved = (SKILL_ROOT / relative_path).resolve()
resolved.relative_to(SKILL_ROOT)
if resolved.suffix.lower() != ".md":
raise ValueError(f"Only markdown resources are routable: {relative_path}")
return resolved.relative_to(SKILL_ROOT).as_posix()
def discover_markdown_resources() -> set[str]:
docs = []
for base in RESOURCE_BASES:
if base.exists():
docs.extend(path for path in base.rglob("*.md") if path.is_file())
return {doc.relative_to(SKILL_ROOT).as_posix() for doc in docs}
def get_routing_key(dispatch_context) -> str:
phase = str(getattr(dispatch_context, "phase", "")).strip().lower()
if phase:
return phase
text = str(getattr(dispatch_context, "text", "")).lower()
if "recovery" in text:
return "stuck"
if "convergence" in text or "synthesis" in text:
return "synthesis"
if "iteration" in text or "dimension" in text:
return "iteration"
return "init"
def route_review_resources(task, dispatch_context):
inventory = discover_markdown_resources()
routing_key = get_routing_key(dispatch_context)
scores = score_intents(task, INTENT_SIGNALS, NOISY_SYNONYMS)
intents = select_intents(scores, ambiguity_delta=1.0)
loaded = []
seen = set()
def load_if_available(relative_path: str) -> None:
guarded = _guard_in_skill(relative_path)
if guarded in inventory and guarded not in seen:
load(guarded)
loaded.append(guarded)
seen.add(guarded)
for relative_path in LOADING_LEVELS["ALWAYS"]:
load_if_available(relative_path)
if max(scores.values() or [0]) < 0.5:
return {
"routing_key": routing_key,
"load_level": "UNKNOWN_FALLBACK",
"needs_disambiguation": True,
"disambiguation_checklist": UNKNOWN_FALLBACK_CHECKLIST,
"resources": loaded,
}
phase_resources = PHASE_RESOURCE_MAP.get(routing_key, [])
if routing_key == "unknown" or not phase_resources:
return {
"routing_key": routing_key,
"notice": f"No review resources found for routing key '{routing_key}'",
"resources": loaded,
}
for intent in intents:
for relative_path in RESOURCE_MAP.get(intent, []):
load_if_available(relative_path)
for relative_path in phase_resources:
load_if_available(relative_path)
task_text = str(getattr(task, "text", "")).lower()
if any(keyword in task_text for keyword in LOADING_LEVELS["ON_DEMAND_KEYWORDS"]):
for relative_path in LOADING_LEVELS["ON_DEMAND"]:
load_if_available(relative_path)
return {
"routing_key": routing_key,
"intents": intents,
"resources": loaded,
"non_markdown_references": NON_MARKDOWN_REFERENCES,
}
Detect the current review phase from dispatch context to load appropriate resources:
| Phase | Signal | Resources to Load |
|---|---|---|
| Init | No JSONL exists in review/ | Loop protocol, state format, state outputs, review contract |
| Iteration | Dispatch context includes dimension + iteration number | Loop protocol, convergence, convergence signals, review contract |
| Stuck | Dispatch context includes "RECOVERY" | Convergence, convergence signals, loop protocol, reducer registry |
| Synthesis | Convergence triggered STOP | Review contract, state format, state outputs, reducer registry |
When {spec_folder}/resource-map.md exists at init, deep review treats it as a mandatory audit input: resource_map_present is persisted in config, a map snapshot seeds Known Context, at least one iteration audits target_files coverage against the map (touched / not-touched expected-by-scope-vs-gap / absent-from-map, findings tagged resource-map-coverage), and synthesis adds the ## Resource Map Coverage Gate report section plus a converged resource-map.md (disable via --no-resource-map). Absent at init, the gate and section are skipped without failing the loop. Full sequencing: references/protocol/loop-protocol.md (init 9a, iteration 3b, synthesis 4); schema: references/state/state-format.md.
During initialization, capture a bounded, pointer-based context snapshot in deep-review-strategy.md Known Context before the first dimension runs: target pointers (files, specs, symbols, resource-map entries), claimed behavior/acceptance criteria to verify, reuse/convention pointers, and risk areas, missing context, stale-graph caveats, and out-of-scope areas. It must not create a context-loop report or widen scope beyond the declared target; use @context for quick retrieval and /speckit:plan only when findings require implementation planning.
/deep:review owns the loop. The YAML workflow initializes state, dispatches one LEAF review iteration at a time, evaluates convergence, synthesizes review-report.md, and saves continuity. The LEAF agent reads state, reviews one dimension, writes iteration-NNN.md, updates strategy, and appends JSONL. Full 4-phase lifecycle: references/protocol/loop-protocol.md.
The review state packet always lives under the target spec's local review/ folder. Root-spec targets use {spec_folder}/review/ directly; child-phase and sub-phase targets use flat-first placement (first run writes flat, a pt-NN sibling packet is allocated only when prior content already exists for a different target). Full resolution rule and worked examples: references/state/state-format.md §1.
Core artifacts: deep-review-config.json, deep-review-state.jsonl, deep-review-strategy.md, deep-review-dashboard.md, .deep-review-pause, resource-map.md, review-report.md, and iterations/iteration-NNN.md.
Each agent dispatch gets a fresh context window; state continuity comes from files, not memory, preventing accumulated findings from biasing later dimensions. Init writes config/strategy/JSONL; each loop reads state, checks convergence, dispatches one dimension, records findings, and reduces state; synthesis compiles the report and saves continuity.
The four primary review dimensions (configured in assets/review-mode-contract.yaml):
| Dimension | Focus | Key Questions |
|---|---|---|
| Correctness | Logic, behavior, error handling | Behavior matches claims? Edge cases handled? |
| Security | Vulnerabilities, exposure, trust boundaries | Inputs validated? Credentials exposed? |
| Spec-Alignment / Traceability | Spec vs. implementation fidelity | Code matches spec.md? Planned items present? |
| Completeness / Maintainability | Coverage, dead code, documentation | TODOs resolved? Code self-documenting? |
Review mode is lineage-aware. Supported lifecycle modes are new, resume, and restart. Required lineage fields include sessionId, parentSessionId, lineageMode, generation, continuedFromRun, and releaseReadinessState. The reducer consumes the latest JSONL delta, the new iteration file, and prior reduced state, then emits finding registry, dashboard metrics, and strategy updates.
| Severity | Criteria | Blocking |
|---|---|---|
| P0 | Correctness failure, security vulnerability, spec contradiction | Yes, blocks PASS verdict |
| P1 | Degraded behavior, incomplete implementation, missing validation | Conditional, triggers CONDITIONAL verdict |
| P2 | Style, naming, minor improvements, documentation gaps | No, PASS with advisories |
| Verdict | Condition |
|---|---|
| PASS | No P0/P1 findings, P2 findings recorded as advisories (hasAdvisories: true) |
| CONDITIONAL | P1 findings present, remediation plan included in report |
| FAIL | Any P0 finding confirmed after adversarial self-check |
When the review target is a spec folder, deep review reflects the AC_COVERAGE validation signal in synthesis for Level 2+ folders, and only once checklist.md exists and implementation-summary.md is in-progress or later (Level 1 folders and fresh scaffolds are exempt). The signal is advisory while the validation rule stays INFO/default-on (non-blocking; RULE_STATUS stays pass) -- it can add traceability context and planning-seed work, but must not alter the iteration final-line contract below unless a later enforcement rollout explicitly changes severity.
Every iteration-NNN.md MUST end with exactly one of the following plain-text lines as the absolute final line (no trailing whitespace, no variation), and every review MUST emit exactly one parseable verdict:
Review verdict: PASS
Review verdict: CONDITIONAL
Review verdict: FAIL
Mapping rule: PASS if no P0 or P1 findings in this iteration. CONDITIONAL if any P1 (but no P0) findings. FAIL if any P0 findings. P2-only findings → PASS.
VERDICT_LOCK: Any confirmed active P0 forces the exact final line Review verdict: FAIL -- never relabel that state as conditional, partial, mixed, or advisory, and truncated/partial output is not a valid substitute for the final line. An optional advisory riskScore may appear in narratives/JSONL for relative risk calibration but never changes the PASS|CONDITIONAL|FAIL mapping.
Downstream automation (including the synthesis phase and CI gate parser) parses this final line via exact string match, do not vary the format.
Executor settings are owned by the YAML workflow and rendered prompt pack -- never hand-dispatch review iterations; each iteration stays LEAF-only and produces the required markdown plus JSONL delta. Full contract (per-iteration invariants, failure modes, JSONL audit field, config surface/precedence, TrustState surface): references/protocol/loop-protocol.md.
iteration-NNN.md.newInfoRatio.[SOURCE: file:line]. Reject inference-only findings.generate-context.js for continuity saves. Owner: the YAML workflow (deep_review_{auto,confirm}.yaml) calls it at the save phase, not the reducer (scripts/reduce-state.cjs) directly — don't expect continuity-save side effects from the reducer alone.BINDING: lines before workflow output.REFUSE: nested Task tool dispatch is forbidden for LEAF agents. Returning partial findings instead.@deep-review is LEAF-only. It cannot dispatch additional agents. When dispatch is requested, use the canonical REFUSE wording (ALWAYS rule 14).deep-review-config.json is read-only after initialization.complete | timeout | error | stuck | insight
insight: Low newInfoRatio but important finding that changes the verdict trajectory.The router discovers reference, asset, and script docs dynamically. Start with references/protocol/quick-reference.md, references/protocol/loop-protocol.md, references/convergence/convergence.md, references/convergence/convergence-signals.md, references/state/state-format.md, references/state/state-outputs.md, references/state/state-reducer-registry.md, assets/deep-review-dashboard.md, assets/deep-review-strategy.md, then load task-specific resources from references/, templates from assets/, and automation from scripts/ when present.
Scripts: scripts/reduce-state.cjs, scripts/runtime-capabilities.cjs.
Detailed contracts: references/protocol/loop-protocol.md (executor invariants, failure modes, config surface), references/protocol/loop-state-and-gates.md (state transitions, error handling, STOP-decision gates), references/protocol/completion-criteria.md (full loop-completion/quality-gate/validation-success checklist), and references/state/state-reducer-registry.md (two-tier content-hash dedup).
Related skills: deep-research for investigation loops, sk-code's code-review mode for single-pass review doctrine, and system-spec-kit for command-owned state and continuity saves.
A review loop is complete only when convergence and every quality gate agree: the composite stop score clears compositeStopScore (or maxIterations is hit without a false-positive STOP), every configured dimension plus required traceability protocols (spec_code, checklist_evidence) have at least one full iteration of coverage, all canonical state files exist and parse cleanly (deep-review-config.json, deep-review-state.jsonl, deep-review-findings-registry.json, deep-review-strategy.md, deep-review-dashboard.md, one iterations/iteration-NNN.md per dispatched iteration), review-report.md carries all 9 core sections plus the conditional ## Resource Map Coverage Gate, and continuity is saved via generate-context.js.
Nine binary quality gates must all pass before STOP is legal: config validity + lineage match, strategy initialization completeness, state/registry consistency, iteration completeness (markdown + JSONL delta), severity-field coverage on every finding (severity/category/file:line/content_hash), the advisory-only riskScore never gating verdict logic, adversarial P0 replay, dimension/protocol coverage stability, acceptance-coverage (advisory AC_COVERAGE signal when the spec-folder lifecycle predicate is active), and the security-sensitive override (minStabilizationPasses=2 + fix-completeness replay) when the target touches security, path handling, env precedence, schema boundaries, persistence, or shared policy. Full gate-by-gate criteria and rationale: references/protocol/completion-criteria.md.
Validate a completed run with skill_advisor.py "run a deep review loop" --threshold 0.8 (skill still surfaces) and bash .opencode/skills/system-spec-kit/scripts/spec/validate.sh <spec-folder> --strict (exits 0).
This skill operates within the behavioral framework defined in the active runtime's root doc (CLAUDE.md or AGENTS.md).
Key integrations:
skill_advisor.py (keywords: deep review, convergence review, iterative review){spec_folder}/review/ state packet location/speckit:resume is the operator-facing recovery surface, resolving context in the order handover.md -> _memory.continuity -> spec docs. During review, the agent writes iteration, strategy, and JSONL state; after synthesis, run generate-context.js to write canonical packet continuity/deep:review is the primary invocation pointThe review loop consumes the shared runtime graph and its strict mode-gate validator; packet-specific convergence and state rules remain in this skill.
Frequently asked questions
Iterative code review and quality auditing protocol with fresh context per iteration, externalized state, convergence detection, and severity-weighted findings (P0/P1/P2).
The source record exposes this install command: npx skills add https://github.com/MichelKerkmeester/opencode--skilled-agent-loops-with-spec-kit-memory --skill ".opencode/skills/system-deep-loop/deep-review". Inspect the command and pinned source before running it.
Static rules flagged exec-script in the source; the page lists the matching lines and excerpts.
Alternatives
drafthq/draft
Single-module production readiness audit (ACID, resilience, observability). Use to audit one service/module end-to-end — NOT for diff/PR review (use review / quick-review) or bug-finding sweeps (use bughunt).
oaustegard/claude-skills
Generate hierarchical _FEATURES.md files that describe what a codebase DOES from a user/consumer perspective, anchored to source symbols via tree-sitting. Supports large complex codebases through feature-driven decomposition into sub-feature files. Uses a multi-pass synthesis: orientation → detail → overview rewrite. Use when someone says "what does this do", "document features", "feature inventory", "_FEATURES.md", or needs to understand a codebase's purpose before modifying it. Complements tre
enuno/unifi-mcp-server
Specialized guide for adding new MCP tools to the UniFi MCP Server following project standards, UniFi API patterns, and test-driven development practices. Use when implementing new UniFi Network Controller features as MCP tools.
PaulRBerg/agent-skills
Create/scaffold/init a project-local agent skill under `.agents/skills` in an ordinary repository; defer to repository instructions that define a source catalog and lifecycle.