Agent Skillswarp-drive-data/warp-drive › mock-cache-checkin

mock-cache-checkin

GitHub

确保使用Holodeck mock server的测试变更时,将生成的.mock-cache fixtures正确暂存和提交。防止因遗漏fixtures导致CI回放失败,保证测试依赖完整性。

.claude/skills/mock-cache-checkin/SKILL.md warp-drive-data/warp-drive

Trigger Scenarios

修改或新增使用了@warp-drive/holodeck的测试文件 准备提交代码或创建PR前检查git状态

Install

npx skills add warp-drive-data/warp-drive --skill mock-cache-checkin -g -y
More Options

Non-standard path

npx skills add https://github.com/warp-drive-data/warp-drive/tree/main/.claude/skills/mock-cache-checkin -g -y

Use without installing

npx skills use warp-drive-data/warp-drive@mock-cache-checkin

指定 Agent (Claude Code)

npx skills add warp-drive-data/warp-drive --skill mock-cache-checkin -a claude-code -g -y

安装 repo 全部 skill

npx skills add warp-drive-data/warp-drive --all -g -y

预览 repo 内 skill

npx skills add warp-drive-data/warp-drive --list

SKILL.md

Frontmatter
{
    "name": "mock-cache-checkin",
    "description": "Ensures `.mock-cache` fixture directories under `tests\/*` are staged and committed whenever a change adds or modifies a test that uses `@warp-drive\/holodeck`'s mock server (`GET`\/`POST`\/`PUT`\/`PATCH`\/`DELETE`\/`HEAD`\/`mock()`). Use before finalizing any commit or opening a PR in this repo, especially from a worktree or agent session where it's easy to stage only the files a task explicitly touched — local test runs silently regenerate these fixtures and it's easy to leave them out of the changeset.",
    "user-invocable": false
}

Holodeck mock-cache check-in

Why this matters

@warp-drive/holodeck records real HTTP request/response fixtures to disk under tests/*/.mock-cache/<testId>/... (hash-named directories, .body.br + .meta.json files) and replays them on later runs instead of re-generating the response live. It looks like a build artifact or local scratch cache — it is not. Per packages/holodeck/server/utils.js:

the .mock-cache directory should be checked-in to the codebase

Locally, recording is the default behavior, not something you opt into. See warp-drive-packages/build-config/src/-private/utils/get-env.ts:

const SHOULD_RECORD = Boolean(!CI || IS_RECORDING);

Whenever CI isn't set in the environment (any normal local run, including one driven by an agent), every GET/POST/PUT/PATCH/DELETE/HEAD/mock() call from @warp-drive/holodeck writes a fresh fixture into .mock-cache instead of validating against one that's already there — silently, with no warning. CI runs in replay-only mode: if a test's fixture was never committed, CI fails with "No meta was found for ... You may need to record a mock for this request" — but only later, in whatever environment first enforces replay.

What to do before finalizing a commit or PR

  1. Run git status and look for new or modified paths under **/.mock-cache/.
  2. If the change added or modified a test that touches the mock server, its fixture(s) under .mock-cache must be staged and committed alongside the test — they're as much a part of the change as the test file itself, not build output to ignore.
  3. Don't reflexively exclude .mock-cache paths because they look like generated/cache content, and don't assume "not part of what I was asked to change" applies to them the way it would to an actual build artifact.
  4. If unrelated .mock-cache entries appear just from running the existing suite (not tied to anything the current change touched), that's pre-existing drift, not something to fold into an unrelated PR — leave those alone and mention it rather than committing fixture noise.

Verifying a fixture actually satisfies replay

Running tests without CI set will always "pass" locally even for a brand-new fixture, because it just recorded what it needed rather than replaying and validating. To actually exercise replay mode before pushing:

CI=1 pnpm test

If a needed fixture is missing, this is what surfaces it — the same way CI will.

Version History

  • 5c1296a Current 2026-08-27 16:30

Same Skill Collection

.claude/skills/ast-grep-codemods/SKILL.md
.claude/skills/ast-grep/SKILL.md

Metadata

Files
0
Version
53ee613
Hash
d2ccb022
Indexed
2026-08-27 16:30

Accueil - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-28 22:05
浙ICP备14020137号-1 $Carte des visiteurs$