/performance:protect [<counter or claim>]from performance
Creates a CI-enforced ceiling on a performance counter after /performance:verify reports MET. Prevents regression by failing the build if the counter increases, and proposes a lower ceiling via PR for human approval.
Ships in performance. 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.
Arguments. [<counter or claim>]. e.g. /performance:protect the 4-to-1 spawn reduction
Answers "what keeps this win from eroding?"
Nothing asserts a new cost, so the next change that adds it back passes every test. A checked-in counter ceiling, checked in CI, makes that change fail the build.
Run it once, after /performance:verify reports MET on a counter. For a change shipped behind
a flag, run it only after the field read that verify's Next routes to shows the gain; if the read
shows no gain, turn the flag off instead. It proposes files; a human approves them. It never
merges, and no model runs in CI: the check is a script and a number.
Read ${CLAUDE_PLUGIN_ROOT}/reference/techniques.md#g-protect-the-win
for the technique entries this skill applies.
ratchet.py add measures twice by default and refuses a counter
whose runs disagree (${CLAUDE_PLUGIN_ROOT}/reference/harness-integrity.md rule 1). --runs N
sets the run count, at least 1. Fix what varies before ratcheting.--runs. A copy of ratchet.py from before plugin 0.5.0 exits 2
on it. Re-copy ratchet.py, ab.sh and summarize.py from ${CLAUDE_PLUGIN_ROOT}/scripts/
before using the new flags.Check whether /toolchain:ratchet is among the available skills in this session.
.performance/ratchets.json with
${CLAUDE_PLUGIN_ROOT}/scripts/ratchet.py. Nothing here needs the toolchain plugin.Propose .performance/ratchets.json, created by
python3 ${CLAUDE_PLUGIN_ROOT}/scripts/ratchet.py add --name <n> --field <f> --goal <g> --command <cmd>
from the repository root:
{"counters": [{"name": "guard-spawns", "command": "<shell command>", "field": "spawns",
"ceiling": 6, "goal": "<the verified goal this protects>. Correlation: unproven: <reason>"}]}
command runs through the shell from the repository root and prints a <field>=<number> token.--goal names the verified goal and ends with the goal's Correlation value, copied as
Correlation: <pointer> or Correlation: unproven: <reason>.spawn-census.sh exits 0 whatever the subject did and prints
rc=<n>, so append | grep -F ' rc=0 '.ratchet.py (one stdlib file) into the
repository, for example .performance/ratchet.py, unless the repository already carries it.A count that lives in a telemetry store (spans, events, a log) is measured by a command that
flushes, queries, and prints the token itself; ratchet.py only runs the command and parses stdout.
{"name": "tool-calls", "field": "calls", "ceiling": 12,
"goal": "<the verified goal this protects>. Correlation: <pointer>",
"command": "id=$(uuidgen); RUN_ID=$id ./run-subject.sh && ./flush-exporter.sh && ./count-run.sh $id"}
count-run.sh is
the counter's query step: it checks for a completion record the subject emits for that id and
exits non-zero without it, so lost telemetry fails the command instead of reading as 0. With the
record present it prints calls=<n>, and calls=0 is valid, since a zero ceiling is legitimate.
The subject's own failure must also fail the command.add and propose-tighten measure twice by default, and --runs tunes the count. A read taken
before the flush sees a partial count: the runs disagree and add refuses, or all read partial
values, agree, and set a ceiling that is too low.check exits 2 when the command fails, and a runner with no telemetry
store fails it. Either the CI job stands up the store and exporter so the command is
self-contained, or the counter is re-expressed as a count the command prints directly. Otherwise
leave it out of the required ratchet.ratchet.py takes no telemetry dependency.ratchet.py check exits 0 at or below every ceiling, 1 when a counter is above its ceiling
(naming it), and 2 when it could not measure. Any CI that runs a command and reads its exit status
can host it. GitHub Actions:
- name: Check performance counter ceilings
run: python3 .performance/ratchet.py check --file .performance/ratchets.json
Put the step inside the check the repository already requires for merge. A ratchet outside the required check reports red and blocks nothing.
When a counter drops, the ceiling drops with it, or the next regression can climb back to the old
ceiling unnoticed. check prints propose-tighten can lower it whenever a counter sits below its
ceiling; propose-tighten --write records the lower value and never raises one.
The proposed workflow file is the setting: keep it to tighten on a schedule, delete it to tighten by hand.
on:
schedule:
- cron: "17 6 * * 1"
workflow_dispatch:
permissions: {}
jobs:
measure:
runs-on: ubuntu-24.04
permissions:
contents: read
outputs:
ceilings: ${{ steps.tighten.outputs.ceilings }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- id: tighten
run: |
python3 .performance/ratchet.py propose-tighten --write
git diff --quiet -- .performance/ratchets.json && exit 0
echo "ceilings=$(jq -c . .performance/ratchets.json)" >> "$GITHUB_OUTPUT"
open-pr:
needs: measure
if: needs.measure.outputs.ceilings != ''
runs-on: ubuntu-24.04
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- env:
GH_TOKEN: ${{ github.token }}
CEILINGS: ${{ needs.measure.outputs.ceilings }}
run: |
jq . <<<"$CEILINGS" > .performance/ratchets.json
git switch -c "ratchet/tighten-$GITHUB_RUN_ID"
git -c user.name="github-actions[bot]" \
-c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
commit -am "perf: lower counter ceilings"
git push origin HEAD
gh pr create --draft --fill
The counter commands run in measure, which holds a read-only token and no stored git credentials,
because a counter can exercise third-party code; only open-pr, which runs no counter, can write.
A workflow's GITHUB_TOKEN can open that PR only when the repository setting "Allow GitHub Actions
to create and approve pull requests" is on, and it is off by default for a new personal-account
repository; the PR's opened event then creates workflow runs in an approval-required state, so a
human approves the checks as well as the merge. To have the checks start without that approval,
open the PR with a GitHub App installation token or a personal access token stored as a secret
instead of GITHUB_TOKEN. Verified 2026-09-24 against
https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository,
https://docs.github.com/en/actions/concepts/security/github_token, and
https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/trigger-a-workflow.
Recheck when any of them stops naming that setting or changes what a GITHUB_TOKEN-created pull
request event triggers.
A ratchet guards a count, not correctness. Guardrails scale with how brittle the optimization is:
Propose these beside the ratchet. The ratchet alone passes a subject that got cheaper by breaking.
goal.Counter: <name> = <measured> (<field>), deterministic across <runs> runs
Ceiling: <value> in <ceilings file>, written by <toolchain:ratchet | protect §2-§4>
Protects: <goal>. Correlation: <goal's value>
CI step: <workflow file and job> Required check: <name>
Tighten: same-PR | scheduled draft PR (<workflow file>)
Guardrails proposed: <tests, or none needed and why>
Awaiting: human approval of the files above
/performance:snapshot captures and /performance:verify proves it;
this protects a result already MET./toolchain:ratchet/source-control:pull-requestWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub melodic-software/claude-code-plugins --plugin performance7 skills in this plugin
/climbPurposeKeep-or-revert loop on a frozen harness: one hypothesis and one commit per attempt, both arms re-measured every time, kept by a rule written before the first attempt, logged outside the tree, in its own worktree and branch. Use when: 'keep trying changes until this counter drops', 'hill-climb this benchmark', 'iterate on this until the target is met', 'run an optimization loop'. After /performance:snapshot baseline, before /performance:verify. Skip when: the score comes from an eval set for an LLM app (`/claude-api hillclimb`); one before-and-after comparison (`/performance:snapshot`)./goalPurposePerformance goal the data can settle: metric, command, realistic and ideal targets, and the floor computed before any work, surfacing 'your target is below the measured floor, no code change can reach it' up front. Human-gated, never unattended. Use when: 'set a performance target', 'is this target achievable', 'define done for this optimization', 'what is the floor here'. After /performance:target, before /performance:snapshot./go-fasterPurposeBackground sweep of the whole AI-assisted development process (this session's work, git, hooks, the rest of the setup) for ways to go faster without losing accuracy, returning evidenced findings ranked by measured size and speedups to adopt now; edits no repository file or setting. Use when: 'go faster', 'how can we go faster', 'speed up this session', 'what is slowing us down', 'whole-process speed sweep'. Skip: ranking candidates already in hand is /performance:target.Other plugins' skills for the same job