/core-skills:fetch-abstraction-drift-detectorfrom core-skills
Detects contract drift when a fetch/API client abstraction changes, by cross-referencing component fetch call sites, prop names, URL patterns, and response envelope shapes against test mock fixtures. Surfaces mismatches before CI catches them.
Ships in core-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Detects contract drift when a fetch/API client abstraction changes, surfacing mismatches between component call sites and test mock fixtures before CI catches them.
Introduced after a dashboard refactor (PR #256) where replacing fetchJson(api + '/contracts/*') with workerContractsClient functions caused 5 test failures — all sharing the same root cause: URL patterns, prop names, and response envelope shapes diverged between components and tests simultaneously.
Required: fs.read, git.read — to inspect component and test source files.
Optional: shell.exec — to run git diff for precise change scope.
Fallback: prompt-only with pasted source.
If abstraction_file is provided, read it directly. Otherwise:
git diff --name-only HEAD~1
Look for files matching *client*, *api*, *fetch*, *contracts*. Read the identified file and extract:
fetchAnalyticsToolUsage)/v1/analytics/tool-usage).data, return a wrapped envelope?workerUrl, token vs api)Find all components that import from the changed abstraction:
grep -r "from.*<module-name>" src/ --include="*.jsx" --include="*.tsx" --include="*.js" -l
For each component, note:
{ workerUrl, token } vs { api })envelope.data, payload?.data ?? payload)Find test files that exercise the affected components (use test_glob if provided):
grep -r "fetch\|vi\.fn\|spyOn\|mockImplementation" src/__tests__/ --include="*.jsx" --include="*.ts" -l
For each test file, extract:
url.includes(...))json: () => Promise.resolve({...}))render(<Component prop=... />))A. URL drift — does the mock intercept the URL the abstraction now builds?
Abstraction builds: `${workerUrl}/v1/analytics/tool-usage`
Test mocks: url.includes("/contracts/analytics.tool_usage") ← MISMATCH
B. Prop drift — do test render calls pass the props the refactored component now expects?
Component accepts: { workerUrl, token }
Test renders: <AnalyticsTab api={API} /> ← MISMATCH
C. Envelope drift — does the mock response shape match what the component now extracts?
Component reads: envelope.data.tools
Mock returns: { tools: [...] } (no data wrapper) ← MISMATCH
For each mismatch:
[TYPE] file:line
Current: <what the test has>
Expected: <what the component/abstraction now requires>
Fix: <one-line concrete change>
Close with a summary:
Drift summary: <N> mismatches across <M> test files
URL: <n>
Props: <n>
Envelope: <n>
If no mismatches found: "No drift detected — test mocks align with current abstraction contract."
Input: "The dashboard was refactored to use workerContractsClient — check for test drift"
Output:
[URL] src/__tests__/AnalyticsTab.test.jsx:15
Current: url.includes("/contracts/analytics.friction_signals")
Expected: url.includes("/v1/analytics/friction-signals")
Fix: Replace URL pattern string
[PROP] src/__tests__/AnalyticsTab.test.jsx:63
Current: render(<AnalyticsTab api={API} />)
Expected: render(<AnalyticsTab workerUrl={WORKER_URL} token={TOKEN} />)
Fix: Update render call props
[ENVELOPE] src/__tests__/AnalyticsTab.test.jsx:40
Current: json: () => Promise.resolve({ tools: [...], total_events: 5 })
Expected: json: () => Promise.resolve({ contract_version: "1.0.0", data: { tools: [...] }, meta: {...} })
Fix: Wrap payload in Worker envelope (add workerEnvelope() helper)
Drift summary: 3 mismatches across 1 test file
URL: 1 Props: 1 Envelope: 1
Input: "I added a new endpoint to the API client — are the tests still aligned?"
Output:
No drift detected — test mocks align with current abstraction contract.
New endpoint fetchAuditHistory is not yet exercised by any component or test.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
35 skills in this plugin
/autoresearchAutonomously optimise any skill by running it repeatedly, scoring outputs against
binary evals, mutating the prompt, and keeping improvements. Based on Karpathy's
autoresearch methodology.
Use when: "optimise this skill", "improve this skill", "run autoresearch on",
"make this skill better", "self-improve skill", "benchmark skill", "eval my skill",
"run evals on". Outputs: an improved SKILL.md copy, a results log, and a changelog
of every mutation tried.
/changelogWhen to useGenerate structured changelog entries from git history, grouping commits by conventional prefix and flagging breaking changes./npx claudepluginhub internet-dot/ai-config-os --plugin core-skills