cursordoctrine 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -59,7 +59,7 @@ No Node? Open `INSTALL.md`, paste its contents into a Cursor agent chat on the t
59
59
 
60
60
  Prerequisites: `git` everywhere; `pwsh` on Windows; `bash` plus `jq` or `python3` on Linux.
61
61
 
62
- The anti-slop skill (`skills/anti-slop/` — SKILL.md and the duplication scanner) installs to `~/.cursor/skills/anti-slop/`. The final review runs the scanner from there; if it's missing (an install from before it shipped), the review falls back to the `~/.agents/hooks/anti-slop.md` checklist instead of failing.
62
+ The anti-slop skill (`skills/anti-slop/` — SKILL.md and the duplication scanner) installs to `~/.cursor/skills/anti-slop/`. The hook checklist (`~/.agents/hooks/anti-slop.md`, 13 items) is the canonical slop detector for both per-edit advisories and final-review axis 4. The final review runs the scanner from the skill path first when available.
63
63
 
64
64
  ## Tuning and kill switches
65
65
 
@@ -154,17 +154,14 @@ checklist_file="$HOME/.agents/hooks/anti-slop.md"
154
154
  checklist=""
155
155
  [ -f "$checklist_file" ] && checklist="$(cat "$checklist_file")"
156
156
  if [ -z "$checklist" ]; then
157
- checklist='ANTI-SLOP SELF-REVIEW - audit the edit you just made and FIX (do not explain) any slop:
158
- 1. Edge cases beyond the happy path (null / empty / zero / boundary / error).
159
- 2. Duplicated logic that already exists in this repo - call it, do not re-implement.
160
- 3. Conventions - match the file'"'"'s existing style / naming / structure / error-handling.
161
- 4. Unnecessary dependencies - remove libs the stdlib or an existing dep covers.
162
- 5. Premature abstraction - no Factory/Repository/Mediator/CQRS/DDD without 2-3 real call sites today.
163
- 6. Accidental complexity - flatten indirection a junior cannot read in 30s.
164
- 7. Tests assert real behaviour and edge cases, not just "it runs".
165
- 8. Cargo cult - delete any construct whose reason you cannot state.
166
- 9. Architecture - respect the project'"'"'s layering and boundaries.
167
- 10. Redundant comments restating code - delete; keep only WHY.'
157
+ checklist='ANTI-SLOP read ~/.agents/hooks/anti-slop.md (13 items). Fallback if missing:
158
+ 1–10: edge cases, duplication, conventions, deps, premature abstraction,
159
+ accidental complexity, tests (no tautologies), cargo cult, architecture,
160
+ redundant comments / prompt residue.
161
+ 11: semantic contracts (behavior change without name/signature change).
162
+ 12: operational slop (retry w/o backoff, await-in-loop, telemetry spam).
163
+ 13: change surface (too many files for a simple request).
164
+ Fix guilty items now. Never revert what the user asked for.'
168
165
  fi
169
166
 
170
167
  flag_block=""
