/kenji:audit-fe-apifrom kenji skills
Audits frontend API calls against backend implementation for contract alignment and network shape. Detects mismatches in routes, methods, params, and types.
Ships in kenji 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.
Read when SKILL.md points to them.
Degree of freedom: MIXED — Steps 0, 1, 3–6 [HIGH freedom]; Step 2
Sentry queries and schema SQL [LOW freedom — run exactly].
Read-only. Present findings; the Phase 6 snippets are the fix shape to recommend, not edits to make in this pass.
| Skill | Owns |
|---|---|
| audit-fe-api (this) | Read-only audit of frontend API calls against the backend contract |
debug-fe-be-integration | Diagnose and fix live frontend-backend contract failures: 4xx/5xx, payloads |
Observe:
useUserGETs/api/users/${id}; noapp/api/users/[id]/route.ts; Sentry 25× 404 in 14d. Interpret: FE calls a route the BE never registered. Classify: missing route (Critical). Severity: Critical — guaranteed 404. Finding:hooks/useUser.ts| GET/api/users/:id| Critical | no BE route.
debug-fe-be-integration; DB shape → audit-db-schema| Dependency | Technology |
|---|---|
@tanstack/react-query | TanStack Query (React Query) |
swr | SWR |
@reduxjs/toolkit with createApi | RTK Query |
axios | Axios HTTP client |
ky | Ky HTTP client |
ofetch or $fetch | Nuxt/ofetch |
@trpc/client | tRPC (type-safe RPC) |
graphql-request or @apollo/client | GraphQL |
openapi-fetch or openapi-typescript | OpenAPI typed client |
Glob: **/app/api/**/route.ts → Next.js App Router API routes
Glob: **/pages/api/**/*.ts → Next.js Pages Router API routes
Glob: **/src/routes/**/*.ts → Express/Hono/Fastify routes
Glob: **/server/api/**/*.ts → Nuxt server routes
Glob: **/src/app.py → Flask/Django
Glob: **/main.go → Go backend
Glob: **/services/*api*.ts → API service files
Glob: **/services/*service*.ts → Service files
Glob: **/api/*.ts → API client files
Glob: **/hooks/use*.ts → Custom hooks (may contain API calls)
Glob: **/lib/api*.ts → API client config
Glob: **/features/*/api.* → Feature-specific API files
Grep: "dev" in package.json scripts → extract port (3000, 3001, 5173, 8080, etc.)
Grep: "PORT" in .env or .env.local
API LAYER DISCOVERY:
- HTTP client: [axios/fetch/ky/ofetch]
- State management: [TanStack Query/SWR/RTK Query/none]
- API style: [REST/GraphQL/tRPC]
- Backend framework: [Next.js API routes/Express/Hono/etc.]
- API service files: [list paths]
- API hooks: [list paths]
- Dev server: http://localhost:[port]
- API docs: [path or URL if detected]
Resolve each major dependency (@tanstack/react-query, axios, zod), then query docs for
"staleTime cacheTime retry error handling optimistic updates". Call bodies:
references/research-calls.md §Context7.
Search <FRAMEWORK> API integration best practices [current year] (limit 5, web source), then one
query per topic below. Call body: references/research-calls.md §Firecrawl.
| Topic | Query |
|---|---|
| Caching | <state library> caching strategy staleTime production |
| Error handling | <framework> API error handling patterns retry |
| Type safety | <framework> type-safe API client OpenAPI Zod |
| Performance | frontend API request optimization batching deduplication |
sentry:search_issues
{
"organizationSlug": "<ORG_SLUG>",
"query": "API errors 4xx 5xx fetch axios network from the last 14 days",
"projectSlugOrId": "<PROJECT_SLUG>",
"regionUrl": "<REGION_URL>",
"limit": 25
}
sentry:search_events
{
"organizationSlug": "<ORG_SLUG>",
"projectSlug": "<PROJECT_SLUG>",
"regionUrl": "<REGION_URL>",
"dataset": "spans",
"query": "span.op:http.client",
"sort": "-span.duration",
"limit": 15
}
For each Sentry error: identify the endpoint, Grep the FE caller, check error/retry/types.
Grep (not bash grep):
Grep: pattern "fetch\(|axios\.|api\.(get|post|patch|put|delete)" glob "*.{ts,tsx,js,jsx}"
Grep: pattern "useQuery|useMutation|useInfiniteQuery|useSuspenseQuery" glob "*.{ts,tsx}"
Grep: pattern "createApi|injectEndpoints" glob "*.{ts,tsx}"
| File | Function/Hook | Method | Endpoint | Params | Used By |
|---|---|---|---|---|---|
services/user.ts | getUsers | GET | /api/users | page, limit | UserList.tsx |
hooks/useUser.ts | useUser | GET | /api/users/:id | id | UserProfile.tsx |
Grep: pattern "<ENDPOINT_PATH>" glob "*.{ts,js,py,go,rb}" — in backend source
App Router: app/api/<path>/route.ts must exist.
| Check | How |
|---|---|
| Required params sent | Compare FE call params with BE validation schema (Zod, Yup, Joi) |
| Naming convention match | FE camelCase vs BE snake_case — check if transform exists |
| Type match | FE sends string but BE expects number, or vice versa |
| Body shape match | Compare FE request body with BE expected schema |
If the backend reads from Supabase, verify the DB schema matches what the frontend expects:
supabase:execute_sql
{
"query": "SELECT column_name, data_type, is_nullable FROM information_schema.columns WHERE table_name = '<TABLE>' ORDER BY ordinal_position"
}
Compare columns/types to FE TypeScript interfaces.
| Issue | Impact | Detection |
|---|---|---|
| Endpoint does not exist | 404 errors | Grep backend for route — not found |
| Missing required parameter | 500/422 errors | Compare FE params with BE schema |
| Wrong HTTP method | 405 errors | FE uses GET, BE expects POST |
| Auth header missing | 401 errors | Check API client interceptor |
| Type mismatch | Runtime errors | FE interface vs BE response shape |
| Issue | Impact | Detection |
|---|---|---|
| Parameter name mismatch | Silently ignored params | camelCase vs snake_case comparison |
| Deprecated endpoint | Future breakage | Version markers in BE routes |
| Missing error handling | Poor UX | useQuery without error state handling |
| No loading state | Poor UX | No isLoading / isPending check |
| Issue | Impact | Detection |
|---|---|---|
| Duplicate requests | Wasted bandwidth | Same queryKey in multiple components |
| No caching configured | Slow UX | staleTime not set (default 0) |
| No request batching | Too many requests | N+1 query pattern in lists |
| Missing prefetch | Slow navigation | No prefetchQuery on hover/focus |
| No optimistic updates | Slow mutations | Mutation waits for server response |
staleTime per query from the data's real freshness need (user profile ~10 min, settings Infinity); default 0 refetches on every mount.const { data } = useQuery({
queryKey: ['user', userId],
queryFn: () => getUser(userId),
staleTime: 1000 * 60 * 10, // User data: 10 minutes
});
onMutate: cancel in-flight queries, snapshot getQueryData, setQueryData to the new value, return the snapshot.onError: restore the snapshot; onSettled: invalidate the key.queryClient.prefetchQuery with the same key and fn as the detail view, on link onMouseEnter/focus.retry: 3 with exponential retryDelay capped at 30 s; render isLoading, isError, and empty branches, in that order.type User = z.infer<...>, and UserSchema.parse(response.data) inside the service function.Full code for 6a–6e: references/fix-patterns.md.
Report sections, in order: header (date, framework, client, state library) → Production Error Summary (Sentry) → Critical Issues → Warnings → Optimization Opportunities (caching, prefetching, batching) → API Inventory (endpoint, method, FE file, BE route, status) → Type Safety Status → Research Findings Applied → Next Steps checklist.
Full template: references/report-template.md.
debug-fe-be-integration — live 4xx/5xx reproduction from BE logsaudit-db-schema — FE types vs DB columnsdebug-sentry-monitor — production error volume on the same endpointsWhat SKILL.md sets; muted values are Claude Code's defaults
highThree short reads, in order
npx claudepluginhub kensaurus/skills --plugin kenji162 skills in this plugin
/audit-accessibilityWCAG 2.2 AA audit via playwright-cli: axe-core, keyboard, contrast, target size, focus, ARIA. Use when "audit accessibility", "check a11y", "WCAG audit", "check keyboard nav", or "test screen reader".
/audit-agent-speedMeasure and fix a slow coding-agent setup: status line, hooks, instruction bloat, effort, worktree pile-up, antivirus and indexer scans. Use when "Claude is slow" or "CPU is pinned". App speed → audit-performance.
/audit-analyticsRead-only audit of product-analytics events (PostHog, Amplitude, Mixpanel, GA4): taxonomy, funnels, consent-gated firing, dead or duplicate events. Use when "audit our analytics", "are we tracking the right events", or "funnel instrumentation".
/audit-auth-flowsRead-only audit of app-layer auth: route×gate matrix, session lifecycle, OAuth, provider traps (getSession vs getUser, middleware-only gates, CVE-2025-29927). Use when "audit our auth" or "check middleware protection". RLS → plan-rls-audit.
/audit-backend-architectureRead-only backend-architecture audit and pattern advisor, gated by stack. Use when "audit backend architecture", "which pattern should I use", "am I over-engineering", or "sync vs event-driven". Enforced boundaries → enhance-arch-boundaries.
/audit-bundle-sizeAnalyse and shrink a web app's JavaScript bundle. Use when "reduce bundle size", "code splitting", "slow initial load", or "why is the bundle so big". Runtime → audit-performance.
Other plugins' skills for the same job