Skip to content

reactive/data-client / .agents/skills/data-client-setup

data-client-setup

Verified

Install and set up @data-client/react or @data-client/vue in a project. Detects project type (NextJS, Expo, React Native, Vue, plain React) and protocol (REST, GraphQL, custom), then follows the bundled protocol-specific setup guide.

FileKindSize
SKILL.mdskill md13.9 KB
evals/evals.jsonconfig12.6 KB
references.jsonconfig523 B
references/DataClientPlugin.mdmarkdown6.6 KB
references/DataProvider.mdmarkdown6.6 KB
references/data-client-endpoint-setup.mdmarkdown8.5 KB
references/data-client-endpoint-setup/references/Endpoint.mdmarkdown20.9 KB
references/data-client-endpoint-setup/references/Endpoint.vue.mdmarkdown20.5 KB
references/data-client-graphql-setup.mdmarkdown4.8 KB
references/data-client-graphql-setup/references/auth.mdmarkdown1.9 KB
references/data-client-rest-setup.mdmarkdown7.6 KB
references/data-client-rest-setup/references/RestEndpoint.mdmarkdown45.2 KB
references/data-client-rest-setup/references/RestEndpoint.vue.mdmarkdown46.1 KB
references/data-client-rest-setup/references/auth.mdmarkdown9.4 KB
references/data-client-rest-setup/references/auth.vue.mdmarkdown9.7 KB
references/data-client-rest-setup/references/axios-migration.mdmarkdown25.4 KB
references/data-client-rest-setup/references/axios-migration.vue.mdmarkdown25.5 KB
references/data-client-rest-setup/references/django.mdmarkdown2.3 KB
references/data-client-rest-setup/references/fetch-migration.mdmarkdown4.0 KB
references/data-client-rest-setup/references/got-migration.mdmarkdown4.5 KB
references/data-client-rest-setup/references/hookifyResource.mdmarkdown6.0 KB
references/data-client-rest-setup/references/hookifyResource.vue.mdmarkdown6.3 KB
references/data-client-rest-setup/references/ky-migration.mdmarkdown3.9 KB
references/data-client-rest-setup/references/resource.mdmarkdown27.0 KB
references/data-client-rest-setup/references/resource.vue.mdmarkdown27.1 KB
references/data-client-rest-setup/references/superagent-migration.mdmarkdown4.1 KB
references/getDefaultManagers.mdmarkdown6.1 KB
references/getDefaultManagers.vue.mdmarkdown3.8 KB
references/installation.mdmarkdown4.0 KB
references/installation.vue.mdmarkdown2.7 KB
references/tanstack-query-migration.mdmarkdown31.1 KB

references/data-client-rest-setup/references/superagent-migration.md

View on GitHub
<!-- Generated by `yarn build:skills` from .agents/skills/data-client-rest-setup/references/superagent-migration.md. Edit the source, not this file. -->

# SuperAgent → @data-client/rest Migration

## Detection

- `"superagent"` in `package.json` dependencies
- `import request from 'superagent'` or `require('superagent')` in source

Search patterns:
- `import.*from ['"]superagent['"]` — import statements
- `require\(['"]superagent['"]\)` — CommonJS require
- `\.(get|post|put|patch|del|delete)\(` — chained method calls (context: superagent import)

## Migration Rules

### Basic requests

```ts
// Before: superagent
import request from 'superagent';
const res = await request
  .get('https://api.example.com/users')
  .set('Authorization', `Bearer ${token}`)
  .query({ page: 1 });
const users = res.body;

// After: RestEndpoint (auth moves to a base class)
import { RestEndpoint } from '@data-client/rest';
import { User } from './User';

export const getUsers = new RestEndpoint({
  urlPrefix: 'https://api.example.com',
  path: '/users',
  searchParams: {} as { page?: number },
  schema: [User],
});
```

### Key conversions

| SuperAgent pattern | RestEndpoint equivalent |
|-------------------|----------------------|
| `.set(name, value)` headers | `getHeaders()` |
| `.query(params)` | `searchParams` type |
| `.send(body)` | `body` type on endpoint |
| `.use(plugin)` | Lifecycle method overrides |
| Chained `.get()/.post()` etc. | `method` option |
| `.type('json')` / `.accept('json')` | Automatic — JSON is default |
| `.withCredentials()` | `getRequestInit()` with `credentials: 'include'` |
| `.timeout({ response, deadline })` | `AbortSignal.timeout(ms)` in a `getRequestInit()` override, so each request gets its own timer ([Timeout](axios-migration.md#timeout)); a `signal` option would start one timer when the endpoint is created |
| `.retry(count)` | Delete it: Data Client has no retry loop, and a failed request is fetched again when a component next needs it after `errorExpiryLength` (default 1 second). Tell the user that automatic retries are dropped |
| `res.body` | Automatic — RestEndpoint returns parsed JSON |
| `res.status` | Available on `NetworkError.status` for error cases |

### Shared config via agent/plugin → base class

```ts
// Before: superagent with shared config
import request from 'superagent';
import prefix from 'superagent-prefix';

const api = request.agent()
  .use(prefix('https://api.example.com'))
  .set('Authorization', `Bearer ${getToken()}`);

const res = await api.get('/users').query({ role: 'admin' });

// After: base class
class ApiEndpoint<O extends RestGenerics = any> extends RestEndpoint<O> {
  urlPrefix = 'https://api.example.com';

  getHeaders(headers: HeadersInit) {
    return {
      ...headers,
      Authorization: `Bearer ${getToken()}`,
    };
  }
}

export const getUsers = new ApiEndpoint({
  path: '/users',
  searchParams: {} as { role?: string },
  schema: [User],
});
```

### POST / mutation patterns

```ts
// Before
const res = await request
  .post('https://api.example.com/users')
  .send({ name: 'Alice', email: 'alice@example.com' });

// After
export const createUser = new RestEndpoint({
  path: '/users',
  method: 'POST',
  schema: User,
});
```

### Error handling

```ts
// Before
try {
  const res = await request.get('/api/users');
} catch (err) {
  if (err.status) {
    console.log(err.status, err.response.body);
  }
}

// After
import { NetworkError } from '@data-client/rest';
try { ... } catch (err) {
  if (err instanceof NetworkError) {
    console.log(err.status);
    const body = await err.response.json();
  }
}
```

### File uploads

```ts
// Before
await request
  .post('/upload')
  .attach('file', blob, 'photo.jpg')
  .field('description', 'My photo');

// After — use FormData with RestEndpoint
const uploadFile = new RestEndpoint({
  path: '/upload',
  method: 'POST',
  body: {} as FormData,
  schema: undefined,
});
// Usage: ctrl.fetch(uploadFile, formData)
```

## Reference

- [RestEndpoint API](https://dataclient.io/rest/api/RestEndpoint) — lifecycle methods reference
- [NetworkError](https://dataclient.io/rest/api/RestEndpoint#fetchResponse) — error class
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 197kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall