Agent Skillseclipse-openvsx/openvsx › migrate-to-tanstack

migrate-to-tanstack

GitHub

将数据获取端点从旧版 ExtensionRegistryService 迁移至 TanStack Query Hook,涉及消费者重构、重试策略调整及测试更新。

webui/.agents/skills/migrate-to-tanstack/SKILL.md eclipse-openvsx/openvsx

Trigger Scenarios

用户明确要求迁移特定端点到 TanStack Query 需要重构遗留的数据获取模式

Install

npx skills add eclipse-openvsx/openvsx --skill migrate-to-tanstack -g -y
More Options

Non-standard path

npx skills add https://github.com/eclipse-openvsx/openvsx/tree/main/webui/.agents/skills/migrate-to-tanstack -g -y

Use without installing

npx skills use eclipse-openvsx/openvsx@migrate-to-tanstack

指定 Agent (Claude Code)

npx skills add eclipse-openvsx/openvsx --skill migrate-to-tanstack -a claude-code -g -y

安装 repo 全部 skill

npx skills add eclipse-openvsx/openvsx --all -g -y

预览 repo 内 skill

npx skills add eclipse-openvsx/openvsx --list

SKILL.md

Frontmatter
{
    "name": "migrate-to-tanstack",
    "description": "Migrate a data-fetching endpoint from the legacy ExtensionRegistryService + fetch-retry pattern to a TanStack Query hook. Only do this when the user explicitly asks — it is an opt-in, in-progress migration. Pairs with the tanstack-query-conventions skill."
}

Migrating an endpoint to TanStack Query

Only run this when the user explicitly asks to migrate an endpoint. The migration is in progress and opt-in — never convert endpoints as a side effect of other work.

The current picture

src/extension-registry-service.ts (ExtensionRegistryService, plus service.admin.*) holds every server call. Legacy, un-migrated consumers call these methods straight from a component, passing an AbortController and relying on fetch-retry's 10-attempt backoff inside sendRequest. That drags along per-component AbortController refs, useEffect fetch-on-mount wiring, and hand-rolled loading/error state.

Migrated endpoints instead go through a use* hook wrapping useQuery/useMutation, and retries move to the shared query client (src/query-client.ts). Roughly half the service is migrated — grep before assuming either state.

Steps

  1. Find every consumer of the method you're migrating: grep -rn "service\.<method>\|\.<method>(" src. List them — you'll migrate all of them or a named subset.

  2. Decide the retry scope — ask if unsure. Ideally the service method flips from sendRequest (retriable) to sendNonRetriableRequest, handing retries to TanStack. Only do that when every consumer is moving to a hook — a legacy consumer still calling the method directly would silently lose its retry. If you're migrating just one of several consumers, either leave the method retriable (the query then double-retries, tolerated in the interim) or confirm scope with the user. When the request doesn't make the consumer scope clear, ask.

  3. Adjust the service method.

    • Query methods: keep the AbortController param — the hook passes controllerFromSignal(signal).
    • Mutation methods: drop the AbortController param — we no longer abort writes.
  4. Create the hook — shape and naming per the tanstack-query-conventions skill. Co-locate it in the feature's folder first; move to src/hooks/ only when a second place needs it. The hook returns the react-query result object as-is, never just data or a picked subset.

  5. Update the consumers. Replace the AbortController / useEffect / manual-state boilerplate with the hook, destructuring and renaming its result (const { data: user, error: userError } = ...; const { mutateAsync, isPending } = ...). Delete the dead boilerplate.

  6. Finish per the write-code skill: add or update tests (write-tests), add a changelog entry, and pass yarn lint.

Don't

  • Don't strip fetch-retry from sendRequest globally — that's the final cleanup once the whole migration is done, and un-migrated direct callers still depend on it. Keep the 429 / Retry-After block regardless.
  • Don't migrate endpoints nobody asked you to.

Version History

  • 4c33308 Current 2026-08-20 15:09

Same Skill Collection

webui/.agents/skills/tanstack-query-conventions/SKILL.md
webui/.agents/skills/write-code/SKILL.md
webui/.agents/skills/write-tests/SKILL.md

Metadata

Files
0
Version
4c33308
Hash
3dabe68b
Indexed
2026-08-20 15:09

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-25 11:33
浙ICP备14020137号-1 $방문자$