一键导入
apollo-optimistic-updates
Apollo Client cache updates for mutations. Use when implementing mutations that should update the UI without refetching queries.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Apollo Client cache updates for mutations. Use when implementing mutations that should update the UI without refetching queries.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Manage a PR stacked on another unmerged branch, and re-point it onto main after the base merges. Use when the user says "stack this PR", "restack", "re-point the PR base", "rebase onto main after the base merged", or has a PR whose base branch just merged.
Run `/code-review` in a fresh-context subagent, triage and address findings, then re-review — looping until no significant findings remain. Use when the user says "subagent review loop", "review loop", "loop until clean", or asks to harden a branch/PR with iterative independent review. Argument is passed through to `/code-review` (default `high`).
Drive native Windows desktop GUI apps with cua-driver (cua-computer-use MCP) — read the screen, click, type, navigate menus/forms. Use when automating a Windows application's UI, ESPECIALLY when pixel clicks land in the wrong place on a high-DPI / scaled display, or when a legacy (Delphi/VCL/Win32) app's clicks "do nothing." Covers the DPI click-offset fix and headless foreground control.
Run a self-perpetuating, multi-agent improvement loop on ANY codebase (chat, ingest, a UI, infra — anything with tests). A committed backlog of file-disjoint, waved tasks is implemented in parallel by a background Workflow, verified, adversarially reviewed, fixed, committed, and then re-scouted into the next round's backlog. Use when the user wants to iteratively harden/improve a project across many tasks ("improve X", "run a round", "keep iterating on Y", "set up an improvement loop"), to continue an existing loop ("run the next round"), or to fold a fresh ask into the next round. Requires the Workflow tool (multi-agent orchestration).
Monitor a PR for CI failures and reviewer comments, fix issues, and respond thoughtfully.
Browse any web app in a real browser using Playwright CLI. Use when asked to "check the app", "open the site", "look at the UI", "verify this page", "browse", or diagnose frontend behavior. General-purpose — not tied to any specific app.
| name | apollo-optimistic-updates |
| description | Apollo Client cache updates for mutations. Use when implementing mutations that should update the UI without refetching queries. |
Use cache.modify in mutation update callbacks instead of refetchQueries: 'active' for faster, more efficient UI updates.
Update specific fields on cached entities directly:
const [mutate] = useMutation(MY_MUTATION, {
onCompleted: () => { /* cleanup */ },
onError: () => { /* handle error */ },
});
// Pass update in the mutation call to capture current values
mutate({
variables: { id, newValue },
update(cache, { data }) {
if (!data?.myMutation?.success) return;
cache.modify({
id: cache.identify({ __typename: 'MyType', id }),
fields: {
myField() {
return newValue;
},
},
});
},
});
update at call site, not hook config - closures in hook config capture stale valuescache.identify to get the cache key for an entity__typename in returned objects for new nested datamutate({
variables: { caseFileId, isRelevant, reason },
update(cache, { data }) {
if (!data?.case?.overrideRelevance?.success) return;
cache.modify({
id: cache.identify({ __typename: 'CaseFile', id: caseFileId }),
fields: {
relevanceOverride() {
return {
__typename: 'RelevanceOverride',
isRelevant,
reason,
createdBy: null, // Server-only field, okay to omit
};
},
},
});
},
});
mutate({
variables: { id },
update(cache, { data }) {
if (!data?.removeItem?.success) return;
cache.modify({
id: cache.identify({ __typename: 'Parent', id: parentId }),
fields: {
item() {
return null;
},
},
});
},
});
import type { Reference } from '@apollo/client/cache';
mutate({
variables: { parentId, newItem },
update(cache, { data }) {
if (!data?.createItem) return;
cache.modify({
id: cache.identify({ __typename: 'Parent', id: parentId }),
fields: {
items(existing: readonly Reference[] = []) {
const newRef = cache.writeFragment({
data: data.createItem,
fragment: gql`
fragment NewItem on Item {
id
name
}
`,
});
return [...existing, newRef];
},
},
});
},
});
import type { Reference, ModifierDetails } from '@apollo/client/cache';
mutate({
variables: { itemId },
update(cache, { data }) {
if (!data?.removeItem?.success) return;
cache.modify({
id: cache.identify({ __typename: 'Parent', id: parentId }),
fields: {
items(existing: readonly Reference[] = [], { readField }: ModifierDetails) {
return existing.filter(
(ref) => readField('id', ref) !== itemId
);
},
},
});
},
});
For instant UI feedback before the mutation even starts:
const [pendingValue, setPendingValue] = useState<T | null>(null);
// Use pending value for display, fall back to server value
const displayValue = pendingValue ?? serverValue;
const handleMutate = () => {
setPendingValue(newValue); // Instant UI update
mutate({
variables: { newValue },
update(cache, { data }) {
// Cache update for other components
},
onCompleted: () => setPendingValue(null),
onError: () => setPendingValue(null),
});
};
Still appropriate when: