GitKrakenでCommite Messageを自動生成

# Gitkrakenが、実験的に機能提供

ChatGPTのAPIキーを渡すと、ボタンポチでコミットメッセージを生成してくれます。

https://help.gitkraken.com/gitkraken-client/experimental-features/#how-to-use-in-gkc

# 背景

コミットメッセージ書くの大事だけど面倒

# やりたいこと

コミットメッセージ自動生成

# やってみた

![トリム済み.gif](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/183059/3063f7fc-1769-47e2-15ec-63287aa2621b.gif)


# 設定

![設定画面.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/183059/598fb1f1-f260-d542-5bee-ce6c7ef83985.png)

1. 設定
1. Experimental
1. OpenAI API Key 貼り付け
1. プロンプトはデフォルトでコミットメッセージ用に用意されています。

オプションで条件を付け足していく場合は、デフォルトのプロンプトに追加してくとよいでしょう。


# プロンプト

## デフォルトのプロンプト

- プロンプト

```
Commit Messages must have a short description that is less than 50 characters followed by a newline and a more detailed description.
- Write concisely using an informal tone
- List significant changes
- Do not use specific names or files from the code
- Do not use phrases like "this commit", "this change", etc.
```

- 結果
```
Refactor invoices page component to include search functionality and UI improvements
- Import Pagination, Search, Table, CreateInvoice components
- Add lusitana font styling
- Add InvoicesTableSkeleton component for suspense fallback
- Comment out Suspense and Table components temporarily
- Comment out Pagination component temporarily
```

## プレフィクスをつける指示追加

### プロンプト

```
Commit Messages must have a short description that is less than 50 characters followed by a newline and a more detailed description.
- Write concisely using an informal tone
- List significant changes
- Do not use specific names or files from the code
- Do not use phrases like "this commit", "this change", etc.
（下を追加）
- Use one of the following prefixes
  fix: Use if there is a problem with an existing feature.
  hotfix: Use when there is a critical problem with an existing feature.
  add: Use to add a new file or feature.
  feat: Use to add a new feature or file.
  update: Used when there is no problem with an existing feature, but a fix is needed.
  change: Used to modify an existing feature due to specification changes.
  refactor: Used to clean up and improve code.
  improve: Used to improve code.
  disable: Used to temporarily disable a feature.
  delete: Used to delete a file or remove a feature.
  rename: Used to rename a file.
  move: Used to move a file.
  upgrade: Used to upgrade a version.
  revert: Revert to a previous commit.
  docs: Used to modify documentation.
  style: Used to modify coding style.
  perf: Used to improve code performance.
  test: Use to modify test code or add test code.
  chore: Use to commit auto-generated by build tools or libraries, or to make modifications that do not apply to the above prefixes.
```

### 結果
```
feat: Add search functionality and pagination to invoices page
This commit adds the following changes to the invoices page:
- Import and use the Search component for searching invoices
- Import and use the Pagination component for navigating through pages of invoices
- Comment out code related to displaying a table of invoices, as it is not yet implemented

These changes enhance the functionality of the invoices page by allowing users to search for specific invoices and navigate through multiple pages of results.
```

日本語にするには、プロンプトを日本語に翻訳したプロンプトにすると、日本語のコミットメッセージを生成してくれます。