@olegkoval/agent-skills 1.90.0 → 1.92.0
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/.github/prompts/self-critique.prompt.md +90 -232
- package/adapters/claude/olko-github-pr/skills/lekker-review/SKILL.md +25 -3
- package/adapters/claude/olko-github-pr/skills/lekker-review/references/codex-workflow.md +13 -0
- package/adapters/claude/olko-github-pr/skills/lekker-review/references/output-format.md +1 -0
- package/adapters/claude/olko-github-pr/skills/lekker-review/scripts/model-matrix.mjs +17 -6
- package/adapters/claude/olko-github-pr/skills/lekker-review/scripts/vendor-bridge.mjs +207 -0
- package/adapters/claude/olko-reflection/skills/self-critique/SKILL.md +90 -232
- package/adapters/claude/olko-reflection/skills/self-critique/references/rules.md +67 -0
- package/adapters/claude/olko-reflection/skills/self-critique/references/scoring.md +99 -0
- package/adapters/claude/olko-reflection/skills/self-critique/references/setup.md +62 -0
- package/adapters/claude/olko-reflection/skills/self-critique/scripts/claim-ledger.mjs +152 -9
- package/adapters/claude/olko-reflection/skills/self-critique/scripts/rule-store.mjs +34 -12
- package/adapters/claude/olko-reflection/skills/self-critique/scripts/run-store.mjs +133 -0
- package/adapters/cursor/olko-reflection/skills/self-critique/SKILL.md +90 -232
- package/adapters/cursor/olko-reflection/skills/self-critique/references/rules.md +67 -0
- package/adapters/cursor/olko-reflection/skills/self-critique/references/scoring.md +99 -0
- package/adapters/cursor/olko-reflection/skills/self-critique/references/setup.md +62 -0
- package/adapters/cursor/olko-reflection/skills/self-critique/scripts/claim-ledger.mjs +152 -9
- package/adapters/cursor/olko-reflection/skills/self-critique/scripts/rule-store.mjs +34 -12
- package/adapters/cursor/olko-reflection/skills/self-critique/scripts/run-store.mjs +133 -0
- package/adapters/grok/olko-reflection/skills/self-critique/SKILL.md +90 -232
- package/adapters/grok/olko-reflection/skills/self-critique/references/rules.md +67 -0
- package/adapters/grok/olko-reflection/skills/self-critique/references/scoring.md +99 -0
- package/adapters/grok/olko-reflection/skills/self-critique/references/setup.md +62 -0
- package/adapters/grok/olko-reflection/skills/self-critique/scripts/claim-ledger.mjs +152 -9
- package/adapters/grok/olko-reflection/skills/self-critique/scripts/rule-store.mjs +34 -12
- package/adapters/grok/olko-reflection/skills/self-critique/scripts/run-store.mjs +133 -0
- package/package.json +1 -1
- package/plugins/olko-apple-kit/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-creative/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-garmin-kit/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-git-tools/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-github-pr/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-github-pr/skills/lekker-review/README.md +20 -0
- package/plugins/olko-github-pr/skills/lekker-review/SKILL.md +25 -3
- package/plugins/olko-github-pr/skills/lekker-review/fix-workflow.js +92 -9
- package/plugins/olko-github-pr/skills/lekker-review/references/codex-workflow.md +13 -0
- package/plugins/olko-github-pr/skills/lekker-review/references/output-format.md +1 -0
- package/plugins/olko-github-pr/skills/lekker-review/scripts/model-matrix.mjs +17 -6
- package/plugins/olko-github-pr/skills/lekker-review/scripts/vendor-bridge.mjs +207 -0
- package/plugins/olko-github-pr/skills/lekker-review/workflow.js +102 -15
- package/plugins/olko-obsidian/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-product/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-reflection/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-reflection/skills/self-critique/SKILL.md +90 -232
- package/plugins/olko-reflection/skills/self-critique/references/rules.md +67 -0
- package/plugins/olko-reflection/skills/self-critique/references/scoring.md +99 -0
- package/plugins/olko-reflection/skills/self-critique/references/setup.md +62 -0
- package/plugins/olko-reflection/skills/self-critique/scripts/claim-ledger.mjs +152 -9
- package/plugins/olko-reflection/skills/self-critique/scripts/rule-store.mjs +34 -12
- package/plugins/olko-reflection/skills/self-critique/scripts/run-store.mjs +133 -0
- package/plugins/olko-release/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-skill-meta/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-web-ops/.claude-plugin/plugin.json +1 -1
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Runs one read-only gate agent on the other vendor's CLI and returns schema-checked JSON.
|
|
3
|
+
//
|
|
4
|
+
// node vendor-bridge.mjs --to codex|claude --model <m> --effort <e>
|
|
5
|
+
// --schema <schema.json> --prompt <prompt.md> --cwd <dir> --out <result.json>
|
|
6
|
+
// [--timeout <seconds>]
|
|
7
|
+
//
|
|
8
|
+
// Exit 0: validated JSON is in --out. Exit 3: --out holds {"fallback": "<reason>"}
|
|
9
|
+
// and the caller reruns the agent on its own vendor. Exit 2: unusable arguments.
|
|
10
|
+
// The prompt travels by stdin and every process gets an argument array, so
|
|
11
|
+
// nothing from the prompt, schema or paths is ever parsed by a shell.
|
|
12
|
+
import { execFileSync, spawn } from 'node:child_process'
|
|
13
|
+
import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from 'node:fs'
|
|
14
|
+
import { dirname } from 'node:path'
|
|
15
|
+
import { text } from 'node:stream/consumers'
|
|
16
|
+
import { fileURLToPath } from 'node:url'
|
|
17
|
+
|
|
18
|
+
export const FALLBACK_EXIT = 3
|
|
19
|
+
export const TARGETS = ['codex', 'claude']
|
|
20
|
+
const DEFAULT_TIMEOUT_SECONDS = 600
|
|
21
|
+
|
|
22
|
+
const REQUIRED = ['to', 'model', 'effort', 'schema', 'prompt', 'cwd', 'out']
|
|
23
|
+
|
|
24
|
+
export function parseArgs(argv) {
|
|
25
|
+
const pairs = argv.reduce((acc, token, i) =>
|
|
26
|
+
token.startsWith('--') && i + 1 < argv.length ? { ...acc, [token.slice(2)]: argv[i + 1] } : acc, {})
|
|
27
|
+
const timeout = pairs.timeout === undefined ? DEFAULT_TIMEOUT_SECONDS : Number(pairs.timeout)
|
|
28
|
+
const missing = REQUIRED.filter(key => !pairs[key])
|
|
29
|
+
if (missing.length > 0) return { error: `missing ${missing.map(k => `--${k}`).join(', ')}` }
|
|
30
|
+
if (!TARGETS.includes(pairs.to)) return { error: `--to must be one of ${TARGETS.join(', ')}` }
|
|
31
|
+
if (!(timeout > 0)) return { error: '--timeout must be a positive number of seconds' }
|
|
32
|
+
return { options: { ...Object.fromEntries(REQUIRED.map(k => [k, pairs[k]])), timeout } }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const typeMatches = (type, value) => ({
|
|
36
|
+
object: v => v !== null && typeof v === 'object' && !Array.isArray(v),
|
|
37
|
+
array: Array.isArray,
|
|
38
|
+
string: v => typeof v === 'string',
|
|
39
|
+
integer: Number.isInteger,
|
|
40
|
+
number: v => typeof v === 'number',
|
|
41
|
+
boolean: v => typeof v === 'boolean',
|
|
42
|
+
}[type]?.(value) ?? true)
|
|
43
|
+
|
|
44
|
+
// The JSON Schema keywords the lekker gate schemas use: type, enum, minLength,
|
|
45
|
+
// pattern, items, required, properties and anyOf. Any other keyword passes
|
|
46
|
+
// unchecked, so a schema must not rely on one this function does not know.
|
|
47
|
+
export function validate(schema, value, path = '$') {
|
|
48
|
+
if (schema.type !== undefined && !typeMatches(schema.type, value)) return [`${path} is not ${schema.type}`]
|
|
49
|
+
if (schema.enum && !schema.enum.includes(value)) return [`${path} is not one of ${schema.enum.join('|')}`]
|
|
50
|
+
if (typeof value === 'string' && schema.minLength !== undefined && value.length < schema.minLength) {
|
|
51
|
+
return [`${path} is shorter than ${schema.minLength}`]
|
|
52
|
+
}
|
|
53
|
+
if (typeof value === 'string' && schema.pattern !== undefined && !new RegExp(schema.pattern).test(value)) {
|
|
54
|
+
return [`${path} does not match ${schema.pattern}`]
|
|
55
|
+
}
|
|
56
|
+
if (schema.anyOf && schema.anyOf.every(sub => validate(sub, value, path).length > 0)) {
|
|
57
|
+
return [`${path} matches none of the anyOf alternatives`]
|
|
58
|
+
}
|
|
59
|
+
if (Array.isArray(value) && schema.items) {
|
|
60
|
+
return value.flatMap((item, i) => validate(schema.items, item, `${path}[${i}]`))
|
|
61
|
+
}
|
|
62
|
+
if (!typeMatches('object', value)) return []
|
|
63
|
+
const absent = (schema.required ?? []).filter(key => !(key in value)).map(key => `${path}.${key} is required`)
|
|
64
|
+
const nested = Object.entries(schema.properties ?? {})
|
|
65
|
+
.filter(([key]) => key in value)
|
|
66
|
+
.flatMap(([key, sub]) => validate(sub, value[key], `${path}.${key}`))
|
|
67
|
+
return [...absent, ...nested]
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Codex strict structured output rejects schemas with optional properties, which
|
|
71
|
+
// every lekker schema has, so Codex gets the schema in the prompt and the bridge
|
|
72
|
+
// validates its answer instead of passing --output-schema.
|
|
73
|
+
export function promptFor(to, prompt, schemaText) {
|
|
74
|
+
return to === 'codex'
|
|
75
|
+
? `${prompt}\n\nReply with only one JSON value, no prose and no code fence, that matches this JSON Schema:\n${schemaText}\n`
|
|
76
|
+
: prompt
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// The Claude target gets no shell at all: git options such as --output can
|
|
80
|
+
// write files, and prefix rules cannot exclude them. A fix verifier needs the
|
|
81
|
+
// worktree's uncommitted diff, so the bridge saves it to a file it can Read.
|
|
82
|
+
const CLAUDE_READ_ONLY_TOOLS = 'Read,Grep,Glob'
|
|
83
|
+
const CLAUDE_DENIED_TOOLS = 'Bash,Edit,Write,NotebookEdit'
|
|
84
|
+
|
|
85
|
+
export function worktreeDiff(cwd) {
|
|
86
|
+
try {
|
|
87
|
+
const status = execFileSync('git', ['-C', cwd, 'status', '--short'], { encoding: 'utf8', maxBuffer: 1 << 26 })
|
|
88
|
+
const diff = execFileSync('git', ['-C', cwd, 'diff', '--no-ext-diff', '--no-color'], { encoding: 'utf8', maxBuffer: 1 << 26 })
|
|
89
|
+
return `# git status --short\n${status}\n# git diff\n${diff}`
|
|
90
|
+
} catch {
|
|
91
|
+
return null
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function withDiffNote(prompt, diffPath) {
|
|
96
|
+
return diffPath === null
|
|
97
|
+
? prompt
|
|
98
|
+
: `${prompt}\n\nYou have no shell. The working tree's uncommitted changes (git status and git diff) are saved at ${diffPath}; Read that file wherever these instructions say to run git.\n`
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function commandFor({ to, model, effort, schemaText, rawOut, cwd }) {
|
|
102
|
+
return to === 'codex'
|
|
103
|
+
? { cmd: 'codex', args: ['exec', '-m', model, '-c', `model_reasoning_effort=${effort}`, '-s', 'read-only',
|
|
104
|
+
'--skip-git-repo-check', '-o', rawOut, '-C', cwd, '-'] }
|
|
105
|
+
: { cmd: 'claude', args: ['-p', '--model', model, '--effort', effort, '--output-format', 'json',
|
|
106
|
+
'--json-schema', schemaText, '--permission-mode', 'default',
|
|
107
|
+
'--allowedTools', CLAUDE_READ_ONLY_TOOLS, '--disallowedTools', CLAUDE_DENIED_TOOLS] }
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const parseJson = raw => {
|
|
111
|
+
try { return { value: JSON.parse(raw) } } catch { return { error: 'output is not valid JSON' } }
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const unfence = raw => raw.trim().replace(/^```(?:json)?\s*\n?([\s\S]*?)\n?```$/, '$1')
|
|
115
|
+
|
|
116
|
+
// `to` names the CLI that ran: codex leaves its last message in a file, claude prints an envelope.
|
|
117
|
+
export function resultFrom(to, { stdout, rawOutText }) {
|
|
118
|
+
if (to === 'codex') return parseJson(unfence(rawOutText ?? ''))
|
|
119
|
+
const envelope = parseJson(stdout)
|
|
120
|
+
if (envelope.error || !typeMatches('object', envelope.value)) return { error: 'claude output is not a JSON envelope' }
|
|
121
|
+
const { is_error: isError, structured_output: structured, result } = envelope.value
|
|
122
|
+
if (isError) return { error: `claude reported an error: ${String(result).slice(0, 200)}` }
|
|
123
|
+
return structured !== undefined && structured !== null ? { value: structured } : parseJson(unfence(String(result ?? '')))
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function writeAtomic(path, value) {
|
|
127
|
+
mkdirSync(dirname(path), { recursive: true })
|
|
128
|
+
const staging = `${path}.tmp`
|
|
129
|
+
writeFileSync(staging, `${JSON.stringify(value)}\n`)
|
|
130
|
+
renameSync(staging, path)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function runProcess(cmd, args, { stdin, cwd, timeoutMs }) {
|
|
134
|
+
return new Promise(resolve => {
|
|
135
|
+
const child = spawn(cmd, args, { cwd, stdio: ['pipe', 'pipe', 'pipe'] })
|
|
136
|
+
const stdout = text(child.stdout).catch(() => '')
|
|
137
|
+
const stderr = text(child.stderr).catch(() => '')
|
|
138
|
+
const timer = setTimeout(() => {
|
|
139
|
+
child.kill('SIGKILL')
|
|
140
|
+
resolve({ reason: `timed out after ${timeoutMs / 1000}s` })
|
|
141
|
+
}, timeoutMs)
|
|
142
|
+
child.on('error', error => {
|
|
143
|
+
clearTimeout(timer)
|
|
144
|
+
resolve({ reason: error.code === 'ENOENT' ? `${cmd} not found on PATH` : `${cmd} failed to start: ${error.message}` })
|
|
145
|
+
})
|
|
146
|
+
child.on('close', async code => {
|
|
147
|
+
clearTimeout(timer)
|
|
148
|
+
resolve({ code, stdout: await stdout, stderr: await stderr })
|
|
149
|
+
})
|
|
150
|
+
child.stdin.on('error', () => {})
|
|
151
|
+
child.stdin.end(stdin)
|
|
152
|
+
})
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const firstLine = raw => String(raw ?? '').trim().split('\n')[0].slice(0, 200)
|
|
156
|
+
|
|
157
|
+
function readInputs(promptPath, schemaPath) {
|
|
158
|
+
try {
|
|
159
|
+
return { prompt: readFileSync(promptPath, 'utf8'), schemaText: readFileSync(schemaPath, 'utf8').trim() }
|
|
160
|
+
} catch (error) {
|
|
161
|
+
return { error: firstLine(error.message) }
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
async function runVendor(options) {
|
|
166
|
+
const { to, model, effort, schema, prompt, cwd, timeout, out } = options
|
|
167
|
+
const inputs = readInputs(prompt, schema)
|
|
168
|
+
if (inputs.error) return { fallback: `cannot read prompt or schema: ${inputs.error}` }
|
|
169
|
+
const schemaValue = parseJson(inputs.schemaText)
|
|
170
|
+
if (schemaValue.error) return { fallback: 'schema file is not valid JSON' }
|
|
171
|
+
|
|
172
|
+
const rawOut = `${out}.raw`
|
|
173
|
+
rmSync(rawOut, { force: true })
|
|
174
|
+
const { cmd, args } = commandFor({ to, model, effort, schemaText: inputs.schemaText, rawOut, cwd })
|
|
175
|
+
const diffText = to === 'claude' ? worktreeDiff(cwd) : null
|
|
176
|
+
const diffPath = diffText === null ? null : `${out}.worktree.diff`
|
|
177
|
+
if (diffPath !== null) writeFileSync(diffPath, diffText)
|
|
178
|
+
const stdin = withDiffNote(promptFor(to, inputs.prompt, inputs.schemaText), diffPath)
|
|
179
|
+
const ran = await runProcess(cmd, args, { stdin, cwd, timeoutMs: timeout * 1000 })
|
|
180
|
+
if (ran.reason) return { fallback: ran.reason }
|
|
181
|
+
if (ran.code !== 0) return { fallback: `${cmd} exited ${ran.code}: ${firstLine(ran.stderr)}` }
|
|
182
|
+
|
|
183
|
+
const rawOutText = existsSync(rawOut) ? readFileSync(rawOut, 'utf8') : undefined
|
|
184
|
+
const parsed = resultFrom(to, { stdout: ran.stdout, rawOutText })
|
|
185
|
+
if (parsed.error) return { fallback: parsed.error }
|
|
186
|
+
const problems = validate(schemaValue.value, parsed.value)
|
|
187
|
+
return problems.length > 0 ? { fallback: `schema mismatch: ${problems[0]}` } : { value: parsed.value }
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
async function main(argv) {
|
|
191
|
+
const { options, error } = parseArgs(argv)
|
|
192
|
+
if (error) {
|
|
193
|
+
console.error(`vendor-bridge: ${error}`)
|
|
194
|
+
process.exit(2)
|
|
195
|
+
}
|
|
196
|
+
const outcome = await runVendor(options)
|
|
197
|
+
const failed = outcome.fallback !== undefined
|
|
198
|
+
writeAtomic(options.out, failed ? { fallback: outcome.fallback } : outcome.value)
|
|
199
|
+
if (failed) console.error(`vendor-bridge: fallback: ${outcome.fallback}`)
|
|
200
|
+
process.exit(failed ? FALLBACK_EXIT : 0)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Real paths, so a skill installed through a symlinked directory still runs.
|
|
204
|
+
const isEntrypoint = () => {
|
|
205
|
+
try { return realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url)) } catch { return false }
|
|
206
|
+
}
|
|
207
|
+
if (isEntrypoint()) main(process.argv.slice(2))
|
|
@@ -21,16 +21,12 @@ Run an adversarial review of **your own previous answer** and report the result
|
|
|
21
21
|
|
|
22
22
|
## Overview
|
|
23
23
|
|
|
24
|
-
A confident answer is not a verified one.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
The point is to surface error before the user does, to make "is this actually right?" a measured
|
|
31
|
-
quantity instead of a vibe, and to make the same mistake cost less the second time than it did the
|
|
32
|
-
first. A critique that ends at a score has bought one corrected answer. A critique that ends at a
|
|
33
|
-
durable rule has bought every answer after it.
|
|
24
|
+
A confident answer is not a verified one. A separate critic agent tries to refute your last answer
|
|
25
|
+
against live sources and hunts for the related issue or pattern you missed. The score is computed
|
|
26
|
+
from a labelled claim ledger. You revise under a ratchet, report honestly including where you were
|
|
27
|
+
wrong, and convert what the critic caught into a rule that survives the session. A critique that ends
|
|
28
|
+
at a score has bought one corrected answer; one that ends at a durable rule has bought every answer
|
|
29
|
+
after it.
|
|
34
30
|
|
|
35
31
|
## When to Use
|
|
36
32
|
|
|
@@ -42,174 +38,120 @@ durable rule has bought every answer after it.
|
|
|
42
38
|
Do not use for trivial one-shot replies or simple chat. The overhead only pays off on load-bearing
|
|
43
39
|
answers.
|
|
44
40
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
which calls the bundled scripts.
|
|
41
|
+
Setup notes (state dir, Cursor install, the optional Stop-hook nudge): `references/setup.md`.
|
|
42
|
+
Penalties, anchors, ledger shape and integrity checks: `references/scoring.md`.
|
|
48
43
|
|
|
49
44
|
## Procedure
|
|
50
45
|
|
|
51
46
|
1. **Snapshot the target.** Capture your last substantial answer verbatim and the original task
|
|
52
|
-
text. This is `v1`.
|
|
47
|
+
text. This is `v1`. Create the run folder (outside the repo, one per run) and use it for every
|
|
48
|
+
file below:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
RUN=$(node <skill>/scripts/run-store.mjs new --cwd "$PWD")
|
|
52
|
+
```
|
|
53
53
|
|
|
54
54
|
Write your claim list before you re-read the answer's prose, and put a real receipt against each
|
|
55
55
|
claim: a quoted field, a `file:line` whose body you actually opened, a command and its output.
|
|
56
|
-
A claim you cannot receipt at snapshot time is already a finding
|
|
56
|
+
A claim you cannot receipt at snapshot time is already a finding: mark it `unverifiable` yourself
|
|
57
57
|
rather than waiting for the critic to find it. Grep output, a file name, a path, an endpoint
|
|
58
|
-
string, or the behaviour of a sibling module are not receipts for what code does
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
`
|
|
68
|
-
|
|
69
|
-
|
|
58
|
+
string, or the behaviour of a sibling module are not receipts for what code does.
|
|
59
|
+
|
|
60
|
+
Save the list to `$RUN/author-claims.json` as an array of `{ id, text, load_bearing, receipt }`.
|
|
61
|
+
Do NOT show it to the critic in round one.
|
|
62
|
+
|
|
63
|
+
**Replay pass.** Before spawning the critic, check the answer against this skill's own rules.
|
|
64
|
+
Resolve the memory dir as the auto-memory dir for the current project, else the repo's
|
|
65
|
+
`.claude/memory`; if neither exists, skip replay, evidence-check, and prune with a one-line note.
|
|
66
|
+
Run `node <skill>/scripts/rule-store.mjs checklist --dir <memory dir>`. It lists only rules marked
|
|
67
|
+
`rule_store: self-critique`; open only those files and read each body before testing the answer
|
|
68
|
+
against it (names and descriptions alone are insufficient). Do not read the rest of the memory
|
|
69
|
+
dir. Tag each hit `(recurring)` in the report and record it with
|
|
70
70
|
`node <skill>/scripts/rule-store.mjs fire <name> --dir <memory dir> --date <today>`.
|
|
71
|
-
Fire counters and pruning apply only to rules in this memory directory. Rules routed to
|
|
72
|
-
`CLAUDE.md`, `AGENTS.md`, or the shared store are neither counted nor pruned.
|
|
73
71
|
|
|
74
72
|
2. **Spawn the critic (blind).** Launch one independent agent with live-source access (issue tracker,
|
|
75
73
|
code host, error monitor, the repo). Round one input is the original task text and the answer
|
|
76
74
|
verbatim, nothing else: the critic extracts the claims itself and never sees your list or sources.
|
|
77
|
-
Use the prompt template below. The critic
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
score is computed in Step 2b.
|
|
75
|
+
Use the prompt template below. The critic returns one fenced JSON block with `claims`, `missed`,
|
|
76
|
+
`where_wrong`, `shapes` and `verdict`. There is no `score` field. **Save the returned JSON
|
|
77
|
+
verbatim** as `$RUN/critic-r<N>.json` (N is the round); the ledger is checked against it.
|
|
81
78
|
|
|
82
79
|
2b. **Merge into the ledger.** Match the critic's claims to yours by meaning and set `origin` on
|
|
83
|
-
each: `both`, `author` (only you found it), `critic` (only the critic found it). Every
|
|
84
|
-
|
|
85
|
-
or `
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
`
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
{ "version": 1,
|
|
97
|
-
"claims": [{ "id": "c1", "text": "...", "load_bearing": true, "origin": "both",
|
|
98
|
-
"status": "verified", "checked_by": "command", "receipt": "quoted output" }],
|
|
99
|
-
"missed": [{ "id": "m1", "text": "...", "load_bearing": false, "checked_by": "read" }] }
|
|
80
|
+
each: `both`, `author` (only you found it), `critic` (only the critic found it). Every entry
|
|
81
|
+
carries its link back: `author_id` (the id in `author-claims.json`) for `author` and `both`,
|
|
82
|
+
`critic_ref` (`"r1:claims.3"` or `"r1:missed.1"`) for `critic` and `both` and on every `missed`
|
|
83
|
+
entry. Nothing from either side may be left out: every author claim and every critic item needs
|
|
84
|
+
an entry. Every critic finding with `checked_by: inferred` must be re-verified by you before it
|
|
85
|
+
may become `verified` or `refuted`; if you cannot, it stays `inferred` (and costs the same as
|
|
86
|
+
unverifiable when load-bearing). Save `$RUN/ledger-v1.json`, then run, always with all three
|
|
87
|
+
flags that apply (`--prev` from round two on):
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
node <skill>/scripts/claim-ledger.mjs score $RUN/ledger-v1.json \
|
|
91
|
+
--author $RUN/author-claims.json --critic r1=$RUN/critic-r1.json [--prev $RUN/ledger-v<N-1>.json]
|
|
92
|
+
node <skill>/scripts/claim-ledger.mjs summary $RUN/ledger-v1.json
|
|
100
93
|
```
|
|
101
94
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
95
|
+
A ledger that drops a claim, cites a missing critic item, or loses an id from the previous round
|
|
96
|
+
exits 2 with the errors as JSON: fix the ledger, not the check. Output with
|
|
97
|
+
`"integrity": "unchecked"` was run without those flags and may not be reported as a score.
|
|
98
|
+
Claims found by only one side go under "Asymmetric claims".
|
|
99
|
+
|
|
100
|
+
3. **Decide and loop.** After each round run
|
|
101
|
+
`node <skill>/scripts/claim-ledger.mjs status $RUN/ledger-v1.json [$RUN/ledger-v2.json ...]`.
|
|
102
|
+
It prints `first_score`, `final_score`, `trajectory`, `open` (`load_bearing` and `other` counts)
|
|
103
|
+
and `done`. **Stop when** `done` is true (no load-bearing claim is refuted, unverifiable or
|
|
104
|
+
inferred, and no load-bearing missed item remains, inferred ones included), OR nothing left open can be fixed by a
|
|
105
|
+
revision (say why in "Declined findings"), OR 3 rounds have run. There is no score threshold:
|
|
106
|
+
the critic-only penalty can never be revised away, so a score target would loop on nothing.
|
|
107
|
+
|
|
108
|
+
Otherwise revise the answer to produce `v2`, write `$RUN/ledger-v2.json` (it keeps every earlier
|
|
109
|
+
claim id), and run
|
|
110
|
+
`node <skill>/scripts/claim-ledger.mjs ratchet $RUN/ledger-v1.json $RUN/ledger-v2.json --author $RUN/author-claims.json --critic r1=$RUN/critic-r1.json --critic r2=$RUN/critic-r2.json`.
|
|
111
|
+
A lower re-score discards the revision and you keep the winner. Round two and later hand the
|
|
112
|
+
critic your receipts for the still-open claims (it is no longer blind). **Hard cap: 3 critic
|
|
113
|
+
rounds.**
|
|
118
114
|
|
|
119
115
|
**Cost.** The critic runs on a mid-tier model (Sonnet class) by default. Escalate one tier only
|
|
120
116
|
when a mid-tier round found nothing and the answer is load-bearing. When the budget is tight,
|
|
121
117
|
verify load-bearing claims first.
|
|
122
118
|
|
|
123
|
-
4. **Report, always, even after a single round.**
|
|
124
|
-
- **
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
119
|
+
4. **Report, always, even after a single round.** Lead with two numbers, then the rest in order:
|
|
120
|
+
- **Headline** - the first-answer score (round 1, what the user would have got without this
|
|
121
|
+
skill) and the open-defect count from `status` (load-bearing and other). The first-answer
|
|
122
|
+
score is the honest quality number; the final score only measures the revision.
|
|
123
|
+
- **Corrected answer (`v_final`)** - restated in full, not as a diff. After a single round with
|
|
124
|
+
no revision, restate `v1` unchanged and label it unrevised. If load-bearing defects are still
|
|
125
|
+
open, give their count and the stop reason beside it; never call that outcome clean.
|
|
126
|
+
- **Score trajectory** - for example `72 -> 88 -> 94 (+22 pts)`, all computed. If only one round
|
|
127
|
+
ran with `done` true, state `no revision needed`; if it stopped with load-bearing defects open, say that instead. Add the trend from
|
|
128
|
+
`node <skill>/scripts/run-store.mjs history --cwd "$PWD"` (first-answer score per run).
|
|
129
|
+
- **Claim ledger** - the `summary` table for the ledger the ratchet kept, and its `score` with
|
|
130
|
+
`integrity: checked`.
|
|
130
131
|
- **Where you were wrong** - consolidated, each item with the receipt the critic cited.
|
|
131
132
|
- **Asymmetric claims** - claims only you found, and claims only the critic found.
|
|
132
133
|
- **Recurring rules fired** - each stored rule the replay pass hit, with its new `fires` count.
|
|
133
|
-
- **Iterations to satisfy** - how many critic rounds it took (1 means it was solid first pass).
|
|
134
|
-
- **Score trajectory** - for example `72 -> 88 -> 94 (+22 pts)`, all computed scores. If only one
|
|
135
|
-
round ran, state `no revision needed`.
|
|
134
|
+
- **Iterations to satisfy** - how many critic rounds it took (1 with `done` true means it was solid first pass).
|
|
136
135
|
- **Unverifiable** - anything you should not present as fact.
|
|
137
136
|
- **Declined findings** - ledger items you chose not to fix, with the reason. Silently dropping
|
|
138
137
|
one looks identical to missing it.
|
|
139
|
-
- **Rules written**
|
|
140
|
-
- **Rules proposed for deletion** - the candidates from the prune pass, or `none`.
|
|
141
|
-
|
|
142
|
-
5. **Convert the outcome into a durable rule.** See below. Skipping this step is what makes the
|
|
143
|
-
same critique necessary again next week.
|
|
144
|
-
|
|
145
|
-
## Step 5: turn the critique into something that outlives the session
|
|
146
|
-
|
|
147
|
-
A score is a measurement, not an improvement. The improvement is the rule you write down, in a
|
|
148
|
-
place a future session actually reads, before you move on.
|
|
149
|
-
|
|
150
|
-
**Not every finding earns a rule.** Write one only when the finding passes both gates:
|
|
151
|
-
|
|
152
|
-
- **Recurrence** - the same *shape* of mistake could plausibly happen again on a different task.
|
|
153
|
-
- **Cost** - it would have reached the user, cost real rework, or damaged their credibility with
|
|
154
|
-
someone else.
|
|
155
|
-
|
|
156
|
-
A one-off factual slip, a typo, or a finding fully explained by this task's specifics fails both.
|
|
157
|
-
Writing a rule for it pollutes the store, and a littered store is worse than a thin one, because
|
|
158
|
-
the next session stops reading it.
|
|
159
|
-
|
|
160
|
-
**Write the shape, not the incident.** The incident is the evidence; the shape is the rule. Ask
|
|
161
|
-
what class of reasoning produced the error, then name that class:
|
|
162
|
-
|
|
163
|
-
| Incident | Shape worth keeping |
|
|
164
|
-
| --- | --- |
|
|
165
|
-
| Called an endpoint a read because the path was a noun and a sibling module imported | A conclusion drawn from evidence that does not cover the claim |
|
|
166
|
-
| Priced an open design question as "small" in the same sentence that asked which design was wanted | Never attach a size to an answer you are simultaneously asking for |
|
|
167
|
-
| Described a batch from the one member that was checked | Check the risk-deciding field on every member before describing the set |
|
|
168
|
-
|
|
169
|
-
**Route it to the narrowest store the host has**, in this order, and only one of them:
|
|
170
|
-
|
|
171
|
-
1. The user's or project's agent memory, when the rule is about how to work with this user or this
|
|
172
|
-
project.
|
|
173
|
-
2. The repository's own `CLAUDE.md` / `AGENTS.md`, when the rule is true only inside that codebase.
|
|
174
|
-
3. A shared, cross-session store, when the rule holds across projects. Use `context-repo` to resolve
|
|
175
|
-
it, or `shared-knowledge-artifact` when several agents need to read the same ledger.
|
|
176
|
-
|
|
177
|
-
Broadening a rule's scope so it qualifies for a wider store is the failure mode to avoid: one
|
|
178
|
-
incident on one afternoon is not standing policy. Let the evidence decide where it lands.
|
|
179
|
-
|
|
180
|
-
**Each rule carries three things.** Without all three the next session cannot act on it:
|
|
138
|
+
- **Rules written** and **Rules proposed for deletion** (Step 5), or `none`.
|
|
181
139
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
- **How to apply**, naming the moment the rule fires ("before drafting outbound text", "before
|
|
185
|
-
describing a batch"), not just the principle.
|
|
140
|
+
5. **Convert the outcome into a durable rule.** Skipping this step is what makes the same critique
|
|
141
|
+
necessary again next week. Write a rule only when the finding passes both gates:
|
|
186
142
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
receipt. This redaction requirement does not apply to local agent memory or repository-rule writes.
|
|
143
|
+
- **Recurrence** - the same *shape* of mistake could plausibly happen again on a different task.
|
|
144
|
+
- **Cost** - it would have reached the user, cost real rework, or damaged their credibility.
|
|
190
145
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
the
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
`rule_store: self-critique` under `metadata:` in its memory file's frontmatter. Mark an existing
|
|
201
|
-
rule only after reading it and confirming it belongs to this workflow. Only marked rules are
|
|
202
|
-
pruning candidates; unrelated project and user memories are excluded. A memory rule's `fires` and
|
|
203
|
-
`last_fired` live under `metadata:` and are written only by `fire`. Rules routed to `CLAUDE.md`,
|
|
204
|
-
`AGENTS.md`, or the shared store are neither counted nor pruned.
|
|
205
|
-
|
|
206
|
-
**Prune pass.** At the end of this step, only when a valid memory directory is available, run
|
|
207
|
-
`node <skill>/scripts/rule-store.mjs prune --dir <memory dir> --idle-days 60`. List the candidates
|
|
208
|
-
in the report under "Rules proposed for deletion". Skip this command when neither supported memory
|
|
209
|
-
directory exists. Never delete a rule without the user's reply.
|
|
210
|
-
|
|
211
|
-
**Then close the loop.** State in your report where the rule was written and what it says, so the
|
|
212
|
-
user can veto it. A rule the user has not seen is a rule they cannot correct.
|
|
146
|
+
A one-off factual slip, a typo, or a finding fully explained by this task's specifics fails both;
|
|
147
|
+
a littered store is worse than a thin one. Write the shape (the class of reasoning that produced
|
|
148
|
+
the error), not the incident. Route it to the narrowest store, in this order, and only one:
|
|
149
|
+
(1) the user's or project's agent memory, (2) the repo's `CLAUDE.md` / `AGENTS.md`, (3) a shared
|
|
150
|
+
cross-session store. Each rule carries three things: **the rule** in the imperative, **why** (the
|
|
151
|
+
incident, dated, with its receipt), and **how to apply** (the moment it fires). Mark memory rules
|
|
152
|
+
`rule_store: self-critique`, dedupe before writing, run the prune pass, and tell the user what you
|
|
153
|
+
wrote so they can veto it. Shapes table, routing detail, dedupe, redaction, identity and the
|
|
154
|
+
prune pass: `references/rules.md`.
|
|
213
155
|
|
|
214
156
|
## Critic prompt template
|
|
215
157
|
|
|
@@ -257,98 +199,14 @@ the default stance is that the answer is wrong until a live source proves otherw
|
|
|
257
199
|
>
|
|
258
200
|
> Do not output a score. It is computed from your claims.
|
|
259
201
|
|
|
260
|
-
### Score anchors
|
|
261
|
-
|
|
262
|
-
The score is `100` minus penalties, floored at 0. Calibrate against these three ledgers (all claims
|
|
263
|
-
`origin: both`; `node <skill>/scripts/claim-ledger.mjs anchors` prints them as JSON).
|
|
264
|
-
|
|
265
|
-
**Strong, score 95**
|
|
266
|
-
|
|
267
|
-
| id | load_bearing | status | checked_by |
|
|
268
|
-
| --- | --- | --- | --- |
|
|
269
|
-
| a1 | no | inferred | inferred |
|
|
270
|
-
|
|
271
|
-
**Middling, score 72**
|
|
272
|
-
|
|
273
|
-
| id | load_bearing | status | checked_by |
|
|
274
|
-
| --- | --- | --- | --- |
|
|
275
|
-
| b1 | no | refuted | read |
|
|
276
|
-
| b2 | no | refuted | read |
|
|
277
|
-
| b3 | no | unverifiable | read |
|
|
278
|
-
| b4 | no | unverifiable | read |
|
|
279
|
-
|
|
280
|
-
**Weak, score 40**
|
|
281
|
-
|
|
282
|
-
| id | load_bearing | status | checked_by |
|
|
283
|
-
| --- | --- | --- | --- |
|
|
284
|
-
| c1 | yes | refuted | read |
|
|
285
|
-
| c2 | yes | refuted | read |
|
|
286
|
-
| c3 | yes | unverifiable | read |
|
|
287
|
-
|
|
288
|
-
Penalties:
|
|
289
|
-
|
|
290
|
-
| Finding | Points off |
|
|
291
|
-
| --- | --- |
|
|
292
|
-
| refuted, load-bearing | 25 |
|
|
293
|
-
| refuted | 10 |
|
|
294
|
-
| unverifiable, load-bearing | 10 |
|
|
295
|
-
| unverifiable | 4 |
|
|
296
|
-
| inferred, accepted | 5 |
|
|
297
|
-
| missed, load-bearing | 15 |
|
|
298
|
-
| missed | 5 |
|
|
299
|
-
| verified but found only by the critic | 5 |
|
|
300
|
-
|
|
301
|
-
## Optional: auto-offer via a Claude Code Stop hook
|
|
302
|
-
|
|
303
|
-
A hook is a shell command, so it cannot run this loop itself. What it can do is **nudge**: after a
|
|
304
|
-
substantial answer, it offers the review and you run the skill only if the user says yes.
|
|
305
|
-
|
|
306
|
-
The hook ships with this skill at `scripts/critique-nudge.mjs`. Register it as a `Stop` hook in your
|
|
307
|
-
Claude Code settings (`.claude/settings.json` for a team, `.claude/settings.local.json` for
|
|
308
|
-
yourself):
|
|
309
|
-
|
|
310
|
-
```json
|
|
311
|
-
{
|
|
312
|
-
"hooks": {
|
|
313
|
-
"Stop": [
|
|
314
|
-
{
|
|
315
|
-
"hooks": [
|
|
316
|
-
{
|
|
317
|
-
"type": "command",
|
|
318
|
-
"command": "node \"$CLAUDE_PROJECT_DIR/.claude/hooks/critique-nudge.mjs\"",
|
|
319
|
-
"timeout": 15
|
|
320
|
-
}
|
|
321
|
-
]
|
|
322
|
-
}
|
|
323
|
-
]
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
```
|
|
327
|
-
|
|
328
|
-
Copy `scripts/critique-nudge.mjs` to `.claude/hooks/critique-nudge.mjs` (or point the command at
|
|
329
|
-
wherever you keep it). After an answer whose final prose is at least 1500 characters, the hook blocks
|
|
330
|
-
the turn once and instructs the agent to append a one-line "critical-thinking review" offer, then
|
|
331
|
-
stop. Two loop guards keep it from firing forever: it does nothing when `stop_hook_active` is set, and
|
|
332
|
-
nothing when the answer already contains the offer phrase. On any malformed input it exits silently
|
|
333
|
-
and never blocks the user.
|
|
334
|
-
|
|
335
|
-
The 1500-character threshold is a heuristic with a known ceiling: it misses short but dense
|
|
336
|
-
tool-heavy turns. If that matters, extend the script to also count tool calls since the last user
|
|
337
|
-
message.
|
|
338
|
-
|
|
339
202
|
## Notes
|
|
340
203
|
|
|
341
|
-
- One critic round is fine and common. If the answer was already solid, report
|
|
204
|
+
- One critic round is fine and common. If the answer was already solid (`done` true), report
|
|
342
205
|
`iterations: 1, no revision needed` and the single score rather than forcing a revision.
|
|
343
206
|
- Diversity beats redundancy: if a claim can fail in more than one way, give the critic distinct
|
|
344
207
|
lenses (correctness, completeness, does-it-reproduce) instead of repeating the same check.
|
|
345
208
|
- The critic verifies against live sources; it does not rewrite the answer or score it. You revise;
|
|
346
209
|
the score is recomputed from the ledger.
|
|
347
|
-
- In round two, hand the critic your receipts for the claims still open, so it spends its budget on
|
|
348
|
-
the claims still standing instead of re-deriving the ones already settled.
|
|
349
210
|
- A critic finding you disagree with is worth one challenge. Put the reasoning to it and let it rule;
|
|
350
211
|
if it concedes, that is a real answer for the report, and the reasoning is what the user needs to
|
|
351
212
|
see either way.
|
|
352
|
-
- The honest test of Step 5 is not that a rule was written, it is that the next task of the same
|
|
353
|
-
class does not need this skill to catch the same thing. If it does, the rule named the incident
|
|
354
|
-
instead of the shape - rewrite it, do not add another.
|