技巧精选

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

在 AGENTS/CLAUDE MD 里面加一句: Every implementation task that changes files MUST end with a git commit be...

精选理由

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

AI 摘要

该规则要求 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 be...

在 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 💬 3 🔄 2 ❤️ 13 👀 2035 📊 6 ⚡