troubleshooting-guide

troubleshooting-guide is a cursor rule for Cursor from cnwinds/ai-detective. It costs 0 tokens per session (4,658 once invoked), scanned B, original, MIT.

A troubleshooting guide for a Python FastAPI application with an AI chat interface. It lists checks for import errors, package structure, server startup, API connections, blank pages, and streaming responses.

In plain words
What is it for?
Use it when Python modules cannot be imported, the FastAPI server will not start, the AI API fails, the frontend is blank, or chat output does not stream.
Why use it?
It gives developers a direct checklist for diagnosing common setup and runtime failures instead of guessing at the cause.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/cnwinds/ai-detective/troubleshooting-guide
Clone the repo
git clone --depth 1 https://github.com/cnwinds/ai-detective

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for troubleshooting-guide

README.md
[![agentmods](https://agentmods.dev/badge/rules/cnwinds/ai-detective/troubleshooting-guide.svg)](https://agentmods.dev/rules/cnwinds/ai-detective/troubleshooting-guide)
Your own site
<a href="https://agentmods.dev/rules/cnwinds/ai-detective/troubleshooting-guide"><img src="https://agentmods.dev/badge/rules/cnwinds/ai-detective/troubleshooting-guide.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 4,658 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 2 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.04658
Opus 5 $0.00000 $0.02329
Sonnet 5 $0.00000 $0.00932
Haiku 4.5 $0.00000 $0.00466

Measured 4d ago against content hash 579336f3fb19, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade B, and why

troubleshooting-guide scanned grade B with 2 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Asks for rootmediumPrivilege escalation

A mod that escalates privileges can change anything on the machine, not only the project.

sudo apt install certbot python3-certbot-nginx

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

const response = await fetch(url, {
.cursor/rules/troubleshooting-guide.mdc · 696 lines

How it starts

The opening of the file, as written. The whole thing — 696 lines — stays where its author put it; the contents beside it link to each section on GitHub.

故障排除和部署指南

常见问题诊断

项目结构问题

问题:模块导入失败

症状: ModuleNotFoundError: No module named 'xxx' 排查步骤:

  1. 检查backend目录是否有__init__.py文件
  2. 确认使用相对导入:from .module_name import ClassName
  3. 验证启动脚本中的导入路径:from backend.module_name import ClassName
  4. 检查Python路径设置和工作目录
问题:包结构错误

症状: 导入成功但运行时出现属性错误 排查步骤:

  1. 确认所有Python文件都在正确的目录中
  2. 检查backend/init.py文件存在
  3. 验证相对导入路径的正确性
  4. 重新启动Python解释器清除缓存

服务器启动问题

问题:FastAPI服务器无法启动

症状: 运行python start_game.py时出现错误 排查步骤:

  1. 检查Python版本 (需要3.7+)
  2. 验证依赖安装: pip install -r requirements.txt
  3. 检查端口占用: netstat -an | findstr :8000
  4. 查看错误日志中的具体错误信息
  5. 确认backend包结构正确
问题:OpenAI API连接失败

症状: AI对话功能不工作,返回API错误 排查步骤:

  1. 检查.env文件中的OPENAI_API_KEY
  2. 验证API密钥有效性和余额
  3. 检查网络连接和防火墙设置
  4. 查看backend/ai_service.py中的错误处理
  5. 确认backend/config.py配置正确

前端问题诊断

问题:页面无法加载或显示空白

症状: 浏览器显示空白页面或加载失败 排查步骤:

  1. 打开浏览器开发者工具查看控制台错误
  2. 检查网络标签页中的HTTP请求状态
  3. 验证静态文件路径是否正确
  4. 检查frontend/desktop.html中的资源引用
  5. 确认FastAPI服务器正常运行
问题:角色对话显示异常

症状: 切换角色时对话历史显示错误或重复 排查步骤:

  1. 检查conversationHistory数组结构
  2. 验证showCharacterConversation()方法逻辑
  3. 查看浏览器控制台中的JavaScript错误
  4. 确认角色ID和名称匹配正确
  5. 检查会话状态管理
问题:流式输出不工作

症状: AI回答不是逐字显示,而是一次性出现 排查步骤:

  1. 检查浏览器是否支持Server-Sent Events
  2. 验证流式API端点是否正常工作
  3. 查看网络请求中的响应类型
  4. 检查frontend/static/js/desktop.js中的流式处理逻辑

WebSocket连接问题

问题:实时通信失败

症状: 游戏状态不同步,WebSocket连接断开 排查步骤:

  1. 检查WebSocket连接URL是否正确
  2. 验证session_id是否有效
  3. 查看服务器端WebSocket处理逻辑
  4. 检查网络代理或防火墙设置
  5. 监控连接重试机制
问题:会话管理异常

症状: 游戏状态丢失或会话过期 排查步骤:

  1. 检查会话ID生成和存储
  2. 验证会话超时设置
  3. 查看服务器内存中的会话管理
  4. 检查浏览器本地存储

调试技巧

前端调试

JavaScript调试
// 在关键位置添加调试信息
console.log('当前游戏状态:', this.gameState);
console.log('对话历史:', this.conversationHistory);
console.log('选中角色:', this.selectedCharacter);

// 使用断点调试
debugger; // 浏览器会在此处暂停执行

// 检查DOM元素状态
console.log('角色列表元素:', document.getElementById('character-list'));
console.log('对话区域:', document.getElementById('conversation-area'));

// 监控状态变化
const originalUpdateState = this.updateGameState;
this.updateGameState = function(newState) {
    console.log('状态更新前:', this.gameState);
    console.log('新状态:', newState);
    originalUpdateState.call(this, newState);
    console.log('状态更新后:', this.gameState);
};

Read the full file on GitHub · 696 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 696 lines · 0 tokens per session scan B 579336f3fb19

Subscribe to this mod's changes

troubleshooting-guide is a cursor rule published in the GitHub repository cnwinds/ai-detective (6 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 4,658 tokens. A static security scan graded it B with 2 findings (asks for root, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.