We raised $3M for agent-native runners

Unnecessary work

Remove work that a change does not need. Explore techniques for scoping workflows, avoiding duplicate runs, and cancelling obsolete work.

Where to start

Diagnose first: does the workflow run twice for one commit, run on unchanged paths, or repeat already verified work?

Before making a job faster, check whether it needs to run. Use changed files, dependency relationships, and run state to identify avoidable work. Keep required checks reporting and preserve the release and deployment paths that still need a complete run.

18 techniques with source-backed company examples.

CI technique

Cancel superseded pull request runs

Free runner capacity by canceling validation that a newer commit has replaced. Keep required main-branch and release runs intact.

How it works

Group validation runs by the pull request or branch they validate. When a newer commit starts another run in that group, cancel the older validation. Scope the cancellation rule to work that the new run replaces; deployment, release and migration workflows need their own completion rules.

Cancel superseded runs, never on main

Anthropic's Python and TypeScript SDKs added a workflow concurrency group keyed on the branch, so a newer push cancels the older run. On main the group is keyed on the commit, so main runs never cancel each other.

Use it when
Developers or agents push to the same branch several times while CI is still running.
Before applying it
Deploy, publish and migration workflows keep running to completion; only runs whose result a newer commit replaces are cancelled.

Cancel obsolete runs using the correct event identity

Mastra added workflow concurrency and cancellation to lint, docs and workspace workflows. Related changes handled workflow_run identity and separated comment-driven approval updates from PR updates.

Use it when
Repeated pushes leave obsolete verification jobs occupying runners.
Before applying it
Key the group on workflow plus the logical PR or ref, with safe fallbacks, so a new commit cancels the old run. Keep release and destructive side-effect jobs out of indiscriminate cancellation.

Cancel superseded pull request runs

Stripe iOS added a concurrency group to its dead-code workflow, keyed by pull request number, with cancel-in-progress so a new push stops the previous scan.

Use it when
Superseded pull request runs keep consuming runners.
Before applying it
Scope cancellation to replaceable pull request validation. Releases, deployments, migrations and default-branch runs that must finish keep cancel-in-progress off.

Cancel superseded pull request runs

Base Web added a concurrency group keyed on the workflow and pull request number to its PR Check workflow, with cancel-in-progress, so a new push stops the run it supersedes. NilAway did the same for its Golden Test workflow.

Use it when
Developers push several commits to a pull request in quick succession and each push starts a full run.
Before applying it
Key the group on the pull request so runs for different pull requests never cancel each other, and keep default-branch and release runs out of cancel-in-progress.
CI technique

Fetch only the repository history a job needs

Limit checkout depth and fetched refs to the comparisons or release history the job actually consumes.

Give each checkout only the files and history it uses

Linear capped fetch depth, removed checkout from jobs that never used a working tree, and used sparse, blobless checkouts where it diffs paths. Capping fetch depth took the slowest change-detection gate from 94 to 20 seconds; removing checkout from jobs that never needed a working tree took them from 27 to 7 seconds.

The median duration of the change-detection job fell from 26 to 8 seconds, p90 from 31 to 12 seconds, and the slowest run from 138 to 37 seconds. Source

Use it when
A job uses only GitHub API metadata or a bounded subset of the repository.
Before applying it
Resolve merge bases, local actions, hashFiles and indirect scripts first. API-only jobs need an explicit repository context; history-dependent checks must retain enough history.

Fetch only the release history the job consumes

The workspace test workflow removed fetch-depth: 0 while preserving the triggering workflow’s head SHA. Release publishing now fetches only main’s history, deepening it in batches without tags.

Release publishing deepens main’s history in batches of 50 commits, without tags. Source

Use it when
Tests consume a source tree without history-based versioning or change detection.
Before applying it
Test tags and ancestry before giving release automation a shallow checkout.

Check out only the history the job reads

