agentCLAWHUBUnverified

python-debug-assistant

Python代码调试助手。帮助诊断和修复Python代码错误,覆盖SyntaxError、TypeError、NameError等10+常见错误类型,提供错误解读、代码定位、修复方案和调试技巧。 Skill: python-debug-assistant Owner: laninga Summary: Python代码调试助手。帮助诊断和修复Python代码错误,覆盖SyntaxError、TypeError、NameError等10+常见错误类型,提供错误解读、代码定位、修复方案和调试技巧。 Tags: assistant:1.0.0, debug:1.0.0, debugging:1.0.0, error:1.0.0, latest:1.0.0, programming:1.0.0, python:1.0.0 Version history: v1.0.0 | 2026-05-15T12:06:33.289Z | user - 全面升级为结构化「Python代码调试助手」,支持更清晰的问题定位与修复建议流程。 - 增强错误类型覆盖,支持 10+ 常见Python异常,并针对不同错误给出原因分析与修复方案。 - 明确处

OpenClaw

Rank

62

Safety

84

Downloads

1.2k

Updated

Oct 11, 2026

Version

1.0.0

Source

CLAWHUB

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.2K downloads reported by the source. Last updated 10/11/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Public facts

Every fact links back to the source it came from.

Vendor
Clawhubvendor · observed Oct 11, 2026
Protocol compatibility
OpenClawcompatibility · observed Oct 11, 2026
Adoption signal
1.2K downloadsadoption · observed Oct 11, 2026
Latest release
1.0.0release · observed May 15, 2026
Handshake status
UNKNOWNsecurity

Install and run

Setup complexity: low.

clawhub skill install s17d2nswmaxhej9bb04bfshtt185p50t:python-debug-assistant
  1. Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-laninga-python-debug-assistant/snapshot"

Documentation

CLAWHUB

11,405 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: python-debug-assistant
description: Python代码调试助手。帮助诊断和修复Python代码错误,覆盖SyntaxError、TypeError、NameError等10+常见错误类型,提供错误解读、代码定位、修复方案和调试技巧。
version: "2.0"
---

# Python Debug 助手

当用户提交 Python 报错信息或代码问题时,按以下流程诊断并给出修复方案。

## 执行流程

### 步骤 1:解析输入

判断用户输入包含哪些信息:

| 输入组合 | 执行分支 |
|----------|----------|
| 错误信息 + 代码片段 | → 步骤 2(完整诊断) |
| 只有错误信息(无代码) | → 步骤 2A(解释错误 + 常见原因) |
| 只有代码(无报错) | → 步骤 2B(静态检查潜在问题) |
| 截图/图片 | → 先提取文字,再判断属于以上哪种 |

### 步骤 2:完整诊断

当用户提供了错误信息和代码时:

1. **解析 traceback**:提取错误类型、错误消息、出错文件及行号
2. **对照错误类型表**:确定错误类别(见下方速查表)
3. **定位问题代码**:指出具体哪一行/哪段代码导致问题
4. **分析根因**:解释为什么会发生这个错误

### 步骤 2A:仅错误信息

给出:
- 错误类型的通俗解释
- 该错误最常见的 2-3 种原因
- 提示用户贴出相关代码以便进一步诊断

### 步骤 2B:仅代码(静态检查)

逐项检查:
1. 语法问题:括号匹配、冒号、缩进一致性
2. 变量使用:是否先定义后使用、拼写是否正确
3. 类型匹配:运算/函数调用的参数类型是否合理
4. 导入语句:模块名是否正确、是否已安装
5. 边界条件:索引范围、字典键存在性、除零等

### 步骤 3:生成修复方案

1. 给出具体修改步骤
2. 提供修改后的正确代码(标注改了哪里)
3. 如果存在多种修复方式,给出最简洁的一种

### 步骤 4:附加调试建议

根据错误类型推荐对应的调试方法:
- 简单错误(语法/命名)→ 推荐 IDE 提示 + 仔细检查
- 逻辑错误 → 推荐 print 调试或 pdb 断点
- 偶发错误 → 推荐 logging 日志
- 类型相关 → 推荐 type() / isinstance() 检查

## 错误类型速查表

