본문으로 건너뛰기
cccskills
무료GitHub에 공개

debugging-guide

Use when debugging Go errors, test failures, or unexpected behavior — step-by-step diagnosis approach

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md3.2 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

harness9 调试指南

诊断顺序

遇到问题时,按以下顺序排查:

1. 编译错误

go build ./...

常见原因:

  • 未使用的 import → 删除或添加 _ blank import
  • 类型不匹配 → 检查接口实现是否完整
  • 循环依赖 → 将接口定义移到使用者侧包中

2. 测试失败

# 详细输出
go test -v ./internal/engine/

# 单个测试
go test -v -run TestAgentLoop ./internal/engine/

# 带 race detector
go test -race ./...

3. 运行时 panic

查看完整 goroutine stack:

go run ./cmd/harness9 2>&1 | head -100

nil pointer panic 通常来自:

  • 未初始化的 map(用 make(map[K]V) 初始化)
  • 接口值为 nil 但调用了方法

4. Agent 行为异常

LLM 不调用工具: 检查工具的 Definition() 描述是否清晰,JSON Schema 是否正确。

工具执行失败: 查看 ToolResult.IsError 和 Output 字段,错误信息会回传给 LLM。

无限循环: 检查 WithMaxTurns 配置,默认 50 Turn。

常用调试技巧

打印 System Prompt

在 internal/context/builder.go 的 Build() 方法末尾临时添加:

fmt.Fprintf(os.Stderr, "=== SYSTEM PROMPT ===\n%s\n===================\n", prompt)

检查工具注册

在 registry.Execute 前打印可用工具列表:

for _, def := range registry.GetAvailableTools() {
    fmt.Fprintf(os.Stderr, "tool: %s\n", def.Name)
}

Provider 请求/响应

如需查看实际 API 请求,在 internal/provider/openai.go 中打印消息列表。

harness9 特有问题

Anthropic Provider:user/assistant 必须严格交替

症状:400 Bad Request 或 invalid_request_error

原因:Anthropic Messages API 禁止连续 assistant 消息。

修复:检查 contextHistory 的消息顺序,确保 system→user→assistant→user→assistant 交替。

路径沙箱拒绝访问

症状:工具返回 路径超出工作区范围 或类似错误

原因:路径包含 ../ 或绝对路径指向启动目录之外。

修复:Agent 应使用相对于启动目录的路径,如 internal/engine/agent_loop.go 而非 /absolute/path/...。

Skills 未加载

症状:Agent 不知道有 Skills 可用

检查:

  1. skills/ 目录是否在项目根目录(启动目录)下
  2. 每个 Skill 是否在独立子目录中,且子目录内有 SKILL.md 文件
  3. SKILL.md 是否包含 name 和 description frontmatter 字段
  4. 启动日志中是否有 [skills] warn 输出

正确的目录结构示例:

skills/
├── go-coding-standards/
│   └── SKILL.md      ← 必须是这个文件名
└── debugging-guide/
    └── SKILL.md

go vet 常见 warning

Warning含义修复
printf 格式不匹配%s 传入了非 string 类型修正格式或类型
unreachable codereturn 后有代码删除死代码
loop variable capturedgoroutine 捕获了循环变量传参而非捕获

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Use when asked about harness9 architecture, module design, or how components interact — explains the system design

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ZhangShenao/harness91422026년 10월 19일 업데이트

autodev

무료

Feature auto-development — clarify requirements, generate spec, dispatch dev sub-agent to implement and merge into current branch

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ZhangShenao/harness91422026년 10월 19일 업데이트

commit

무료

Use when the user invokes /commit or asks to commit changes, after a code review has been completed and the changes are confirmed ready to stage and commit to git.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ZhangShenao/harness91422026년 10월 19일 업데이트

cr

무료

Use when the user invokes /cr, requests a code review, or before committing to verify correctness, security, and quality of new or modified code in the working tree.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ZhangShenao/harness91422026년 10월 19일 업데이트

Use when writing or reviewing Go code — explains harness9 project coding conventions and patterns

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ZhangShenao/harness91422026년 10월 19일 업데이트

pr

무료

Use when the user invokes /pr or asks to push changes and open a pull request, after commits are ready to be pushed to a remote branch and merged into the main branch.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ZhangShenao/harness91422026년 10월 19일 업데이트

ZhangShenao의 스킬 모두 보기

이 스킬의 문제 신고