Set up and migrate to @data-client/rest for REST APIs. Detects existing HTTP patterns (axios, fetch, ky, superagent, got) and migrates them. Creates custom RestEndpoint base class with common behaviors. Use when adopting @data-client/rest in a new or existing project.
Set up and migrate to @data-client/rest for REST APIs. Detects existing HTTP patterns (axios, fetch, ky, superagent, got) and migrates them. Creates custom RestEndpoint base class with common behaviors. Use when adopting @data-client/rest in a new or existing project.
disable-model-invocation
true
REST Protocol Setup & Migration
This skill configures @data-client/rest for a project. It handles both fresh setup and migration from existing HTTP libraries. It should be applied after skill "data-client-setup" detects REST API patterns.
First, apply the skill "data-client-rest" for accurate implementation patterns.
Step 1: Installation
Install the REST package alongside the core package:
Scan the codebase to determine what's currently used. Multiple patterns may coexist — run each applicable migration sub-procedure independently on the relevant files.
Detection Checklist
Check package.json dependencies and scan source files:
Check
Pattern
Action
"axios" in dependencies, or import.*from ['"]axios['"] in source
If you cannot confidently determine which patterns are used (e.g., no clear imports but HTTP calls exist), ask the user:
I found HTTP calls in your codebase but couldn't determine the library. Are you migrating from:
axios
Raw fetch / custom fetch wrapper
ky
superagent
Something else (please describe)
Starting fresh (no migration needed)
Mixed Codebases
When multiple HTTP libraries are detected, run each sub-procedure on the relevant files. The sub-procedures are independent and don't conflict:
Identify which files use which library (group by import statements)
Run each applicable migration sub-procedure on its file group
After all migrations, proceed to the base class setup
Migration References
Each migration is a self-contained reference. Read only the relevant one(s) based on detection results above. After completing migrations, return here for base class setup.
When auth tokens live in React context (not localStorage), getHeaders() on a base class cannot access them. Use hookifyResource() to inject context-derived headers into every endpoint:
Body typing: Use body: {} as BodyType (truthy value) — not undefined as unknown as BodyType. The truthy value is needed so the endpoint correctly sends a request body for POST/PUT/PATCH.
Coexisting with existing validation (Zod, Yup)
If the codebase already validates responses with Zod/Yup, prefer Entity as the source of truth for types that benefit from caching/normalization. Keep Zod only for types that don't need normalization (auth tokens, form validation types, one-off responses). See the migration reference files for detailed options.
Next Steps
Define Entity classes (skill "data-client-schema") and wire them to endpoints via schema: — this is essential, not optional. Endpoints with schema: undefined bypass normalization and caching.
Apply skill "data-client-rest" for resource and endpoint patterns
Apply skill "data-client-react" or "data-client-vue" for hook-based usage