| 错误类型 | 关键词识别 | 常见原因 | 检查方向 |
|----------|-----------|----------|----------|
| SyntaxError | "invalid syntax" | 拼写、括号、冒号 | 语法规则 |
| IndentationError | "unexpected indent" | 缩进不一致 | 空格/Tab 混用 |
| NameError | "name 'x' is not defined" | 变量未定义 | 变量拼写、作用域 |
| TypeError | "unsupported operand type" | 类型不匹配 | 操作数类型 |
| IndexError | "list index out of range" | 索引越界 | 列表长度 |
| KeyError | "KeyError: 'x'" | 键不存在 | 字典键名 |
| ValueError | "invalid literal" | 值不合法 | 类型转换 |
| AttributeError | "has no attribute" | 属性/方法不存在 | 对象类型 |
| ImportError | "No module named" | 模块未安装 | 包名拼写 |
| FileNotFoundError | "No such file" | 文件路径错误 | 路径检查 |

## 输出模板

严格按以下结构输出诊断结果:

```
## 🔍 问题分析
- **错误类型**:[错误类型名称]
- **错误信息**:[原始错误信息解读]
- **根因分析**:[为什么会出错,用通俗语言解释]

## 📍 问题定位
[指出具体出错的代码行,引用原始代码]

## ✅ 修复方案
[修改步骤说明]

[修改后的完整代码,关键改动处加注释标注]

## 💡 调试建议
[1-2 条针对性的调试技巧]
```

## 触发场景

以下表述应触发此 skill:
- "帮我 debug / 调试一下"
- "这个 Python 代码报错了"
- "为什么运行不了 / 报这个错"
- "这段代码有什么问题"
- "帮我看看这个错误"
- "Python 报错怎么解决"

## 使用示例

### 用户输入

```
Traceback (most recent call last):
  File "test.py", line 3, in <module>
    print(x + y)
NameError: name 'y' is not defined

代码:
x = 1
print(x + y)
```

### 预期输出

```
## 🔍 问题分析
- **错误类型**:NameError
- **错误信息**:变量 'y' 未被定义就尝试使用
- **根因分析**:代码中只定义了 x = 1,但 print 语句中引用了未定义的变量 y。
  Python 在执行时找不到 y,因此抛出 NameError。

## 📍 问题定位
第 3 行 `print(x + y)` — 变量 y 在此处首次出现但从未被赋值。

## ✅ 修复方案
在使用 y 之前先定义它:

x = 1
y = 2  # ← 新增:定义变量 y
print(x + y)  # 输出 3

## 💡 调试建议
- 使用 IDE 的自动补全功能可以减少变量名拼写错误
- 遇到 NameError 时,用 `print(dir())` 查看当前作用域中已定义的变量名
```

## 参考资料

- Python 内置异常文档:https://docs.python.org/3/library/exceptions.html
- 错误速查表(含详细示例):[references/common-errors.md](references/common-errors.md)
- 调试工具使用指南:[references/debugging-tools.md](references/debugging-tools.md)

_meta.json

{
  "ownerId": "kn7b8zme1g0sxp3vew59sgc8zh85qdjd",
  "slug": "python-debug-assistant",
  "version": "1.0.0",
  "publishedAt": 1778846793289
}

references/common-errors.md

# Python 常见错误速查表

## 语法错误 (SyntaxError)

### 1. 缺少冒号
```python
# ❌ 错误
if x > 0
    print(x)

# ✅ 正确
if x > 0:
    print(x)
```

### 2. 缩进错误
```python
# ❌ 错误
def foo():
print("hello")

# ✅ 正确
def foo():
    print("hello")
```

### 3. 括号不匹配
```python
# ❌ 错误
print("hello"

# ✅ 正确
print("hello")
```

---

## 名称错误 (NameError)

### 1. 变量未定义
```python
# ❌ 错误
print(x)  # x 未定义

# ✅ 正确
x = 10
print(x)
```

### 2. 变量名拼写错误
```python
# ❌ 错误
my_list = [1, 2, 3]
print(mylist)  # 拼写错误

# ✅ 正确
print(my_list)
```

---

## 类型错误 (TypeError)

### 1. 类型不匹配
```python
# ❌ 错误
print("Hello" + 123)

# ✅ 正确
print("Hello" + str(123))
# 或
print("Hello", 123)
```

