ci-speedup
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCI Speedup
CI 加速
Find the stage where changes wait between push and deploy, fix that stage with numbers, and write down what changed and when to look again.
- IS: measuring where changes wait from push to deploy; a pipeline's critical path; check placement per lane and the required-check set; merge queue sizing or the post-merge design; main-health detection, attribution and revert; the agentic merge loop that reverts, re-lands and repairs without a human; flake policy; deploy throughput; cost per merged change; the ledger.
- IS NOT:
- one PR's red build, conflict or single rerun ()
pr-babysitter - package releases ()
autoship - which checks exist, enforcing a rule, hook wiring, protected paths, or the sandbox rules for an unattended agent job (); this skill owns the merge controller that dispatches those jobs and decides revert, merge and deploy
codebase-architecture - pruning tests ()
test-audit - reviewing a workflow diff ()
tidy - repositories with no pipeline yet (,
scaffold-cli)scaffold-nextjs - how many agents to run, or writing the repository's merge-risk policy (this skill reads that policy; it does not author it)
- one PR's red build, conflict or single rerun (
找出变更从 push 到 deploy 之间在哪个阶段等待,用数据修复该阶段,并记录改动内容以及何时再次检查。
- 属于: 测量变更从 push 到 deploy 的等待位置;pipeline 的 critical path;按 lane 安排 check 和 required-check 集合;merge queue sizing 或 post-merge 设计;main-health 检测、归因与 revert;无需人工即可 revert、re-land 和 repair 的 agentic merge loop;flake policy;deploy 吞吐量;每次 merged change 的成本;ledger。
- 不属于:
- 单个 PR 的 red build、conflict 或单次 rerun()
pr-babysitter - package releases()
autoship - 哪些 checks 存在、规则强制执行、hook wiring、protected paths,或 unattended agent job 的 sandbox 规则();此 skill 拥有 merge controller,由其 dispatch 这些 jobs,并决定 revert、merge 和 deploy
codebase-architecture - pruning tests()
test-audit - reviewing a workflow diff()
tidy - 尚无 pipeline 的 repositories(、
scaffold-cli)scaffold-nextjs - 应运行多少 agents,或撰写 repository 的 merge-risk policy(此 skill 会读取该 policy,但不会编写它)
- 单个 PR 的 red build、conflict 或单次 rerun(
The Model
模型
The objective is X = changes merged and deployed per hour, held inside three budgets and one hard limit:
| Symbol | Budget |
|---|---|
| R | main-red minutes per week |
| C | runner-minutes per merged change: PR runs × pushes, queue runs including discarded speculation, the main run, reruns, and per-push review bots |
| F | p90 time from push to a verdict the author can act on; an agent's context decays while it waits |
Irreversible damage (destructive migrations, infrastructure, leaked secrets) stays at zero whatever it costs X.
Symbols used across every file: λ = arrival rate (merges/hour); T = merge-path CI minutes; p = failure rate on the merged tree, flakes included; p_mb = merge-breakage rate given the head was green; B = batch size; D = speculation depth.
Finding the constraint. Pull per-PR timestamps for open, ready, head green, approved, enqueued, merged, main verdict and deployed. Label each stage WAIT or WORK; review and queue time are wait. The constraint is the stage with the most queued minutes per week, and Little's law (WIP = λ × lead time) checks the arithmetic. Exploit it, subordinate the other stages to it, then elevate it, and re-measure after every fix because the constraint moves. Cutting CI duration when CI is not the constraint is a cost lever, not a throughput lever.
Pipeline duration. When the pipeline is the constraint, its wall-clock is the slowest chain of dependent jobs, not their sum. A lever that saves runner minutes off that chain lowers C, not F, and the ledger records it as a cost saving.
Lanes and placement. Every check runs in one lane: author pre-push, PR gate (exact head), merge path (the merged tree, or nothing), post-merge main (coalesced runs; drives auto-revert), pre-deploy (the exact artifact) or nightly (never a merge verdict). Place each check by asking, in order: irreversible if it ships (block before merge, human tier); merge-breakable, meaning its result can change when merged with other PRs (run it on the merged tree; otherwise at the PR head only); deterministic (only these may drive auto-revert); and what it adds to T against what it catches. The classification table and the YAML are in .
references/lanes.mdThe default architecture: no merge queue. PRs merge on evidence for their exact head; main verifies itself after merge in coalesced runs, so each run is a batch; deterministic failures are bisected and reverted by code, and the re-land, conflict and flake repairs go to agents as new tasks; deploys follow the newest verified commit; humans own the high-risk tier, the kill switch and a sampled audit. This is the shape Anthropic runs at 30,000+ merges a day, and it holds at low volume too, where each batch is one commit. Never answer with "require branches up to date" or "require green main before merging": both serialise merges. Flip to a merge queue only when the red budget cannot be met, deploys cannot be limited to verified commits, breakages are mostly nondeterministic, or main cannot be reverted; the flip conditions and the queue math are in , and the GitHub implementation is in with .
references/merge-path.mdassets/github/references/github-build.md目标是在三个预算和一个硬性限制内实现 X = 每小时完成 merge 和 deploy 的变更数:
| 符号 | 预算 |
|---|---|
| R | 每周 main 处于 red 状态的分钟数 |
| C | 每次 merged change 的 runner-minutes:PR runs × pushes、包含被丢弃 speculation 的 queue runs、main run、reruns,以及每次 push 的 review bots |
| F | 从 push 到作者能够据以行动的 verdict 的 p90 时间;agent 等待期间,其 context 会衰减 |
无论为提高 X 付出多少代价,不可逆损害(破坏性迁移、基础设施变更、密钥泄漏)都必须保持为零。
所有文件中使用的符号:λ = arrival rate(merges/hour);T = merge-path CI minutes;p = merged tree 的 failure rate(含 flakes);p_mb = head 为 green 时的 merge-breakage rate;B = batch size;D = speculation depth。
寻找约束。 拉取每个 PR 在 open、ready、head green、approved、enqueued、merged、main verdict 和 deployed 各阶段的时间戳。将每个阶段标记为 WAIT 或 WORK;review 和 queue 时间属于 wait。约束是每周 queued minutes 最多的阶段,并用 Little's law(WIP = λ × lead time)校验计算。充分利用该约束,让其他阶段服从它,然后提升它;每次修复后都要重新测量,因为约束会转移。如果 CI 不是约束,缩短 CI duration 只是 cost lever,而不是 throughput lever。
Pipeline duration。 当 pipeline 是约束时,它的 wall-clock 是相互依赖 jobs 的最慢链,而不是它们的总和。如果某项 lever 从这条链上节省 runner minutes,它降低的是 C,而不是 F;ledger 会将其记录为 cost saving。
Lanes 与 placement。 每个 check 都运行在一条 lane 中:author pre-push、PR gate(exact head)、merge path(merged tree,或 nothing)、post-merge main(coalesced runs;驱动 auto-revert)、pre-deploy(exact artifact)或 nightly(绝不产生 merge verdict)。按以下顺序询问来放置每个 check:发布后是否不可逆(merge 前阻断,human tier);是否 merge-breakable,即结果可能因与其他 PRs 合并而改变(在 merged tree 上运行,否则只在 PR head 上运行);是否 deterministic(只有这些才能驱动 auto-revert);以及它对 T 的增加量与其捕获的问题之间的权衡。分类表和 YAML 位于 。
references/lanes.md默认架构:不使用 merge queue。 PRs 依据其 exact head 的 evidence 进行 merge;main 在 merge 后通过 coalesced runs 自行验证,因此每次 run 都是一个 batch;deterministic failures 由代码进行 bisect 并 revert,而 re-land、conflict 和 flake repairs 会作为新 tasks 分派给 agents;deploys 跟随最新的 verified commit;humans 负责 high-risk tier、kill switch 和 sampled audit。这是 Anthropic 每天处理 30,000+ merges 时采用的形态,在低流量下也适用,此时每个 batch 就是一个 commit。绝不要回答“require branches up to date”或“require green main before merging”:两者都会将 merges 串行化。仅当 red budget 无法满足、deploys 无法限制为仅包含 verified commits、breakages 大多是非确定性的,或 main 无法 revert 时,才切换到 merge queue;切换条件和 queue math 位于 ,GitHub implementation 位于 ,相关说明见 。
references/merge-path.mdassets/github/references/github-build.mdReference Files
参考文件
| File | Read when |
|---|---|
| Step 1, or the user asks where PRs wait: stage definitions, WAIT vs WORK, Little's law, health metrics, cost per merged change, reading |
| Pipeline duration is the constraint, or Step 5 is crediting an after-run: run, job and step timings, the three ratios, the critical path, |
| Choosing duration levers: setup, execution, toolchain and image-build levers, what each needs to be true, and the traps |
| Placing a check; editing |
| Whether a flip condition calls for a merge queue, queue sizing, a backed-up queue, ejections, conflicts, merge policy |
| Main is red, or designing detection, attribution, auto-revert or re-land |
| Designing the agentic merge system: what code decides versus what agents repair, post-merge batching, the agent task contract, the autonomy ladder, loop health, and the agent runtime (Claude in Actions, eve, Devin). Read with |
| Installing or adapting the loop on GitHub: Anthropic's design mapped to rulesets and workflows, setup order, how the controller keeps state, checkout cost, verifying an install |
| The templates |
| Building or changing any bot that writes: revert, repair, re-queue, re-land |
| Intermittent failures, retry or quarantine policy, and before batching or bisecting |
| Deploy is the constraint, or deploys trail merges |
| Step 6: the ledger, flow-metric trend, merge-path decision record, instruction-file lines |
| Step 1: per-stage median, p90 and minutes per week for merged PRs with a CONSTRAINT line; |
| Step 2, pipeline: one run's jobs, steps and critical path, or |
| Step 2, main: red episodes on main with first-bad and last-good SHAs, red minutes per week, and flake candidates |
Every script is read-only, takes (or ), and prints its forms with . holds scenarios and the with-versus-without comparison for changing this skill; it never loads during a task.
--repo owner/nameGH_REPO--helpevals/evals.json| 文件 | 阅读时机 |
|---|---|
| Step 1,或用户询问 PRs 在哪里等待:阶段定义、WAIT 与 WORK、Little's law、health metrics、每次 merged change 的成本、读取 |
| pipeline duration 是约束,或 Step 5 需要将效果归因于某次 after-run 时:run、job 和 step timings、三项比率、critical path、 |
| 选择 duration levers 时:setup、execution、toolchain 和 image-build levers,各自成立所需的前提,以及相关陷阱 |
| 放置 check 时;编辑 |
| 判断某个切换条件是否要求使用 merge queue、queue sizing、队列积压、ejections、conflicts、merge policy 时 |
| main 变红时,或设计 detection、attribution、auto-revert、re-land 时 |
| 设计 agentic merge system 时:哪些决策由代码负责、哪些问题由 agents repair、post-merge batching、agent task contract、autonomy ladder、loop health,以及 agent runtime(Claude in Actions、eve、Devin)。应与 |
| 在 GitHub 上安装或调整此 loop 时:将 Anthropic 的设计映射到 rulesets 和 workflows、setup order、controller 如何保持状态、checkout cost、安装验证 |
| |
| 构建或修改任何会执行写入的 bot 时:revert、repair、re-queue、re-land |
| 处理 intermittent failures、retry 或 quarantine policy,以及 batching 或 bisecting 之前 |
| deploy 是约束,或 deploys 落后于 merges 时 |
| Step 6:ledger、flow-metric trend、merge-path decision record、instruction-file lines |
| Step 1:已合并 PRs 各阶段的 median、p90 和每周分钟数,并输出一行 CONSTRAINT;支持 |
| Step 2 的 pipeline:一次 run 的 jobs、steps 和 critical path,或使用 |
| Step 2 的 main:main 上的 red episodes 及 first-bad 和 last-good SHAs、每周 red minutes,以及 flake candidates |
每个 script 都是只读的,接受 (或 ),并可通过 打印其用法。 保存用于变更此 skill 的 scenarios 和 with-versus-without comparison;执行 task 时不会加载它。
--repo owner/nameGH_REPO--helpevals/evals.jsonWorkflow
工作流
Copy this checklist to track progress:
text
CI speedup progress:
- [ ] Step 1: Find the constraint (per-stage WAIT and WORK minutes per week)
- [ ] Step 2: Measure the constraint stage (pipeline, merge path, main, or deploy)
- [ ] Step 3: Decide with numbers (predicted X, R, C; one option; its flip condition)
- [ ] Step 4: Change it on a branch; re-time locally; dry-run every bot
- [ ] Step 5: After-measurement from the branch's own runs or a bot replay
- [ ] Step 6: Ledger, decision record, instruction-file lines, re-measure date复制此 checklist 以跟踪进度:
text
CI speedup progress:
- [ ] Step 1: Find the constraint (per-stage WAIT and WORK minutes per week)
- [ ] Step 2: Measure the constraint stage (pipeline, merge path, main, or deploy)
- [ ] Step 3: Decide with numbers (predicted X, R, C; one option; its flip condition)
- [ ] Step 4: Change it on a branch; re-time locally; dry-run every bot
- [ ] Step 5: After-measurement from the branch's own runs or a bot replay
- [ ] Step 6: Ledger, decision record, instruction-file lines, re-measure dateStep 1: Find the constraint
Step 1:寻找约束
Run against the default branch and name the constraint in a sentence: which stage, WAIT or WORK, minutes per week, and how it compares with the next stage. A scoped ask (one suite, one job) skips to Step 2's pipeline branch. With fewer than about 20 merged PRs in the window, reason from the workflow config and the volumes the user states, and label every number a projection.
scripts/ci-flow.sh针对 default branch 运行 ,并用一句话指出 constraint:哪个阶段、WAIT 还是 WORK、每周多少分钟,以及与下一阶段相比如何。对于范围明确的请求(一个 suite、一个 job),直接进入 Step 2 的 pipeline 分支。如果窗口内 merged PRs 少于约 20 个,则根据 workflow config 和用户给出的 volumes 进行推理,并将每个数字标记为 projection。
scripts/ci-flow.shStep 2: Measure the constraint stage
Step 2:测量约束阶段
- Pipeline: for median and p90 per job, then the single-run form for the steps and the chain. Classify every minute on the critical path as toolchain, gating, setup or execution before proposing anything.
scripts/ci-timings.sh --runs 20 --workflow ci.yml - Merge path: runs give T, p and ejections; arrivals from Step 1 give λ.
merge_group - Main: gives red episodes, R, and which checks failed on the same SHA they passed on.
scripts/ci-health.sh - Deploy: deployment timings against merge times, and how many merges each deploy carries.
- Pipeline: 运行 ,获取每个 job 的 median 和 p90,再使用 single-run 形式查看 steps 和依赖链。在提出任何优化方案之前,将 critical path 上的每一分钟归类为 toolchain、gating、setup 或 execution。
scripts/ci-timings.sh --runs 20 --workflow ci.yml - Merge path: runs 可给出 T、p 和 ejections;arrivals 来自 Step 1,可得出 λ。
merge_group - Main: 可给出 red episodes、R,以及哪些 checks 在相同 SHA 上曾通过后又失败。
scripts/ci-health.sh - Deploy: 对比 deployment timings 与 merge times,并确定每次 deploy 携带多少 merges。
Step 3: Decide with numbers
Step 3:用数据决策
State the predicted change in X, R and C, one recommended option, and the measurement that would flip it. When wall-clock falls and runner minutes rise, say by roughly how much and whether the repository pays for minutes.
说明预计的 X、R、C 变化,给出一个推荐选项,以及会促使你切换方案的 measurement。当 wall-clock 降低而 runner minutes 增加时,说明大致增加多少,以及 repository 是否承担这些 minutes 的成本。
Step 4: Change it on a branch
Step 4:在 branch 上修改
Edit workflow, test and bot configuration in one branch, and re-time locally whatever can be measured without pushing. A change that makes a shard fail is a finding, not a reason to skip the shard. Dry-run every bot that writes by replaying the red episodes from Step 2 and listing what it would have reverted, repaired or re-queued. Building the merge loop: on GitHub, install by the setup order in , adapt and the setup action to the repository, prove it on a throwaway repository first, ship it at rung 0, and promote only on replay numbers.
assets/github/references/github-build.mdmerge-loop.jsonKeep the guards. Change detection, concurrency groups, merge checks and deploy gates usually exist because of a past incident; move them, never drop them, and keep the comment that cites the incident next to the guard.
在一个 branch 中编辑 workflow、test 和 bot configuration,并对所有无需 push 即可测量的内容进行本地 re-timing。导致某个 shard 失败的 change 是一个 finding,而不是跳过该 shard 的理由。通过重放 Step 2 中的 red episodes,对每个会执行写入的 bot 进行 dry-run,并列出它会 revert、repair 或 re-queue 的内容。构建 merge loop 时:在 GitHub 上,按照 中的 setup order 安装 ,根据 repository 调整 和 setup action,先在 throwaway repository 中验证,以 rung 0 发布,并且仅根据 replay 数据提升 rung。
references/github-build.mdassets/github/merge-loop.json保留 guards。Change detection、concurrency groups、merge checks 和 deploy gates 通常是因过去的事故而存在;可以移动它们,但绝不能删除,并应将引用该事故的注释保留在 guard 旁边。
Step 5: Read the after-measurement
Step 5:读取事后测量结果
The branch's own runs are the after-measurement; apply the after-run rules in before crediting a lever. When predicted and measured disagree, find out why before adding another lever. A change that waits on a repository setting the user owns gets its after-measurement on the re-measure date, and the ledger says so. Repeat Steps 2 to 5 until the constraint moves to another stage or the remaining options need a decision the user owns.
references/measuring.md该 branch 自身的 runs 就是 after-measurement;在将效果归因于某项 lever 之前,应用 中的 after-run rules。如果预测值和测量值不一致,应先找出原因,再添加另一项 lever。如果某项 change 必须等待由用户管理的 repository setting,则在 re-measure date 获取其 after-measurement,并在 ledger 中注明。重复 Steps 2 到 5,直到约束转移至其他阶段,或者剩余选项需要由用户决定。
references/measuring.mdStep 6: Ledger and decision record
Step 6:Ledger 和 decision record
Write the ledger from into the repository's docs: before, changes, after with run ids, the flow-metric trend row, the decision record with its flip conditions, the queue of options not taken with what each waits on, and the re-measure date. Add the instruction-file lines that stop the layout regressing.
references/ledger.md按照 将 ledger 写入 repository 的 docs:修改前的情况、改动内容、带 run ids 的修改后数据、flow-metric trend 行、包含 flip conditions 的 decision record、未采用选项的队列及其等待条件,以及 re-measure date。添加用于防止布局回退的 instruction-file lines。
references/ledger.mdPermissions and Done
权限与完成标准
Granted without a check-in, because each is read-only, branch-local or reversible: reads, running the scripts, local re-timing, pushing the working branch, and opening PRs, revert PRs included.
ghThe user's call, because each spends money or changes what every other change must pass:
- spending: paid runners, higher queue concurrency or speculation depth on a metered plan
- repository settings: rulesets, required checks, enabling the merge queue
- creating the GitHub App, storing its key and the model key, creating the Managed Agents agent and environment, turning on Claude Code Review, and raising above 0
MERGE_LOOP_RUNG - merging anything to main
Done means a mergeable change, after-numbers from real runs or a bot replay, a decision record with its flip conditions, and a ledger row with a re-measure date.
以下操作无需 check-in 即可执行,因为每项都是只读、branch-local 或可逆的: 读取操作、运行 scripts、本地 re-timing、pushing working branch,以及 opening PRs,包括 revert PRs。
gh以下事项必须由用户决定,因为每项都会花钱,或改变所有其他 changes 必须通过的流程:
- 产生费用:paid runners、在按用量计费的 plan 上提高 queue concurrency 或 speculation depth
- Repository settings:rulesets、required checks、启用 merge queue
- 创建 GitHub App、存储其 key 和 model key、创建 Managed Agents agent 与 environment、启用 Claude Code Review,以及将 提高到 0 以上
MERGE_LOOP_RUNG - 将任何内容 merge 到 main
完成意味着交付一项可合并的 change、来自真实 runs 或 bot replay 的事后数据、一份包含 flip conditions 的 decision record,以及一行带 re-measure date 的 ledger 记录。
Gotchas
常见陷阱
- Sharding a pipeline whose PRs go green in minutes and then wait hours for review or merge changes nothing in X. Measure open to deployed with before touching the pipeline.
ci-flow.sh - After a fix the constraint moves: re-timing only the stage just fixed reports a win while X stays flat. Re-run after every change.
ci-flow.sh - on main cancels a superseded run mid-rollout and leaves the merged commits with no verdict; on a PR it throws away your own measurement run when a later push lands. Cancel superseded runs on PRs only, and hold pushes until the measured run completes.
cancel-in-progress: true - ,
turbo runandpnpm -r runskip workspaces that lack the script, so a green root command proves nothing about them. Check the per-workspace output.lerna run - A workflow step that calls a wrapper script: editing the workflow line changes nothing, because the wrapper owns the real command. Find where the command runs before re-timing.
- 对那些 PRs 几分钟内变绿、随后却等待数小时 review 或 merge 的 pipeline 进行 sharding,对 X 毫无改变。修改 pipeline 前,先使用 测量从 open 到 deployed 的全过程。
ci-flow.sh - 修复后约束会转移:只重新测量刚修复的阶段会显示有所改善,但 X 可能保持不变。每次 change 后都重新运行 。
ci-flow.sh - 在 main 上使用 ,会在 rollout 中途取消被取代的 run,使 merged commits 没有 verdict;在 PR 上使用,则会在后续 push 落地时丢弃你自己的 measurement run。只应在 PRs 上取消被取代的 runs,并推迟 pushes,直到被测量的 run 完成。
cancel-in-progress: true - 、
turbo run和pnpm -r run会跳过缺少相应 script 的 workspaces,因此根命令显示 green 并不能证明这些 workspaces 没问题。应检查各 workspace 的输出。lerna run - 如果 workflow step 调用了 wrapper script,仅编辑 workflow 中的那一行不会产生任何效果,因为真正的 command 由 wrapper 控制。重新计时前,应先找到 command 的实际执行位置。
Related Skills
相关 Skills
- for one PR that is red, conflicted or needs a rerun, and for watching the PR this work opens.
pr-babysitter - for package releases and their CI.
autoship - for which checks should exist, enforcing a rule, hook wiring, protected paths, and the sandbox an unattended agent job runs in.
codebase-architecture - when the suite is slow because it holds tests that prove nothing; pruning is its job, timing is this one's.
test-audit - for reviewing the workflow diff this skill produces.
tidy - and
scaffold-cliwhen the repository has no pipeline yet; this skill starts from timestamps a new repository lacks.scaffold-nextjs
- :用于处理 red、conflicted 或需要 rerun 的单个 PR,以及监控本工作创建的 PR。
pr-babysitter - :用于 package releases 及其 CI。
autoship - :用于确定应存在哪些 checks、规则强制执行、hook wiring、protected paths,以及 unattended agent job 的 sandbox。
codebase-architecture - :当 suite 变慢是因为保留了毫无证明价值的 tests 时使用;pruning 是它的职责,timing 则是本 skill 的职责。
test-audit - :用于 reviewing 本 skill 生成的 workflow diff。
tidy - 和
scaffold-cli:当 repository 尚无 pipeline 时使用;本 skill 从新 repository 所缺少的 timestamps 开始工作。scaffold-nextjs