AI を使ってコードを書いているときに、そのやりとりを何かしらの形で残せると良いよねという課題感があったが、コミットメッセージに残せばよいというアイデアを見かけてこれを試している。
これを毎回そのようにしてと頼むのは面倒なので、 Claude Code の Slash Comannd として用意してそれを使っている。
Create a commit that includes **all conversation** between the user and yourself up to this point, following Conventional Commits format:
```
<type>[optional scope]: <description>
[optional body]
prompt: <user's input prompt>
----
<your response>
----
prompt: <user's input prompt>
----
<your response>
[optional footer(s)]
```
- Breaking changes: Use ! after type/scope or add BREAKING CHANGE: footer
- Common types: feat, fix, docs, style, refactor, test, chore, ci, build, perf
- Scope examples: (api), (ui), (auth), (parser)
- Description: Present tense, lowercase, under 50 chars, no period
- Separate conversation exchanges with ----
これを ~/.claude/commands/commit.md
として保存しておくと /user:commit
が使えるようになる。ルール化するなら project:
にしてもいいと思う。
実際にできるメッセージは自分の入力はそのまま残る一方で、 Claude Code 側のものは結構要約されたりする。すべてそのまま残ってほしい気もするが、それはそれで膨大になりそうなので今のところ必要十分という感じ。
Refs
使ったプロンプトをコミットログにぶち込んでおくのCloudflareの人も実践してたhttps://t.co/Q0WSOsfPcW https://t.co/SKXx0Ytmwz
— Iaiso (@laiso) June 7, 2025