### 2. 参数数量错误
```python
# ❌ 错误
def greet(name, greeting):
    print(f"{greeting}, {name}!")

greet("Alice")  # 缺少 greeting 参数

# ✅ 正确
greet("Alice", "Hello")
```

---

## 索引错误 (IndexError)

### 列表索引越界
```python
# ❌ 错误
my_list = [1, 2, 3]
print(my_list[5])  # 索引超出范围

# ✅ 正确
print(my_list[2])  # 输出 3
# 或使用循环
for i in range(len(my_list)):
    print(my_list[i])
```

---

## 键错误 (KeyError)

### 字典键不存在
```python
# ❌ 错误
my_dict = {"a": 1, "b": 2}
print(my_dict["c"])  # 键不存在

# ✅ 正确
print(my_dict.get("c", "默认值"))  # 输出默认值
# 或
if "c" in my_dict:
    print(my_dict["c"])
```

---

## 值错误 (ValueError)

### 值不符合函数预期
```python
# ❌ 错误
int("abc")  # 无法将字符串转换为整数

# ✅ 正确
int("123")  # 正常转换
# 或
try:
    result = int("abc")
except ValueError:
    print("转换失败")
```

---

## 文件未找到错误 (FileNotFoundError)

### 文件路径错误
```python
# ❌ 错误
with open("data.txt", "r") as f:
    content = f.read()

# ✅ 正确
# 使用绝对路径
with open(r"C:\path\to\data.txt", "r") as f:
    content = f.read()
# 或检查文件是否存在
import os
if os.path.exists("data.txt"):
    with open("data.txt", "r") as f:
        content = f.read()
```

---

## 属性错误 (AttributeError)

### 对象没有该属性/方法
```python
# ❌ 错误
my_list = [1, 2, 3]
my_list.add(4)  # list 没有 add 方法

# ✅ 正确
my_list.append(4)
```

### 类型错误使用了不存在的方法
```python
# ❌ 错误
text = "hello"
text.append(" world")  # str 没有 append 方法

# ✅ 正确
text += " world"
```

---

## 导入错误 (ImportError)

### 模块不存在
```python
# ❌ 错误
import numpyoo  # 拼写错误

# ✅ 正确
import numpy as np
```

---

## 常见错误快速诊断表

| 错误类型 | 关键词 | 检查点 |
|----------|--------|--------|
| SyntaxError | "invalid syntax" | 括号、冒号、缩进 |
| NameError | "name 'x' is not defined" | 变量是否定义 |
| TypeError | "unsupported operand type" | 数据类型 |
| IndexError | "list index out of range" | 索引范围 |
| KeyError | "KeyError: 'x'" | 字典键是否存在 |
| ValueError | "invalid literal" | 值是否合法 |
| ImportError | "No module named" | 模块是否安装 |
| FileNotFoundError | "No such file" | 文件路径是否正确 |

references/debugging-tools.md

# Python 调试工具使用指南

## 1. Print 调试法

最简单直接的调试方式,通过打印变量值观察程序状态。

```python
def calculate_sum(numbers):
    result = 0
    for i, num in enumerate(numbers):
        # 打印每一步的中间结果
        print(f"i={i}, num={num}, result={result}")
        result += num
    return result

calculate_sum([1, 2, 3, 4, 5])
```

**输出:**
```
i=0, num=1, result=0
i=1, num=2, result=1
i=2, num=3, result=3
i=3, num=4, result=6
i=4, num=5, result=10
```

---

## 2. pdb 断点调试

Python 内置的交互式调试器。

### 基本命令

| 命令 | 简写 | 说明 |
|------|------|------|
| `n` (next) | `n` | 执行下一行 |
| `s` (step) | `s` | 进入函数内部 |
| `c` (continue) | `c` | 继续执行直到下一个断点 |
| `p` (print) | `p` | 打印变量值 |
| `l` (list) | `l` | 查看当前代码上下文 |
| `q` (quit) | `q` | 退出调试 |

### 使用方式

```python
import pdb

def buggy_function(x, y):
    pdb.set_trace()  # 设置断点
    result = x / y
    return result

buggy_function(10, 0)  # 会触发断点
```

### 启动方式

```bash
# 方式1: 命令行启动
python -m pdb myscript.py

# 方式2: 代码中设置断点
import pdb; pdb.set_trace()

# 方式3: 使用 breakpoint() (Python 3.7+)
breakpoint()
```

