multiline-commit-messages
它能做什么
这份指南告诉你的智能体,如何以 shell 能可靠传递的形式编写多行提交信息。适合智能体负责提交、但提交信息偶尔会出错的开发者。
适用场景
- ✓当你的智能体编写超过一行的 git 提交信息的时候。
- ✓当提交信息中混入了多余的 shell 文本的时候。
- ✓当你希望提交信息包含一行摘要和一段正文的时候。
技能链接
https://github.com/prisma/orm/blob/main/skills-contrib/multiline-commit-messages/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请用简短的摘要和两段说明来提交这些改动,并把说明写进提交信息中。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会把提交信息写成一个带有真实换行的单引号字符串,而不是在命令替换中使用 heredoc。这样 shell 就会原样把它交给 git。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Multiline commit messages
The Shell tool sends commands as a single string. Heredoc syntax (<<'EOF') inside $(cat ...) is fragile and fails silently — the literal $(cat <<'EOF' ... ends up as the commit message instead of the intended text.
Rule
Never use $(cat <<'EOF' ...) or $(cat <<EOF ...) for commit messages.
Use single-quoted strings with embedded newlines:
git commit -m 'short summary line
Longer body paragraph explaining why the change exists.
Additional context if needed.'
Why heredocs fail
The Shell tool passes the command as a single string argument. When you write:
git commit -m "$(cat <<'EOF'
message
EOF
)"
The shell may not parse the heredoc correctly in this context — the EOF delimiter, newlines, and nested quoting interact unpredictably. The result is the raw $(cat <<'EOF' ... text appearing as the commit message.
Single-quoted strings with literal newlines are simple, portable, and always work.
常见问题
为什么 heredoc 会失败?
该技能说明,在这种情况下 shell 可能无法正确解析它,于是原始命令文本可能会变成提交信息。
这适用于哪些场景?
该技能是为智能体的 Shell 工具编写的,该工具将每条命令作为一个字符串发送,因此在那里这种方法最安全。
主要规则是什么?
提交信息不要在命令替换中使用 heredoc,应使用带换行的单引号字符串。
详情
作者的原始描述
Use single-quoted strings for multiline git commit messages in the Shell tool. Prevents heredoc escaping failures that produce garbled commit messages.
repo: prisma/orm
热度
- GitHub 星标
- 48k
- 排名
- #6311
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
adr-review
48k教你的智能体以新鲜的视角审阅架构决策记录,然后重写,让新读者也能清楚理解其中的决定。
ast-visitor-pattern
48k教你的智能体一种代码模式,用于处理在多个位置被使用的联合类型,使新增的变体能被编译器捕获。
markdown-no-artificial-line-wraps
48k帮你的智能体把整段文字写在同一行中,让文字在屏幕上自然换行,并保持文件改动清晰。
product-direction
48k帮你的智能体依据项目已书面记录的产品方向来评判功能请求,给出有理由的结论,并记录每一次否决。