0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Copilotでいい感じのCommitメッセージを作ってもらおう

Last updated at Posted at 2025-12-11

はじめに

RUNTEQ Advent Calendar 2025 を担当します seki です!
テーマは『みんなにおすすめしたい〇〇tips』ということで、私は業務でも使っている copilot の tips についてお話ししようと思います!

commit を copilot に書いてもらう

修正したファイルに合わせたcommitメッセージを書くのは時間がかかるし、面倒じゃないですか?
今回はそれを/commitというコマンドを打ったら自動的にいい感じのcommitメッセージをcopilotに作成してもらうinstructions.mdを公開します!

mdファイルの中身

.github配下のinstructionsフォルダの下にmy.instructions.mdファイルを作成してください(「my」の部分は好きな名前に置き換えてもらって構いません。)
.github/
└── instructions/
└── my.instructions.md

mdファイルの中身に以下を入れてください

---
applyTo: "**"
---

## Custom slash Commands

- `/commit`と指示したら「commitメッセージを提案する」と認識してください。git commitはしないでください。
    - commitメッセージは日本語で簡潔に書いてください。
    - git statusコマンドとgit diffコマンドで変更差分は確認してください

## git コミットメッセージ

Conventional Commits 1.0.0準拠で、絵文字プレフィックス付きの日本語メッセージを生成してください。

### 構造
<絵文字> <type>[optional scope]: <日本語description>

### type
feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert

### 絵文字プレフィックス
:recycle: Refactoring
:green_heart: Fix broken spec
:shirt: Fix lint / Cosmetic
:art: Update design
:ambulance: Fix bug
:wrench: Update configration
:sparkles: Added A feature
:horse_racing: Fix performance
:memo: Add Comment / Update documentation
:heavy_plus_sign: Add gem
:heavy_minus_sign: Remove gem
:cop: Fix security
:m: Update Database Schema
:warning: Avoiding Problems
:twisted_rightwards_arrows: Merge from __

これを入れることによって、copilotが絵文字付きのいい感じのcommitメッセージを考えてくれるようになります!

中身の構造

  • applyTo: "**"
    • copilotに事前にこのファイルを読み込ませておく設定です
  • customn slash commnads
    • /commitと打ったら、commitメッセージを考えるように設定しています。面倒だったら、commitもしてもらってもいいと思います。
  • Conventional Commits 1.0.0準拠
    • https://www.conventionalcommits.org/ja/v1.0.0/ という人間も機械もわかりやすいコミットメッセージの考え方の記載がある公式ドキュメントです。これをcopilotに渡すことによりいい感じのcommitメッセージを生成してくれます。commitメッセージの考え方も載っているので興味あれば一読してみてください。
  • 絵文字プレフィックス
    • 絵文字があった方が一目で何を修正したかわかりやすいため、載せています。 📝だったらドキュメント修正、バグ修正だったら🐛みたいな感じです。

実際の動き

コメントを修正します

- def perform_bulk(args, **options)
-   client = @klass.build_client
-   client.push_bulk(@opts.merge({"class" => @klass, "args" => args}, options))
- end
+ # 複数のジョブを一括でRedisにエンキューするメソッド
+ # args: ジョブ引数の配列の配列
+ # **options: キーワード引数
+ def perform_bulk(args, **options)
+  client = @klass.build_client
+  client.push_bulk(@opts.merge({"class" => @klass, "args" => args}, options))
+ end

copilotに依頼

/commit

copilotが変更を確認して、いい感じの絵文字付きprefixのcommitメッセージを提案します

現在の変更を確認してコミットメッセージを提案します。

:memo: docs: perform_bulkメソッドにコメントを追加
または
:memo: docs: Setter#perform_bulkに日本語コメントを追加して理解を深める

終わりに

どうだったでしょうか?commitメッセージは大事なのですが、結構面倒だし軽視する部分も多い箇所だと思います。このinstructionsで少しでもためになったら幸いです✨

参考リンク

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?