---

## 3. logging 日志调试

适合正式项目,可以控制日志级别和输出格式。

```python
import logging

# 配置日志
logging.basicConfig(
    level=logging.DEBUG,
    format='%(asctime)s - %(levelname)s - %(message)s'
)

logger = logging.getLogger(__name__)

def divide(a, b):
    logger.debug(f"a = {a}, b = {b}")
    if b == 0:
        logger.error("除数不能为零!")
        return None
    result = a / b
    logger.debug(f"result = {result}")
    return result

divide(10, 2)
divide(10, 0)
```

---

## 4. try-except 异常捕获

```python
def read_number(s):
    try:
        value = int(s)
        print(f"成功转换: {value}")
    except ValueError as e:
        print(f"转换失败: {e}")
        print(f"输入内容: '{s}'")
        return None
    return value

read_number("123")
read_number("abc")
```

---

## 5. IDE 调试工具

### VS Code 调试配置

1. 安装 Python 扩展
2. 在代码左侧点击设置断点
3. 按 F5 启动调试

### PyCharm 调试

1. 点击代码行号左侧设置断点
2. 右键选择 "Debug"
3. 使用调试窗口观察变量

---

## 6. 单元测试辅助

```python
import unittest

def add(a, b):
    return a + b

class TestMath(unittest.TestCase):
    def test_add(self):
        self.assertEqual(add(1, 2), 3)
        self.assertEqual(add(-1, 1), 0)
        self.assertEqual(add(0, 0), 0)

if __name__ == '__main__':
    unittest.main()
```

---

## 7. 快速检查变量

```python
# 查看变量类型
print(type(my_variable))

# 查看变量所有属性和方法
print(dir(my_variable))

# 查看对象详细信息
import pprint
pprint.pprint(vars(my_object))
```

---

## 调试流程建议

1. **先看错误信息** — 明确错误类型和位置
2. **缩小范围** — 注释掉部分代码,定位问题区间
3. **打印关键变量** — 在可疑处打印变量值
4. **使用 pdb** — 复杂问题用断点调试
5. **检查数据类型** — 很多错误源于类型不匹配
6. **查看文档** — 确认函数参数和使用方式

---

## 常见调试场景

| 场景 | 推荐方法 |
|------|----------|
| 简单错误 | print 打印 |
| 循环中的错误 | print + 计数器 |
| 函数返回值错误 | pdb 断点 |
| 偶发错误 | logging 记录 |
| 未知异常 | try-except + traceback |

skill-card.md

## Description:

Python Debug Assistant helps diagnose and fix Python errors, covering common exception types such as SyntaxError, TypeError, and NameError with error interpretation, code localization, repair options, and debugging tips.

This skill is ready for commercial/non-commercial use.

## Publisher:

