pi-lens: Skill for Claude Code

.claude/skills/merge-train/SKILL.md

merge-train is a skill for Claude Code from apmantza/pi-lens. It costs 57 tokens per session (9,121 once invoked), scanned A, original, MIT.

A procedure for processing open pull requests, which are proposed code changes, through review, fixes, verification, and merging. It uses pi-lens review rules and requires checks to run on the exact version being merged.

In plain words
What is it for?
Use it to land pull requests, process a review backlog, or manage a merge queue. It coordinates adversarial reviews, sends findings to fixers, rechecks fixes, and gates merging on review and test results.
Why use it?
It prevents unreviewed or weakly verified changes from entering the main codebase. It also handles repeated fix rounds while keeping the same reviewer responsible for verification.

Skill for Claude Code

Written for Claude Code: SubagentStop hook event. Also seen: reads .claude/ paths; mentions AGENTS.md.

This is apmantza/pi-lens's own configuration. It tells Claude Code how to work on pi-lens itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything pi-lens configures →

Reuse

Borrowing it

Nothing to install: this file belongs to apmantza/pi-lens. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/apmantza/pi-lens/master/.claude/skills/merge-train/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/apmantza/pi-lens

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for merge-train

README.md
[![agentmods](https://agentmods.dev/badge/skills/apmantza/pi-lens/merge-train/github.svg)](https://agentmods.dev/skills/apmantza/pi-lens/merge-train)
Your own site
<a href="https://agentmods.dev/skills/apmantza/pi-lens/merge-train"><img src="https://agentmods.dev/badge/skills/apmantza/pi-lens/merge-train/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for merge-train

Your own site · 80×15
<a href="https://agentmods.dev/skills/apmantza/pi-lens/merge-train"><img src="https://agentmods.dev/badge/skills/apmantza/pi-lens/merge-train.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 57 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 9,121 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 2 findings, up to high

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • high Privilege Escalation · line 95
    Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
    Fix: Remove references to credential paths. Use environment variables or secrets managers. For docs, use placeholder paths (e.g., /path/to/config). Never load .env or token files in production code paths.
  • medium Data Exfiltration · line 94
    Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
    Fix: Verify the destination URL is trusted and necessary. Remove or replace with documented APIs. Ensure no secrets, tokens, or PII are transmitted.
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00057 $0.09121
Opus 5 $0.00028 $0.04561
Sonnet 5 $0.00011 $0.01824
Haiku 4.5 $0.00006 $0.00912

Measured yesterday against content hash da10a9e08016, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

merge-train scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/merge-train/SKILL.md · 453 lines

How it starts

The opening of the file, as written. The whole thing — 453 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Merge train

Source of truth for every rule below is AGENTS.md ("Role contracts for delegated work" → "Orchestrator rules", plus the defect catalog). This file is the procedure and the record; on any conflict AGENTS.md wins.

The policy that landed the 2026-08-17 arc (11 PRs, every one adversarially reviewed, zero unreviewed merges). Apply it to each PR in the queue.

The loop, per PR

  1. Review. Spawn pi-lens-reviewer (worktree isolation) with the PR number, a one-paragraph summary of the claim, and any PR-specific attack angles. Self-authored and small PRs get reviewed too — the depth follows the review tier below, never the priority label.
  2. Fix rounds. Send findings back to the PR's original author agent when its worktree survives (SendMessage — cheapest context); otherwise spawn pi-lens-fixer on the branch with the findings inlined. Since #2486, SubagentStop REAPS the stopped agent's own worktree (maintainer decision, 2026-09-02, reversing the earlier "never removes here" rule, which left ten stale trees in one afternoon). So by default an agent's tree is gone the moment it finishes, and SendMessage to it lands on a branch with no checkout. Its branch survives — a tree is never removed unless its HEAD is already in an origin/* ref — so nothing committed is lost and a fresh pi-lens-fixer on the branch always works. If this session intends to resume fixers by SendMessage, export PILENS_HYGIENE_KEEP_AGENT_TREES=1 for the session (or add --keep-agent-tree to the registered hook) and the reap is off. Kept trees are then reaped by the SessionStart sweep — which runs on startup and resume only, not on /clear, compaction or a fork — once they have been idle ≥30m and are clean and pushed. Idle is measured from the checkout directory and the worktree's HEAD (and its reflog), never from the git index, so the sweep's own dirty check cannot make a finished tree look busy. A tree with uncommitted work, or with work not yet on an origin/* ref, is never removed at any age, by any sweep — so a fix round in flight is safe by its own state, not by the clock.
  3. Verify. The SAME reviewer verifies each fix round with its own probes. Do not take the fixer's word; do not swap reviewers mid-PR. A reviewer's worktree is an agent-* tree too, so once its report lands the tree is clean+pushed and SubagentStop reaps it exactly like a fixer's — a SendMessage resume finds no checkout, same as above. Recreate it: the merge-train practice is a FRESH reviewer worktree per VERIFY round, not a kept one. Continuity is the reviewer AGENT (SendMessage still reaches the same identity, so the same judgment and probes carry over); the checkout under it is expected to be rebuilt each round, not preserved. Do not set --keep-agent-tree / PILENS_HYGIENE_KEEP_AGENT_TREES=1 merely to dodge this — that decision stays off by default (see step 2).
  4. Merge gate. Merge only when: verdict is merge-ready; every gating check genuinely EXECUTED and passed on the exact head SHA (node scripts/ci-verdict.mjs <pr-number|sha> — a DIRTY PR silently skips them, absent is not green); every failing check was read and judged (infra failures — codeload 429/503, SARIF-upload errors, Initialize-CodeQL outages — may be waved through only with the log read and the judgment recorded).
  5. Merge. gh pr merge <N> --merge (merge commit, repo convention). If "not up to date", gh api -X PUT .../pulls/<N>/update-branch, wait for CI, re-gate, merge. On GitHub 503s: retry with backoff, never switch to raw-API merge endpoints. Alternative, once the verdict is in: apply the train:approved label (add train:squash for a squash merge) and let the merge-train lane workflow land it (#2185). The lane merges only when both required checks have CONCLUDED success on the exact current head, so a fix round pushed after labeling re-gates itself. Removing the label aborts. Steps 1 through 4 are unchanged: only the maintainer applies the label, and only after the review verdict.
  6. After each merge. Master moved: check other open PRs for BEHIND/DIRTY, check in-flight agents for file overlap with the merged diff and nudge affected ones to merge origin/master before their next push. Then prune the lane — and ONLY the lane: the merged-ness test is "this tree's branch is the head of the PR just merged" (gh pr view <n> --json headRefName), never merge-base --is-ancestor: a live fixer's branch with no commits yet passes the ancestor test, and on 2026-09-06 that removed #2358's tree with its uncommitted work. git worktree remove every tree on the merged branch (fixer AND reviewer trees, wherever they were created) and delete the merged local branch. A lane's tree lives until its PR merges, not after — the orchestrator owns this step; the reaper only sees .claude/worktrees/agent-*, and on 2026-09-06 twenty-one merged trees were still standing at the regroup.

Read the full file on GitHub · 453 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday Changed · +22 lines da10a9e08016
  2. 2d ago Changed · +106 lines 4659201563cb
  3. 4d ago Changed · +77 lines ed65b5b2a43c
  4. 5d ago Changed · +81 lines 025816830ed8
  5. 8d ago Changed · +109 lines 8705ae140904
  6. 13d ago First seen · 58 lines · 57 tokens per session scan A c72693bd7c2b

Subscribe to this mod's changes

merge-train is a skill published in the GitHub repository apmantza/pi-lens (405 stars, last pushed today), licensed MIT. It adds 57 tokens to every session and 9,121 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

github-automation

GitHub workflow automation, PR management, issue tracking, and code review coordination. Integrates with GitHub Actions and repository management. Use when: PR creation, code review, issue management, release automation, workflow setup. Skip when: local-only changes, non-GitHub repositories.

ruvnet/ruflo · 61 tokens

github

GitHub via gh CLI: PRs, issues, reviews, repos, auth.

NousResearch/hermes-agent · 19 tokens

github

Full GitHub CLI control — issues, PRs, code reviews, repo management. Uses gh CLI with auth detection, rate limiting, and templates. Triggers on: github, issue, pull request, PR, code review, repo, branch, label, assignee, milestone, release, workflow, actions.

adolfousier/opencrabs · 0 tokens

release

Release gentle-pi through GitHub and npm. Trigger: release, publish, npm publish, GitHub release, version bump.

Gentleman-Programming/gentle-pi · 28 tokens

release-pr-review

Review pass on an open release PR (release/ → main) — the step between git-wrapup and release-and-publish when a project releases in gated release PR mode. Reads the PR's commit range through the code-simplifier lens plus a correctness review, verifies whatever an automated reviewer left on the PR, lands fixes as…

cyanheads/obsidian-mcp-server · 139 tokens

pre-publish-review

Nuclear-grade 12-agent pre-publish release gate. Runs /get-unpublished-changes to detect all changes since last npm release, spawns up to 10 ultrabrain agents for deep per-change analysis, invokes /review-work (orchestrator manual QA plus one gate reviewer) for holistic review, and 1 oracle for overall release…

code-yeongyu/oh-my-openagent · 161 tokens