Skip to content
Skills Library
DevOps & cloud · Analysis

optimize-build-and-cache

/optimize-build-and-cache

Diagnose and fix a slow build by measuring the task graph and cache-hit rate, auditing cache CORRECTNESS (input-hash completeness, hermeticity leaks) before any speed tuning, then applying the highest-leverage fix (affected-only, remote cache, parallelism, splitting the long pole). Reach for this when the user says 'the build is slow' or 'is remote caching worth it / even correct?'. Used by `build-systems-architect` (primary).

Repository
ravenclaude ↗
Licence
MIT
Last repository change
27.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 27.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Diagnose and fix a slow build by measuring the task graph and cache-hit rate, auditing cache CORRECTNESS (input-hash completeness, hermeticity leaks) before any speed tuning, then applying the highest-leverage fix (affected-only, remote cache, parallelism, splitting the long pole). Reach for this when the user says 'the build is slow' or 'is remote caching worth it / even correct?'. Used by `build-systems-architect` (primary).

Triggers from the description

the build is slowis remote caching worth it / even correct?
Original author description

Diagnose and fix a slow build by measuring the task graph and cache-hit rate, auditing cache CORRECTNESS (input-hash completeness, hermeticity leaks) before any speed tuning, then applying the highest-leverage fix (affected-only, remote cache, parallelism, splitting the long pole). Reach for this when the user says 'the build is slow' or 'is remote caching worth it / even correct?'. Used by `build-systems-architect` (primary).

How it works

  1. Procedure
  2. Worked example
  3. Guardrails
Original SKILL.md headings · 51 lines, 643 words
SKILL.md preview
---
name: optimize-build-and-cache
description: "Diagnose and fix a slow build by measuring the task graph and cache-hit rate, auditing cache CORRECTNESS (input-hash completeness, hermeticity leaks) before any speed tuning, then applying the highest-leverage fix (affected-only, remote cache, parallelism, splitting the long pole). Reach for this when the user says 'the build is slow' or 'is remote caching worth it / even correct?'. Used by `build-systems-architect` (primary)."
---

# Skill: optimize-build-and-cache

> **Invoked by:** `build-systems-architect` (primary). Also consulted by `monorepo-engineer` when validating a graph/cache it just wired.
>
> **When to invoke:** "our build/CI is slow"; "is remote caching worth it?"; "is our cache correct?"; "why didn't this rebuild / why did everything rebuild?".
>
> **Output:** a measured diagnosis (task graph + cache-hit rate + the long pole), a cache-correctness verdict *before* any speed work, then the single highest-leverage fix with its expected payoff.

## Procedure

