# Debug Analysis

> 深度调试分析 - 直接调用 Gemini/Codex CLI 进行系统性问题诊断，支持会话延续。

- **Type:** Skill
- **Install:** `agentstack add skill-materialofair-oh-my-antigravity-debug-analysis`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [materialofair](https://agentstack.voostack.com/s/materialofair)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [materialofair](https://github.com/materialofair)
- **Source:** https://github.com/materialofair/oh-my-antigravity/tree/main/.agent/skills/local/debug-analysis
- **Website:** https://github.com/materialofair/oh-my-antigravity

## Install

```sh
agentstack add skill-materialofair-oh-my-antigravity-debug-analysis
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Debug Analysis - 深度调试分析 Skill

## 🎯 核心功能

通过直接调用 Gemini 和 Codex CLI，进行系统性问题诊断和根因分析。

**替代**: PAL MCP debug 工具

## 📋 触发场景

**自动触发**:
- "调试问题"
- "系统性错误分析"
- "debug 这个问题"
- "根因分析"
- "为什么出现这个错误"

**手动触发**:
```
使用 debug-analysis 分析：
```

## 🔄 Workflow

### Step 1: 问题收集

收集问题的完整信息：
- 错误信息
- 日志片段
- 相关代码
- 复现步骤
- 环境信息

### Step 2: Gemini 深度分析 (1M 上下文)

**⚠️ 重要: 优先使用 `gemp` (长任务优化版)，`gemini` CLI 作为备用**

```bash
# Step 1: 写入 prompt 到临时文件
cat > /tmp/gemini_debug_prompt.txt 

【错误日志】

【相关代码】

请进行系统性分析：
1. 问题表象分析
2. 可能的根本原因 (列出3-5个假设)
3. 验证方法
4. 修复建议

使用结构化思维，逐步推理。
PROMPT_EOF

# Step 2: 优先使用 gemp (20分钟超时，输出纯净)
cat /tmp/gemini_debug_prompt.txt | node ~/.gemini/long_task_runner.js 2>&1
```

**备用方案** (如果 gemp 失败):
```bash
cat /tmp/gemini_debug_prompt.txt | gemini --yolo 2>&1 | grep -v "STARTUP\|YOLO\|Load"
```

### Step 3: Codex 代码层面诊断

```bash
codex exec --json --dangerously-bypass-approvals-and-sandbox \
  --enable web_search_request \
  -c 'mcp_servers={}' \
  "作为代码诊断专家，分析以下问题：

【问题描述】

【代码片段】

请从代码层面诊断：
1. 代码逻辑问题
2. 边界条件检查
3. 异常处理缺陷
4. 并发/竞态问题
5. 具体修复代码

给出可直接使用的修复方案。
" 2>&1 | grep '"type":"item.completed"' | tail -1 | python3 -c "
import sys, json
data = json.loads(sys.stdin.read())
print(data['item']['text'])
"
```

### Step 4: Claude 综合诊断

基于两个模型的分析，Claude 提供：

1. **根因确认**
   - 最可能的根本原因
   - 证据支持
   - 确信度评估

2. **修复方案**
   - 立即修复 (临时方案)
   - 彻底修复 (根本方案)
   - 预防措施

3. **验证步骤**
   - 如何验证修复有效
   - 测试用例建议

## 📊 输出格式

```markdown
## 🔍 深度调试分析报告

**问题**: [问题描述]

---

### 🤖 Gemini 系统分析 (深度推理)

**问题表象**:
[问题的外在表现]

**根因假设** (优先级排序):
1. **假设1**: [描述] (可能性: 80%)
   - 证据: [...]
   - 验证: [...]

2. **假设2**: [描述] (可能性: 15%)
   - 证据: [...]
   - 验证: [...]

**详细分析**:
[Gemini 的完整推理过程]

---

### 💻 Codex 代码诊断

**代码层面问题**:
- [问题1]
- [问题2]

**具体修复方案**:

```typescript
// 修复前

// 修复后

```

**修复说明**:
[Codex 的详细解释]

---

### 🎯 Claude 综合诊断

#### 根本原因

**确定的根因**: [最可能的原因]

**确信度**: [高/中/低]

**证据**:
- 证据1: [...]
- 证据2: [...]

#### 修复方案

**方案1: 立即修复** (临时)
```typescript

```
- 优点: [...]
- 缺点: [...]
- 适用场景: 紧急上线

**方案2: 彻底修复** (推荐)
```typescript

```
- 优点: [...]
- 实施步骤:
  1. [步骤1]
  2. [步骤2]

#### 验证步骤

**1. 单元测试**:
```typescript
test('修复后不应出现错误', () => {
  // 测试用例
});
```

**2. 集成测试**:
- [测试场景1]
- [测试场景2]

**3. 监控指标**:
- 错误率应降至  /tmp/gemini_debug1.txt &1

# 第二轮：深入某个假设
cat > /tmp/gemini_debug2.txt &1

# 第三轮：验证方案
cat > /tmp/gemini_debug3.txt &1
```

**备用方案** (gemini CLI 多轮):
```bash
gemini -p "分析这个错误..." --yolo
gemini -p "深入分析假设1..." --resume latest --yolo
```

## ⚠️ 错误处理

### CLI 调用失败

**降级策略**:
- Gemini 失败 → Codex + Claude
- Codex 失败 → Gemini + Claude
- 都失败 → Claude 单模型分析

## 🆚 vs PAL MCP Debug

| 特性 | PAL MCP | Direct CLI Skill |
|------|---------|-----------------|
| 超时问题 | ❌ 容易超时 | ✅ 不会超时 |
| 深度推理 | ✅ 支持 | ✅ Gemini 原生支持 |
| 代码诊断 | ✅ 支持 | ✅ Codex GPT-5 |
| 上下文延续 | ✅ continuation_id | ✅ --resume |
| 调试难度 | ❌ 黑盒 | ✅ 透明 |

---

**创建时间**: 2025-12-19
**版本**: v1.0
**替代**: PAL MCP debug 工具

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [materialofair](https://github.com/materialofair)
- **Source:** [materialofair/oh-my-antigravity](https://github.com/materialofair/oh-my-antigravity)
- **License:** MIT
- **Homepage:** https://github.com/materialofair/oh-my-antigravity

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-materialofair-oh-my-antigravity-debug-analysis
- Seller: https://agentstack.voostack.com/s/materialofair
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
