home / skills / cacr92 / wereply / debugging

debugging skill

/.trae/skills/debugging

This skill helps you diagnose and resolve debugging issues efficiently across Rust, React, and database layers by guiding reproduction and validation.

npx playbooks add skill cacr92/wereply --skill debugging

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
1.1 KB
---
name: debugging
description: 当用户要求排查Bug、定位问题、异常排查或性能瓶颈时使用。
---

# Debugging Skill

## 适用范围
- Rust/Tauri 后端问题排查
- React 前端状态与渲染异常
- 数据库/迁移问题

## 关键规则(Critical Rules)
- 先复现,再定位
- 优先缩小范围与影响面
- 记录关键输入与边界条件

## 系统化流程
1. 复现问题(最小输入)
2. 收集上下文(日志、参数、数据状态)
3. 提出假设并验证
4. 修复后回归验证

## 常见检查点
- Tauri 命令未注册:检查 `#[tauri::command]` 与 `#[specta::specta]`
- 类型不匹配:检查 DTO `specta::Type` 与 camelCase
- 数据库错误:确认迁移已执行、表名/字段名正确
- React 过度渲染:检查依赖与 `useMemo`/`useCallback`

## 工具建议
- Rust:使用 `tracing` 记录关键路径
- DB:使用 `EXPLAIN QUERY PLAN` 分析索引
- 前端:用 UI 提示展示关键状态,避免 `console.*`

## 检查清单
- [ ] 已复现并最小化输入
- [ ] 已验证关键假设
- [ ] 修复后回归验证通过

Overview

This skill helps diagnose and resolve bugs, exceptions, and performance bottlenecks for a chat auto-reply assistant built with Rust/Tauri backend, React frontend, and relational databases. It focuses on reproducible investigation, targeted narrowing of scope, and validated fixes. The goal is fast root-cause identification and reliable regression verification.

How this skill works

Start by reproducing the issue with the smallest possible input and environment. Collect contextual data—logs, request/response parameters, DB state, and UI signals—then form testable hypotheses and validate them iteratively. Apply fixes, then run focused regression checks to confirm the problem is resolved without regressions.

When to use it

  • App crashes, unhandled exceptions, or native command failures in the Tauri backend
  • React UI state mismatches, rendering glitches, or unexpected re-renders
  • Slow queries, missing data, or migration-related errors in the database
  • Intermittent issues that require narrowing input and reproducing reliably
  • When you need a systematic, repeatable approach to validate a fix

Best practices

  • Always reproduce the bug with a minimal input or scenario before changing code
  • Log structured, contextual events (use tracing in Rust) covering inputs, decisions, and errors
  • Shrink the blast radius: isolate components (backend, frontend, DB) to find the layer causing the issue
  • Record boundary conditions and critical inputs so fixes are verifiable and repeatable
  • Use EXPLAIN/EXPLAIN QUERY PLAN for slow queries and add indexes based on evidence
  • Avoid relying solely on console logs in production; surface key states in UI tests or health checks

Example use cases

  • Tauri command not found: verify #[tauri::command] attributes and exposed signatures, then reproduce locally
  • React excessive renders: reproduce with a simple component, check dependency arrays, and apply useMemo/useCallback
  • Database migration error: confirm migrations ran, compare expected and actual schemas, and run targeted rollback/reapply
  • Performance hotspot: capture slow request traces with tracing, analyze DB plan, and optimize the hot path
  • Intermittent message delivery: log message lifecycle across frontend, backend, and DB to identify where it drops

FAQ

What should I capture in logs to speed debugging?

Capture timestamps, request IDs, input parameters, user identifiers, decision points, and error stacks; structured logs make correlation across services straightforward.

How do I minimize false leads during investigation?

Use a minimal reproducible test, isolate components, and validate one hypothesis at a time. Revert any speculative changes if they don’t pass targeted tests.