@@ -1,56 +1,54 @@
1
- ANTI-SLOP SELF-REVIEW — you just edited a file. Before you do anything else,
2
- audit your own change against the checklist below. This is NOT the bug pass
3
- (the self-review trigger covers security/correctness). This is about *slop*:
4
- code that runs but should not ship.
5
-
6
- For each item: if your edit is guilty, FIX IT NOW with Edit — delete the
7
- abstraction, inline the duplicate, drop the dependency, remove the comment.
8
- Do not explain, do not report, just fix. If the edit is clean, say nothing.
9
-
10
- 1. EDGE CASES — Does it only handle the happy path? Check the null / empty /
11
- zero / boundary / error inputs the task implies. An unhandled obvious
12
- edge case is a bug waiting in production.
13
-
14
- 2. DUPLICATION — Did you write logic that already exists in this repo? Look
15
- before you add. If it exists, call it; do not re-implement it.
16
-
17
- 3. CONVENTIONS — Does it match the FILE's existing style, naming, structure,
18
- error-handling, and import patterns? Match the neighbours, not your
19
- defaults.
20
-
21
- 4. DEPENDENCIESDid you add a library for something the stdlib or an
22
- existing dependency already does? Remove it. A new dependency must earn
23
- its place.
24
-
25
- 5. PREMATURE ABSTRACTIONFactory / Repository / Mediator / Strategy /
26
- Builder / base classes / interfaces / CQRS / Event Sourcing / DDD
27
- layering: is there a REAL, PRESENT problem — two or three concrete call
28
- sites that exist TODAYthat requires it? "For future flexibility" is
29
- not a reason. Delete it and write the direct code. Abstraction debt is
30
- layers without problems.
31
-
32
- 6. ACCIDENTAL COMPLEXITYCould a junior read this in 30 seconds? Extra
33
- indirection, generics, config, or layers that do not earn their keep
34
- flatten them.
35
-
36
- 7. TESTS Do your tests assert real BEHAVIOUR and the edge cases, or do
37
- they just prove the code runs / mirror the implementation line-for-line?
38
- A test that cannot fail is slop. Make it verify outcomes.
39
-
40
- 8. CARGO CULT — Can you state WHY each non-obvious construct is there? If you
41
- reproduced a pattern without the historical reason behind it, that reason
42
- may not hold here. Remove what you cannot justify. Replicating a shape you
43
- have seen is not the same as needing it.
44
-
45
- 9. ARCHITECTURE Does it respect the project's layering and boundaries — no
46
- reaching across layers, no business logic in the wrong place, no breaking
47
- a constraint the codebase clearly holds? Honour the constraints.
48
-
49
- 10. REDUNDANT COMMENTS — Delete comments that restate the code
50
- ("// increment i", "# return the result"). Keep only comments that
51
- explain WHY, never WHAT.
52
-
53
- Hard constraints: never revert the change the USER asked for — slop is the
54
- stuff you added on top. Do not "improve" beyond removing slop. At most a few
55
- targeted edits, then stop. The bar: would this pass a senior review at a top
56
- engineering org without a single "why is this here?" comment.
1
+ ANTI-SLOP SELF-REVIEW — you just edited a file (or you are auditing the
2
+ session diff at final review). Code that runs but should not ship.
3
+
4
+ Intent trace (Tier 0 hallucinated requirements, scope drift) runs FIRST at
5
+ stop via final-review axis 0, not here. This checklist covers code-shape and
6
+ cost slop. Apply every item; if guilty, FIX with Edit — delete, inline, drop.
7
+ Do not explain. If clean, say nothing.
8
+
9
+ 1. EDGE CASES — Happy path only? Check null / empty / zero / boundary / error
10
+ inputs the task implies.
11
+
12
+ 2. DUPLICATION Logic that already exists in this repo? Call it; do not
13
+ re-implement. Same function in many files (isRecord-class) → one source.
14
+
15
+ 3. CONVENTIONS Match the FILE's style, naming, structure, error-handling,
16
+ imports. Not your defaults.
17
+
18
+ 4. DEPENDENCIES New library for something stdlib or an existing dep covers?
19
+ Remove it. A dependency must earn its place.
20
+
21
+ 5. PREMATURE ABSTRACTION Factory / Repository / Mediator / Strategy / Builder /
22
+ CQRS / Event Sourcing / DDD: is there a REAL problem with 2–3 call sites
23
+ TODAY? "Future flexibility" is not a reason. Delete and write direct code.
24
+
25
+ 6. ACCIDENTAL COMPLEXITYCould a junior read this in 30 seconds? Flatten
26
+ indirection, generics, config, layers that do not earn their keep.
27
+
28
+ 7. TESTS (epistemic slop)Assert real OUTCOMES and edge cases, not "it runs",
29
+ not a mirror of the implementation, not expect(true).toBe(true). A test
30
+ that cannot fail is slop.
31
+
32
+ 8. CARGO CULTCan you state WHY each non-obvious construct is there? Remove
33
+ what you cannot justify. A shape you have seen a shape you need.
34
+
35
+ 9. ARCHITECTURE — Respect layering and boundaries. No reaching across layers,
36
+ no business logic in the wrong place, no breaking project constraints.
37
+
38
+ 10. REDUNDANT COMMENTS Delete comments that restate the code ("// increment
39
+ i"). Keep only WHY, never WHAT. No prompt residue ("in a real app...").
40
+
41
+ 11. SEMANTIC CONTRACTS (Tier 1) Did any existing function's BEHAVIOR change
42
+ without its name, signature, or docstring changing? Names are contracts.
43
+ deleteUser() that now soft-deletes is silent contract break.
44
+
45
+ 12. OPERATIONAL SLOP (Tier 3) Retry loops without backoff/sleep/jitter?
46
+ await fetch / ctx.db / prisma inside a for/while/map? Six or more
47
+ console.log / print added in one edit? Token burn with no user value →
48
+ remove or bound.
49
+
50
+ 13. CHANGE SURFACE (Tier 5) Did a simple request touch many files? Every
51
+ file in the diff must trace to the task. Trim unrelated hunks.
52
+
53
+ Hard constraints: never revert what the USER asked for — slop is what got added
54
+ on top. At most a few targeted edits, then stop.
@@ -45,17 +45,23 @@ is present — sandboxed verify run, no transcript — skip this axis.)
45
45
  - Add the missing tests; delete tautological ones.
