返回 Skill 列表
extension
分类: 开发与工程无需 API Key

error-fixer

修复管理后台中为AI标记的JavaScript和HTTP错误。查询数据库中ai_status='flagged_for_ai'的错误,分析这些错误,并尝试修复它们。使用场景:- 用户说“修复错误”或“修复已标记的错误”- 用户说“检查错误队列”- 用户提到AI错误队列或AI标记的错误- 在管理后台标记错误后触发词:“修复错误”,“错误队列”,“AI错误”,“标记的错误”,“修复AI错误”,“/fix-errors”

person作者: jakexiaohubgithub

Error Fixer

Fetch and fix errors flagged for AI correction in the admin dashboard. Supports both JS errors (error_reports) and HTTP errors (http_error_logs).

Workflow

1. FETCH    → Get AI-flagged errors from both tables
2. ANALYZE  → Understand each error (stack trace, context, URL, status)
3. FIX      → Apply fixes using systematic debugging
4. MARK     → Mark errors as ai_fixed with notes
5. REPORT   → Summarize what was fixed

Step 1: Fetch Flagged Errors

Query both error tables using Supabase MCP:

JS Errors:

SELECT id, error_type, error_message, stack_trace, context, user_action, ai_prompt, created_at
FROM error_reports WHERE ai_status = 'flagged_for_ai'

HTTP Errors:

SELECT id, method, url, status_code, response_body, request_context, navigation_path, ai_prompt, created_at
FROM http_error_logs WHERE ai_status = 'flagged_for_ai'

Or use RPC functions: get_errors_for_ai() and get_http_errors_for_ai().

Important: The ai_prompt field contains specific instructions from the admin.

Step 2: Analyze Each Error

JS Errors

  1. Read the ai_prompt - Admin's instruction
  2. Parse stack trace - File path, line number, call chain
  3. Check context - route, action, other data
  4. Read affected file(s)

HTTP Errors

  1. Read the ai_prompt - Admin's instruction
  2. Check URL and status code - What endpoint failed and why
  3. Review response_body - Error message from server
  4. Check navigation_path - User's journey to this error
  5. Find the code - Locate fetch/API call that made this request

Step 3: Fix Using Systematic Debugging

DO NOT GUESS. Follow systematic-debugging:

  1. Understand root cause - Don't patch symptoms
  2. Find the actual source - Trace back through stack/code
  3. Make minimal fix - One change at a time
  4. Verify locally - Run build/tests after fix

Common JS Error Patterns

| Error Type | Common Fix | |------------|------------| | TypeError: Cannot read property 'x' of undefined | Add null checks, optional chaining | | TypeError: x is not a function | Check imports, verify function exists | | ChunkLoadError | Code splitting issue, check lazy imports | | NetworkError | Add error handling, retry logic |

Common HTTP Error Patterns

| Status | Common Fix | |--------|------------| | 400 Bad Request | Validate request params, check payload format | | 401/403 Unauthorized | Check auth token, verify RLS policies | | 404 Not Found | Verify endpoint exists, check URL construction | | 500 Server Error | Check Edge Function logs, fix server-side code | | CORS errors | Update Edge Function CORS headers |

Step 4: Mark as Fixed

JS Errors: Call mark_error_ai_fixed(p_id, p_fix_notes)

HTTP Errors: Call mark_http_error_ai_fixed(p_id, p_fix_notes)

Good fix notes examples:

  • "Added null check for user object in ProfileCard.tsx:45"
  • "Fixed RLS policy for authenticated users on topics table"
  • "Added missing CORS header to edge function"

Step 5: Report Summary

## Error Fix Summary

### JS Errors
#### Fixed (X)
- [error_type] in file.tsx:line - Brief description

#### Could Not Fix (X)
- [error_type] - Reason

### HTTP Errors
#### Fixed (X)
- [status_code] [method] /path - Brief description

#### Could Not Fix (X)
- [status_code] [method] /path - Reason

Database Schema Reference

-- error_reports (JS errors)
ai_status: 'pending' | 'flagged_for_ai' | 'ai_fixed' | 'verified'
ai_prompt: text
ai_fixed_at: timestamp
ai_fix_notes: text

-- http_error_logs (HTTP errors)
ai_status: 'pending' | 'flagged_for_ai' | 'ai_fixed' | 'verified'
ai_prompt: text
ai_fixed_at: timestamp
ai_fix_notes: text

-- RPC functions
get_errors_for_ai()              -- JS errors flagged for AI
get_http_errors_for_ai()         -- HTTP errors flagged for AI
mark_error_ai_fixed(p_id, p_fix_notes)       -- Mark JS error fixed
mark_http_error_ai_fixed(p_id, p_fix_notes)  -- Mark HTTP error fixed

Best Practices

  1. Always read ai_prompt first - Admin may have specific instructions
  2. Don't fix what you don't understand - Mark as "could not fix"
  3. Run build after fixes - Verify no new errors
  4. Write clear fix notes - Help admin understand what changed
  5. Group related errors - Multiple errors may have same root cause
  6. Check Edge Function logs - For HTTP 500 errors, use Supabase MCP get_logs