Автопилот конвейера — доделать всё до конца субагентами после утверждения спеки. Pipeline autopilot — after SPEC approval, execute everything to the end with subagents. Waves of 1–3 tickets, independent review at every milestone, fix cycles ≤3 with model escalation, parallelism ≤2, stops at dangerous boundaries. Use ONLY on explicit command or phrase — «/pf-auto», «сделай на автопилоте», «сделай сам всё до конца», autopilot. Never enable silently (§8).
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Pf Auto?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/turvodnik-pf-auto)
---
name: pf-auto
description: Автопилот конвейера — доделать всё до конца субагентами после утверждения спеки. Pipeline autopilot — after SPEC approval, execute everything to the end with subagents. Waves of 1–3 tickets, independent review at every milestone, fix cycles ≤3 with model escalation, parallelism ≤2, stops at dangerous boundaries. Use ONLY on explicit command or phrase — «/pf-auto», «сделай на автопилоте», «сделай сам всё до конца», autopilot. Never enable silently (§8).
---
# pf-auto — autopilot: from approved spec to done
Always communicate with the user in the user's language (Russian in the origin system). Registry, tickets, journal and report formats stay exactly as specified.
You are the orchestrator. You do NOT execute tickets yourself: you dispatch jobs to subagents, accept short summaries, verify through independent hands, and keep the registry. Your window is the most expensive resource: full results live in tickets and files, not in the chat.
## Preconditions
- An approved SPEC.md and tickets in `.agents/runtime/tasks/`. Missing — first the regular `/pf-spec` → human's «ок» → `/pf-tickets`: the interview is not automatable, a human answers the questions.
- An explicit human command (see description). Autopilot enabled silently is a §8 violation.
## Parameters (defaults; the human may override in words at launch)
`fix_rounds = 3` · `parallel = 2` · `batch = 1–3 tickets per job` · `gate = auto` (by risk; alternatives in words: «гейт после каждого» / «гейт по вехам»).
## Cycle
1. **Waves.** Group tickets into jobs of 1–3 related ones (by `depends_on` and volume: a job ≤ half the executor's window — §13 heuristic). A dependency must be `done` before the job that needs it starts (pf-do step 1); the orchestrator may explicitly except a job onto a dependency still in `review`, but only as a decision recorded in the wave registry (step 2, with a reason) — never silently. Build the wave order; in parallel — up to `parallel` jobs, and only with no shared files. Print the wave plan as one table for transparency and continue without waiting for a reply. **Swarm ceiling**: more than 10 agents in one run — only after a pilot wave of 3 whose results were checked (the result format actually works) and a HANDOFF checkpoint (§13); 311 agents without a pilot gave 13 % completion (retro 03.09).
2. **Registry before every wave**: «задание → тикеты → субагент → статус» — in the HANDOFF (if the pf-handoff companion is installed, §13 rule) or in `.agents/runtime/autopilot-run.md` (template — `references/registry-template.md`). Update on every event: summary accepted, review verdict, fix round, dependency exception (a job started on a `review`, not yet `done`, dependency — record the reason). The registry's `session_id:` is the value from the session-start line `Сессия: <id> — это значение поля session_id в HANDOFF/реестре` already in your context — printed by pf-handoff's start hook, or by pf-workflow's own `hooks/pf-session-id.sh` when pf-handoff is not installed; copy the full id, never a placeholder: the Stop hook `wait-guard.sh` guards only a registry whose `session_id` equals this session's. No such line in your context — write `session_id: —` and say in the registry that the stop guard is off for this run.
3. **Executor** — a fresh subagent with a clean context (mechanics — Sonnet-class, integration/judgment — a senior model; state the model explicitly). Record BASE first (`git rev-parse HEAD` of the tree it starts from — for a worktree, its start commit), then launch it and rewrite the registry row at once — job + subagent id (`agentId`; PID or `council.sh` marker for an external process): after a compaction only this row links the completion notification to its job (`Milestone handoff` in pf-handoff; under 50 % of the window a short snapshot is enough). The prompt — per `references/dispatch-templates.md`: ticket paths + "work by the pf-do contract" + interfaces/decisions from earlier jobs that are not in the tickets + "full result into the tickets, reply with a summary ≤15 lines". Never paste session history into a prompt. Launch executors with `isolation: worktree` when the repository has another live session (`_tools/.agents/runtime/claims.md`) or the wave runs more than one executor: a shared tree mixes their uncommitted edits into each other's diffs (14 incidents, retro 03.09). The launch is not the end of the turn: right after dispatching, wait for the job by a **blocking** call (`TaskOutput(task_id, block=true)`, see "Waiting contract" below) — never by ending the turn.
**Role lookup** (T-117, pf-agents scaffold): before falling back to the standard `pf-executor`/`pf-reviewer` roles, check `agents/index.yaml` (`~/.claude/agents/index.yaml` when installed globally) for an entry matching the ticket's domain — present → dispatch that role's file as the executor/reviewer instead; absent → silently use the standard roles, no note needed. The registry is empty until the pf-agents distribution ships (Ф4); this is only the lookup rule ahead of it.
**Waiting contract** (I-029: three stalled autopilots — 13.08, 15.09 ×2 — each ended a turn with «Жду» while jobs were running). Delivery of a completion notification is not guaranteed over hours (15.09: lost with Monitor/subagent notifications after hours idle); short runs do resume on their own (T-109: a background Bash notification started a new turn within 1–2 s after 8 and 20 min) — the contract does not rely on it. A turn NEVER ends while the registry has a job in «запущен». Waiting is only a blocking call, and it must be the LAST tool call of the turn: `TaskOutput(task_id, block=true)` in a loop over every running subagent (one call per job, re-issue after each result until the registry has no «запущен» left), or — where `TaskOutput` is not available — a foreground `Bash` (no `run_in_background`) whose command is an `until`/`while` wait loop or a `--wait` (`until [ -f <marker> ]; do sleep 20; done`, `bash council.sh --wait <marker>`; Bash `timeout` ≤ 600 000 ms, re-issue on expiry). `Monitor` is NOT a wait: it is a background stream ("you keep working"), and the 15.09 stall was lost on exactly its kind of notification — use it for event feeds, never to wait for a job. A notification that arrives "by itself" is a confirmation, not the signal you wait for. Ending a turn with the word «Жду» / "Wait" (or any equivalent: "I'll wait", "waiting for the subagent") is forbidden explicitly — the `wait-guard.sh` Stop hook (pf-workflow `hooks/`) blocks such a turn when the registry of THIS session still has «запущен» and the turn's LAST tool call was not `TaskOutput(block=true)` / a foreground Bash wait loop (waited for A, edited the registry, ended in prose while B runs — still the stall). Backup wake-up for hour-long waits (the 15.09 scenario, not reproducible in minutes — T-109): when a wave is launched, set `CronCreate` every 20 min (`*/20 * * * *`) with the prompt «проверь реестр: есть запущенные задания без принятой сводки? — прими, продолжи волну», and remove it when the wave is finished; no `CronCreate` in the session — `/loop 20m` with the same prompt. Before a blocking question to the human (step 6) — a HANDOFF checkpoint first (§13), so that the answer lands in a session that can resume.
**Output diet** (T-116: a 1 500-case suite, a bare `git log`, an installer — each lands whole in the window, and the orchestrator re-reads all of it on every later turn). Any command whose output is expected to exceed ~200 lines — a full test run, `git log` without `-n`, an installer, a build — runs through the wrapper `bash <pf-do>/scripts/pf-run.sh -- <command>` (resolver as for codex-review.sh: `PR=$(ls ~/.claude/skills/pf-do/scripts/pf-run.sh ~/.codex/skills/pf-do/scripts/pf-run.sh ~/.gemini/skills/pf-do/scripts/pf-run.sh 2>/dev/null | head -1)`). It keeps the full output in a file (`PF_RUN_DIR`, else `<repo>/.agents/runtime/out/` — add that path to the project's `.gitignore` if it is not there yet, or step 8's clean-tree check will flag the logs) and prints only the first 10 + last 30 lines (60 on failure), up to 20 failure-looking lines (`FAIL|ERROR|Traceback|✗`) from the omitted middle, and one line `saved: <path> (<N> lines, rc=<code>)`; the exit code is the command's, so `&& …` chains and rc checks keep working. The `saved:` path goes into the wave registry next to the passed/failed counts — that is the proof; the reviewer opens the file, the chat does not carry the output. Executors get the same rule through the dispatch prompt (`PF_AUTOPILOT=1` + the script path, template 1); their «Результат» quotes `saved:` lines, not pasted output. Output under 60 lines passes through unchanged (no file, nothing to clean). Outside the autopilot the wrapper is optional.
4. **Gate** — a fresh reviewer subagent (pf-reviewer role) gets the ticket paths + the BASE..HEAD diff as a file + the acceptance criteria. It re-verifies with proofs and does not trust the executor's «Результат»; it also compares `git diff --name-only BASE..HEAD` against the ticket's own file list — anything outside it is scope creep (🟡), flagged automatically even when the extra change looks helpful (T-103, 15.09: a wandering fix quietly restored a CHANGELOG lost by T-101, noticed only by luck). `done`/«ЧИСТО» only from the reviewer's FINAL message (never from a draft report or a chat verdict); remove the reviewer's worktree only after `task-notification finished` (T-119, 17.09: `done` was committed on a draft while a 412-test run was still going). Clean → tickets `done` (§9 authority), registry, next wave. Review reports — one convention: `<проект>/.agents/runtime/reviews/T-###-<роль>-<дата>.md` (a spec-level audit: `<slug>` instead of `T-###`); to the chat — a summary ≤15 lines.
If a wave edited a rules/skill file, its dispatch template orders the gate's own probe subagent to `Read` the file explicitly and quote a line that THIS session's edit CHANGED — a probe's system-prompt snapshot may predate the edit, so a "pass" without that order proves nothing; a quote of any other line is not proof (T-043; gate T-071 caught a probe quoting an untouched line).
**When to place gates (`gate = auto`)** — by risk, not mechanically:
- *after every job* — when jobs build on each other or touch executables: code, configs, data schemas, scripts, infrastructure. An error here sinks into the foundation of the following jobs, and a late find costs a multiple of a reviewer;
- *one gate per milestone* (a group of jobs) — when jobs are independent and a fix is cheap: texts, documentation, separate pages/articles, markup. The reviewer gets all the milestone's diffs at once.
- **Always mandatory, regardless of mode**: a gate before a job that depends on the group's results; a gate before any external action; the final end-to-end review (step 7).
- Write the chosen mode and the reason into the registry in one line — the retro will show whether you guessed right.
- **Evals smoke before EVERY gate invocation** (SPEC-plugin-evals p. 1, 6; T-146; same check as pf-do step 5b — run HERE by the orchestrator, not per-executor; executors skip it under `PF_AUTOPILOT=1` for exactly this reason, so it is never billed twice against the same diff. **Not «once per wave»**: run it again before EVERY gate this wave calls — after every job in gate-after-every-job mode, before the one milestone gate in one-gate-per-milestone mode, AND after every fix round (step 5, before its scoped re-review) whose own diff still touches a trigger file below — a fix round that rewrites `pf-auto/SKILL.md` or a hook is exactly the diff this check exists for, and nothing else re-runs it if the wave-start smoke already happened). If `git diff --name-only BASE..HEAD` (or, for a fix round, the diff since the round started) touches a distribution's role file (`agents/*.md`, canon `skill-library/agents/*.md`), skill file (`skills/*/SKILL.md`, `skills/*/references/*`, canon `skill-library/skills/*/SKILL.md`, `skill-library/skills/*/references/*`), or hook (`hooks/*.sh`, `context-hooks/*.sh`, canon `skill-library/hooks/*.sh`) — first make sure `repos/<plugin>` reflects the diff under review (sync the dev clone if canon was edited and the clone is stale; a green run against a stale clone is not proof — the plugin under eval is `repos/<plugin>`, not canon), then run `EV="${PF_TOOLS:-$HOME/ai/_tools}/skill-library/tests/evals.sh"; if [ -f "$EV" ]; then bash "$EV" smoke <plugin> <tag-args>; else echo "evals smoke: unavailable — $EV не найден (PF_TOOLS?)"; fi` — one run per touched plugin, `<tag-args>` built as in pf-do step 5b (a role/skill file → `--tag <its name>`, repeatable for several files in one run; a hook with a documented owning skill → that skill's tag, e.g. `hooks/wait-guard.sh` → `--tag pf-auto`; a hook with no documented owner — pf-handoff's `hooks/*.sh` today — → no `--tag`, the plugin's whole smoke set, never a guessed tag from the hook's own basename) — before the reviewer subagent for that gate is launched. Write the result into the registry column «маркер препасса» next to the Codex marker, as `evals smoke: N/M` (rc 0, a real pass), `skip` (no diff in the globs above, or rc 0's «пропущен — нет кейсов» line), `partial` (rc 2 with `evals: partial run — reason: <partialReason>` — `interrupted` re-runs once, `cost_ceiling` does NOT auto-retry (records `partial` and asks the human before spending more), `auth_failed` needs the credential fixed first; never relabelled `unavailable`), or `unavailable` (no script at the resolved path, or rc 1's `недоступен на этом аккаунте` message — quote it). A refused invocation (rc 2 `--tag '' (empty tag)` / `is outside … — not trusted`) or rc 1 `unknown plugin`/a bad option is a broken command, not `partial`/`unavailable` — fix it and re-run before proceeding. rc 1 with an actual case below threshold is a red smoke — the wave stops like a red test, the gate does not run until it is green.
- **Codex pre-pass before the gate (code milestones only) — detached.** Bash tool calls share no shell state: spell the recorded sha out as text (registry, «BASE волны N»). Run yourself, before spending a reviewer subagent: `PF_AUTO_BASE="${PF_AUTO_BASE:-}"; if [ -z "$PF_AUTO_BASE" ]; then echo "no BASE recorded for this wave — put the wave BASE sha (registry, step 2) into PF_AUTO_BASE= at the start of this line"; else SC=$(ls ~/.claude/skills/pf-do/scripts/codex-review.sh ~/.codex/skills/pf-do/scripts/codex-review.sh ~/.gemini/skills/pf-do/scripts/codex-review.sh 2>/dev/null | head -1); if [ -n "$SC" ]; then bash "$SC" --async --base "$PF_AUTO_BASE" --deep; else echo "no script — skip this step"; fi; fi`. It answers at once: `PENDING: <marker>` — write the marker into the registry column «маркер препасса» and launch the reviewer subagent in parallel; or `SKIP:` (no Codex, no consent, docs-only diff) — the normal path, proceed to the gate unchanged. Before the verdict read it (a later Bash call — re-run the resolver, `$SC` does not survive): `SC=$(ls … | head -1); bash "$SC" --wait <marker> --timeout 500` (Bash tool `timeout` ≥ 520 000 ms — the default 120 s kills the wait). `OK:` — findings go to the reviewer as an extra checklist, not as a verdict. `FAIL:` = not reviewed — record it in the registry and proceed. `FAIL: wait timeout` = not finished yet — re-run `--wait`, at most 3 times; still no `<marker>.done` after that (or a timeout on a marker path that does not exist) = the run was killed: not reviewed — record it in the registry and start `--async` once more; a second failure goes into the report as «препасс не состоялся» and the gate runs on the reviewer alone. `PENDING:` alone is a scheduled review, not a review. It never replaces the gate: Codex judges the diff, not the acceptance criteria.
5. **Fix cycle ≤ `fix_rounds`**: rounds 1–2 — the same executor, remarks verbatim; round 3 — a fresh executor on a stronger model ("the previous one tried twice — here is its report and the open remarks"). Track rounds explicitly: the wave registry's `fix_rounds` column starts at 0 and increments by one on every round; round 3 without a clean gate is not a fourth attempt — `blocked` is mandatory, and the registry gets a line «fuse tripped: T-###» (I-026: the safety fuse never once fired in the 8-fix-round wave of 15.09, because the round count lived only as words in this file, with no counter anywhere to trip it). After each round — evals smoke first if the round's own diff touches a role/skill/hook file (step 4's «before EVERY gate invocation» bullet — a fix round is one such gate), THEN the scoped re-review strictly against the remark list. The full test suite runs once per wave: the executor of the wave's last job runs it before the wave's gate, after every job of the wave is merged, and writes the passed/failed counts into its «Результат»; the orchestrator copies them into the wave registry. A fix round re-runs only the subset the remarks touch (`pytest --lf` or named tests). Failure after round 3 → tickets `blocked`, this branch of waves halts; independent branches continue; the report goes into the final report (or immediately if everything is halted).
6. **Stops** — the autopilot halts and asks the human:
- a question only a human can decide (batch them up unless the current wave is blocked);
- **a ticket needs a secret** (API key, password, token): subagents and headless runs usually cannot call `ai-secret`. Do not push such tickets through the fix cycle — straight to `blocked` with «нужна интерактивная сессия, scope <имя>» and into the report to the human. Visible in advance — pull them out of the waves at planning time;
- a ticket contradicts the SPEC → a mini-report in the pf-replan spirit (impact class, options);
- an external irreversible action — publishing to a live site, deploy, mailing, DNS changes, spending money: prepare everything and stop. Commit and push to the private repo are allowed (pf-do rule);
- orchestrator window thresholds (§13): at 40% — a short HANDOFF checkpoint; at 60% — start no new waves, accept the current ones, full handoff; at 75% — final handoff and a stop-point report.
The HANDOFF checkpoint before a blocking question is already covered above (step 3, "Waiting contract" — T-110): do not duplicate it here. While a question sits with the human, independent branches with no dependency on the blocked one keep running; further human-decision questions accumulate rather than triggering a second stop. No keep-alive for the reply itself: do not poll or ping just to keep the session "warm" while waiting on the human (unlike the `CronCreate`/`/loop` backup wake-up in step 3, which exists only to resume a stalled JOB wait, not to babysit a pending human answer) — the checkpoint already makes the answer land in a session that can resume normally.
7. **Final**. On an L task, first two pf-reviewer modes (named as in the role file): **Blind acceptance (G4)** — a fresh reviewer gets the requirement in the human's own wording (SPEC goal / the human's verbatim command) plus the result, not the tickets and not «Результат», answers `closed` / `not closed`; then **Consistency auditor** — SPEC vs tickets vs `AGENTS.md`, as a subagent, full report to the reviews file, ≤15 lines back. Only then the end-to-end review of the whole task diff against the SPEC — a fresh subagent on the strongest available model. Remarks → ONE fix pass (one subagent with the whole list, not a fixer-per-remark) + one scoped re-review. Leftovers: non-critical — park in the report with a "why acceptable" verdict; critical — `blocked` to the human. Clean → final report to the human: done / proofs / deviations / parked / statistics (waves, subagents, fix rounds — the maximum rounds reached and how many times the fuse tripped). Journal entry (§10).
8. **Hygiene between waves**: after accepting summaries check `git status` — the tree must be clean. `council.sh`'s own artefacts (`.claude/worktrees/`, `.agents/runtime/council-ledger.tsv`, `.agents/runtime/council/`) do not count: the launcher lists them in the repository's local `.git/info/exclude` (no commit to the project), so they do not show up; anything else that does is a tail to clear. An executor stopped by a blocker must commit its work (pf-do step 4); an uncommitted "tail" breaks the diffs of subsequent gates and is lost on session change.
## Without a subagent tool
Codex, Antigravity, Grok CLI and other platforms with no subagent tool run the same cycle; only the launcher changes. In Claude Code jobs stay subagents (the Agent tool) — except a role the human named on another agent («проверь через Antigravity Gemini») or its fallback: that role runs through `council.sh run` below. `<CS>` below = `pf-do/scripts/council.sh` (resolver as for `codex-review.sh`); its header is the full reference.
- **Before the first wave** — `bash <CS> check` (spends nothing; it rewrites `available` in `council.json` — commit it with the status edits, so the wave starts and merges from a clean tree). Copy every `недоступен: <agent> (<reason>)` line into the registry. The wave goes on with the agents that are available: an unusable primary is replaced by `roles.<role>.fallback` (`запасная: <agent>/<model> (<reason>)` → registry). No usable agent for a role (primary and fallback both unavailable) → stop and ask the human (step 6).
- **Models in words.** The human's phrase («исполнитель Sonnet, ревьюер Opus 5.5; если нет — Codex», «проверь через Antigravity Gemini») becomes `roles.{executor,reviewer}.{primary,fallback}.{agent,model}` in `.agents/council.json`; write the translation into the registry as one line (`модели: executor claude/sonnet → codex/<m>; reviewer claude/opus`). The executor writes only with `"delegate": true` there — it is the human's consent, never set it yourself. Executor `claude` with `delegate`: read the warning in pf-do («Scripts») first.
- **Executor** — `bash <CS> run --task <ticket> --role executor --async` from the project root (template: `references/dispatch-templates.md`, 1a). It works in its own worktree `<repo>/.claude/worktrees/<id>` (branch `<id>`), under the delegate guards, and is told not to commit: after it exits 0 the launcher commits the worktree itself (`commit: <sha> <T-id>: <title> (council run <agent>/<model>)`). Before it, in this order: `.git/config`, `.git/hooks`, the worktree's `.git`, `commondir` and `gitdir`, plus the scan's ledger `.agents/security/false-positives.yaml` and `.gitignore` in the worktree, are compared with their state before the run — first, before any `git` command; then no commit of the agent's own and no edit of `.agents/security/false-positives.yaml`; then the canon's secret scan (`security/repo-hooks/pre-commit`) on the worktree's index. Any of them fails → `FAIL`, nothing committed, no fallback on that tree. The repository's hooks are off for this commit and a merge commit runs no pre-commit — that explicit scan is the only one before the base branch. A `FAIL … changed git control files … or the scan's ledger / .gitignore` is an autopilot stop: run no `git` in this repository until a human has checked them. Registry id = the `PENDING: <marker>`; wait for it by the Waiting contract (step 3): a foreground `bash <CS> --wait <marker> --timeout 590` as the last tool call, re-issued until a result line arrives.
- **Statuses are yours.** The agent never writes the ticket; the launcher appends its final message to «Результат» (executor) or «Ревью» (reviewer). So: `in_progress` + owner before the executor run, `review` after its `OK:` with the `commit:` line (any `FAIL` — `blocked` with the report, or a fix round), `done` after the reviewer's `APPROVE`; `RETURN` is a fix round (step 5). Commit each status edit by path.
- **Gate** — `bash <CS> run --task <ticket> --role reviewer --worktree <the executor's worktree> --async` (template 2a): read-only, and a reviewer that moved a file is `FAIL`. The verdict is the first line under `## Verdict` in «Ревью». Codex pre-pass, evals smoke and all gate rules of step 4 stay.
- **Merge** after a clean gate: `git merge --no-edit <id>` into the base branch — a merge commit, not a fast-forward: your status commits moved the base since the worktree was cut — then remove the worktree (step 8 hygiene).
- **Unchanged**: waves of 1–3 tickets, independent review, fix rounds ≤ `fix_rounds` with model escalation (round 3 — `--agent/--model` of a stronger model), stops at dangerous boundaries, registry in the HANDOFF, the Waiting contract (in Claude Code — `wait-guard`).
## Forbidden
- Executing or fixing tickets with the orchestrator's hands: the context is for coordination, and fixes bypassing review are a quality hole.
- Setting `done` without independent verification; skipping mandatory gates (before a dependent job, before an external action, the final one) — «гейт по вехам» does not cancel them.
- Continuing the fix cycle past the limit; silently dropping remarks (only parking with a verdict in the report).
- Running jobs with shared files in parallel.
- Taking external irreversible actions without asking the human.