46
46
 
47
47
  ## 4. Anti-slop
48
- - If `~/.cursor/skills/anti-slop/scripts/scan_slop.py` exists (INSTALL.md step 2
49
- copies it there), run the whole-codebase duplication scan:
48
+ Axis 0 already caught intent drift. This axis catches code-shape and cost slop
49
+ across the whole session diff.
50
+
51
+ Step A — mechanical scan (if available):
52
+ If `~/.cursor/skills/anti-slop/scripts/scan_slop.py` exists, run:
50
53
  python ~/.cursor/skills/anti-slop/scripts/scan_slop.py --all
51
- If it does NOT exist, do not treat that as a failure and do not hunt for the
52
- file: apply the checklist in `~/.agents/hooks/anti-slop.md` to the session
53
- diff and look for duplicate function bodies in the files you touched.
54
- - Either way, consolidate clones: same function in many files / identical bodies
55
- (the isRecord-class) ONE shared definition, re-point imports, delete the
56
- copies.
57
- - Premature abstraction (Factory / Repository / Mediator / CQRS / DDD with fewer
58
- than 2–3 real call sites), unnecessary dependencies, redundant restate-the-code
59
- comments, dead helpers, accidental complexity → remove.
60
-
61
- Fix with edits now; re-run the scan and the tests; then stop.
54
+ If it does NOT exist, skip Step A (not a failure; do not hunt for the file).
55
+
56
+ Step B canonical checklist (always):
57
+ Read `~/.agents/hooks/anti-slop.md` and apply ALL 13 items to every hunk you
58
+ changed this session. That file is the single source of truth for slop
59
+ detection — items 1–10 are structural/code, 11 is semantic contracts, 12 is
60
+ operational slop (retries, await-in-loop, telemetry spam), 13 is change
61
+ surface. Fix every hit; consolidate clones to one source of truth.
62
+
63
+ Step C — session footprint (also in the header above):
64
+ If "Session footprint" shows >5 files or the request was simple, justify each
65
+ file or trim. Unjustified files are slop.
66
+
67
+ Fix with edits now; re-run the scan (if Step A ran) and the tests; then stop.
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env bash
2
2
  # final-review.sh - stop hook (Cursor, Linux).
3
3
  #
4
- # ONE comprehensive end-of-implementation review across four axes:
5
- # correctness, reliability, coverage, and anti-slop. When the agent finishes
4
+ # ONE comprehensive end-of-implementation review across five axes:
5
+ # intent, correctness, reliability, coverage, and anti-slop. When the agent finishes
6
6
  # an implementation that touched files, Cursor auto-submits this hook's
7
7
  # `followup_message` as the next user turn, so the model re-audits everything
8
8
  # it changed this session and FIXES what fails.
@@ -76,11 +76,11 @@ if [ -z "$body" ]; then
76
76
  released on every path, no races, input validated at the boundary.
77
77
  3. Coverage - behaviour-bearing changes have real tests; RUN the suite if present;
78
78
  no tautological tests.