Four lint and test workflows in frontier-evals switched from a full-history checkout to a single commit, and three of them stopped downloading LFS files.

Four workflows check out one commit, and the three lint workflows stopped fetching LFS files Source

Use it when
Checkout steps fetch full history or LFS files that the job never reads.
Before applying it
Jobs that compute versions, changelogs or diffs from Git history still need full history.

Fetch the comparison, not every branch

Stripe iOS replaced a fetch that could pull every branch with a shallow checkout of the PR head followed by progressively deeper fetches of only the PR and master histories until their merge base resolves.

Some jobs had spent up to 30+ minutes fetching history; in Stripe’s combined CI runs with the related changes, lint went from about 7 to about 6 minutes. Source

Use it when
Checkout dominates CI, but lint or affected-target selection needs history.
Before applying it
Change detection needs a verified comparison base. Validate the PR head, the base and the merged tree, and run the full check whenever the base is ambiguous.
CI technique

Skip jobs whose inputs have not changed

Gate expensive workflows and jobs on the files they consume, keeping required check behavior intact.

Skip workflows a change cannot affect

Translated to GitHub Actions

What Anthropic built
Anthropic runs a selected set of tests on each pull request.
Your GitHub Actions version
Path and job-level filters that keep expensive workflows to changes in the files they depend on.

Anthropic runs a selected set of tests on each pull request. In GitHub Actions, path and job-level filters keep expensive workflows to changes in the files they depend on.

Use it when
An expensive workflow runs for unrelated files, or app-specific jobs ignore the dependency graph.
Before applying it
Required checks stay reachable: a changes job with job-level conditions keeps a skipped job reporting success.
GitHub Actions adaptation
Compare the source system with your own workflow before applying this translation.

Skip whole jobs only when their inputs are unchanged

Mastra gated AGENTS and peer-dependency validation by relevant inputs and generated workspace matrices from affected packages. Job-level conditions and validated matrices sit on top of trigger-level paths filters.

Use it when
A workflow serves several independent packages or checks with distinct inputs.
Before applying it
Workflow files, shared config, dependency changes and routing-tool changes can affect every target. Keep required status reporting and treat invalid routing artifacts as full coverage.

Skip platform jobs for documentation-only changes

Checkout Kit keeps one shared filter file with per-platform filters that exclude Markdown files and docs directories, so a docs-only pull request starts none of the platform suites while workflow and filter changes still trigger validation. The same exclusions now live in .ci/changed-file-filters.yml on the default branch. Shopify CLI tried the workflow-level form and restored the tests, because they are required to merge.

Merged 2026-06-26; the exclusions are on the default branch. Source

Use it when
Documentation edits start expensive platform suites that build and test only source code.
Before applying it
A workflow skipped at the trigger never reports its required checks; filter at the job level so the checks still report.

Gate expensive checks on their real inputs

Stripe iOS decides whether SDK or build inputs changed before installing tools and running API or dead-code analysis; build configuration counts as an input even inside example or test directories. Sorbet runs its editor-extension jobs on branches only when the extension changed, and always on master. Stripe React Native skipped its end-to-end workflow for Markdown-only pull requests.

Use it when
Documentation or unrelated changes trigger an expensive, narrowly scoped check.
Before applying it
A whole-workflow path filter can leave a required check pending. An always-present gate that reports a no-work result keeps branch protection intact; include global build inputs in the scope.
CI technique

Install and build only the workspace packages a job uses

Scope dependency installation and builds to the package or lane under test, including its actual dependencies.

Install or build only the workspace packages this step needs

Linear restricted its API test install to the API package and its dependencies, which cut pnpm install from 44-73 seconds to 16-18 seconds, then applied the same filter to API-adjacent jobs. In its public SDK, the release-preparation job builds only the package schema generation imports before updating the schema.

Use it when
A job’s dependency closure is smaller than the workspace.
Before applying it
Include transitive dependencies and generated prerequisites.

Build only the dependencies the test consumes

The memory test build replaced the entire stores wildcard with libsql, pg and upstash while retaining its other required packages. Another change moved a docs-server build out of the changed-test gate.

Use it when
A narrow test job pays for unrelated workspace builds.
Before applying it
Trace transitive dependencies and generated artifacts. Before moving a build out of a gate, confirm another required check still runs it.

Give each CI lane a defined package set

The app libraries ran everything in ci.yml in sequence, once per Node version. Shopify/shopify-app-js#2777 split that into a lint job and three package-family jobs that run in parallel; each builds its own dependency closure with pnpm filters and tests only its family. The pattern match is partial: the filters scope each lane, and the speedup comes from running the lanes in parallel.

The PR reports CI running in about 5 minutes against about 11 before. Source

Use it when
A monorepo runs one long sequential job that builds and tests every package on every run.
Before applying it
A new package has to be added to a lane, and each lane repeats install and setup.
CI technique

Remove repeated build steps

Trace artifact producers and consumers so package, release, or test stages reuse work instead of triggering the same build again.

Build release artifacts after the final version change

Stable publishing removed an early build and kept one build after prerelease exit and installation. Earlier version-PR automation removed builds from the metadata-only versioning step.

Use it when
A release job builds twice around version or manifest changes.
Before applying it
Keep the build that produces published artifacts after all version changes.

Let the package lifecycle build once

Codex Security removed the explicit build steps before pnpm pack, because the package's prepack script already runs the build.

One build per packaging job, run by prepack Source

Use it when
A package lifecycle hook repeats a build in the same job.
Before applying it
Remove the explicit build only when the exact packaging command runs the hook. Disabled hooks or a changed lifecycle would ship a stale package.

Let test and lint stages reuse the build stage

Confidence's Dockerfile ran each component's test and lint stages as siblings from the same base, so each stage compiled the source on its own. The change adds a build stage per component and derives the test and lint stages from it, letting cargo, Go and Maven reuse the compiled artifacts across six components.

In a local no-cache Docker build on an Apple M1 Max, total compute across the affected stages fell 61%, from 1807s to 712s. Source

Use it when
A multi-stage Dockerfile or build compiles the same source separately for its build, test and lint stages.
Before applying it
Test and lint now wait for the build stage. Components that need a different build profile keep their own base.

Stop rebuilding just to export artifacts

After the cached Docker build and test step, every Confidence CI run ran a second docker build to export the WebAssembly artifact to the runner, then wrote a step summary listing the artifacts. The change removes both steps from the job.

Use it when
A job runs a second build only to copy outputs out or print a summary that nothing downstream reads.
Before applying it
Check that no later step, release or reviewer uses the exported files before removing the export.
CI technique

Run CI once per pull request commit

Remove overlapping push and pull request triggers so each change receives one intended validation run.

Run CI once per change

Anthropic reports more CI jobs in a given day. As a StarSling pattern for GitHub Actions, removing duplicate push and pull_request runs and metadata-only triggers keeps each change to one run.

Use it when
Run history shows duplicate events for the same commit, or metadata events rerun checks that do not depend on that metadata.
Before applying it
Preview deployments, cache warming, release side effects and metadata-dependent checks keep the triggers they need.

Run each pull-request commit once

The Ruby extension's workflow ran on every push and every pull request, so each in-repo branch got two identical runs; for one commit they started three seconds apart. Shopify/vscode-shopify-ruby#808 limits push to main and adds a concurrency group whose cancellation applies only to pull_request events, so a main run that is already running is never cancelled, though a main run still waiting in the same group is replaced by a newer push.

Merged 2026-09-18; the workflow on the default branch is unchanged since. Source

Use it when
The same commit runs equivalent validation through both push and pull_request, and developers push several times in a row.
Before applying it
Check that the two runs test the same ref with the same permissions before treating them as duplicates.

Run push builds only on the default branch

target-determinator's presubmit workflow ran on every push and on every pull request, so a commit pushed to a pull request branch in the repository ran the test matrix twice. The change restricts the push trigger to main; pull requests still run through the pull_request event.

Use it when
A workflow triggers on both push and pull_request, and the push trigger covers every branch.
Before applying it
Branches without a pull request no longer get push builds; the workflow keeps workflow_dispatch for running them by hand.
CI technique

Build only what the test or analysis consumes

Declare the build dependencies of each validation lane so unrelated targets do not join its critical path.

Build only what the analysis consumes

Stripe iOS stopped packaging XCFrameworks for the API check, which compares arm64 Swift interfaces only. Dead-code scanning builds the SDK frameworks directly and hands the fresh index to Periphery, after verifying the expected SDK roots. Stripe Android’s Financial Connections end-to-end job builds only the release variant it tests.

Use it when
A scan builds artifacts, architectures or test bundles that it never analyzes.
Before applying it
The build the analysis reads stays. Keep all analyzed symbols, required architectures, compiler settings and index completeness, and rebuild when the scheme no longer matches what the scan expects.

Build only the services each test consumes

SubmitQueue stopped building every Linux service before integration and end-to-end tests. Each test declares the cross-compiled binaries, Dockerfiles and configurations it consumes, and a minimal Docker context is staged from those inputs. OPT13 is adapted: the build stays, scoped to declared target dependencies.

The author reports all nine Docker suites and 79 unit tests passing locally, plus cached test results on a second run. Source

Use it when
A test target invokes a broad preparatory build even though it exercises only a subset of services.
Before applying it
Declare every runtime input and keep the compile-only gate. Image tags need a hash of the declared contents (the follow-up below), and test-result reuse depends on hermetic inputs and environment.

Build test dependencies in the test lane

SubmitQueue added --build_tests_only to its Bazel unit-test command and kept bazel build //... in a separate required job, so the test lane builds only the test dependency closure.

The merged Makefile narrows the unit-test build scope, and the separate build job keeps compile-only validation. Source

Use it when
A broad test command also builds non-test targets that another required job already compiles.
Before applying it
Check the build tool's exact target-selection rules, keep every discovered test, and keep compile-only targets in a required job.
CI technique

Install tools only in the jobs that need them

Keep lightweight discovery and validation jobs from paying for tools used only by other stages.

Install only what the change detector needs

Change-detection jobs disabled the workspace install and used a standalone Turbo executable. Later graph discovery installed only its root tools.

Current graph discovery uses a filtered tools install. Source

Use it when
A metadata or graph-discovery job spends more on setup than its actual decision.
Before applying it
Pin the detector version and prove its dependency discovery works without install scripts.

Install tools only where they are used

Stripe Android installed Ruby in its shared prepare step for every check. It moved the install into the screenshot and dependency-update jobs that actually run Ruby.

Ruby installation, about 2 minutes per the author, now runs only in the jobs that use Ruby. Source

Use it when
A shared setup step installs browsers, language runtimes or CLIs for every job.
Before applying it
Trace indirect script and action dependencies before moving setup, and declare every tool a job needs explicitly.
CI technique

Reject irrelevant events before allocating runners

Put event and change conditions before runner allocation so irrelevant comments or edits do not start expensive jobs.

Do not start a runner for irrelevant comments

Mastra gated the major-version job on the exact command in the new or previous comment body. This adapts the non-content-event recipe to issue_comment, preserving command removal as well as addition.

Use it when
Comment-triggered automation starts expensive checks for ordinary discussion.
Before applying it
Event matching and command parsing must agree. Preserve author authorization, edit/removal handling and fork trust, and keep permission checks separate from event filtering.

Keep metadata edits from restarting source validation

Codex Security skips its source checks on body-only PR edits, gives those events their own concurrency group, and renames the skipped aggregates. Title, base and combined edits still run full validation.

Body-only edits skip source validation in their own concurrency group Source

Use it when
Description-only edits rerun the same source checks or cancel an active run.
Before applying it
Title validators, retargets and metadata checks still need their events. A skipped run must never overwrite a failed, pending or missing required result.
CI technique

Run shared validation once

Remove overlapping task or matrix invocations that perform the same check on the same inputs.

Avoid repeating CI checks in a version bot’s commit hook

The versioning action disabled Husky because separate workflows already handled its precommit checks. This adapts the duplicate-command recipe and depends on required CI running the same checks.

Use it when
An automated version PR repeats hooks already enforced by required CI.
Before applying it
Never bypass a check merely because it is expensive. Prove equivalent file scope and failure propagation in required workflows; retain checks that only the hook performs.

Run snapshot checks once in a dedicated lane

Stripe iOS re-records snapshots in a dedicated job and skips those snapshot classes in the main unit-test jobs only when that dedicated job is part of the pipeline. Standalone framework jobs keep every test.

Use it when
Snapshot or generated-output checks run both on their own and inside a broad suite.
Before applying it
Skip a class in one lane only while a required lane runs it, and keep runtime variants and aggregate results unchanged.

Stop invoking tests twice through overlapping tasks

Stripe Android’s screenshot verification already ran the unit tests. A new dispatcher task runs screenshot verification for modules that have it and unit tests for the rest, so each module runs its tests once. Stripe .NET removed a Debug build and test pass that repeated the Release pass for an SDK with no configuration-specific code.

Use it when
A test wrapper invokes another test task that CI also calls directly, or two configurations run the same code.
Before applying it
Compare the test and screenshot inventories before and after, and keep a configuration that has its own code paths or its own published build.
CI technique

Wait until a draft is ready for expensive checks

Avoid spending runner time on expensive validation until a draft pull request becomes ready for review.

Run expensive checks when a draft becomes ready

Checkout Kit skips its change-detection job, and so every platform job behind it, while a pull request is a draft. Adding ready_for_review to the trigger types starts a full run as soon as the draft is marked ready.

Merged 2026-06-16; both lines are on the default branch. Source

Use it when
Developers push to draft pull requests many times before asking for review.
Before applying it
Without ready_for_review, a draft promoted to ready keeps its skipped result on an untested commit.

Wait until a draft is ready for expensive checks

SubmitQueue added draft guards to every CI job and its required aggregate, then added ready_for_review to the workflow events. Pushes to main and merge-queue runs keep their validation.

Drafts skip the full suite, and it runs when the pull request is marked ready for review. Source

Use it when
Drafts receive frequent exploratory commits and your team agrees that expensive checks can wait.
Before applying it
Drafts get feedback later, so agree on it as a team policy. Test draft, ready, reopened, main and merge-queue events so every required check still reports.
CI technique

Bake stable dependencies into runner images

Prepare versioned system dependencies and build downloads once in the runner image instead of installing them on every job.

Bake stable system dependencies into the CI image

Each API test shard spent 7 to 8 seconds installing the same Postgres client with apt. Linear moved it into a small CI base image with Node and the client, and later added the native build headers whose downloads could occasionally hang.

Together, the CI base image, the filtered install and dropping the node_modules cache reduced per-shard setup time by roughly 44%, from 110-140 seconds to 67-73 seconds. Source

Use it when
Multiple jobs repeat stable OS-package setup on equivalent environments.
Before applying it
Pin and rebuild the image, patch vulnerabilities and measure image-pull cost. Repository secrets and mutable build outputs do not belong in the image.
CI technique

Build before starting the emulator

Compile the app first, then boot the emulator and install the finished build.

Build before starting the emulator

Stripe React Native moved app compilation ahead of emulator startup and installed the finished APK. It also built only the emulator’s x86_64 architecture and removed a disk-cleanup step, which the author estimated at 20 seconds.

