跳到正文
Skillpedia
通用编程48k · #6311

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。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/prisma/orm/blob/main/skills-contrib/multiline-commit-messages/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能