- All playbooks
- Caching and setup
- Cache package downloads and dependency stores
Cache package downloads and dependency stores
Restore package-manager downloads or dependency stores while keeping a locked install that validates the requested dependency graph.
How companies used this technique
Read what each company changed and follow the original sources.
Cache Go modules and build output
The first CI workflow for the project pins Go from go.mod and sets the setup action's cache input explicitly (the action caches by default in the version it uses), which restores downloaded modules and build output on later runs. Tests run with -count=1, so Go executes them every time.
- Use it when
- Go jobs download modules or rebuild unchanged packages on every run.
- Before applying it
- Key the cache on go.sum and the toolchain version, and measure restore time against a cold run on your runner.
Cache the pnpm store, in the right setup order
Linear’s SDK repository installs pnpm before setup-node and caches the pnpm store in its build, release, schema and dependency workflows, keyed on pnpm-lock.yaml.
- Use it when
- pnpm installs repeatedly download the same dependency content.
- Before applying it
- Keep the install and every check running on a cache hit; the cache shortens the download.
Cache Yarn downloads while keeping a locked install
Linear’s Zapier integration enables setup-node’s Yarn cache and installs with yarn install --frozen-lockfile, in its test job and its new release workflow.
- Use it when
- Yarn installs repeatedly fetch the same dependency content.
- Before applying it
- Point the cache at the actual lockfile, keep frozen installs, and keep untrusted runs from writing caches that privileged jobs restore.
Cache the native dependencies behind a JavaScript build
The React Native jobs already restored pnpm and Bundler caches, while the Android jobs still downloaded Gradle distributions during each run. Checkout Kit turned on the setup-java Gradle cache, keyed on the Android, React Native and sample-app Gradle and package files.
Merged 2026-05-21; the Gradle cache is on the default branch. Source
- Use it when
- Package-manager caches hit while native dependency setup stays cold.
- Before applying it
- Cache dependency stores and keep native build outputs out of the cache.
Cache Bazel downloads and build outputs
target-determinator's presubmit and release jobs now start with setup-bazel, which caches Bazelisk and downloaded Bazel versions, the external repository cache, and a disk cache for build outputs keyed per tested Bazel version. Pull request runs restore the caches without saving them, so trusted builds on main populate them.
- Use it when
- Bazel jobs download toolchains and external dependencies and rebuild every output on each run.
- Before applying it
- Restore-only pull request runs keep untrusted code from writing shared caches; a disk cache per Bazel version keeps versions apart.
Use the ecosystem’s cache integration
Stripe React Native replaced hand-maintained Gradle cache paths with gradle/actions/setup-gradle and built the Android app with --build-cache.
With full caches, the author measured new-architecture app builds at 2:34 against 8:03 and old-architecture builds at 1:42 against 3:50, across all the PR’s changes. Stripe React Native later moved these tests to another CI system in stripe/stripe-react-native#2137. Source
- Use it when
- Gradle cache maintenance is ad hoc, or builds never reuse cached task outputs.
- Before applying it
- The source PR changed caching, build flags and emulator ordering together. Measure the cache action on its own, and audit cache paths, trust scope and configuration-cache encryption.
Persist the build cache between runners
Tango added a persistent Bazel disk cache to its integration job. The same PR runs nested queries in a fresh batch-mode Bazel process and raises the outer request timeout. OPT61 is extended from dependency installs to content-addressed build outputs.
The PR reports a local pass in 81s and a successful CI integration job in 6m45s. Source
- Use it when
- Ephemeral CI jobs repeatedly rebuild the same inputs, or a persistent build process keeps stale state after a checkout changes.
- Before applying it
- Keep cache validity under the build tool's control and restrict cache writes across trust boundaries. Treat a hung build server as its own problem.
Company Playbooks
- Read Anthropic’s playbookRun only affected tests
- Read DoorDash’s playbookRun build and test in parallel, sharded across CI agents
- Read Linear’s playbookBenchmark the same job on faster hardware
- Read Mastra’s playbookStarSling runners for the slowest test workflow
- Read OpenAI’s playbookRank CI fixes by the minutes they save
- Read Ramp’s playbookMove a CPU-bound test suite to a faster CPU
- Read Shopify’s playbookLet an agent iterate against one CI metric
- Read Spotify’s playbookBuild arm64 on native arm64 runners
- Read Stripe’s playbookRun only the tests a change can reach
- Read Uber’s playbookBuild the merge-queue speculations most likely to be needed