web-api-integrated
Integrate API endpoints into the frontend with Zod schemas, response types, constants, and react-query hooks. Use when implementing endpoints from an API contract, Postman, or Swagger.
- License 许可
- MIT
- 最近更新
- 2026-09-06
- Stars
- ★ 3
- Forks
- 0
01 前言 Front Matter
- name
- web-api-integrated
- description
- Integrate API endpoints into the frontend with Zod schemas, response types, constants, and react-query hooks. Use when implementing endpoints from an API contract, Postman, or Swagger.
02 资源文件 3
- 参考文档agents/openai.yaml323 B
- 参考文档references/context.md3.3 KB
- 参考文档templates/checklist.md1.0 KB
03 SKILL.md 正文
Skill: Web API Integrated
Context (Required)
- Folder scope + code examples:
references/context.md - Execution checklist:
templates/checklist.md
Integrate APIs into the frontend with a consistent architecture.
Workflow
0. Read the API Contract
- If the user provides an API contract (Postman, Swagger, OpenSpec specs), read and understand every endpoint: method, URL, payload, and response.
- Check
openspec/changes/{slug}/specs/for OpenSpec-based contracts.
1. Create Zod Schema (packages/schemas/)
- Follow the pattern: type constants + labels array +
get{Type}Label()+ Zod schema + type alias - Read guide:
.agents/guides/shared-schema.md
2. Create Response Types (packages/types/)
- One file per response type, e.g.
packages/types/payment-method-response.ts - Import from frontend via
@openstate/types/payment-method-response - Re-export from
packages/types/index.tsif needed from the root package
3. Register Constants
- Add URL to
apps/web/constants/api-routers.ts(use:idpath variables) - Add query key to
apps/web/constants/query-keys.ts(flat strings) - Read guide:
.agents/guides/web-constant.md
4. Create Custom Hooks (apps/web/hooks/transactions/use-{domain}/)
- One folder per domain, one file per operation
- Hooks call axios directly — no service function required
- File order:
use-data-table.ts,use-get-one.ts,use-insert-one.ts,use-update-one.ts,use-delete-one.ts,index.ts - Read guide:
.agents/guides/web-hook.md - See example:
.agents/examples/web-api-integrated/hooks/use-examples/
Prohibitions
- FORBIDDEN to call
axios/fetchdirectly inside JSX/TSX components. - FORBIDDEN to use
anyas a type. - FORBIDDEN to skip Zod schema — every payload must be validated.
- FORBIDDEN to hardcode API URLs — use
apiRoutersfrom constants. - FORBIDDEN to use functions for URL building — use
:idpath variable +pathVariable().
Pre-Completion Checklist
- [ ] Zod schema created in
packages/schemas/(full pattern: constants + labels + helper + schema + type) - [ ] Response type created in
packages/types/as a flat file per domain + re-export from root if needed - [ ] URL registered in
constants/api-routers.ts(:idpath variables) - [ ] Query key registered in
constants/query-keys.ts(flat strings) - [ ] Custom hooks created:
useDataTable,useGetOne,useInsertOne,useUpdateOne,useDeleteOne - [ ]
index.tsre-exports all hooks - [ ] No direct
axios/fetchin components - [ ] No
any - [ ] Every file ends with a newline (EOF)
04 同仓库更多 Skills
web-slicing
Convert screenshot/Figma designs into pixel-perfect frontend UI with reusable components. Use when the task focuses on visual and layout implementation.
web-seo-geo-friendly
Optimize public Next.js App Router pages for SEO and GEO (Generative Engine Optimization). Use when the user explicitly requests SEO/GEO optimization on public pages.
web-code-review
Review frontend code with a firm senior-lead standard, focusing on bugs, regressions, architecture risks, and test gaps in apps/web and the shared contracts the frontend depends on.
web-bugfix
Fix frontend bugs with minimum-touch changes, keep other surfaces stable, and sync schema, types, hooks, constants, tests, and related docs when impacted.
web-api-integrated
Integrate API endpoints into the frontend with Zod schemas, response types, constants, and react-query hooks. Use when implementing endpoints from an API contract, Postman, or Swagger.
skill-creator
Create a new skill from scratch with full structure — SKILL.md, references, templates, openai.yaml, Claude/OpenCode wrappers, and registration in manifest + AGENTS.md + CLAUDE.md.