Use it when
Compilation runs while an emulator competes for the same CPU and memory.
Before applying it
Keep the device and ABI coverage other lanes require, and measure disk headroom before removing cleanup.
CI technique

Keep full history and download old blobs on demand

Change detection often needs commit history and filenames, not old file contents.

Keep full history and download old blobs on demand

Seven full-history checkouts gained filter: blob:none while retaining fetch-depth: 0. History stays complete, and old blobs download on demand.

The PR reports transfer falling from 1,572 MB to 189 MB, about 88% fewer bytes. Source

Use it when
Checkout transfer dominates jobs that compare names or trees across commits.
Before applying it
Lazy blob reads still need network access and appropriate credentials.
CI technique

Package once, and build full installers after merge

Drop the build step that packaging repeats, and build the unpacked app pull requests test.

Package once, and build full installers after merge

The desktop job ran a Build step and then packaging, which runs the same electron-vite build again. The PR removed the standalone Build step. Pull requests now package the unpacked app that the end-to-end journeys consume; pushes to main still build and inspect the full installers.

Use it when
A job builds explicitly before a packaging or test command that builds again, or pull requests build release artifacts that no test reads.
Before applying it
Read the wrapper scripts before removing a build step. The full installers still need a post-merge run that someone watches.
CI technique

Reduce the setup floor before increasing shard count

Each extra shard repeats checkout, dependencies and container setup.

Reduce the setup floor before increasing shard count

Each extra shard repeats checkout, dependencies and container setup. Before its setup work, Linear’s test job used 4 shards and spent 8.3 minutes on setup; afterward it ran 8 shards with 7.5 minutes of setup.

Use it when
More shards would repeat substantial fixed setup work.
Before applying it
Remeasure per-shard setup before changing shard count.
CI technique

Serve checkouts from pre-warmed repository clones

Keep repository clones warm on a few machines and run Git operations against them, so jobs skip the cold clone.

Serve checkouts from pre-warmed repository clones

Translated to GitHub Actions

What Uber built
Uber's GitFarm serves checkouts from pre-warmed bare clones, so clients get a full Git checkout in under 500 milliseconds.
Your GitHub Actions version
Check out from a pre-warmed repository clone or a shallow fetch, sized to what the job reads.

Cloning Uber's Go monorepo takes roughly 15 minutes and consumes around 6 CPU cores, 32 GB of memory and over 40 GB of disk. GitFarm runs standard Git commands for other services inside ephemeral sandboxes backed by pre-warmed repository checkouts. Each backend keeps one bare clone per repository, updated by push-based events with a fetch every 5 minutes behind them. Clients get a full Git checkout in under 500 milliseconds and no local clone.

Uber reports that clients get a full Git checkout in under 500 milliseconds, and services no longer suffer cold starts of 10-15 minutes due to initial clones on each host. Source

Uber reports a CODEOWNERS service's startup time going from 15-20 minutes to under 1 minute, and its CPU from over 70 cores to 16 cores, after switching to GitFarm API calls. Source

Use it when
Many jobs or services clone the same large repository, and each pays for the clone and adds load on the Git server.
Before applying it
Freshness is eventually consistent with the upstream repository, so let a caller ask for the latest state when a job needs it.
GitHub Actions adaptation
Compare the source system with your own workflow before applying this translation.
CI technique

Test supported runtimes concurrently

Give each target framework its own job that installs only what it needs.

Test supported runtimes concurrently

Stripe .NET replaced one sequential build-and-test job with per-framework matrix jobs and a native Windows .NET Framework lane. Each lane installs the latest SDK plus only its target runtime, and example builds run in their own job.

Use it when
A multi-runtime suite runs sequentially or installs every toolchain in every lane.
Before applying it
Keep every supported runtime gated, let every diagnostic matrix leg run to completion, and update branch protection for the new job names.

Company Playbooks