Upfetch
ResearchupfetchUpfetch is an Agent Skill for research published in the L-Blondy/up-fetch repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Load this skill for any up-fetch task: `up(fetch, getDefaultOptions?)`, `upfetch(url, options?)`. Covers dynamic defaults, auth, request shaping, validation, error handling, lifecycle timing, and runtime caveats.
QUICK START
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/L-Blondy/up-fetch/blob/HEAD/skills/upfetch/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/upfetch, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
upfetch
Use up-fetch when you need a reusable fetch client with request-scoped defaults, automatic request/response shaping, runtime validation, retries, and lifecycle hooks.
Mental model
up(fetchFn, getDefaultOptions?)creates the reusable client.getDefaultOptions(input, options, ctx)runs on every request.upfetch(input, options?, ctx?)performs one request.- Keep
SKILL.mdhigh-level; load the relevant file underreferences/for details.
Minimum pattern
import { up } from 'up-fetch'
import { z } from 'zod'
export const upfetch = up(fetch, () => ({
baseUrl: 'https://api.example.com',
headers: {
Authorization: readToken() ? `Bearer ${readToken()}` : undefined,
},
timeout: 5000,
}))
const user = await upfetch('/users/1', {
schema: z.object({
id: z.number(),
name: z.string(),
}),
})
Workflow
- Start with client setup and dynamic defaults.
- If the request needs auth, params, body shaping, or merge semantics, read auth and request shaping.
- If the response contract matters, read validation, parsing, and errors.
- If retries, timeouts, or hook timing matter, read retries, timeouts, and lifecycle.
- If streaming or runtime quirks matter, read streaming and runtime caveats.
High-value rules
- Pass a function as the second argument to
up(), not a plain object. - Read auth and other mutable defaults inside that function so values stay fresh.
- Use
paramsandbodyinstead of hand-serializing query strings or JSON. - Use
schemawhen you need runtime trust; TypeScript generics alone do not validate payloads. - If you want error-as-value behavior, set
reject: () => falsebefore relying onparseResponse. - Prefer
globalThis.fetchover importedundici.fetch.