Task Caching
Task caching lets qp skip re-running stable command tasks when inputs have not changed.
Enable Caching
Caching is per-task and opt-in.
Simple on/off
tasks:
test:
desc: Run unit tests
cmd: go test ./...
cache: trueContent-aware caching
tasks:
build:
desc: Build CLI binary
cmd: go build ./cmd/qp
cache:
enabled: true
paths:
- go.mod
- go.sum
- cmd/**/*.go
- internal/**/*.goWith paths, qp hashes matching file contents as part of the cache key.
What A Cache Key Includes
For cache-enabled command tasks, the key includes:
- task configuration
- resolved command
- parameter values
- effective env overlays
- working directory
- selected profile
- optional content hash from
cache.paths
Hit/Miss Behavior
qp build
# first run: executes command, writes cache result
qp build
# second run: cache hit, returns cached resultCached results preserve structured fields used by --json.
Upstream Freshness Invalidation
If a dependency ran fresh in the current invocation, dependent cached tasks also run fresh.
tasks:
lint:
desc: Lint code
cmd: golangci-lint run
cache: true
build:
desc: Build after lint
needs: [lint]
cmd: go build ./cmd/qp
cache: trueWhen lint executes freshly, build does not reuse stale downstream cache from before that new run.
Disable Cache For One Run
qp build --no-cache
qp guard ci --no-cacheUseful for:
- debugging flaky behavior
- verifying environment-sensitive steps
- forcing full CI-like execution locally
Inspect And Clean Cache
qp cache status
qp cache status --json
qp cache clean
qp cache clean --json
qp cache clean --all--all also removes guard cache state (.qp/last-guard.json) in addition to task cache files.
Practical Strategy
- Start by caching expensive, deterministic command tasks.
- Add
cache.pathsfor language/package inputs. - Keep environment-dependent deploy/publish tasks uncached.
- Use
--no-cachein debugging and release confidence checks.
Next Step
For transient failures and resilient retries around unstable commands, continue to Retry Policies.