79
- 4. Anti-slop - if ~/.cursor/skills/anti-slop/scripts/scan_slop.py exists, run
80
- `python ~/.cursor/skills/anti-slop/scripts/scan_slop.py --all`; otherwise
81
- apply ~/.agents/hooks/anti-slop.md to the session diff (a missing scanner
82
- is not a failure). Consolidate clones/duplicates to one source of truth;
83
- drop premature abstraction, unneeded deps, redundant comments, dead helpers.
79
+ 4. Anti-slop - read ~/.agents/hooks/anti-slop.md and apply all 13 items to
80
+ the session diff. If ~/.cursor/skills/anti-slop/scripts/scan_slop.py exists,
81
+ run `python ~/.cursor/skills/anti-slop/scripts/scan_slop.py --all` first.
82
+ Consolidate clones; drop premature abstraction, unneeded deps, operational
83
+ slop (retries, await-in-loop, log spam), unjustified files.
84
84
  Fix now, re-run the scan + tests, then stop. If an axis is clean, say so in one line.'
85
85
  fi
86
86
  body="$(expand_agent_paths "$body")"
@@ -159,6 +159,9 @@ try:
159
159
  q = m.group(1).strip()
160
160
  if len(q) > 2000:
161
161
  q = q[:2000] + "..."
162
+ q = re.sub(r"\bnpm_[A-Za-z0-9]{10,}\b", "[REDACTED_NPM_TOKEN]", q)
163
+ q = re.sub(r"\b(sk-[A-Za-z0-9]{10,}|ghp_[A-Za-z0-9]{20,}|gho_[A-Za-z0-9]{20,})\b", "[REDACTED_TOKEN]", q)
164
+ q = re.sub(r"(?i)(api[_-]?key|token|secret|password)\s*[:=]\s*\S+", r"\1=[REDACTED]", q)
162
165
  print(q)
163
166
  break
164
167
  except Exception:
@@ -172,6 +175,7 @@ except Exception:
172
175
  printf '%s' "$reversed" |
173
176
  grep -m1 -oE '<user_query>[^<]*</user_query>' 2>/dev/null |
174
177
  sed -E 's@</?user_query>@@g' |
178
+ sed -E 's/\bnpm_[A-Za-z0-9]{10,}\b/[REDACTED_NPM_TOKEN]/g' |
175
179
  head -c 2000
176
180
  }
177
181
 
@@ -4,7 +4,7 @@
4
4
  # Counterpart of final-review.sh for delegated work. afterFileEdit DOES fire
5
5
  # inside subagents (verified: a subagent run left its edits in
6
6
  # session-edits-<subagent-cid>.txt), but subagents get no `stop` event, so
7
- # that marker is never drained and the four-axis review never fires for
7
+ # that marker is never drained and the five-axis review never fires for
8
8
  # delegated implementations. This hook closes the loop: when a subagent
9
9
  # finishes and ITS conversation has a session-edits marker, return ONE
10
10
  # followup_message so the subagent audits its own implementation before the
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cursordoctrine",
3
- "version": "0.2.0",
4
- "description": "Thin self-review hooks for Cursor — the model is the auditor. One command installs the doctrine, the hook pack, and the anti-slop skill. Adds an intent-trace final-review axis that catches clean-code-wrong-feature (the worst AI slop).",
3
+ "version": "0.2.2",
4
+ "description": "Thin self-review hooks for Cursor — the model is the auditor. Intent-trace final review (Tier 0), unified 13-item anti-slop checklist, operational slop detection.",
5
5
  "bin": {
6
6
  "cursordoctrine": "bin/cli.mjs"
7
7
  },
@@ -223,10 +223,15 @@ management*, not token volume — one source of truth per concept.
223
223
 
224
224
  ## Automatic final review
225
225
 
226
- The `stop` hook (`anti-slop-final-review.ps1`) fires after the agent finishes
227
- an implementation that edited files: it returns a `followup_message` Cursor
228
- auto-submits, so the model re-audits everything it changed this session and
229
- removes slop it introduced one bounded pass.
226
+ The `stop` hook (`~/.agents/hooks/final-review.ps1` on Windows,
227
+ `~/.agents/hooks/final-review.sh` on Linux) fires after the agent finishes an
228
+ implementation that edited files. It extracts the last `<user_query>` from the
229
+ session transcript (Tier 0 intent trace), reports session footprint (Tier 5),
230
+ and auto-submits a `followup_message` so the model audits five axes: intent,
231
+ correctness, reliability, coverage, anti-slop. Axis 4 delegates to this skill's
232
+ scanner (`scan_slop.py --all`) and the canonical checklist at
233
+ `~/.agents/hooks/anti-slop.md` (13 items, including semantic contracts,
234
+ operational slop, and change surface). One bounded pass per implementation.
230
235
 
231
236
  ## Hard constraints
232
237
 
@@ -259,9 +264,11 @@ Diff: {before} → {after} lines. Tests: {pass | n/a}
259
264
  | Install path | `~/.cursor/skills/anti-slop/` |
260
265
  | Invoke | `/anti-slop`, or "remove the AI slop" |
261
266
  | Scanner | `python scripts/scan_slop.py --all` |
262
- | Final review | automatic via `stop` hook |
267
+ | Final review | automatic via `stop` hook (`final-review.ps1` / `final-review.sh`) |
268
+ | Hook checklist | `~/.agents/hooks/anti-slop.md` (13 items; per-edit + final-review axis 4) |
263
269
 
264
270
  The scanner is stdlib-only and needs Python 3.9+. Pairs with the **anti-slop
265
- hook** (advisory, per edit), the **stop hook** (auto final review), and
266
- **minimal-editing** (smallest-diff). This skill is the active "delete it now"
267
- layer those only nudge toward.
271
+ audit hook** (`anti-slop-audit.ps1` / `.sh`, advisory per edit), the **stop
272
+ hook** (`final-review.ps1` / `.sh`, five-axis session review incl. intent
273
+ trace), and **minimal-editing** (smallest-diff). This skill is the active
274
+ "delete it now" layer those only nudge toward.
@@ -195,17 +195,14 @@ $checklist = ''
195
195
  if (Test-Path -LiteralPath $checklistFile) { $checklist = Get-Content -Raw -LiteralPath $checklistFile }
196
196
  if (-not $checklist) {
197
197
  $checklist = @'
198
- ANTI-SLOP SELF-REVIEW - audit the edit you just made and FIX (do not explain) any slop:
199
- 1. Edge cases beyond the happy path (null / empty / zero / boundary / error).
200
- 2. Duplicated logic that already exists in this repo - call it, do not re-implement.
201
- 3. Conventions - match the file's existing style / naming / structure / error-handling.
202
- 4. Unnecessary dependencies - remove libs the stdlib or an existing dep covers.
203
- 5. Premature abstraction - no Factory/Repository/Mediator/CQRS/DDD without 2-3 real call sites today.
204
- 6. Accidental complexity - flatten indirection a junior cannot read in 30s.
205
- 7. Tests assert real behaviour and edge cases, not just "it runs".
206
- 8. Cargo cult - delete any construct whose reason you cannot state.
207
- 9. Architecture - respect the project's layering and boundaries.
208
- 10. Redundant comments restating code - delete; keep only WHY.
198
+ ANTI-SLOP read ~/.agents/hooks/anti-slop.md (13 items). Fallback if missing:
199
+ 1–10: edge cases, duplication, conventions, deps, premature abstraction,
200
+ accidental complexity, tests (no tautologies), cargo cult, architecture,
201
+ redundant comments / prompt residue.
202
+ 11: semantic contracts (behavior change without name/signature change).
203
+ 12: operational slop (retry w/o backoff, await-in-loop, telemetry spam).
204
+ 13: change surface (too many files for a simple request).
205
+ Fix guilty items now. Never revert what the user asked for.
209
206
  '@
210
207
  }
211
208
 
