observe-before-editing

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Observe Before Editing

编辑前先观察

Before editing code to fix a bug, confirm what the system actually produced.
在编辑代码修复bug之前,先确认系统实际生成的内容

Pattern

模式

Outputs don't lie. Code might. Check outputs first.
输出不会说谎。代码可能会。先检查输出。

DO

要做的事

  1. Check if expected directories exist:
    ls -la .claude/cache/
  2. Check if expected files were created:
    ls -la .claude/cache/learnings/
  3. Check logs for errors:
    tail .claude/cache/*.log
  4. Run the failing command manually to see actual error
  5. Only then edit code
  1. 检查预期目录是否存在:
    ls -la .claude/cache/
  2. 检查预期文件是否已创建:
    ls -la .claude/cache/learnings/
  3. 检查日志中的错误:
    tail .claude/cache/*.log
  4. 手动运行失败的命令以查看实际错误
  5. 之后再编辑代码

DON'T

不要做的事

  • Assume "hook didn't run" without checking outputs
  • Edit code based on what you think should happen
  • Confuse global vs project paths (check both:
    .claude/
    and
    ~/.claude/
    )
  • 不检查输出就假设“钩子未运行”
  • 根据你认为应该发生的情况来编辑代码
  • 混淆全局路径与项目路径(检查这两个路径:
    .claude/
    ~/.claude/

Source Sessions

来源会话

  • a541f08a: Token limit error was invisible until manual run revealed it
  • 6a9f2d7a: Looked in wrong cache path (
    ~/.claude/
    vs
    .claude/
    ), assumed hook failure
  • a8bd5cea: Confirmed hook worked by finding output files in project cache
  • 1c21e6c8: Verified Artifact Index indexing by checking DB file exists
  • a541f08a:直到手动运行才发现令牌限制错误
  • 6a9f2d7a:查看了错误的缓存路径(
    ~/.claude/
    .claude/
    ),误以为钩子失败
  • a8bd5cea:通过在项目缓存中找到输出文件确认钩子正常工作
  • 1c21e6c8:通过检查DB文件是否存在来验证Artifact Index的索引功能