Agent SkillsAjayIrkal23/agentic-mercy-10x › frontend-response-handling

frontend-response-handling

GitHub

前端API集成规范,负责解析成功响应、标准化错误处理及后端驱动的分页排序查询逻辑。适用于涉及API调用、数据适配及异步状态管理的场景,确保前后端契约一致与数据安全。

skills/frontend-response-handling/SKILL.md AjayIrkal23/agentic-mercy-10x

Trigger Scenarios

需要解析前端API成功响应 实现标准化的错误处理机制 开发后端驱动的分页、过滤或排序功能

Install

npx skills add AjayIrkal23/agentic-mercy-10x --skill frontend-response-handling -g -y
More Options

Use without installing

npx skills use AjayIrkal23/agentic-mercy-10x@frontend-response-handling

指定 Agent (Claude Code)

npx skills add AjayIrkal23/agentic-mercy-10x --skill frontend-response-handling -a claude-code -g -y

安装 repo 全部 skill

npx skills add AjayIrkal23/agentic-mercy-10x --all -g -y

预览 repo 内 skill

npx skills add AjayIrkal23/agentic-mercy-10x --list

SKILL.md

Frontmatter
{
    "name": "frontend-response-handling",
    "schema": 1,
    "category": "frontend",
    "surfaces": [
        "frontend"
    ],
    "triggers": {
        "paths": [
            "\/api-client",
            "\/api\/",
            "\/auth\/",
            "\/guard\/",
            "\/login\/",
            "api.js",
            "api.ts",
            "protected",
            "session"
        ],
        "intents": [
            "frontend"
        ],
        "keywords": [
            "api",
            "backend",
            "backend-driven",
            "behavior",
            "calls",
            "conform",
            "contracts",
            "error",
            "errors",
            "fetch",
            "flows",
            "frontend",
            "frontend-response-handling",
            "handle",
            "handling",
            "have",
            "implementing",
            "instead",
            "layer",
            "layers",
            "limit",
            "list",
            "list\/query",
            "must",
            "needs",
            "normalization",
            "normalize",
            "normalized",
            "page",
            "parse",
            "parsing",
            "prefer",
            "query",
            "raw",
            "response",
            "responses",
            "sdk",
            "sortby",
            "sortorder",
            "success",
            "success\/error",
            "work",
            "wrappers",
            "yet"
        ]
    },
    "platforms": [
        "linux",
        "darwin",
        "windows"
    ],
    "token-cost": 792,
    "description": "ALWAYS invoke when frontend API work needs success parsing, normalized error handling, or backend-driven list, filter, sort, and pagination behavior.",
    "disable-model-invocation": false
}

Frontend Response Handling

Overview

This is the canonical frontend API integration skill.

It combines backend-driven list/query behavior with success-envelope parsing and normalized error handling.

