/project-toolkit:skilloptfrom project-toolkit
Improves skills, agent files, or prompts through bounded patches and a held-out acceptance gate. Use when a skill keeps failing or you need measured optimization.
Ships in project-toolkit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
A candidate lands only when it adds at least one held-out pass and loses none. No scored eval set means no gate, and no gate means no edit.
SkillOpt treats a skill document as the trainable state of a frozen model. You run rollouts and reflect on failures. The bundled scripts decide whether an edit may exist: the edit budget, the patch applier, the protected-section guard, the rejected-edit buffer, and the acceptance gate are deterministic. Do not edit the target by hand. Route every edit through the scripts so the gate is real. Method: Yang et al., arXiv:2605.23904. The paper's reported gains are its claims; this skill does not reproduce them.
| Phrase | Action |
|---|---|
optimize this skill | Run the Process below against a scored eval set |
make this skill better | Same, after the Preconditions pass |
compress these skills safely | Declare a resource task up front, then gate |
tune this prompt against an eval | Same loop with a prompt as the target |
| A skill keeps failing the same way | Mine sessions, confirm the defect, then gate |
| Need | Owner |
|---|---|
| Create a skill, find one, or route a request to one | skillforge |
| Decide skill vs passive context, or compress markdown with no eval | context-optimizer |
| Measured improvement of an existing skill, agent file, or prompt | this skill |
Held-out optimization of agents, rules, and hooks inside the rjmurillo/ai-agents checkout | optimize-artifact.py in that repository's eval tooling (not shipped) |
SKILL.md, agent file, or prompt.sel split with per-task pass or
fail verifiers (references/eval-set-format.md). Without one, stop and say
so. score and pair-gate exit 2 on a missing or empty split.sel runner must
be separate: a fresh subagent or another session. The sel runner writes
and holds the full eval.json. The author gets a train-only copy that
keeps the sel task ids but drops the sel task bodies; apply reads
only those ids. In every step the author must not write, run, or see the
sel prompts, verifiers, or per-task results. Only the gate verdict goes
back. If the harness cannot provide both, do not run skillopt. Report that the gate cannot be
independent. Replacement holdouts written by the same agent are still
exposed.Freeze the train and sel task lists before authoring any candidate. Keep
sel prompts, verifiers, and outcomes away from the candidate author for the
whole run (Precondition 4). If they were exposed, list them under exposed in
the manifest, move them to train, and add untouched holdout tasks written
by a runner who has not seen the candidate (Precondition 4).
pair-gate exits 2 while an exposed or invalid task sits in the sel split.
Deterministic tasks taken from a written spec before any candidate exists
are frozen once their list and verifiers stop changing. Freezing is not
isolation. If the agent that wrote them also writes the candidate, it has
seen every verifier, so list them under exposed and keep them in train.
They still catch regressions. They count as sel only when a different
author or session wrote them and kept them from the candidate author.
Read references/target-selection.md before you fund rollouts for a target,
and when a patch fails to apply. It covers confirming the defect, splitting
after baseline, anchor rules, and library-wide passes.
Every subcommand takes explicit file paths, so it runs from any working directory and needs no clone of the source repository. Pure standard library.
( for d in "${CLAUDE_PLUGIN_ROOT}" "${COPILOT_PLUGIN_ROOT}" .claude; do if [ -n "$d" ] && [ -f "$d/lib/ptk_run.py" ]; then exec python3 "$d/lib/ptk_run.py" skills/skillopt/scripts/skillopt.py --help; fi; done; echo "ptk_run: no plugin root holds lib/ptk_run.py" >&2; exit 2 )
( for d in "${CLAUDE_PLUGIN_ROOT}" "${COPILOT_PLUGIN_ROOT}" .claude; do if [ -n "$d" ] && [ -f "$d/lib/ptk_run.py" ]; then exec python3 "$d/lib/ptk_run.py" skills/skillopt/scripts/mine_sessions.py --help; fi; done; echo "ptk_run: no plugin root holds lib/ptk_run.py" >&2; exit 2 )
SKILLOPT_DIR="${SKILLOPT_DIR:-${COPILOT_PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-.claude}}/skills/skillopt/scripts}"
If neither COPILOT_PLUGIN_ROOT nor CLAUDE_PLUGIN_ROOT is set (for example
Codex, or a plain checkout under PowerShell), use the directory that holds
this SKILL.md. Set SKILLOPT_DIR to the scripts folder beside it:
SKILLOPT_DIR="<folder that holds this SKILL.md>/scripts"
python3 "$SKILLOPT_DIR/skillopt.py" --help
On Windows PowerShell, no Bash required:
if (-not $SkillOptDir) {
$Root = if ($env:COPILOT_PLUGIN_ROOT) { $env:COPILOT_PLUGIN_ROOT } else { $env:CLAUDE_PLUGIN_ROOT }
if (-not $Root) { throw 'Set COPILOT_PLUGIN_ROOT or CLAUDE_PLUGIN_ROOT, or set $SkillOptDir to the scripts folder beside this SKILL.md' }
$SkillOptDir = Join-Path $Root 'skills\skillopt\scripts'
}
$SkillOpt = Join-Path $SkillOptDir 'skillopt.py'
py -3 $SkillOpt --help
Below, skillopt.py means that resolved path. References use $SKILLOPT_DIR
($SkillOptDir in PowerShell) for the same folder.
| Command | Exit codes |
|---|---|
skillopt.py budget, apply, score, buffer-add | 0 success, 2 usage or validation error |
skillopt.py gate, pair-gate | 0 accept, 1 reject, 2 usage or validation error |
skillopt.py efficiency-gate | 0 ACCEPT_EFFICIENCY, 1 reject, 2 usage or validation error |
skillopt.py report | 0 report printed, 2 usage or validation error. Never gates |
skillopt.py run | 0 results written, 1 results written with a task UNVERIFIED, 2 refused or invalid (no results written) |
skillopt.py hash PATH... | 0 digests printed; a directory hashes as one whole bundle |
skillopt.py hash PATH --expect SHA | 0 match, 1 MISMATCH, 2 usage or validation error |
skillopt.py buffer-check | 0 KNOWN-BAD (discard), 1 NOVEL (proceed), 2 usage or validation error |
mine_sessions.py sources, rank, tasks, collect, merge | 0 success, 2 usage or validation error |
buffer-check is inverted on purpose: exit 0 means the edit was already
rejected. Branch on the printed word or the exact code, never on &&.
Modules named _skillopt_*.py and _mine_*.py are internal helpers the
two entry scripts import. Do not call them directly.
One optimization step:
references/rollout-validity.md before the first
rollout. Split the roles first. The candidate author sees only
train tasks and their results. A separate runner, such as a fresh
subagent or another session (Precondition 4), holds the sel prompts,
verifiers, and results in every step, and reports only the verdict back.
Each runner preflights its own tasks: prompt, verifier, inputs, fixtures,
and permitted scope. Run the rollout under exactly the scope the task grants.
A rollout with the wrong artifact or a scope change is invalid, not a pass
or a fail; mark the task "status": "invalid" and replace it. Grade the
complete persisted output against every clause of the verifier. A runner's
self-check or summary is not proof. A clipped or missing answer is
"UNVERIFIED" in the results file, which the gate refuses to count.
Record {"task_id": true|false} to incumbent_results.json and hash the
incumbent: skillopt.py hash target.md. For tasks with an argv command,
skillopt.py run --eval eval.json --bundle DIR --role incumbent --out-dir results/ runs them and writes results/incumbent_results.json. It
replaces the whole file, so run it first and add your grades for tasks with
no command after it finishes. Read the security note in
references/eval-set-format.md first, because eval.json commands run any
binary on PATH. When the target is a skill directory with scripts, pass
the directory to hash and apply; it hashes as one whole bundle. When the
manifest sets
"scorer": "nondeterministic", the sel runner also reruns the
byte-identical incumbent into null_results.json now (see Before
promotion, step 2).skillopt.py budget --step T --total N prints L_t, the
cosine-decayed cap on atomic patches this step. T is 0-based, from 0 to
N-1; --step N exits 2 with out of range.patches.json. Use only train
evidence.skillopt.py buffer-check --buffer rejected.jsonl --patches patches.json. Exit 0 prints KNOWN-BAD: discard and reflect
again. Exit 1 prints NOVEL: proceed.skillopt.py apply --skill target.md --eval eval.json --patches patches.json --budget L_t --out candidate.md. The
incumbent is never written; an --out that resolves to the incumbent exits
2. Exit 2 is a usage or validation error, not a gate loss: an empty sel
split, an incumbent --out, budget overflow, a bad anchor, a protected
fence, or marker text inside a patch.candidate.md into candidate_results.json.
For a bundle, apply writes a new directory. Finish every edit to its
scripts first, then run the command tasks, then hash the final
CANDIDATE_DIR. That digest is the candidate's identity, so results from
an earlier state of the bundle would gate a different candidate. The sel
runner does the sel half. For command tasks, run
skillopt.py run --eval eval.json --bundle CANDIDATE_DIR --role candidate --out-dir results/, then add your grades for tasks with no command.skillopt.py pair-gate --eval eval.json --incumbent-results incumbent_results.json --candidate-results candidate_results.json. If you
used run --out-dir results/, pass the files under results/. For a
nondeterministic scorer, add --null-results null_results.json --incumbent-sha256 <sha> --null-sha256 <sha>; without them the gate exits
2.
ACCEPT_PARETO: at least one held-out gain, zero held-out
regressions, every held-out result a literal boolean.REJECT_UNVERIFIED first (a missing or non-boolean
result), then REJECT_NULL_CONTROL (the null run moved and no genuine
gain remains), then REJECT_CEILING (the incumbent already passes every
sel task and the candidate regresses none), then ACCEPT_PARETO or
REJECT.REJECT, REJECT_UNVERIFIED, or REJECT_NULL_CONTROL: record
it with skillopt.py buffer-add --buffer rejected.jsonl --patches patches.json --score <cand> --incumbent <best> --note "..." --step T.REJECT_CEILING: the edit lost nothing and is not bad. Do not
buffer it. No candidate can pass a gate that has no headroom, so stop the
loop and read the hint: freeze a new sel set of harder tasks that
sample the failure mode, re-score the incumbent on it, then author a
fresh candidate. Never re-gate this candidate on tasks written after it.
For a first draft whose sel tasks came from its own requirements, hand
back to skillforge.sel task and the claim is a gain declared in the frozen manifest
before authoring, run skillopt.py efficiency-gate --eval eval.json --incumbent-results incumbent_results.json --candidate-results candidate_results.json --measurements measurements.json. Read
references/eval-set-format.md (Efficiency measurements, Efficiency
gate) first. It never replaces pair-gate for a claim of better behavior.Use pair-gate as the acceptance decision. Scalar gate --candidate X --incumbent Y (exit 0 ACCEPT, exit 1 REJECT, ties reject) is only for a
single-objective experiment declared before the candidate existed. A resource
objective such as context reduction may be one sel task with
"kind": "resource", declared before candidate creation. It cannot offset a
semantic regression, because pair-gate rejects any regression.
ACCEPT_PARETO is necessary, not sufficient:
pair-gate --split train and read its
regressions. A lost training pass on a load-bearing verifier blocks
promotion. If fixing it changes the candidate, freeze a fresh sel set."scorer": "nondeterministic" in the manifest;
pair-gate on sel then exits 2 without --null-results. Rerun the
byte-identical incumbent (confirm with
skillopt.py hash target.md --expect <sha256>, exit 1 on MISMATCH) into
null_results.json, then pass --null-results null_results.json --incumbent-sha256 <sha> --null-sha256 <sha> to pair-gate, using the
digests hash printed for the incumbent and for the file the null run
used. Both are required, and a mismatch exits 2. A gain the no-op also
produced is noise; if no genuine gain remains the verdict is
REJECT_NULL_CONTROL.rejected.jsonl, and one line of evidence per task.
skillopt.py report lays out the evidence, benchmark spread, and case
signals (references/eval-set-format.md, Run report). It explains, never gates.skillopt.py hash canonical.md --expect <candidate sha256>). It must
equal the accepted candidate's hash before you check the live copy.If any step stops short, report ACCEPTED_NOT_DEPLOYED. Never call an
eval-workspace candidate installed.
Fence guidance that step edits must never touch:
<!-- SLOW_UPDATE_START -->
Durable guidance changed only by hand, at epoch boundaries.
<!-- SLOW_UPDATE_END -->
Contract: references/slow-section-convention.md.
mine_sessions.py ranks skills by usage and a weak correction signal from
local transcripts, and pulls the prompts that triggered a skill:
sources lists each supported source and whether it is available.rank, tasks --skill X, collect --out PATH, merge.--patterns patterns.json reads a session-patterns/1 handoff instead of
transcripts.Supported sources: Claude Code transcripts (~/.claude/projects/**/*.jsonl)
and the GitHub Copilot CLI session store (~/.copilot/session-store.db),
both resolved from the user's home directory on Linux, macOS, and Windows.
Any other harness is unsupported; supply a session-patterns/1 file
instead. A missing source is skipped, never an error; sources shows which
ones were found, and a run with no source at all prints a note to stderr. Session
data stays local; keep extracted prompts out of git unless the user names
another destination.
A correction nominates a candidate. It is not a gold label. Confirm the
defect in the target and in two distinct sessions before funding rollouts.
Workflow: references/cross-machine-mining.md.
Read references/description-optimization.md before you edit a description
field or claim a skill triggers better. Output-quality rollouts do not measure
activation, so score a description candidate on trigger rate instead.
When a candidate patch adds or rewrites skill prose, read
../skillforge/references/skill-content-rules.md first.
The gate needs tasks with checkable pass or fail outcomes. A style guide or
taste document with no measurable success signal has no sel split, so the
gate cannot run. Say that you are flagging, not gating, and do not invent a
score to make the gate pass.
A harness that cannot run a separate sel runner must not run skillopt at
all, not even to flag. See Precondition 4.
| Avoid | Why | Instead |
|---|---|---|
| Editing the target by hand | The gate never sees the edit | Route every edit through apply |
| Promoting on a higher aggregate score | It can hide a lost behavior | Use pair-gate |
Reflecting on sel tasks | That trains on the test set | Reflect on train only |
| Treating a correction as a defect | Corrections are weak signals | Confirm in the target and two sessions |
| Calling an accepted candidate installed | Acceptance is not deployment | Report ACCEPTED_NOT_DEPLOYED until promoted |
eval.json has a nonempty sel split frozen before the candidate.sel tasks,
and the author never saw them.sel task is exposed or invalid.apply.pair-gate returned ACCEPT_PARETO with no unverified task.ACCEPTED_NOT_DEPLOYED.pair-gate, with a test, not in prose.mine_sessions.py sources and its table
in references/cross-machine-mining.md.After each run, check this skill and its references for a reusable lesson from a user correction, failed verifier, or tool discovery. Patch the class-level guidance; do not add an incident-named reference.
references/eval-set-format.md: eval manifest, patch, and results schemas.references/description-optimization.md: trigger-rate eval for description edits.references/rollout-validity.md: preflight, grading, and audit rules for rollouts.references/target-selection.md: defect confirmation, split timing, anchors, cohorts.references/slow-section-convention.md: protected-fence contract.references/mechanism.md: the training analogy and paper citation.references/cross-machine-mining.md: session sources and the handoff.references/example-eval.json with example-incumbent-results.json and
example-candidate-results.json: a runnable pair-gate example.references/cross-machine-mining.md (opens in a new tab)references/description-optimization.md (opens in a new tab)references/eval-set-format.md (opens in a new tab)references/example-candidate-results.json (opens in a new tab)references/example-eval.json (opens in a new tab)references/example-incumbent-results.json (opens in a new tab)references/mechanism.md (opens in a new tab)references/rollout-validity.md (opens in a new tab)references/slow-section-convention.md (opens in a new tab)references/target-selection.md (opens in a new tab)scripts/_mine_handoff.py (opens in a new tab)scripts/_mine_records.py (opens in a new tab)scripts/_mine_sources.py (opens in a new tab)scripts/_skillopt_buffer.py (opens in a new tab)scripts/_skillopt_bundle.py (opens in a new tab)scripts/_skillopt_efficiency.py (opens in a new tab)scripts/_skillopt_gates.py (opens in a new tab)scripts/_skillopt_patching.py (opens in a new tab)scripts/_skillopt_report.py (opens in a new tab)scripts/_skillopt_runner.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Generated from the plugin's indexed repository (rjmurillo/ai-agents) — no native marketplace selected
npx claudepluginhub p/rjmurillo-copilot-cli-agents-src-copilot-cli104 skills in this plugin
/adr-generatorCreate comprehensive Architectural Decision Records (ADRs). Researches the destination directory to detect existing template conventions, gathers context, determines next ADR number, generates the ADR, validates completeness, and saves. Supports multiple ADR formats (MADR, Nygard, Alexandrian, project canonical). Use when documenting technical decisions, creating new ADR files, or capturing rationale so future readers can revisit a choice. Use when you say "write an ADR", "document this decision", "document these design choices", "record why we chose this", "capture the rationale", or "for future maintainers", or when creating an ADR-like markdown file under docs/decisions/, docs/adr/, docs/architecture/, architecture/decisions/, or .project-toolkit/architecture/. Do NOT use to debate or review an existing ADR (use adr-review)./adr-reviewMulti-agent debate orchestration for Architecture Decision Records. Automatically triggers on ADR create/edit/delete. Coordinates architect, critic, independent-thinker, security, analyst, and high-level-advisor agents in structured debate rounds until consensus. Use when you say "review this ADR", when an ADR is created/edited/deleted, or when reviewing, accepting, or updating a decision file under .project-toolkit/architecture/, docs/architecture/, docs/decisions/, docs/adr/, or architecture/decisions/, including intent like "review this decision record" or "check this rationale for future maintainers". Do NOT use to author a new ADR (use adr-generator)./agent-harness-referenceField reference for Claude Code and GitHub Copilot CLI hook contracts. Covers hook locations, events, matchers, payloads, decisions, exit codes, timeouts, plugin roots, and cloud limits with official URLs and versioned probes. Use for `harness contract`, `copilot cli hook behavior`, `hook payload format`, `stale plugin root`, `Errno 2 _dispatch.py`, or before changing cross-harness hooks. Do NOT use to run the porting campaign (in the ai-agents repository, use `ai-agents-portability-campaign`)./ai-agents-external-claimsVerify external, vendor, and third-party claims (numbers, attributions, structure) against authoritative primary sources before they land in a repo artifact or external deliverable. Covers stake-holding sources, round-number tells, citation-chain drift, and the walk-the-gate-or-file-conservative discipline. Use when you say `verify an external claim`, `check a vendor number`, `is this stat real`, `validate a third-party citation`. Do NOT use for running an experiment (use `ai-agents-research-methodology` in the ai-agents repository) or command-injection scanning (use `security-scan`)./analysis-provenanceIdentify code ownership before modifying validators or linters. Checks file headers for provenance indicators, reviews documentation, and determines provenance as UPSTREAM, LOCAL, VENDOR, or UNKNOWN. Prevents accidental modification of upstream tools./analyzeSystematic multi-step codebase analysis producing prioritized findings with file-line evidence. Covers architecture reviews, security assessments, and code quality evaluations through guided exploration, investigation planning, and synthesis. Use when you say "analyze this codebase", "run security assessment", "architecture review of this system", "find code smells", or "review code quality" across multiple files. Do NOT use for single-file maintainability scoring (use code-qualities-assessment) or CWE-78 injection pattern scanning (use security-scan).Other plugins' skills for the same job