@@ -1,56 +1,54 @@
1
- ANTI-SLOP SELF-REVIEW — you just edited a file. Before you do anything else,
2
- audit your own change against the checklist below. This is NOT the bug pass
3
- (the self-review trigger covers security/correctness). This is about *slop*:
4
- code that runs but should not ship.
5
-
6
- For each item: if your edit is guilty, FIX IT NOW with Edit — delete the
7
- abstraction, inline the duplicate, drop the dependency, remove the comment.
8
- Do not explain, do not report, just fix. If the edit is clean, say nothing.
9
-
10
- 1. EDGE CASES — Does it only handle the happy path? Check the null / empty /
11
- zero / boundary / error inputs the task implies. An unhandled obvious
12
- edge case is a bug waiting in production.
13
-
14
- 2. DUPLICATION — Did you write logic that already exists in this repo? Look
15
- before you add. If it exists, call it; do not re-implement it.
16
-
17
- 3. CONVENTIONS — Does it match the FILE's existing style, naming, structure,
18
- error-handling, and import patterns? Match the neighbours, not your
19
- defaults.
20
-
21
- 4. DEPENDENCIESDid you add a library for something the stdlib or an
22
- existing dependency already does? Remove it. A new dependency must earn
23
- its place.
24
-
25
- 5. PREMATURE ABSTRACTIONFactory / Repository / Mediator / Strategy /
26
- Builder / base classes / interfaces / CQRS / Event Sourcing / DDD
27
- layering: is there a REAL, PRESENT problem — two or three concrete call
28
- sites that exist TODAYthat requires it? "For future flexibility" is
29
- not a reason. Delete it and write the direct code. Abstraction debt is
30
- layers without problems.
31
-
32
- 6. ACCIDENTAL COMPLEXITYCould a junior read this in 30 seconds? Extra
33
- indirection, generics, config, or layers that do not earn their keep
34
- flatten them.
35
-
36
- 7. TESTS Do your tests assert real BEHAVIOUR and the edge cases, or do
37
- they just prove the code runs / mirror the implementation line-for-line?
38
- A test that cannot fail is slop. Make it verify outcomes.
39
-
40
- 8. CARGO CULT — Can you state WHY each non-obvious construct is there? If you
41
- reproduced a pattern without the historical reason behind it, that reason
42
- may not hold here. Remove what you cannot justify. Replicating a shape you
43
- have seen is not the same as needing it.
44
-
45
- 9. ARCHITECTURE Does it respect the project's layering and boundaries — no
46
- reaching across layers, no business logic in the wrong place, no breaking
47
- a constraint the codebase clearly holds? Honour the constraints.
48
-
49
- 10. REDUNDANT COMMENTS — Delete comments that restate the code
50
- ("// increment i", "# return the result"). Keep only comments that
51
- explain WHY, never WHAT.
52
-
53
- Hard constraints: never revert the change the USER asked for — slop is the
54
- stuff you added on top. Do not "improve" beyond removing slop. At most a few
55
- targeted edits, then stop. The bar: would this pass a senior review at a top
56
- engineering org without a single "why is this here?" comment.
1
+ ANTI-SLOP SELF-REVIEW — you just edited a file (or you are auditing the
2
+ session diff at final review). Code that runs but should not ship.
3
+
4
+ Intent trace (Tier 0 hallucinated requirements, scope drift) runs FIRST at
5
+ stop via final-review axis 0, not here. This checklist covers code-shape and
6
+ cost slop. Apply every item; if guilty, FIX with Edit — delete, inline, drop.
7
+ Do not explain. If clean, say nothing.
8
+
9
+ 1. EDGE CASES — Happy path only? Check null / empty / zero / boundary / error
10
+ inputs the task implies.
11
+
12
+ 2. DUPLICATION Logic that already exists in this repo? Call it; do not
13
+ re-implement. Same function in many files (isRecord-class) → one source.
14
+
15
+ 3. CONVENTIONS Match the FILE's style, naming, structure, error-handling,
16
+ imports. Not your defaults.
17
+
18
+ 4. DEPENDENCIES New library for something stdlib or an existing dep covers?
19
+ Remove it. A dependency must earn its place.
20
+
21
+ 5. PREMATURE ABSTRACTION Factory / Repository / Mediator / Strategy / Builder /
22
+ CQRS / Event Sourcing / DDD: is there a REAL problem with 2–3 call sites
23
+ TODAY? "Future flexibility" is not a reason. Delete and write direct code.
24
+
25
+ 6. ACCIDENTAL COMPLEXITYCould a junior read this in 30 seconds? Flatten
26
+ indirection, generics, config, layers that do not earn their keep.
27
+
28
+ 7. TESTS (epistemic slop)Assert real OUTCOMES and edge cases, not "it runs",
29
+ not a mirror of the implementation, not expect(true).toBe(true). A test
30
+ that cannot fail is slop.
31
+
32
+ 8. CARGO CULTCan you state WHY each non-obvious construct is there? Remove
33
+ what you cannot justify. A shape you have seen a shape you need.
34
+
35
+ 9. ARCHITECTURE — Respect layering and boundaries. No reaching across layers,
36
+ no business logic in the wrong place, no breaking project constraints.
37
+
38
+ 10. REDUNDANT COMMENTS Delete comments that restate the code ("// increment
39
+ i"). Keep only WHY, never WHAT. No prompt residue ("in a real app...").
40
+
41
+ 11. SEMANTIC CONTRACTS (Tier 1) Did any existing function's BEHAVIOR change
42
+ without its name, signature, or docstring changing? Names are contracts.
43
+ deleteUser() that now soft-deletes is silent contract break.
44
+
45
+ 12. OPERATIONAL SLOP (Tier 3) Retry loops without backoff/sleep/jitter?
46
+ await fetch / ctx.db / prisma inside a for/while/map? Six or more
47
+ console.log / print added in one edit? Token burn with no user value →
48
+ remove or bound.
49
+
50
+ 13. CHANGE SURFACE (Tier 5) Did a simple request touch many files? Every
51
+ file in the diff must trace to the task. Trim unrelated hunks.
52
+
53
+ Hard constraints: never revert what the USER asked for — slop is what got added
54
+ on top. At most a few targeted edits, then stop.
@@ -45,17 +45,23 @@ is present — sandboxed verify run, no transcript — skip this axis.)
45
45
  - Add the missing tests; delete tautological ones.
46
46
 
47
47
  ## 4. Anti-slop
48
- - If `~/.cursor/skills/anti-slop/scripts/scan_slop.py` exists (INSTALL.md step 2
49
- copies it there), run the whole-codebase duplication scan:
48
+ Axis 0 already caught intent drift. This axis catches code-shape and cost slop
49
+ across the whole session diff.
50
+
51
+ Step A — mechanical scan (if available):
52
+ If `~/.cursor/skills/anti-slop/scripts/scan_slop.py` exists, run:
50
53
  python ~/.cursor/skills/anti-slop/scripts/scan_slop.py --all
51
- If it does NOT exist, do not treat that as a failure and do not hunt for the
52
- file: apply the checklist in `~/.agents/hooks/anti-slop.md` to the session
53
- diff and look for duplicate function bodies in the files you touched.
54
- - Either way, consolidate clones: same function in many files / identical bodies
55
- (the isRecord-class) ONE shared definition, re-point imports, delete the
56
- copies.
57
- - Premature abstraction (Factory / Repository / Mediator / CQRS / DDD with fewer
58
- than 2–3 real call sites), unnecessary dependencies, redundant restate-the-code
59
- comments, dead helpers, accidental complexity → remove.
60
-
61
- Fix with edits now; re-run the scan and the tests; then stop.
54
+ If it does NOT exist, skip Step A (not a failure; do not hunt for the file).
55
+
56
+ Step B canonical checklist (always):
57
+ Read `~/.agents/hooks/anti-slop.md` and apply ALL 13 items to every hunk you
58
+ changed this session. That file is the single source of truth for slop
59
+ detection — items 1–10 are structural/code, 11 is semantic contracts, 12 is
60
+ operational slop (retries, await-in-loop, telemetry spam), 13 is change
61
+ surface. Fix every hit; consolidate clones to one source of truth.
62
+
63
+ Step C — session footprint (also in the header above):
64
+ If "Session footprint" shows >5 files or the request was simple, justify each
65
+ file or trim. Unjustified files are slop.
66
+
67
+ Fix with edits now; re-run the scan (if Step A ran) and the tests; then stop.
@@ -1,7 +1,7 @@
1
1
  # final-review.ps1 - stop hook (Cursor).
2
2
  #
3
- # ONE comprehensive end-of-implementation review across four axes:
4
- # correctness, reliability, coverage, and anti-slop. When the agent finishes an
3
+ # ONE comprehensive end-of-implementation review across five axes:
4
+ # intent, correctness, reliability, coverage, and anti-slop. When the agent finishes an
5
5
  # implementation that touched files, Cursor auto-submits this hook's
