技巧精选

在 AGENTS/CLAUDE MD 中添加 git 提交规则

精选理由

给 AI 编程时加这条规则,改完代码自动 git commit,再也不怕改了大动脉找不到历史了。

该规则要求 AI 在执行文件修改任务后,必须在最终响应前完成 git commit。具体步骤包括:在编辑前检查 `git status`,将预存或并发变更视为用户所有;

正文

提交前审查最终 diff 并运行相应的验证;仅暂存当前任务的文件或 hunks,不混合无关变更;

使用简洁描述性提交信息在 `main` 分支上提交,报告 commit hash,除非用户要求否则不推送或改写历史。只读或无文件变更的任务不创建空提交。

原文 · 宝玉

在 AGENTS/CLAUDE MD 里面加一句: Every implementation task that changes files MUST end with a git commit before the final response. - Inspect `git status` before editing and treat pre-existing or concurrent changes as user-owned. - Review the final diff and run proportionate verification before committing. - Stage only files or hunks that belong to the current task. Never bundle unrelated changes unless the user explicitly asks. - Use a concise descriptive commit message on `main`, report the commit hash, and do not push, amend, or rewrite history unless asked. - Read-only tasks and tasks with no file changes do not create empty commits. Xiangyu 香鱼🐬 @xiangyuli 我一定要教会我们团队的人怎么用git 现在ai改了一堆代码, 然后一个项目里完全没有提交过任何git状态 他妈的改天改到大动脉,自己都不知道改了啥 🔗 View Quoted Tweet📊 6 ⚡

产业坐标与信源核验

本条情报归属 AITOP「技巧」核心栏目,重点聚焦北美前沿实验室与硅谷科技巨头。在跨区域产业观察坐标中,该动态直接关联「AI 开发者工具链、Coding Agent 与工程化实践」研究主线,反映出当前技术演进与商业落地的最新风向。涉及核心实体与技术议题包括:AGENTS、CLAUDE MD、git、提示词工程,读者可通过下方标签进入对应专题页查阅历史脉络与关联对比。

信源核验说明:本文原始线索采编自「宝玉」(@dotey),经 AITOP 多维评分管线结构化提炼。

发现摘要或翻译有误? 告诉我们