agentsclimarketplace

Debug fe be integration

Skill kensaurus/cursor-kenji/skills/debug-fe-be-integration

πŸ¦–Curated Cursor AI agent skills, slash commands, MCP configs, subagents & rules for full-stack dev β€” React 19, Next.js 15, Supabase, Tailwind v4, TypeScript

Install
npx -y skills add kensaurus/cursor-kenji --skill debug-fe-be-integration

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 6 stars6 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Debug frontend-backend integration issues for any project by analyzing backend logs, identifying incorrect API calls, and fixing both sides. Auto-detects FE/BE frameworks, API style (REST/GraphQL/tRPC), and validation library. Uses Sentry MCP for production error context, Firecrawl for debugging pattern research, and Supabase MCP for data verification. Replaces hardcoded paths with auto-detected patterns. Use when diagnosing API errors, mismatched requests, integration issues between frontend and backend, or when the user mentions API 4xx/5xx errors, validation failures, or FE-BE contract mismatches.

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

12.0 KB, as published. Nobody here has run it

Frontend-Backend Integration Debug Skill

Systematic approach to debugging frontend-backend integration issues by analyzing backend logs, production errors, and source code to identify root causes and fix both sides.


Step 0: Auto-Detect Stack

Before debugging, discover the project's architecture.

0a. Detect Frontend Framework

Read package.json and look for:

SignalFramework
nextNext.js
nuxtNuxt
@remix-run/reactRemix
@sveltejs/kitSvelteKit
vite + reactVite React SPA
@angular/coreAngular

0b. Detect Backend Framework

Glob: **/app/api/**/route.ts β†’ Next.js App Router
Glob: **/pages/api/**/*.ts β†’ Next.js Pages Router
Glob: **/server/api/**/*.ts β†’ Nuxt server
Glob: **/src/routes/**/*.ts β†’ Express/Hono/Fastify
Glob: **/src/app.ts or **/src/index.ts β†’ Node backend entry
Glob: **/main.py or **/app.py β†’ Python backend
Glob: **/main.go β†’ Go backend

0c. Detect API Style and Validation

SignalTechnology
@trpc/servertRPC (type-safe, no REST audit needed)
graphql or @apollo/serverGraphQL
zod in BE dependenciesZod validation
joi in BE dependenciesJoi validation
yup in BE dependenciesYup validation
class-validatorNestJS-style validation
pydanticPython Pydantic validation

0d. Find Route and Controller Patterns

Grep: pattern "router\.(get|post|patch|put|delete)" glob "*.{ts,js}" β€” Express-style
Grep: pattern "app\.(get|post|patch|put|delete)" glob "*.{ts,js}" β€” Hono/Express
Grep: pattern "export (async function |const )(GET|POST|PATCH|PUT|DELETE)" glob "**/route.ts" β€” Next.js
Grep: pattern "defineEventHandler" glob "*.{ts,js}" β€” Nuxt/H3

0e. Record Discovery

STACK DISCOVERY:
- Frontend: [framework + version]
- Backend: [framework + version]
- API style: [REST / GraphQL / tRPC]
- Validation: [Zod / Joi / Yup / Pydantic / none]
- Route files: [pattern and locations]
- Controller files: [pattern and locations]
- Schema files: [pattern and locations]

Step 1: Research Debugging Patterns

1a. Firecrawl β€” Integration Debugging

firecrawl:firecrawl_search
{
 "query": "<FE_FRAMEWORK> <BE_FRAMEWORK> API integration debugging best practices [current year]",
 "limit": 5,
 "sources": [{ "type": "web" }]
}

Additional targeted searches:

TopicQuery
Validation errors<VALIDATION_LIB> error handling API response best practices
CORS issues<BE_FRAMEWORK> CORS configuration debugging
Type mismatchesTypeScript API type safety frontend backend shared types

1b. Context7 β€” Framework Docs

context7:resolve-library-id
{
 "libraryName": "<VALIDATION_LIB>",
 "query": "error handling error messages custom errors"
}

Step 2: Gather Error Evidence

2a. Check Sentry for Production Errors

