代码调试

A debugging workflow that reproduces a problem with a failing test, collects evidence, finds the underlying cause, applies a fix, and runs regression checks. Regression checks verify that the fix does not break behavior that already worked.

In plain words
What is it for?
Use it for bugs, failed tests, and runtime errors. It helps confirm reproduction steps, trace calls and data flow, compare expected with actual behavior, test possible causes, and verify the repair.
Why use it?
It prevents fixing only the visible error while leaving its cause in place, and limits repeated unsuccessful fixes in the same module.

Skill for Claude CodeCodex

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 skills/jianchen08/agent-os-open/code-debug
Any agent
npx skills add jianchen08/Agent-os-open --skill code-debug
Clone the repo
git clone --depth 1 https://github.com/jianchen08/Agent-os-open

Made for: Claude Code, Codex.

Per session 82 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,950 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 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.00082 $0.04950
Opus 5 $0.00041 $0.02475
Sonnet 5 $0.00016 $0.00990
Haiku 4.5 $0.00008 $0.00495

Measured yesterday against content hash 84672fb786df, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

代码调试 scanned grade A with 0 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 yesterday.

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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/code-debug/SKILL.md · 310 lines

How it starts

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

代码调试

总原则

先确认"谁在执行",再优化"怎么执行"。 报错位置常常是受害者,不是凶手。

强制流程(跳步视为流程违规)

写失败测试(规则 0)
  → 收集数据(规则 8)
  → 分析根因(规则 7 / 9 / 12)
  → 写回归测试并验证(规则 11)
  → 修改代码

本技能遵循《编程领域规则》中的行为测试规范(§6.3 行为测试原则、§6.4 时序测试铁律)。


执行流程

第 1 步:确认需要(调试前必做)

进入调试前,先确认故障信息和复现条件就位,缺则停下追问,不靠猜测推进。

  1. 确认故障现象:报的什么错、什么场景下出现、预期行为 vs 实际行为
  2. 确认复现条件:最小复现路径、触发输入、运行环境;无法复现的 bug 先和上报方确认复现步骤
  3. 确认需求维度:这个 bug 是"功能没实现/行为不符合预期"还是"报错崩溃"。前者是需求符合性问题——核对实际行为偏离了哪个 AC、设计本意应该是什么,不能只盯着报错;后者才是纯技术故障
  4. 确认涉及范围:故障在哪个模块、调用链上下游、可能受影响的依赖
  5. 确认已有线索:错误日志、stack trace、已知的可疑点、之前是否修过该模块
  6. 信息不全则停下:通过 human_interaction 向上追问,确认齐了再进入第 2 步

第 2 步:摸清现有实现(防重复修复、防破坏架构,调试前必做)

调研故障模块现有实现,需要得出以下结论:

  • 调用链摘要:故障模块的调用链上下游、数据流、依赖方向
  • 可复用项:现有代码里有没有已经正确处理该场景的函数/分支
  • 接口契约:本模块对外接口的签名、入参出参、异常、调用约束
  • 架构边界:本模块职责边界、依赖方向,修复会不会跨过模块边界乱改、破坏对外接口契约

第 3 步:复现与定位(最多 2 轮,只加诊断标记,禁止改代码)

按 coding_domain_rules.md §1.5 Bug修复安全执行。

  1. 先写失败测试(见规则 0):必须先写一个能复现该 bug 的行为测试,确认它失败。已有测试能复现则跳过这步。
  2. 最小输入复现:用最小的输入触发失败
  3. 收集数据(见规则 8):按数据收集清单采集事实,不靠直觉
  4. 确认 WHO 不只是 WHAT(见规则 1):确认"是哪个对象/实例在执行",而不只是"报了什么错"

第 4 步:追踪根因(最多 2 轮,只加诊断标记,禁止改代码)

  1. 逐层追问根因(见规则 7):用 5 Whys 追到可操作根因
  2. 管理假设(见规则 9):同时跟踪不超过 3 个假设,各列正反证据
  3. 在构造函数加 traceback(limit=4)
  4. 确认对象被创建了几次、由谁创建
  5. 检查 fork/clone/rebuild 是否丢失依赖
  6. 检查对象生命周期:bug 通常在对象被重建时丢失属性,不在报错代码本身

第 5 步:修复根因

  1. 修复真正的根因(不是症状)
  2. 完整系统中验证(不是只跑隔离测试——见规则 2)
  3. 移除所有临时诊断代码(print/traceback 标记)

第 6 步:回归验证

  1. 写回归测试(见规则 11):必须是行为测试,验证根因被修复而非症状消失
  2. 重新运行全部测试(包括之前通过的)
  3. 复验失败测试:原来复现 bug 的测试现在应通过
  4. 如果仍有失败 → 回到第 3 步(同方向最多 3 次,超过则切换假设)

调试原则(含使用条件与示例)

规则 0:用测试捕获理想行为(前置硬门槛)

使用条件:发现 bug 的第一时间——任何分析代码、读日志、改逻辑之前。

怎么使用

  • 第一动作是写出能暴露 bug 的行为测试(红灯),而不是分析代码。该测试即理想模型的可执行形式——精确描述"在给定输入下,正确的可观察行为应该是什么"。
  • 优先于所有分析动作。先有失败测试,再谈诊断。
  • 测试必须断言可观察行为(输入 → 输出 / 副作用),而非内部实现细节,遵循《编程领域规则》§6.3。
  • 如果无法写出测试(缺乏可观测性),不要绕过这一步——先重构增加可观测性(暴露事件、时间戳、状态查询接口),再写测试。

小例子

通知推送时序错了,先不读代码。直接写一个测试断言"通知推送时间戳 ≤ LLM 收到请求时间戳",跑一次,红灯——这就是 bug 的可执行形式。

Read the full file on GitHub · 310 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. yesterday First seen · 310 lines · 82 tokens per session scan A 84672fb786df

Subscribe to this mod's changes

代码调试 is a skill published in the GitHub repository jianchen08/Agent-os-open (5 stars, last pushed 6d ago), licensed Apache-2.0. It adds 82 tokens to every session and 4,950 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

deep-research

深度研究编排方法论:澄清范围、拆解规划、并行调度子智能体调研、对抗式核验、综合成带引用的结构化报告。当任务需要多来源、可追溯、需事实核查的深度研究时使用此技能。.

xerrors/Yuxi · 69 tokens

mysql reporter

生成 MySQL 查询报表并生成可视化图表。当用户需要查询 MySQL 数据库并以报表形式展示结果时使用此技能,包括:统计销售数据、分析用户行为、生成业务报表、查询业务指标等。.

xerrors/Yuxi · 55 tokens

frontend-feature

Build a new page, view, or data-driven feature in the Next.js frontend. Use when adding a route under the dashboard/marketing area, wiring UI to a backend endpoint, adding client state, or creating a localized page. Covers App Router, data fetching, Zustand stores, and i18n.

vstorm-co/full-stack-ai-agent-template · 64 tokens

rag-knowledge

Work with the RAG knowledge base — ingest documents, run semantic search, manage collections, or add a sync source/connector (Google Drive, S3). Use when populating or debugging the knowledge base, tuning retrieval, or adding a new document source. This project uses {{ cookiecutter.vectorstore }} + {{…

vstorm-co/full-stack-ai-agent-template · 76 tokens

alembic-migration

Create, review, and apply database schema changes with Alembic. Use whenever a SQLAlchemy model is added or changed, a column/index/constraint needs to change, or a data backfill is required — anything that alters the PostgreSQL schema.

vstorm-co/full-stack-ai-agent-template · 56 tokens

image-gen

在 Agent 沙盒中生成图片并保存到 outputs。当用户要求生成图片、海报、插画、文生图,或指定 Qwen-Image、其它兼容图片生成接口时使用此技能。.

xerrors/Yuxi · 48 tokens