원클릭으로
rtk-query-api
RTK Query createApi best practices
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
RTK Query createApi best practices
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
| name | rtk-query-api |
| description | RTK Query createApi best practices |
state-manager/api.ts files// ✅ GOOD - state-manager/api.ts
import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
import { EntityTags } from "./types";
export const myApi = createApi({
reducerPath: "myApi",
baseQuery: fetchBaseQuery({ baseUrl: "/api" }),
tagTypes: [EntityTags.Entity, EntityTags.Entities],
endpoints: (build) => ({
getEntity: build.query<Entity, string>({
query: (id) => `entities/${id}`,
providesTags: [EntityTags.Entity],
}),
}),
});
export const { useGetEntityQuery } = myApi;
Define tags as enums in state-manager/types.ts:
export enum EntityTags {
Entity = "Entity",
Entities = "Entities",
}
build.query for GET requestsbuild.mutation for POST/PUT/DELETEbuild.query<ResponseType, ArgType>void for no arguments: build.query<Data[], void>types.tsprovidesTags on queries for cache invalidationinvalidatesTags on mutations to trigger refetchkeepUnusedDataFor for custom cache durationendpoints: (build) => ({
getItems: build.query<Item[], void>({
query: () => "items",
providesTags: [ItemTags.Items],
keepUnusedDataFor: 60, // seconds
}),
addItem: build.mutation<Item, Partial<Item>>({
query: (body) => ({ url: "items", method: "POST", body }),
invalidatesTags: [ItemTags.Items],
}),
}),
transformResponse to reshape API datatransformErrorResponse for custom error handlinggetItems: build.query<Item[], void>({
query: () => "items",
transformResponse: (response: ApiResponse) => response.data.items,
}),
baseQuery or queryFn{ data } on success, { error } on failure// ✅ GOOD - errors are caught and returned
queryFn: async (arg) => {
try {
const data = await fetchData(arg);
return { data };
} catch (error) {
return { error: { status: "CUSTOM_ERROR", data: error } };
}
},
Register APIs in reducers/rtkQueryApi.ts:
const APIs = {
[myApi.reducerPath]: myApi,
};
Enforce import boundaries inside the devtools scope. Use for any work in "devtools/**".
Official Ledger wallet-cli - USB-based CLI for Ledger hardware wallet flows (account discover, receive, balances, operations, send, swap quote/execute/status, genuine-check, assets token / token-by-id). Use for any wallet-cli command execution and for mapping informal requests to the right command.
Handle batches of Jira tickets through shared analysis, per-ticket feature-dev, Lumen UI guardrails, changesets, and draft PRs. Use when the user provides multiple Jira tickets or asks to deliver tickets one by one with PRs.
Trigger the on-demand production build workflows on LedgerHQ/ledger-live-build (Desktop, Android APK, iOS) for a ledger-live branch, then post a PR comment. Use when asked to "run builds", "produce a build", "build the app(s)", or "make an APK/iOS/desktop build" for a PR/branch.
Guided feature development with codebase understanding and architecture focus
Rules and layout for coin module packages under libs/coin-modules/. Read when adding or modifying a coin module.