创建

登录 ReadmeX

或

了解我们如何处理你的信息: 隐私政策

ReadmeX

陪你读懂 AI 动态

今天,想先了解什么?

选一份动态总结,或直接聊聊你的问题。

社区和关注动态总结只属于你自己。

资讯

Reddit 用户用规则限制 Claude Code 无关重构

AI 总结

一名 Reddit 用户称,Claude Code 修复一个小型错误时产生了涉及导入重排、变量重命名和注释删除的 360 行差异。作者称,在 CLAUDE.md 中加入明确的“外科手术式修改”规则,并要求每行改动都对应用户提示,可减少无关差异。

深度见解

该帖提供了限制 Claude Code 修改范围的实用配置,但有效性仅来自作者个人体验,尚未得到独立验证。

One of the most common annoyances when running Claude Code on an existing repository is drive-by refactoring. You ask it to fix an off-by-one check in a single function, and the resulting git diff touches 360 lines because it decided to reorder imports, rename helper variables, and strip comments across the file. Adding vague instructions like "keep changes minimal" to CLAUDE.md rarely stops this, because the model still considers formatting and cleanup to be helpful improvements. What actually stopped the extra diff noise for us was adding an explicit Surgical Changes block to CLAUDE.md (adapted from Andrej Karpathy's coding agent guidelines) that defines exact boundaries for git diff: # Surgical Changes - Touch only the lines required to solve the requested task. - Do not reformat, reorder imports, or rename unrelated variables in files you are editing. - Do not delete existing comments or dead code unless asked; mention them in your final summary instead. - Only clean up unused imports or helpers that your own edit made unused. - Every changed line in `git diff` must trace directly to the user's prompt. Two rules in that block do almost all the work: submitted by /u/Independent-Sir3234 [link] [comments]

#Claude Code#CLAUDE.md

原文约 1 分钟读完阅读原文
群聊

还没有评论,来说说你的看法。