/mock: API surface mocks (TDD step 2)
Write the feature's complete API surface as type-level mocks (declare) in its real source file, matching the approved spec.
When to run
- Previous step:
/spec(an approved, co-locatedspecs.mdmust exist). - Next step:
/type-tests. - Gate (enter): if the co-located
specs.mdis missing, refuse to run and direct the user to/specfirst. No exceptions.
Procedure
- Read the spec. Load the co-located
specs.md. Every acceptance criterion must be attributable to some part of the surface you are about to write.
- Write the mock surface in the real source file (the file the implementation will live in, not a separate
*.mock.ts). Use thedeclarekeyword for anything that would need a runtime body. Cover the complete surface:
- Function signatures (including overloads)
- Classes and their methods
- Constants and variables
- Type definitions and interfaces
- Exports (named exports; follow module-organization rules for barrels)
- The Effect error union: declare every tagged error type the feature can fail with
- JSDoc everything exported. All exported functions, types, and values get JSDoc now. It is part of the surface, and
/documentlater only has to sync it, not create it. Omit@typeannotations; describe non-obvious parameters.
- Follow the standards while shaping the surface:
readonlyextensively,Option>undefined>null, generic constraints over flexibility, Schema for unknown/I-O boundaries, no JSX-style deferred component descriptors.
- Mock-vs-spec review checklist. Finish by walking it explicitly:
- [ ] Every acceptance criterion in
specs.mdmaps to a declared signature, type, or error. - [ ] Every declared export is justified by the spec (no speculative surface).
- [ ] The error union covers every failure mode named in the spec.
- [ ] Types are complete: a consumer could compile against this surface.
If the checklist exposes a spec gap: pause, return to /spec, then redo this step.
- Hand off. Next step is
/type-tests.
Rules
- Mocks live in the real source file and are replaced in-place by
/implement. Signatures must be final-quality, not sketches. - No runtime implementation in this step;
declareonly. - Changing this surface later (during
/implementor beyond) requires the pause rule: back to/spec+/mockfirst.