一键导入
mocking
When and how to mock (system boundaries only, DI, SDK-style APIs). Use when writing tests, reviewing mocks, or the user asks what to mock.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
When and how to mock (system boundaries only, DI, SDK-style APIs). Use when writing tests, reviewing mocks, or the user asks what to mock.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Reduz consumo de tokens e créditos no Cursor com leitura mínima de contexto. Use quando o usuário pedir para "ler só o necessário", diminuir custo, definir .cursorignore/.gitignore, limitar escopo, ou trabalhar com contexto grande.
Turn a PRD into a multi-phase implementation plan using tracer-bullet vertical slices, saved under ./prd/PRD-NNN-feature-slug/plan.md (see prd/INDEX.md). Use when user wants to break down a PRD, create an implementation plan, plan phases from a PRD, or mentions "tracer bullets".
Deep vs shallow modules (Ousterhout). Use when designing APIs, reviewing module boundaries, or when the user wants smaller interfaces with richer implementations.
Interview the user relentlessly about a plan or design until reaching shared understanding, resolving each branch of the decision tree. Use when user wants to stress-test a plan, get grilled on their design, or mentions "grill me".
Interface design for testability (dependency injection, pure results, small surface). Use when designing APIs, reviewing testability, or refactoring for tests.
Refactor candidates after TDD (duplication, long methods, shallow modules, etc.). Use during refactor phase of red-green-refactor or when reviewing code quality.
| name | mocking |
| description | When and how to mock (system boundaries only, DI, SDK-style APIs). Use when writing tests, reviewing mocks, or the user asks what to mock. |
Mock at system boundaries only:
Don't mock:
At system boundaries, design interfaces that are easy to mock:
1. Use dependency injection
Pass external dependencies in rather than creating them internally:
// Easy to mock
function processPayment(order, paymentClient) {
return paymentClient.charge(order.total);
}
// Hard to mock
function processPayment(order) {
const client = new StripeClient(process.env.STRIPE_KEY);
return client.charge(order.total);
}
2. Prefer SDK-style interfaces over generic fetchers
Create specific functions for each external operation instead of one generic function with conditional logic:
// GOOD: Each function is independently mockable
const api = {
getUser: (id) => fetch(`/users/${id}`),
getOrders: (userId) => fetch(`/users/${userId}/orders`),
createOrder: (data) => fetch('/orders', { method: 'POST', body: data }),
};
// BAD: Mocking requires conditional logic inside the mock
const api = {
fetch: (endpoint, options) => fetch(endpoint, options),
};
The SDK approach means: