2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Claude Code] PR titleとdescriptionを最新に更新する slash command

2
Posted at

はじめに

Claude CodeでPRを作成すると、PR titleとDescriptionをしっかり書いてくれます。これは非常に便利な機能ですが、実際の開発フローでは以下のような課題に直面することがあります。

課題

DraftPRを作成してから、変更を積み重ねていざOpenしようとすると、最初にPRを作成したときとは大きく異なる変更が入っているケースがあります。

その際、毎回「Update PR title and description」と手動で指示していましたが、以下の問題がありました:

  1. 手間がかかる - 毎回同じ指示を書くのが面倒
  2. 精度の問題 - 直前の変更だけを反映してしまい、PR全体の変更を適切に反映できない

具体例

例えば、直前でRenameをしていると、PRタイトルまたはDescriptionに「Rename xxx」と書かれてしまいますが、実はそのPRで追加された変数を途中で変更しただけで、PRタイトルやDescriptionとしてふさわしくないケースがあります。

解決策:カスタムSlash Command

この問題を解決するため、最新のPRの状態全体を確認してTitleとDescriptionを更新するSlash commandを作成しました。/pr-update

Slash Commandの実装

以下が作成したSlash commandの定義です。正直めちゃくちゃシンプルです。

# Update PR title and description

## ARGUMENTS

<pr number>

## Usage

/pr-update 123

## Instruction

1. Use `git diff` command to check the changed files and changes of the PR.
2. Update the PR title and description based on the changes obtained in the step 1.

## Rules

1. PR title should follow conventional commits

使い方

基本的な使用方法

  1. DraftPRで作業を進める
  2. PRをOpenする前に、以下のコマンドを実行:
    /pr-update 123
    
    (123はPR番号)

動作の流れ

  1. 差分の確認 - git diffコマンドでPR全体の変更内容を取得
  2. 分析 - 取得した変更内容を分析し、PRの本質的な変更を理解
  3. 更新 - Conventional Commitsに従ったタイトルと、包括的なDescriptionを生成

正直めちゃくちゃシンプルですが、これだけでもめんどくささがかなり減りました。

まとめ

Claude Codeのslash command機能を活用することで、PRのタイトルとDescriptionの更新という繰り返し作業を効率化できました。このようなカスタムコマンドを作成することで、チームの開発フローに合わせた最適化が可能になります。

PR titleやdescriptionはPULL_REQUEST_TEMPLATEを使っているケースもあるので、もうすこしカスタマイズするとチームにあった形で更新できるようになると思います。

参考リンク

2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?