跳到正文
cccskills
免费在 GitHub 公开

backend-debugging

Debug backend runtime errors (500s, crashes, unexpected behavior). Use when something is broken at runtime — not for writing new code.

中文简介正在准备中。当前显示原文说明。

ayunis-core/ayunis-core星标 34(GitHub 34 + cccskills 0)

实测评分 未实测

查看安装方法

包含的文件(1)

  • SKILL.md3.9 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Backend Debugging

Step 0 — If it's a regression, check git history first

When the user reports "it worked before X" / "broke after the refactoring" / "used to work" — read the git history of the affected code path before proposing any fix. A defensive try/catch or null check is the wrong opening move on a regression; the bug is almost always something a recent commit dropped (a break, a return, a case arm, a relation in a query).

# Find the commits that touched the failing handler/file:
git log --oneline -20 -- <path/to/handler.ts>

# Diff against the last-known-good state:
git show <commit>:<path/to/handler.ts>
git log -p -5 -- <path/to/handler.ts>

The fix is then "restore what was lost," not "patch around the symptom." Only after you have the diff against the working version should you consider defensive code.

Step 1 — Read the logs

Before reading code, guessing, or querying the database, check the backend logs:

# From the repo root (slot is remembered from ./dev up):
./dev logs backend                # Last 80 lines
./dev logs --tail 200 backend     # More context

# Or read the log file directly:
cat .dev/slot-$(cat .dev/slot)/backend.log

The logs contain full stack traces with file names and line numbers. This tells you exactly what's broken — no guessing needed.

Do not skip this step. Code review without the actual error is guesswork.

Step 2 — Reproduce the error

Confirm the error independently with curl. This isolates whether the problem is backend vs. frontend vs. CORS:

# Login first (adjust credentials as needed):
curl -s -c /tmp/cookies.txt http://localhost:3020/api/auth/login \
  -X POST -H 'Content-Type: application/json' \
  -d '{"email":"...","password":"..."}'

# Hit the failing endpoint:
curl -s -b /tmp/cookies.txt "http://localhost:3020/api/..." | head -50

Replace port 3020 with whatever the current slot uses. Check with ./dev status.

Recognizing CORS errors

If the browser console shows "blocked by CORS policy" but the request returns a valid status code (e.g., 201), the backend works — the browser is rejecting the response. Look for:

  • Hardcoded Access-Control-Allow-Origin headers in the controller that override the global CORS middleware
  • The global CORS config in src/main.ts — in development mode (NODE_ENV !== 'production') it should allow all origins

Step 3 — Go to the error location

The stack trace gives you the exact file and line. Read that code. Common patterns:

"Cannot read properties of undefined (reading 'map')"

A relation wasn't loaded by TypeORM but the mapper assumes it's always present. Fix with optional chaining:

// Before — crashes when relation not loaded:
items.map(x => ...)

// After:
items?.map(x => ...) ?? []

This is especially common when:

  • A findAll query doesn't load the same relations as findOne
  • Eager relations don't cascade through deeply nested joins (e.g., thread → sourceAssignments → source → details → contentChunks)

"Invalid source type" / "Invalid message role"

A mapper's instanceof or switch doesn't cover all cases. Check what the database actually contains:

# Quick database query through the dev stack:
cd ayunis-core-backend
pnpm exec ts-node -r tsconfig-paths/register -e "
import './src/config/env';
import { DataSource } from 'typeorm';
// ... query the relevant table
"

Step 4 — Fix, verify, check logs again

  1. Make the fix
  2. Wait for nest --watch to reload (or check ./dev logs backend for compilation errors)
  3. Re-run the curl command from Step 2
  4. Check ./dev logs backend to confirm no new errors
  5. Load nestjs-hexagonal-backend and run its validation sequence at the level required by the repository's Proportional Workflow.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Query Ayunis deployed-environment telemetry in AppSignal — incidents, occurrence counts and error traces via the `appsignal-cli` binary; structured log attributes (user.id, org.id, nestjs.context, custom metadata) via the v2 logs API. Use when investigating a production/staging incident or log data — NOT for local dev logs (see backend-debugging).

中文简介正在准备中。当前显示原文说明。

ayunis-core/ayunis-core342026年10月26日 更新

Ayunis Core backend specifics — module boundaries, key files, and project conventions. Complements the nestjs-hexagonal-backend skill.

中文简介正在准备中。当前显示原文说明。

ayunis-core/ayunis-core342026年10月26日 更新

Frontend development in ayunis-core. Use when creating, modifying, or debugging frontend code (React, Feature-Sliced Design, API client).

中文简介正在准备中。当前显示原文说明。

ayunis-core/ayunis-core342026年10月26日 更新

Shared test fixtures for backend specs — port mock factories, domain builders, and shared IDs in a per-module testing/ folder. Use when a module's *.use-case.spec.ts files repeat the same mock-repository literal, inline entity construction, or hardcoded UUIDs across files.

中文简介正在准备中。当前显示原文说明。

ayunis-core/ayunis-core342026年10月26日 更新

Analyze Cursor Bugbot PR comments through a root-cause lens: is the finding valid, and is the suggested fix the real fix or a bandaid over a deeper problem? Use when the user asks to check, assess, or triage bugbot comments.

中文简介正在准备中。当前显示原文说明。

ayunis-core/ayunis-core342026年10月26日 更新

Self-review local changes before creating a PR. Use when the user says "review", "review my code", "check my changes", or wants confidence before submitting.

中文简介正在准备中。当前显示原文说明。

ayunis-core/ayunis-core342026年10月26日 更新

查看 ayunis-core 的全部技能

报告此技能的问题