mocking-stubbing
Skill85 starsChanged 6 months agoApache-2.0View on GitHub
Use this skill at Step 9 of the v2 SOP to run the change's tests against the stage-isolated synthetic mock data produced at Step 5. Handles fixture loading, mock service stand-up (DB / external APIs / LLM endpoints), runs the test pyramid (unit + integration + e2e where applicable), and produces a test result report. On failure, hand off to systematic-debugging. Chinese trigger examples: "mock 测试", "Step 9", "跑测试用 mock", "联调 mock", "存根服务测试". Do NOT use to test against production data, do NOT use without verified mock fingerprints. Success = all tests green against stage mock, test result XML produced, no real service contacted.
In this repository24 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- ask-questions-if-underspecifiedSkill
- audit-snapshot-microSkill
- audit-snapshotSkill
- compliance-precheckSkill
- compliance-reviewSkill
- memory-curateSkill
- openspec-apply-changeSkill
- openspec-continue-changeSkill
- openspec-new-changeSkill
- openspec-verify-changeSkill
- phi-desensitizeSkill
- prd-authorSkill
- prd-implementation-precheckSkill
- prd-precheckSkill
- prdSkill
- prompt-injection-scanSkill
- quick-fixSkill
- requesting-code-reviewSkill
- systematic-debuggingSkill
- task-decompositionSkill
- tdd-alignmentSkill
- test-data-generationSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 41
No real service contacted during Step 9: If a test "needs prod", the test is wrong.
- Distinctive: line 49
Run test pyramid: unit → integration → e2e.
- Very specific: line 51
If green → emit TEST_REPORT.md + hand off to Step 10.
- Very specific: line 52
If red → hand off to systematic-debugging.
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Mocking Stubbing
The "tests must pass against synthetic data" gate.
Mock layers
| Layer | What's mocked | How |
| DB | All persistence | sqlite-in-memory or testcontainers + synthetic fixtures |
| External APIs | Hospital HIS / 3rd party | responses library / wiremock |
| LLM | Model calls | deterministic stub via mcp-model-router test mode |
| Time | clocks | freezegun / fake clock |
| Storage | Object store | localstack / minio |
Discipline
- No real service contacted during Step 9. If a test "needs prod", the test is wrong.
- No real PHI in fixtures (enforced upstream by
test-data-generation). - Deterministic — LLM stubs return canned responses; flaky tests are bugs.
Workflow
- Load fixtures from
mock/阶段N-*/. - Stand up mock services (script:
scripts/test/up_mocks.sh). - Run test pyramid: unit → integration → e2e.
- Collect results as JUnit XML.
- If green → emit TEST_REPORT.md + hand off to Step 10.
- If red → hand off to
systematic-debugging.
Common failure modes
- "Just this once" real call — test reaches real LLM. Mitigation: hooks block production endpoints in test env.
- Flaky LLM stub — random response in stub. Mitigation: deterministic by seed.
- Fixture drift — fixtures stale vs schema. Mitigation: schema-driven generation.
- Mock leak — test uses real env var. Mitigation: explicit env clear before each test.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

