Discipline Log First

三、日志优先(可观测性)

yli769227-jpg Updated

File contents

三、日志优先(可观测性)

写代码犯错是正常的,定位问题才是真正困难的。

  1. 所有新代码必须包含关键路径日志:连接建立、状态变化、错误发生、请求/响应。
  2. 日志格式统一,带前缀标识模块,便于 grep。
  3. 错误日志必须包含上下文:什么操作、什么参数、什么错误。
  4. Agent 写代码时也必须遵守。

加载时机

  • 即将写新模块 / 新接口 / 新外部调用 / 新异步任务
  • 正在 debug 一段没有日志的代码
  • 派 agent 子任务写代码前(任务描述里要明确"加关键路径日志")

配套

具体反面例子 / 正面例子见 EXAMPLES.md

yli769227-jpg/awesome-claude-code-cn/tree/main/skills/discipline-log-first commit a612ee7761

Frequently asked questions

npx skillmds@latest add yli769227-jpg/discipline-log-first