/lastlight:lastlight-evals-loopfrom Last Light
Iteratively improves a Last Light EVAL (pr-review) score by mining failures, proposing candidate fixes, and validating on a blind held-out split to prevent overfitting.
Ships in Last Light. 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.
A loop that raises an eval score without gaming it. The trap: the loop can see both the gold answer and the agent's answer for every case, so it could overfit — hardcode a repo's finding into a prompt, or edit a gold answer to force a pass. That lifts the number and ruins the reviewer. Every guardrail here exists to force generic, cross-cutting changes that would help on repos the loop has never seen.
Scope: the pr-review tier (its judge trace gives you the agent-vs-gold detail diagnosis needs). The pattern extends to triage/code-fix, but start here.
The method — weakness-mine → propose a few minimal candidates → keep the one that survives a blind held-out gate — follows Self-Harness: Harnesses That Improve Themselves (arXiv:2606.09498), adapted to keep our anti-gaming discipline. See references/approach.md for the mapping.
lastlight-evals first if you don't have one. Confirm a
bare lastlight-evals run pr-review --limit 1 --no-open grades a case.instance/ overlay (the deployment overlay) to receive generic edits —
see lastlight-overlay. The loop edits copies here, never core.scripts/mine-failures.ts (ranks
the TRAIN failure signatures into an evidence bundle — the diagnosis input) and
scripts/diff-runs.ts (compares two runs and calls keep/revert).One change kept per round. A round may explore a few minimal candidates,
but at most one is ever kept and committed to instance/ — the rest are reverted.
So which edit moved the number is always attributable, and no overfit edit rides
along with a good one. Never keep two edits from one round without re-measuring
each in isolation.
| You have… | Go to |
|---|---|
| Never run this loop on this dataset | §1 Set up the split then §2 |
| A split + baseline already recorded | §3 Diagnose (mine failures) |
| Candidate change(s) ready to test | §5 Audit → §6 Apply → §7 Measure → §8 Decide |
Split the tier's instance_ids into TRAIN (you diagnose on these — traces
visible) and HELD-OUT (blind — you NEVER read their traces; only their
aggregate F1 gates a keep). ~70/30, deterministic (sort ids, take the first 70%
as train). Record both lists at the top of the journal (§9) — they must stay
fixed across the whole loop, or the held-out gate means nothing.
# list the ids (jq over instances.json), then split deterministically
lastlight-evals run pr-review --instance <all-ids> --no-open # or omit --instance for the whole tier
Set a target: an F1 goal (e.g. 0.55) or "improve until plateau" (N=3 consecutive no-keep rounds).
Run both splits and record avgFbeta for each in the journal. Use the cheapest
adequate model while iterating on prompts; switch to the real target model only to
confirm a kept change.
lastlight-evals run pr-review --overlay instance --instance <train-ids> --no-open
lastlight-evals run pr-review --overlay instance --instance <heldout-ids> --no-open
Each writes eval-results/pr-review/<runId>/scorecard.json. Note the two runIds.
Mine the TRAIN scorecard into a ranked evidence bundle — recall-loss and precision-loss signatures ordered by impact — instead of reading traces by hand:
npx tsx scripts/mine-failures.ts <train-scorecard.json> --train <train-ids> --keywords
It reads only the TRAIN split (never held-out) and prints two ranked blocks:
falseNegatives, weighted by severity): the
real issues the agent missed. Biggest F1 headroom is at the top.falsePositives): findings that matched no gold.Each signature is axis·severity·area with a frequency, case count, example ids,
and (with --keywords) a heuristic category guess. Take the top systematic
pattern — not a one-off — and name it: "misses security-relevant findings",
"posts style nits the rubric says to suppress", "confidence bar too low →
noise", "no awareness of the repo's conventions → wrong-fit findings". See
references/levers.md for how each pattern maps to an edit. (You can still open
individual TRAIN review.traces to read a signature's underlying findings — just
never a held-out trace.)
For the top signature, draft K = 2–4 candidate edits, each minimal (touches
only what the pattern needs) and each targeting a different mechanism or a
different formulation of the same one — e.g. one tightens the severity bar in the
code-review skill, another adds a confidence gate in the reviewer prompt. K stays
small on purpose: selecting the best of many candidates optimistically inflates the
train number, so keep the field narrow and let the held-out gate (§7b) be the check.
Drafting one candidate is fine — best-of-K is an option, not an obligation.
Every candidate uses the lowest lever that could move the cluster (full detail in references/levers.md):
instance/repo-context/AGENTS.md injected into every repo. Must be general.datasets/pr-review/context/<id>/AGENTS.md
the harness injects only for that repo — the portable "add this to your repo"
finding. Human approves before writing.review_gold[] ONLY when the
gold is demonstrably wrong/incomplete; name the evidence. Human approves.Escalate a candidate only when a lower lever genuinely can't address the pattern, and write down why.
Before measuring, run the generality + leak auditor sub-agent (prompt template in references/guardrails.md) on every candidate. It REJECTS if the change:
instance_id / file path (lever a must be generic), orRejected candidates are dropped (not counted); survivors go to §6. If none survive, back to §4.
Apply each surviving candidate on its own throwaway branch (or stash between candidates) so their §7a measurements don't cross-contaminate — only the winner is committed in §8.
repo-context/AGENTS.md): apply automatically to
instance/… once the auditor passes.The blind held-out set must be consumed once per round, not once per candidate — gating every candidate on held-out and keeping the best would inflate it (max-of-K selection bias). So split measurement in two:
7a. Rank candidates on TRAIN only. Run each survivor on the TRAIN split and diff
without --heldout (the verdict prints REVIEW — no held-out, expected here):
npx tsx scripts/diff-runs.ts <baseline-train.json> <candidate-train.json> --train <train-ids>
Pick one winner: highest train Δ → tie-break lowest lever → smallest diff → fewest per-case train regressions. Do not touch held-out in 7a.
7b. Confirm the winner on HELD-OUT, once. Run the winner on both splits and diff with the full gate:
npx tsx scripts/diff-runs.ts <baseline.json> <winner.json> \
--train <train-ids> --heldout <heldout-ids>
(Run the two splits in one --instance <all-ids> run so a single scorecard holds
both.) If a candidate may legitimately be held-out-driven with flat train, add
--symmetric for the paper's non-regressive gate (KEEP iff neither split regresses
and one improves); record which gate you used. With a single candidate, 7a and 7b
collapse into one gated run.
git checkout
the overlay file, or remove the sidecar. Exactly one edit (or none) survives the
round — that is the "one change kept per round" rule.Append one entry per round (schema in references/journal-format.md): the mined pattern, the K candidates with each one's train Δ, which won, the winner's single held-out Δ, the decision, and the running best. Then return to §3. Stop at the target or the plateau (N=3 consecutive no-keep rounds).
Run the loop on a cadence with the built-in /loop if you want it to keep going
unattended between your check-ins — but the lever-(b)/(c) sign-off stops still
apply.
The target F1 is reached or the loop plateaus, the journal records every
hypothesis and its train/held-out deltas, kept changes live in instance/ (and,
with sign-off, per-repo context/ sidecars), and no change was kept that
regressed the blind held-out set. Report: baseline → final F1 (train and
held-out), the kept changes, any per-repo recommendations, and anything that
needed human sign-off.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
lastlight, evals, improvement-loop, pr-review, overfitting-prevention
npx claudepluginhub nearform/lastlight --plugin lastlight7 skills in this plugin
/lastlight-clientInstall the `lastlight` CLI and connect it as a CLIENT to an existing Last Light server — log in, save the token, and verify the connection. Use when the user wants to "connect / point my lastlight CLI at a server", "log in to Last Light", "set up the lastlight client", or run lastlight commands against a remote instance. For standing up the server itself use lastlight-server; for editing a deployment's config use lastlight-overlay./lastlight-debugDebug a running Last Light instance over its admin API with the `lastlight` CLI — no SSH. Use when the user wants to "look at / debug a failed or stuck workflow", "why didn't the bot do X", "check a bad agent run / phase error on <instance>", "tail a session", "search the logs", "read the server/docker logs", "list/trigger a cron", "resolve an approval", or "check stats/cost" against a deployed server. Needs a CLI already connected (see lastlight-client to log in). For standing up the server use lastlight-server; for editing config/workflows use lastlight-overlay./lastlight-evalsScaffold, configure and run a Last Light EVALS workspace — the harness that runs Last Light's real workflows against a mocked GitHub and grades them deterministically. Use when the user wants to "set up / scaffold Last Light Evals", "create an evals workspace or instance", "run evals", "compare models", or author new eval cases — including "create an eval dataset/case from this PR/issue <github url>" and "create a PR-review eval dataset from these gold PRs" (triage / code-fix / pr-review instances, via `add-case --pr <url> --review|--code-fix` / `--issue`). GitHub is mocked when running, so no real GitHub token is needed — only a model provider API key (the one exception is `add-case`, which reads real PRs/issues via `gh`)./lastlight-guideOrientation & router for the Last Light skills. Use ONLY when the user has NOT named a concrete Last Light task — i.e. they're unsure which skill/flow they need, ask "what can Last Light do / where do I start", say "help me with Last Light" with no specific goal, or want a guided tour across server / client / overlay / debug / evals. Do NOT use when the ask already names a task — "set up/deploy a server" → lastlight-server, "connect/log in my CLI" → lastlight-client, "customize a workflow/prompt/persona/config" → lastlight-overlay, "debug a failed/stuck workflow or run on an instance" → lastlight-debug, "run evals / compare models / author a case / build a PR-review dataset" → lastlight-evals, "iteratively improve an eval toward a target score" → lastlight-evals-loop: invoke that skill directly. This skill only routes and, when the goal is ambiguous, asks. Also invocable as /lastlight-guide./lastlight-overlayCreate or customize a Last Light deployment OVERLAY (the private instance/ repo) — scaffold it, then fork built-in workflows, prompts, skills, or the agent persona (agent-context) so a deployment can override them. Use when the user wants to "create a Last Light overlay / instance repo", "customize / fork a workflow", "override a prompt or skill", "change the agent's persona/soul/rules", or tune a deployment's config without forking the whole codebase. For first-time server install use lastlight-server./lastlight-serverInstall and configure a Last Light SERVER — the GitHub maintenance agent plus its docker-compose stack — on a host. Use when the user wants to "set up / install / deploy / stand up a Last Light server or instance", configure its GitHub App, models, managed repos, or domain, or get the agent running for the first time. Drives the `lastlight` CLI; for connecting an existing CLI to a server use lastlight-client instead, and for editing a running deployment's config use lastlight-overlay.Other plugins' skills for the same job