1. **Measure, don't guess.** Capture the baseline before touching anything (see the measurement playbook in [`../../knowledge/build-caching-and-performance.md`](../../knowledge/build-caching-and-performance.md)):
   - total build/CI wall-clock and the **per-task timing** (find the long pole — it's rarely "the whole build"),
   - **cache-hit rate** (local and remote, cold vs warm),
   - **affected-graph size** for a typical PR (how much *should* rebuild vs how much does).
2. **Validate the task graph.** Confirm the graph's edges match reality. A missing edge → a dependent silently doesn't rebuild (correctness bug); a spurious edge → over-rebuilding (perf bug). Fix the graph before anything downstream — caching and affected-only both derive from it.
3. **Audit cache CORRECTNESS before cache SPEED.** This gate is non-negotiable. Check:
   - **input-hash completeness** — does the cache key include every input that affects output (source, deps, tool version, config, env that matters)? Missing inputs → stale-cache-returns-wrong-artifact.
   - **hermeticity leaks** — timestamps, absolute/machine paths, network fetches mid-build, unpinned tool versions, locale. Each is a non-determinism that poisons cache trust.
   - A cache that can return a wrong artifact is **worse than no cache** — fix correctness first or disable the cache.
4. **Pick the single highest-leverage fix** against the measured long pole, cheapest-first:
   - **affected/since-only** builds (stop rebuilding untouched packages) — usually the biggest early win,
   - **local caching** of cacheable tasks (correct keys first),
   - **parallelism** across independent graph branches,
   - **remote caching** (share artifacts across CI runs + devs) — only after correctness passes; weigh CI-minutes saved vs backend cost/operational surface,
   - **split / re-architect the long pole** task if it's un-cacheable by nature.
5. **Re-measure and report the delta** — payoff vs the baseline from step 1. Name the seam: `devops-cicd` owns hosting the remote-cache backend and the runner config; this skill owns the build-tool configuration.

## Worked example

> User: "We turned on Turborepo remote caching but builds are still slow and sometimes ship stale output."

- **Stale output is a red flag — stop and audit correctness (step 3) before any speed work.** Likely an incomplete cache key: e.g. an env var or a generated file that affects output isn't in the hashed inputs, so a changed input reuses a stale artifact.
- Fix: bring the missing input into the hash (e.g. declare the env/global dep in `turbo.json` `globalDependencies` / task `inputs`), or eliminate the non-determinism.
- Only then chase speed: measure per-task timing, confirm affected-only is on, check remote cache-hit rate cold vs warm.

```text
Step 1 baseline: CI 25m; cache-hit 30% warm; long pole = `build` of pkg-core (8m, on every run)
Step 2 graph: pkg-core has no inbound edge from its config file → cache never invalidates correctly
Step 3 correctness: FAIL — `inputs` omits codegen output; stale artifact reused → fix keys first
Step 4 fix (post-correctness): affected-only + correct keys → only pkg-core's dependents rebuild
Re-measure: CI 25m → 9m warm; cache-hit 30% → 85%
Seam: devops-cicd hosts the remote cache backend; we own turbo.json inputs/pipeline
```

## Guardrails
- **Never tune speed before correctness.** A stale/wrong cached artifact is the worst failure mode here (house opinion #2).
- Don't prescribe a fix without the baseline measurement — the long pole is rarely where intuition points (house opinion #1).
- Fix the task graph before trusting affected-only or cache invalidation (house opinion #4).
- Remote caching is an economics + operational decision, not a default — do the CI-minutes-vs-cost arithmetic. See [`../../knowledge/build-caching-and-performance.md`](../../knowledge/build-caching-and-performance.md).

Versions

The database has no other skills named optimize-build-and-cache.

Database snapshot: 13.11.2026 · package version f005d444a96e (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100build-optimization
    Makes builds fast and reproducible through incremental and hermetic builds, remote or shared caching, dependency caching, and parallelism, without trading correctness for speed. Use this whenever the user complains builds are slow, asks about build caching or cache keys, wants…
  • 91turborepo
    Turborepo monorepo build system guidance. Triggers on: turbo.json, task pipelines, dependsOn, caching, remote cache, the "turbo" CLI, --filter, --affected, CI optimization, environment variables, internal packages, monorepo structure/best practices, and boundaries. Use when…
  • 100dev-build-optimization
    Use to diagnose or improve build speed, cache behavior, bundle size, packaging output, and monorepo task execution.
  • 91turborepo
    Turborepo monorepo build system guidance. Triggers on: turbo.json, task pipelines, dependsOn, caching, remote cache, the "turbo" CLI, --filter, --affected, CI optimization, environment variables, internal packages, monorepo structure/best practices, and boundaries. Use when…
  • 100optimize-pipeline
    Optimize Harness CI/CD pipeline performance via MCP. Configure parallel test execution with Test Intelligence, design multi-layer caching strategies, analyze pipeline bottlenecks with stage-level timing breakdowns, optimize cache hit rates, and design monorepo CI pipelines with…
  • 100xmake-build-cache
    Use when configuring or debugging xmake's local build cache (built-in, replaces ccache) or the remote compile cache service (shared across machines via `xmake service --ccache`). Covers enabling/disabling, fallbacks to external ccache, remote cache server/client setup, and cache cleaning.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.