/harness-claude:redux-rtk-optimisticfrom harness-claude
Applies optimistic and pessimistic cache updates with onQueryStarted for instant UI feedback and automatic rollback on failure.
Claude never picks this skill on its own
Its frontmatter has no description. Without a description, Claude Code leaves it out of the list Claude chooses from. Typing /harness-claude:redux-rtk-optimistic still runs it.
What the skill costs in Claude's context, stage by stage
No description Claude Code can read, so Claude's list leaves it out: only you can start it.
SKILL.md joins the conversation and stays.
Apply optimistic and pessimistic cache updates with onQueryStarted for instant UI feedback with automatic rollback
onQueryStarted in the mutation endpoint to perform cache updates before or after the server responds.dispatch(api.util.updateQueryData(...)) immediately inside onQueryStarted, before awaiting the result. Save the return value — it contains an undo function.await queryFulfilled in try/catch. On failure, call patchResult.undo() to revert the optimistic change.await queryFulfilled first, then update the cache with the server's response.updateQueryData — a mismatch silently does nothing.// Optimistic update — toggle a todo's completed status
toggleTodo: builder.mutation<Todo, { id: string; completed: boolean }>({
query: ({ id, completed }) => ({
url: `/todos/${id}`,
method: 'PATCH',
body: { completed },
}),
async onQueryStarted({ id, completed }, { dispatch, queryFulfilled }) {
// Optimistically update the cache immediately
const patchResult = dispatch(
api.util.updateQueryData('getTodos', undefined, (draft) => {
const todo = draft.find((t) => t.id === id);
if (todo) todo.completed = completed;
})
);
try {
await queryFulfilled;
} catch {
// Revert on failure
patchResult.undo();
}
},
}),
// Pessimistic update — server assigns the ID
createTodo: builder.mutation<Todo, { title: string }>({
query: (body) => ({ url: '/todos', method: 'POST', body }),
async onQueryStarted(_, { dispatch, queryFulfilled }) {
try {
const { data: newTodo } = await queryFulfilled;
// Update cache with server response
dispatch(
api.util.updateQueryData('getTodos', undefined, (draft) => {
draft.push(newTodo);
})
);
} catch {
// No cache to revert — the mutation failed before we touched it
}
},
}),
updateQueryData arguments: updateQueryData(endpointName, queryArg, updateFn). The queryArg must exactly match what was passed to the query hook. If the query was called with useGetTodosQuery(undefined), pass undefined. If called with useGetTodosQuery({ filter: 'active' }), pass { filter: 'active' }.
Combining with invalidation: You can use optimistic updates AND invalidatesTags together. The optimistic update gives instant feedback, and the invalidation ensures the cache is eventually consistent with the server.
Multiple cache entries: If the same data appears in multiple queries (a list query and a detail query), update both:
async onQueryStarted({ id, title }, { dispatch, queryFulfilled }) {
const patchList = dispatch(api.util.updateQueryData('getPosts', undefined, (draft) => {
const post = draft.find((p) => p.id === id);
if (post) post.title = title;
}));
const patchDetail = dispatch(api.util.updateQueryData('getPost', id, (draft) => {
draft.title = title;
}));
try {
await queryFulfilled;
} catch {
patchList.undo();
patchDetail.undo();
}
},
Anti-patterns:
undo() on failure — leaves the UI in a stale statehttps://redux-toolkit.js.org/rtk-query/usage/manual-cache-updates
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeRead when SKILL.md points to them.
793 skills in this plugin
/a11y-aria-patternsARIA Patterns> Apply ARIA roles, states, and properties correctly to enhance assistive technology support for custom widgets/a11y-color-contrastColor Contrast and Color Independence> Ensure sufficient color contrast ratios and never use color as the sole means of conveying information/a11y-form-patternsAccessible Form Patterns> Build accessible forms with proper labeling, grouped controls, inline validation, and clear error communicationOther plugins' skills for the same job