Audit written code in one fresh subagent — first conformance, whether everything the task asked is in the code and nothing unasked is, each row proven by a tool call; then quality, against the 5W OPORD and negative failure criteria (.sdd-flow/rejections.md) — record human-operator rejections that slipped past review. Use before the human check in sdd-code-review, when the human operator rejects code, or when the user invokes sdd-code-critic or /sdd-critic.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Sdd Code Critic?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/zakyrion-sdd-code-critic)
---
name: sdd-code-critic
description: Audit written code in one fresh subagent — first conformance, whether everything the task asked is in the code and nothing unasked is, each row proven by a tool call; then quality, against the 5W OPORD and negative failure criteria (.sdd-flow/rejections.md) — record human-operator rejections that slipped past review. Use before the human check in sdd-code-review, when the human operator rejects code, or when the user invokes sdd-code-critic or /sdd-critic.
---
# Load
```clojure
{:requires [".sdd-flow/references/CLOJURE_NOTATION.md"]
:fields ".sdd-flow/references/ARTIFACT_FIELDS.md — read when writing or checking rejection and verdict keys"
:examples "examples.md beside this file — conformance replies good and bad, built-in code anti-patterns, and a recorded operator rejection"
:rejections ".sdd-flow/rejections.md — read when present; never read by the code generator"
:light "this file is the whole procedure — the glossary is the only required read"
:missing (:then (stop!)
(tell-user! "run sdd-flow doctor ."))
:project (when (project-adapter-present? ".sdd-flow/project.md")
(:then (read-last! ".sdd-flow/project.md")))
:adapter-gives "# Tools with :proves — the tools the conformance check looks through; the project's bans and deterministic meters — what a script already catches needs no LLM rejection entry"}
```
# Activate
```clojure
{:modes [:audit :conform :record :on :off]
:by #{"sdd-code-review invokes :audit (sdd-flow eval is on) or :conform (sdd-flow eval is conform) after deterministic meters pass and before asking the human operator"
"sdd-code-review or the lifecycle invokes :record whenever the human operator rejects code"
"the user invokes sdd-code-critic or /sdd-critic [audit | conform | record | on | off] directly"}
:conform "the conformance step of the same audit alone — the critic step is not run"
:toggle "three settings — on: conformance and critic; conform: conformance alone; off: neither. on / off run 'sdd-flow eval on' or 'sdd-flow eval off', a bare conform setting is 'sdd-flow eval conform', all on .sdd-flow/config.json (owner's word only, never auto-toggled); when sdd-flow stats shows >= 85% clean-pass-rate over >= 10 cycles the owner judged, the owner may distill rules (sdd-code-distill) or set conform — code style coasts on codebase inertia, the completeness of a task does not — and return to on if quality drifts"
:separation "the generator reads only positive exemplars (:exemplars); negative code examples and operator rejections live exclusively here so the generator is never primed on bad code"}
```
# Audit
```clojure
(def audit ;; one fresh subagent, two steps over one reading of the diff, before the human operator
{:where "a fresh subagent — never the session that wrote or planned the code"
:order (-> (:conform "does the code hold everything the task asked, and nothing it did not")
(:critic "only after :conform passed and only when eval is on — is the code good"))
:stop "a rejected :conform ends the audit — the critic never polishes code that does the wrong thing"
:prompt {:opord "the task's 5W OPORD — :why, :goal, :when, :where, :off-limits"
:task "the confirmed contract, confirmed amendments, # Acceptance and the confirmed answers of # Decisions — copied as they stand; the ALGO document when the task has one"
:diff "git diff with the new untracked files, or the exact touched files — Flows/ left out, so # Added stays withheld"
:tools "the launcher's list of lookups (def conform-tools)"
:criteria "this skill's examples.md and .sdd-flow/rejections.md when present — read at the critic step only"}
:withheld "# Added of the FLOW — the launcher compares it after the reply, so the agent finds additions by itself"
:again "after a fix the same subagent is continued where the harness allows it, on the new diff alone plus every row the fix touches; otherwise a fresh one"
:boundary "always check :acceptable-when before flagging a match — flag real defects, never nitpick valid simple code"
:never #{"editing product source files from the critic"
"passing raw session chat history to the critic subagent"}})
```
# Conform
```clojure
(def conform-tools ;; a row is proven by a call, not by an impression
{:law "start with the cheapest call; stop at the first one that guarantees the answer; go one step up only when the answer is not guaranteed"
:cost (-> "what is already in hand — the diff, the task text, the launcher's meter readings"
"one grep -n for a name, its output limited"
"one exact query — an adapter tool carrying :proves, a tool skill, or a live Roslyn, language server or code graph"
"a read of the lines a grep hit, used when no exact query is available"
"a test or a run")
:guarantees {:exists "the declaration line in the diff or in a grep hit"
:absent "an empty grep over the whole searched place for a name nothing builds at run time; otherwise an exact query"
:wired "an exact query naming the caller or registration; without one, the hit lines read and shown to be a call — a bare grep hit may be a comment, a string or another symbol of the same name"
:behavior "a test or run that exercises it — a reading the launcher already has is reused, never rerun"}
:skip-grep "when the question is :wired and an exact query is available, go to it at once — reading many hits costs more than one query"
:batch "names asked of the same place go into one call"
:no-guarantee "every step spent and still not guaranteed — the row is :unproven with what was tried, and goes to the owner; it neither passes nor rejects"
:discovered "a live tool the adapter does not list and that answered is named under :discovered — after the verdict the launcher offers the owner to record it in # Tools, or /sdd-project-init where no adapter exists"})
```
```clojure
(def conform
{:items #{":result and :goal" "each entry of :decided" "each confirmed answer in # Decisions that shapes the code" "each confirmed amendment" "each row of # Acceptance" "each step of the ALGO document when the task has one" "each entry of :off-limits and :skip"}
:forward "from the task to the code — one row per item: {:item \"in the task's words\" :status #{:present :missing :partial :contradicts :off-limits :unproven :owner} :at \"file:line\" :proof #{:exists :wired :behavior} :by \"the call that showed it\"}"
:backward (-> "list candidates from the diff already read — every added declaration, setting, dependency, new file, changed behavior; the diff holds everything added, so nothing is searched for"
"drop what :not-an-addition covers — the declaration line shows its visibility"
"look its name and its purpose up in the task text — an item that asks for it clears it, no tool call"
"for the rest only: does an asked item need it — who uses it, by the :wired guarantee; used on the way to an asked item clears a type, member or state the item cannot work without; a new dependency, setting or file format is always reported"
"what remains is reported")
:from-code-row "{:from-code \"what it is\" :at \"file:line\" :by \"the diff line, or the call that showed who uses it\"}"
:counts-as-addition #{"a behavior" "a public type, member or contract" "state that survives across calls or frames" "a dependency" "a setting or a file format"}
:not-an-addition #{"a local" "a private helper" "a test of an asked item" "an import the asked code needs"}
:proof-law "a row without :at and :by is :unproven, and :missing needs the :absent guarantee; an :off-limits or :skip row cites the call that found nothing; behavior proof is asked where # Acceptance names a meter, and its launcher-run reading counts"
:owner "a row only the owner can read — playing the scene, trying the screen — is :owner; it goes to the human check and fails nothing"
:ambiguous "an item that reads two ways goes under :ambiguous with both readings — the question returns to the owner through the register and no code is rejected for it; the verdict waits"
:verdict (cond
(any-row? #{:missing :partial :contradicts :off-limits}) :reject
(or (any-ambiguous?) (any-row? #{:unproven})) :pending
:else :pass)})
```
```clojure
(def from-code ;; the launcher's step after the reply
{:declared "# Added of the FLOW — what the author of the code wrote there while writing it, each with its :why"
:compare (cond
(in-added? addition) "an owner question by the register — accept or remove; unanswered, the review is :pending"
:else "the conformance verdict becomes :reject with reason :invented")
:accepted "an accepted addition becomes a confirmed amendment, so the next audit reads it as asked"
:standalone "with no FLOW every addition is undeclared and is told to the owner as a question, never rejected"})
```
# Verdict
```clojure
{:reply "one Clojure map and nothing around it: {:conform {:verdict :rows [...] :from-code [...] :ambiguous [...] :discovered [...]} :critic {:verdict :findings [...]} :distill [...]}"
:conform-pass "still carries every row — a bare :pass is not a conformance answer"
:critic-pass "{:verdict :pass} alone — zero findings, zero non-blocking nits"
:critic-reject "{:verdict :reject :findings [{:file \"path\" :matched :r-1 :why-bad \"one sentence: how it violates OPORD or the rejection criterion\" :level #{:code :algorithm}}]}"
:critic-checks #{"whether the code defeats :why with a local shortcut"
"whether any changed block matches a :ban or a :bad-code / :human-opinion in .sdd-flow/rejections.md outside its :acceptable-when boundary"
"built-in code anti-patterns in examples.md — artificial over-decomposition into one-use helpers, state-machine guards hidden inside callees, single-frame hand-over fields, hidden spine steps, silent undeclared mutable fields, missing or mechanism-only type/entry summaries (sentence one must state purpose) or <param>/name-restatement doc bloat, swallowed errors"}
:logged-by "the launcher, after (def from-code), one call per step that ran, always with --task: 'sdd-flow stats conform-pass', 'sdd-flow stats conform-reject <:missing|:partial|:contradicts|:invented|:off-limits...> --why \"<what was not fulfilled>\"', 'sdd-flow stats pass', 'sdd-flow stats critic-reject <:matched...>'; a :pending verdict is not logged until it is answered"
:undeclared-after-critic "when the subagent passed :conform and the comparison turned it into :reject, the critic's part is dropped unlogged — the fix is audited again"}
```
# Record
```clojure
(def record-rejection ;; flywheel when the critic missed and the human operator rejected
{:when "the human operator rejects code that passed meters and :audit"
:by "the audit's subagent continued, or a fresh one — the session that writes code never opens rejections.md"
:before-the-fix "recorded while the rejected code still stands in the working tree"
:handed {:words "the operator's words, verbatim" :opord "the task's :why, :goal, :where" :diff "the touched files, or the commit"}
:target ".sdd-flow/rejections.md — create from .sdd-flow/templates/REJECTIONS.md when absent; project-owned outside manifest.json"
:entry "{:id :r-N :at \"YYYY-MM-DD\" :category :error-class :opord {:why \"...\" :goal \"...\" :where \"...\"} :details [{:human-opinion \"what was wrong, in the operator's own words\" :context \"where it stands and when it runs, in words\" :bad-code \"the fragment that shows the fault, nothing around it\" :acceptable-when \"optional boundary when a similar shape is valid\"}]}"
:fragment "only the lines that show the fault, good code around them told in :context; a structural fault is a skeleton — signatures and who calls whom, no bodies"
:fixed-by "optional :fixed-in, the commit that corrected it — found in git by the subagent that distills; the ban is tried on it"
:lint "run sdd-flow lint .sdd-flow/rejections.md after writing"
:returns "{:id :r-N :category :error-class :alike <how many entries share its meaning, this one counted>} — no code, no other entry"
:unclear "words that do not point at a place in the diff come back as a question for the operator, nothing written"
:stats "the launcher appends one telemetry row from what was returned, via 'sdd-flow stats human-reject <:category> <:id> --task <task>' — never read .sdd-flow/evals.edn into context"
:re-enable "when sdd-flow eval is conform or off, tell the owner and offer 'sdd-flow eval on'"
:overflow-trigger "at :alike five or more the launcher tells the owner and offers sdd-code-distill"
:seen-in-audit "a critic step that meets five alike in rejections.md adds :distill [{:category :from [:r-1 ...]}] to its reply, whatever the verdict; asked to, the same subagent drafts by sdd-code-distill :draft"})
```