sentry:search_issues
{
 "organizationSlug": "<ORG_SLUG>",
 "query": "API integration errors 4xx 5xx validation from the last 7 days",
 "projectSlugOrId": "<PROJECT_SLUG>",
 "regionUrl": "<REGION_URL>",
 "limit": 25
}

If the project has separate FE and BE Sentry projects, check both:

  • FE project: network errors, unhandled rejections from API calls
  • BE project: validation errors, unhandled exceptions, 500s

2b. Read Backend Terminal Logs

Read the terminal files for the running backend process:

Read: terminals/*.txt β€” find the terminal running the backend (npm run dev, etc.)

Look for errors in the last 3-5 minutes:

  • 4xx errors (400, 401, 403, 404, 422)
  • 5xx errors (500, 502, 503)
  • ZodError / ValidationError β€” validation failures
  • AppError / custom error classes
  • Stack traces
  • Warning messages

2c. Categorize Errors Found

CategoryLog PatternRoot Cause
Missing parameterZodError: expected string, received undefinedFE not sending required param
Wrong typeZodError: invalid_typeFE sending wrong type
Endpoint not found404 /api/...FE calling non-existent endpoint
Auth error401 UnauthorizedMissing or invalid token
Permission error403 ForbiddenUser lacks permission
Validation error422 UnprocessableInvalid request body
Server error500 InternalBackend bug
CORS errorCORS policyMissing CORS configuration

Step 3: Trace Errors to Source Code

3a. Map Errors to Endpoints

For each error found, use Grep to locate:

Frontend call:

Grep: pattern "<ERROR_ENDPOINT>" glob "*.{ts,tsx,js,jsx}"

Backend route:

Grep: pattern "<ERROR_ENDPOINT>" glob "*.{ts,js,py,go,rb}" β€” in backend source

Validation schema:

Grep: pattern "z\.object|z\.string|z\.number" in the controller/route file
SemanticSearch: "validation schema for <ENDPOINT>" target: [backend directory]

3b. Read the Full Chain

For each error, read the complete request chain:

  1. Frontend call β€” Read the file making the API call (service, hook, or component)
  2. API client config β€” Read the axios/fetch interceptor configuration
  3. Backend route β€” Read the route handler
  4. Backend controller β€” Read the controller/service logic
  5. Validation schema β€” Read the Zod/Joi/Yup schema for the endpoint
  6. Database query β€” Read the DB query (if the error is data-related)

3c. Verify Data State with Supabase MCP

If the error might be data-related:

supabase:execute_sql
{
 "project_id": "<PROJECT_ID>",
 "query": "SELECT * FROM <TABLE> WHERE <CONDITION> LIMIT 5"
}

Check:

  • Does the data the FE expects actually exist?
  • Are enum values correct?
  • Are foreign key relationships intact?
  • Does the RLS policy allow access for this user?

Step 4: Generate Fix Recommendations

4a. Frontend Fixes

For each error, provide:

### Issue: [Endpoint] β€” [Error Type]

**Current FE Call:**
[show the actual code from Grep results]

**Correct FE Call:**
[show the fixed code]

**Why:** [explanation of required parameter/type/format]

**Files to Update:** [list specific files]

4b. Backend Enhancements

For each error, consider backend improvements:

### Backend Enhancement: [Endpoint]

**Current Behavior:** Returns 500 with cryptic validation error

**Recommended Enhancement:**
- Add default value for optional params
- Add clear error message for required params
- Add type coercion where appropriate
- Return helpful 422 instead of 500

Example backend enhancement pattern:

// Before: bare schema, cryptic error on missing param
const schema = z.object({
 year: z.string(),
});

// After: defaults, coercion, clear errors
const schema = z.object({
 year: z.string({
 required_error: "year is required (format: YYYY)"
 }).default(() => new Date().getFullYear().toString()),
 page: z.coerce.number().default(1).int().positive(),
 limit: z.coerce.number().default(10).int().max(100),
});

Step 5: Backend Robustness Checklist

Input Validation

  • All required params have clear error messages
  • Default values for optional params with sensible defaults
  • Type coercion where appropriate (string to number)
  • Range validation (dates, numbers)
  • Format validation (email, UUID, date strings)

Error Handling

  • Catch and wrap database errors
  • Provide actionable error messages (not "Internal Server Error")
  • Log errors with context (userId, endpoint, params)
  • Do not expose internal details to client (stack traces, SQL)

API Contract Consistency

  • Response shape is consistent ({ data } or { error })
  • Status codes are correct (200 success, 201 create, 204 delete)
  • Pagination format is consistent across all list endpoints
  • Date formats are consistent (ISO 8601)
  • Error response shape is consistent

Output Template

## Frontend-Backend Integration Debug Report

**Analyzed:** [timestamp range]
**Frontend:** [framework]
**Backend:** [framework]
**API style:** [REST/GraphQL/tRPC]

---

### Production Errors (Sentry)

| Endpoint | Error | Events (7d) | Root Cause |
|----------|-------|-------------|------------|
| [endpoint] | [error msg] | [count] | [FE/BE/Data] |

---

### Backend Log Errors

| Endpoint | Method | Status | Error Type | Root Cause |
|----------|--------|--------|------------|------------|
| `/api/...` | GET | 500 | ZodError | Missing `year` param |
| `/api/...` | GET | 404 | Not Found | Endpoint not implemented |

---

### Critical Issues (Must Fix)

#### 1. [Endpoint] β€” [Status Code]
- **Error:** [error message]
- **Root Cause:** [explanation]
- **Frontend Fix:** [what FE needs to change, with code]
- **Backend Enhancement:** [optional BE improvement, with code]
- **Files:** FE: [path], BE: [path]

---

### Warnings (Should Fix)

#### 1. [Issue description]
- **Impact:** [what happens if not fixed]
- **Recommendation:** [how to fix]

---

### Backend Enhancements (Robustness)

#### 1. [Enhancement description]
- **Current:** [current behavior]
- **Recommended:** [better approach]
- **Benefit:** [why this helps]

---

### Research Findings Applied
- [Pattern from research]: [how it applies]
- [Best practice]: [gap identified]

---

### Summary Table

| Endpoint | Issue | Fix Required | Priority |
|----------|-------|--------------|----------|
| `/api/...` | Missing param | Frontend | HIGH |
| `/api/...` | No error handling | Both | MEDIUM |
| `/api/...` | Endpoint 404 | Remove or implement | LOW |

---

### Next Steps

1. [ ] Frontend fixes: [action items with files]
2. [ ] Backend enhancements: [action items with files]
3. [ ] Re-test: [verification steps]
4. [ ] Monitor: Check Sentry after deploy for regression

Common Patterns and Fixes

Pattern 1: Missing Query Parameter

Symptom: ZodError: expected string, received undefined

FE Fix: Add the missing parameter to the API call.

BE Fix: Add a default value or a clear error message.

Pattern 2: Endpoint Not Found (404)

Symptom: 404 /api/endpoint-name

Debug steps:

  1. Grep for the endpoint path in backend route files
  2. Check if the endpoint exists under a different name
  3. Check API docs if available
  4. Decide: remove FE call, fix typo, or implement endpoint

Pattern 3: Service Failure (500)

Symptom: 500 Internal Server Error with no useful message

Debug steps:

  1. Read the backend controller for unhandled exceptions
  2. Check if the service handles DB errors gracefully
  3. Check RLS policies if using Supabase (data might be blocked)
  4. Add try/catch with meaningful error responses

Pattern 4: CORS Error

Symptom: CORS policy: No 'Access-Control-Allow-Origin'

Debug steps:

  1. Check backend CORS configuration
  2. Verify the origin, methods, and headers allowed
  3. Check if credentials mode matches between FE and BE

Pattern 5: Duplicate / Stale Requests

Symptom: Same API called multiple times, or stale data shown

Debug steps:

  1. Check if TanStack Query / SWR staleTime is configured
  2. Check if cache invalidation happens after mutations
  3. Check if the queryKey is correct and unique
  4. Check for component re-mount causing refetch

Integration with Other Skills

  • fe-api-audit: Proactive audit from FE code perspective (run first).
  • sentry-monitor: Triage and fix Sentry errors from production.
  • db-schema-audit: Verify DB schema matches API expectations.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.