Use When

  • Touching src/api/**, src/apis/**, thunks, async query layers, or API-backed list/table screens.
  • Adapting frontend code to an existing backend contract.
  • Normalizing transport failures into frontend-safe errors.

Do Not Use

  • Pure visual work.
  • General module layout without async data.
  • Backend-side query validation or DB strategy.

Owns

  • Parsing success envelopes.
  • Normalizing frontend-safe error objects.
  • Backend-driven list/query behavior on the frontend.
  • Layer responsibilities between component, store/query layer, API module, and API client.

Contract Lock First

  1. Read the relevant frontend API docs and existing API client/types/pattern file. Use repo-local docs to confirm whether the repo standard is src/api/** or src/apis/**.
  2. Inspect backend route -> schema -> controller -> service.
  3. Lock request keys, success envelope, error envelope, and pagination metadata before coding.

Success Rules

Expected backend success envelope:

{
  "success": true,
  "data": {},
  "message": "",
  "meta": {}
}
  • API modules must parse the envelope explicitly.
  • Return typed domain data, not raw transport objects.
  • Use an adapter if the backend still exposes a legacy shape.

Error Rules

Expected backend error envelope:

{
  "success": false,
  "error": {
    "code": "ERROR_CODE",
    "message": "Safe message",
    "details": {}
  }
}

Frontend normalized error shape:

type NormalizedApiError = {
  code: string
  message: string
  statusCode: number
  details?: Record<string, unknown>
  isRetryable: boolean
}
  • Map timeout, network, and unknown failures to stable fallback codes.
  • Never leak raw transport or internal backend details to UI.

Backend-Driven Query Rules

  • The query object is the single source of truth.
  • Filters, sort, and pagination update query state only.
  • Any meaningful query change triggers a refetch.
  • Reset page when filter/search changes invalidate the current page.
  • Never do client-side filtering or pagination for server datasets.

Layer Boundaries

  • API layer: call backend, parse success, normalize and throw typed errors.
  • Store/query layer: map normalized results into user-facing state and messages.
  • Component/page layer: render state only; no raw error.response or raw payload parsing.

Workflow

  1. Lock the contract first.
  2. Implement the API adapter once.
  3. Normalize errors once.
  4. Wire query-driven state.
  5. Verify loading, empty, error, and success states together.

References

  • Use references/api-module-template.md for a reusable API module template.
  • Use frontend-server-data-patterns when the main question is screen-level query-state design.

Completion Checklist

  • Backend contract was verified before implementation.
  • Success envelope is parsed explicitly.
  • Query behavior is backend-driven.
  • One normalized error shape is used.
  • No raw internal errors leak to UI.

Version History

  • 581d130 Current 2026-07-19 09:08

Same Skill Collection

attic/2026-07-09/skills-pre-update/taste-skill/SKILL.md
attic/2026-07-09/skills-pre-update/ui-ux-pro-max/SKILL.md
skills/agent-development/SKILL.md
skills/api-and-interface-design/SKILL.md
skills/api-contract-standards/SKILL.md
skills/architect-system-design/SKILL.md
skills/backend-api-standards/SKILL.md
skills/backend-code-review/SKILL.md
skills/backend-error-handling/SKILL.md
skills/backend-performance-standards/SKILL.md
skills/backend-standards-always-follow/SKILL.md
skills/canary-playwright/SKILL.md
skills/caveman/SKILL.md
skills/ci-cd-and-automation/SKILL.md
skills/code-execution-standard/SKILL.md
skills/code-review-and-quality/SKILL.md
skills/code-simplification/SKILL.md
skills/codebase-design/SKILL.md
skills/codebase-start-point-guide/SKILL.md
skills/command-development/SKILL.md
skills/composition-patterns/SKILL.md
skills/context-engineering/SKILL.md
skills/dead-code-and-change-audit/SKILL.md
skills/debug-investigation/SKILL.md
skills/debugging-and-error-recovery/SKILL.md
skills/deprecation-and-migration/SKILL.md
skills/design-extract/SKILL.md
skills/design-review-playwright/SKILL.md
skills/diagnose/SKILL.md
skills/documentation-and-adrs/SKILL.md
skills/domain-modeling/SKILL.md
skills/domain-scaffold-patterns/SKILL.md
skills/doubt-driven-development/SKILL.md
skills/dox-doc-tree/SKILL.md
skills/eval-harness/SKILL.md
skills/fix-lint-format/SKILL.md
skills/forensic-change-coupling/SKILL.md
skills/forensic-complexity-trends/SKILL.md
skills/forensic-debt-quantification/SKILL.md
skills/forensic-hotspot-finder/SKILL.md
skills/frontend-api-standards/SKILL.md
skills/frontend-code-review/SKILL.md
skills/frontend-server-data-patterns/SKILL.md
skills/frontend-standards-always-follow/SKILL.md
skills/frontend-structure-standards/SKILL.md
skills/frontend-ui-engineering/SKILL.md
skills/git-workflow-and-versioning/SKILL.md
skills/golang-patterns/SKILL.md
skills/golang-testing/SKILL.md

Metadata

Files
0
Version
fc73590
Hash
6762c29f
Indexed
2026-07-19 09:08

Главная - Вики-сайт
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-03 05:53
浙ICP备14020137号-1 $Гость$