[laninga](https://clawhub.ai/user/laninga)

### License/Terms of Use:

MIT-0

## Use Case:

Developers and learners use this skill to interpret Python tracebacks or code snippets, locate likely causes, and receive concise repair steps with example corrected code. It is especially suited to Chinese-language debugging workflows.

### Deployment Geography for Use:

Global

## Known Risks and Mitigations:

Risk: The skill may produce incorrect or incomplete debugging advice for user-provided code.

Mitigation: Review proposed fixes and run tests before applying changes to production or important code.

Risk: The reviewed security guidance notes the skill is primarily Chinese-language and may feel rigid for other languages or output formats.

Mitigation: Use it for Chinese-language Python debugging workflows, and request a different format or language explicitly when needed.

## Reference(s):

- [Python Built-in Exceptions](https://docs.python.org/3/library/exceptions.html)
- [ClawHub Skill Page](https://clawhub.ai/laninga/skills/python-debug-assistant)
- [Common Python Errors](references/common-errors.md)
- [Python Debugging Tools](references/debugging-tools.md)

## Skill Output:

**Output Type(s):** [Text, Markdown, Code, Shell commands, Guidance]

**Output Format:** [Markdown diagnostic report with explanatory text, code blocks, and occasional shell commands]

**Output Parameters:** [1D]

**Other Properties Related to Output:** [The source artifact requests a fixed report structure for problem analysis, location, repair plan, and debugging advice.]

## Skill Version(s):

1.0.0 (source: server release metadata and target metadata; artifact frontmatter reports 2.0)

## Ethical Considerations:

Users should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.
Github ReposUpdated 1d agoRank 70

AionUi

Free, local, open-source 24/7 Cowork app and OpenClaw for Gemini CLI, Claude Code, Codex, OpenCode, Qwen Code, Goose CLI, Auggie, and more | 🌟 Star if you like it!

MCPOPENCLAW
Github ReposUpdated 6mo agoRank 70

activepieces

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

OPENCLAW
Github ReposUpdated 6mo agoRank 70

cherry-studio

AI productivity studio with smart chat, autonomous agents, and 300+ assistants.

MCPOPENCLAW
Github ReposUpdated 7mo agoRank 70

CopilotKit

The Frontend for Agents & Generative UI. React + Angular

OPENCLAW

Machine-readable data

The same record, as JSON, for agents and crawlers.

{
  "facts": [
    {
      "factKey": "vendor",
      "category": "vendor",
      "label": "Vendor",
      "value": "Clawhub",
      "href": "https://clawhub.ai/laninga/skills/python-debug-assistant",
      "sourceUrl": "https://clawhub.ai/laninga/skills/python-debug-assistant",
      "sourceType": "profile",
      "confidence": "medium",
      "observedAt": "2026-10-11T03:47:45.275Z",
      "isPublic": true
    },
    {
      "factKey": "protocols",
      "category": "compatibility",
      "label": "Protocol compatibility",
      "value": "OpenClaw",
      "href": "https://www.xpersona.co/api/v1/agents/clawhub-laninga-python-debug-assistant/contract",
      "sourceUrl": "https://www.xpersona.co/api/v1/agents/clawhub-laninga-python-debug-assistant/contract",
      "sourceType": "contract",
      "confidence": "medium",
      "observedAt": "2026-10-11T03:47:45.275Z",
      "isPublic": true
    },
    {
      "factKey": "traction",
      "category": "adoption",
      "label": "Adoption signal",
      "value": "1.2K downloads",
      "href": "https://clawhub.ai/laninga/python-debug-assistant",
      "sourceUrl": "https://clawhub.ai/laninga/python-debug-assistant",
      "sourceType": "profile",
      "confidence": "medium",
      "observedAt": "2026-10-11T03:47:45.275Z",
      "isPublic": true
    },
    {
      "factKey": "latest_release",
      "category": "release",
      "label": "Latest release",
      "value": "1.0.0",
      "href": "https://clawhub.ai/laninga/python-debug-assistant",
      "sourceUrl": "https://clawhub.ai/laninga/python-debug-assistant",
      "sourceType": "release",
      "confidence": "medium",
      "observedAt": "2026-05-15T12:06:33.289Z",
      "isPublic": true
    },
    {
      "factKey": "handshake_status",
      "category": "security",
      "label": "Handshake status",
      "value": "UNKNOWN",
      "href": "https://www.xpersona.co/api/v1/agents/clawhub-laninga-python-debug-assistant/trust",
      "sourceUrl": "https://www.xpersona.co/api/v1/agents/clawhub-laninga-python-debug-assistant/trust",
      "sourceType": "trust",
      "confidence": "medium",
      "observedAt": null,
      "isPublic": true
    }
  ],
  "events": [
    {
      "eventType": "release",
      "title": "Release 1.0.0",
      "description": "- 全面升级为结构化「Python代码调试助手」,支持更清晰的问题定位与修复建议流程。 - 增强错误类型覆盖,支持 10+ 常见Python异常,并针对不同错误给出原因分析与修复方案。 - 明确处理不同输入情境(报错、代码、报错+代码、图片),自动适配诊断分支。 - 输出格式统一为标准诊断报告,包括问题分析、定位、修复方案、调试建议。 - 附带典型触发场景、参考资料及交互示例,提升易用性与可扩展性。",
      "href": "https://clawhub.ai/laninga/python-debug-assistant",
      "sourceUrl": "https://clawhub.ai/laninga/python-debug-assistant",
      "sourceType": "release",
      "confidence": "medium",
      "observedAt": "2026-05-15T12:06:33.289Z",
      "isPublic": true
    }
  ]
}

Record generated Oct 11, 2026.

Sponsored

Ads related to python-debug-assistant and adjacent AI workflows.