6
6
  # `followup_message` as the next user turn, so the model re-audits everything it
7
7
  # changed this session and FIXES what fails - the model-as-auditor pattern over
@@ -86,11 +86,11 @@ FINAL REVIEW - audit everything you changed this session and FIX what fails
86
86
  released on every path, no races, input validated at the boundary.
87
87
  3. Coverage - behaviour-bearing changes have real tests; RUN the suite if present;
88
88
  no tautological tests.
89
- 4. Anti-slop - if ~/.cursor/skills/anti-slop/scripts/scan_slop.py exists, run
90
- `python ~/.cursor/skills/anti-slop/scripts/scan_slop.py --all`; otherwise
91
- apply ~/.agents/hooks/anti-slop.md to the session diff (a missing scanner
92
- is not a failure). Consolidate clones/duplicates to one source of truth;
93
- drop premature abstraction, unneeded deps, redundant comments, dead helpers.
89
+ 4. Anti-slop - read ~/.agents/hooks/anti-slop.md and apply all 13 items to
90
+ the session diff. If ~/.cursor/skills/anti-slop/scripts/scan_slop.py exists,
91
+ run `python ~/.cursor/skills/anti-slop/scripts/scan_slop.py --all` first.
92
+ Consolidate clones; drop premature abstraction, unneeded deps, operational
93
+ slop (retries, await-in-loop, log spam), unjustified files.
94
94
  Fix now, re-run the scan + tests, then stop. If an axis is clean, say so in one line.
95
95
  '@
96
96
  }
@@ -73,7 +73,17 @@ function Resolve-AgentPath([string]$p) {
73
73
  return ConvertTo-FwdPath $p
74
74
  }
75
75
 
76
- # Extract the last user <user_query> from a Cursor transcript JSONL. The
76
+ # Strip secrets from text before embedding in agent-facing followups. Intent
77
+ # trace must not re-broadcast tokens the user pasted in chat.
78
+ function Redact-SecretsFromIntent([string]$text) {
79
+ if (-not $text) { return $text }
80
+ $text = $text -replace '\bnpm_[A-Za-z0-9]{10,}\b', '[REDACTED_NPM_TOKEN]'
81
+ $text = $text -replace '\b(sk-[A-Za-z0-9]{10,}|ghp_[A-Za-z0-9]{20,}|gho_[A-Za-z0-9]{20,})\b', '[REDACTED_TOKEN]'
82
+ $text = $text -replace '(?i)(api[_-]?key|token|secret|password)\s*[:=]\s*\S+', '$1=[REDACTED]'
83
+ return $text
84
+ }
85
+
86
+ # Extract the last user <user_query> from a Cursor transcript JSONL.
77
87
  # transcript is an array of {role, message} records; we walk backward from the
78
88
  # end, find the last user turn whose content has a <user_query> tag, and return
79
89
  # its text. Returns '' if there is no transcript or no user_query. Capped at
@@ -108,7 +118,7 @@ function Get-LastUserQuery($obj) {
108
118
  if ($text -match '(?s)<user_query>\s*(.+?)\s*</user_query>') {
109
119
  $q = $Matches[1].Trim()
110
120
  if ($q.Length -gt 2000) { $q = $q.Substring(0, 2000) + '...' }
111
- return $q
121
+ return (Redact-SecretsFromIntent $q)
112
122
  }
113
123
  }
114
124
  return ''
@@ -3,7 +3,7 @@
3
3
  # Counterpart of final-review.ps1 for delegated work. afterFileEdit DOES fire
4
4
  # inside subagents (verified: a poteto subagent run left ~58 entries in
5
5
  # session-edits-<subagent-cid>.txt), but subagents get no `stop` event, so
6
- # that marker is never drained and the four-axis review never fires for
6
+ # that marker is never drained and the five-axis review never fires for
7
7
  # delegated implementations. This hook closes the loop: when a subagent
8
8
  # finishes and ITS conversation has a session-edits marker, return ONE
9
9
  # followup_message so the subagent audits its own implementation before the