Shared – TypeScript Contracts (packages/shared)
Use this skill when a type crosses the API boundary.
When to Use This Skill
- •“Add/change response DTO”, “add new shared interface”
- •“Fix API/web type mismatch”, “contract drift”
- •“Add pagination/error envelope types”
Reference
- •
docs/standarts/shared-types-standards.md - •
docs/technical-overview.md(type groups and consumers)
Rules
- •Keep shared types framework-agnostic (no Express/React types).
- •Prefer
interfacefor objects. - •Use union literals for string enums.
- •Re-export public API from
packages/shared/src/index.ts(avoid deep imports).
Step-by-Step Workflow: Change a Shared Contract
- •Update/add types in
packages/shared/src/index.ts(or a submodule re-exported through it). - •Update API to produce the new shape.
- •Update web to consume the new shape.
- •Run:
- •
pnpm typecheck - •
pnpm lint
- •
Versioning Guidance
- •Bump the shared package version for breaking TypeScript changes (even if not published).
Troubleshooting
- •TS errors in consumers: confirm you are importing from
@workspace/sharedand not deep paths. - •Response mismatch: verify API response envelope (
{ data: ... }) matches the shared DTO.