insforge-debug
Original:🇺🇸 English
Not Translated
Use this skill when encountering errors, bugs, performance issues, or unexpected behavior in an InsForge project — from frontend SDK errors to backend infrastructure problems. Trigger on: SDK returning error objects, HTTP 4xx/5xx responses, edge function failures or timeouts, slow database queries, authentication/authorization failures, realtime channel issues, backend performance degradation (high CPU/memory/slow responses), edge function deploy failures, or frontend Vercel deploy failures. This skill guides diagnostic command execution to locate problems; it does not provide fix suggestions.
2installs
Sourceinsforge/insforge-skills
Added on
NPX Install
npx skill4agent add insforge/insforge-skills insforge-debugSKILL.md Content
InsForge Debug
Diagnose problems in InsForge projects — from frontend SDK errors to backend infrastructure issues. This skill helps you locate problems by running the right commands and surfacing logs/status. It does NOT suggest fixes; hand the diagnostic output to the developer or their agent for repair decisions.
Always use — never install the CLI globally.
npx @insforge/cliQuick Triage
Match the symptom to a scenario, then follow that scenario's steps.
| Symptom | Scenario |
|---|---|
SDK returns | #1 SDK Error |
| HTTP 400 / 401 / 403 / 404 / 429 / 500 | #2 HTTP Status Code |
| Function throws or times out | #3 Edge Function Failure |
| Query slow or hangs | #4 Database Slow |
| Login fails / token expired / RLS denied | #5 Auth Failure |
| Channel won't connect / messages missing | #6 Realtime Issues |
| High CPU/memory, all responses slow | #7 Backend Performance |
| #8 Function Deploy |
| #9 Frontend Deploy |
Scenario 1: SDK Returns Error Object
Symptoms: SDK call returns . PostgREST error codes like , , etc.
{ data: null, error: { code, message, details } }PGRST301PGRST204Steps:
- Read the error object — extract ,
code,messagefrom the SDK response.details - Check aggregated error logs to find matching backend errors:
bash
npx @insforge/cli diagnose logs- Based on the error code prefix, drill into the relevant log source:
| Error pattern | Log source | Command |
|---|---|---|
| postgREST.logs | |
| Database/SQL errors | postgres.logs | |
| Generic 500 / server error | insforge.logs | |
- If the error is DB-related, check database health for additional context:
bash
npx @insforge/cli diagnose db --check connections,locks,slow-queriesInformation gathered: Error code, backend log entries around the error timestamp, database health status.
Scenario 2: HTTP Status Code Anomaly
Symptoms: API calls return 400, 401, 403, 404, 429, or 500.
Steps:
- Identify the status code from the response.
- Follow the path for that status code:
| Status | What to check | Command |
|---|---|---|
| 400 | Request payload/params malformed | |
| 401 | Auth token missing or expired | |
| 403 | RLS policy or permission denied | |
| 404 | Endpoint or resource doesn't exist | |
| 429 | Rate limit hit — no backend logs recorded | See 429 note below |
| 500 | Server-side error | |
- For 500 errors, also check aggregate error logs across all sources:
bash
npx @insforge/cli diagnose logs- 429 Rate Limit: The backend does not log 429 responses and does not return or
Retry-Afterheaders. Checking logs will not help. Instead:X-RateLimit-*- Review client code for high-frequency request patterns: loops without throttling, missing debounce, retry without exponential backoff, or parallel calls that could be batched.
- Check overall backend load to see if the system is under heavy traffic:
bash
npx @insforge/cli diagnose metrics --range 1h - A 429 status confirms the request was rate-limited. The fix is always on the client side: reduce request frequency, add backoff/debounce, or batch operations.
Information gathered: Status code context, relevant log entries, request/response details from logs. For 429: client-side request patterns and backend load metrics.
Scenario 3: Edge Function Execution Failure/Timeout
Symptoms: returns error, function times out, or throws runtime exception.
functions invokeSteps:
- Check function execution logs:
bash
npx @insforge/cli logs function.logs --limit 50- Verify the function exists and is active:
bash
npx @insforge/cli functions list- Inspect the function source for obvious issues:
bash
npx @insforge/cli functions code <slug>Information gathered: Function runtime errors, function status, source code, EC2 resource metrics.
Scenario 4: Database Query Slow or Unresponsive
Symptoms: Queries take too long, hang indefinitely, or connection pool is exhausted.
Steps:
- Check database health — slow queries, active connections, locks:
bash
npx @insforge/cli diagnose db --check slow-queries,connections,locks- Check postgres logs for query errors or warnings:
bash
npx @insforge/cli logs postgres.logs --limit 50- Check index usage and table bloat:
bash
npx @insforge/cli diagnose db --check index-usage,bloat,cache-hit,size- If the whole system feels slow, check EC2 instance metrics:
bash
npx @insforge/cli diagnose metrics --range 1hInformation gathered: Slow query details, connection pool state, lock contention, index efficiency, table bloat, cache hit ratio, EC2 resource usage.
Scenario 5: Authentication/Authorization Failure
Symptoms: Login fails, signup errors, token expired, OAuth callback error, RLS policy denies access.
Steps:
- Check insforge.logs for auth-related errors (login failures, token issues, OAuth errors):
bash
npx @insforge/cli logs insforge.logs --limit 50- Check postgREST.logs for RLS policy violations:
bash
npx @insforge/cli logs postgREST.logs --limit 50- Verify the project's auth configuration:
bash
npx @insforge/cli metadata --json- If RLS suspected, inspect current policies:
bash
npx @insforge/cli db policiesInformation gathered: Auth error details, RLS violation logs, auth configuration state, active RLS policies.
Scenario 6: Realtime Channel Issues
Symptoms: WebSocket won't connect, channel subscription fails, messages not received or lost.
Steps:
- Check insforge.logs for realtime/WebSocket errors:
bash
npx @insforge/cli logs insforge.logs --limit 50- Verify the channel pattern exists and is enabled:
bash
npx @insforge/cli db query "SELECT pattern, description, enabled FROM realtime.channels"- If access is restricted, check RLS on realtime tables:
bash
npx @insforge/cli db policies- If the issue is widespread (all channels affected), check overall backend health:
bash
npx @insforge/cli diagnoseInformation gathered: WebSocket error logs, channel configuration, realtime RLS policies, overall backend health.
Scenario 7: Backend Performance Degradation
Symptoms: All responses slow, high latency, intermittent failures across the board.
Steps:
- Check EC2 instance metrics — CPU, memory, disk, network:
bash
npx @insforge/cli diagnose metrics --range 1h- Check database health (often the bottleneck):
bash
npx @insforge/cli diagnose db- Check aggregate error logs:
bash
npx @insforge/cli diagnose logs- Check advisor for known critical issues:
bash
npx @insforge/cli diagnose advisor --severity criticalInformation gathered: CPU/memory/disk/network metrics (current and trend), database health, error log summary, advisor warnings.
Scenario 8: Edge Function Deploy Failure
Symptoms: command fails, function not appearing in the list after deploy.
functions deploy <slug>Steps:
- Re-run the deploy command and capture the error output:
bash
npx @insforge/cli functions deploy <slug>- Check deployment-related errors:
bash
npx @insforge/cli logs function-deploy.logs --limit 50- Verify whether the function exists in the list:
bash
npx @insforge/cli functions listInformation gathered: Deploy command error output, function deployment logs, function list status, backend error logs.
Scenario 9: Frontend (Vercel) Deploy Failure
Symptoms: command fails, deployment status shows error, Vercel build errors.
deployments deploySteps:
- Check recent deployment attempts:
bash
npx @insforge/cli deployments list- Get the status and error details for the failed deployment:
bash
npx @insforge/cli deployments status <id> --jsonThe output includes a object with Vercel-specific context: , , , , , (e.g., or ), etc. This metadata captures the full deployment context and can be used for debugging or AI-assisted investigation.
--jsonmetadatatargetfileCountprojectIdstartedAtenvVarKeyswebhookEventTypedeployment.succeededdeployment.error- Verify the local build succeeds before investigating further:
bash
npm run buildInformation gathered: Deployment history, deployment metadata (Vercel context, status, webhook events), local build output, backend deployment API logs.
Command Quick Reference
Logs
bash
npx @insforge/cli logs <source> [--limit <n>]| Source | Description |
|---|---|
| Main backend logs |
| PostgREST API layer logs |
| PostgreSQL database logs |
| Edge function execution logs |
| Edge function deployment logs |
Source names are case-insensitive.
Diagnostics
bash
# Full health report (all checks)
npx @insforge/cli diagnose
# EC2 instance metrics (CPU, memory, disk, network)
npx @insforge/cli diagnose metrics [--range 1h|6h|24h|7d] [--metrics <list>]
# Advisor scan results
npx @insforge/cli diagnose advisor [--severity critical|warning|info] [--category security|performance|health] [--limit <n>]
# Database health checks
npx @insforge/cli diagnose db [--check <checks>]
# checks: connections, slow-queries, bloat, size, index-usage, locks, cache-hit (default: all)
# Aggregate error logs from all sources
npx @insforge/cli diagnose logs [--source <name>] [--limit <n>]Supporting Commands
bash
# Project metadata (auth config, tables, buckets, functions, etc.)
npx @insforge/cli metadata --json
# Edge functions
npx @insforge/cli functions list
npx @insforge/cli functions code <slug>
# Secrets
npx @insforge/cli secrets list [--all]
npx @insforge/cli secrets get <key>
npx @insforge/cli secrets add <key> <value> [--reserved] [--expires <ISO date>]
# Database
npx @insforge/cli db policies
npx @insforge/cli db query "<sql>"
# Deployments
npx @insforge/cli deployments list
npx @insforge/cli deployments status <id> --json