Skip to main content

ワークフロー クイックスタート

このチュートリアルでは、GitHub Pull Request のレビューを自動化するワークフローを作成します。CLIツール、ファイル分析、ユーザー操作を組み合わせる方法を紹介します。

前提条件

  • Careti がインストール済み
  • GitHub CLI(gh) をインストールして認証済み
  • テスト対象の PR がある Git リポジトリを開いている

PRレビュー ワークフローを作成する

このワークフローは PR 情報を取得し、変更点を分析し、レビューコメントを作成します。

ワークフローファイルを作成

プロジェクト専用のワークフローディレクトリを作成します。

  1. プロジェクトルートに .agents/context/workflows フォルダを作成
  2. その中に pr-review.md ファイルを作成

ワークフロー内容を記述

pr-review.md に以下を追加します。

# Pull Request Reviewer

This workflow helps me review a pull request by analyzing the changes and drafting a review.

## 1. Gather PR Information
First, I need to understand what this PR is about. I'll fetch the title, description, and list of changed files.

```bash
gh pr view PR_NUMBER --json title,body,files
```

## 2. Examine Modified Files
Now I will examine the diff to understand the specific code changes.

```bash
gh pr diff PR_NUMBER
```

## 3. Analyze Changes
I will analyze the code changes for:
* **Bugs:** Logic errors or edge cases.
* **Performance:** Inefficient loops or operations.
* **Security:** Vulnerabilities or unsafe practices.

## 4. Confirm Assessment
Based on my analysis, I will present my findings and ask how you want to proceed.

```xml
<ask_followup_question>
<question>I've reviewed PR #PR_NUMBER. Here is my assessment:

[Insert Analysis Here]

Do you want me to approve this PR, request changes, or just leave a comment?</question>
<options>["Approve", "Request Changes", "Comment", "Do nothing"]</options>
</ask_followup_question>
```

## 5. Execute Review
Finally, I will execute the review command based on your decision.

```bash
# If approving:
gh pr review PR_NUMBER --approve --body "Looks good to me! [Summary of analysis]"

# If requesting changes:
gh pr review PR_NUMBER --request-changes --body "Please address the following: [Issues list]"

# If commenting:
gh pr review PR_NUMBER --comment --body "[Comments]"
```
ℹ️Note

実行時に PR_NUMBER を実際のPR番号に置き換えてください (例: /pr-review.md 123).

ワークフローを実行

準備ができたら実行します。

  1. Careti のチャットパネルを開く
  2. /pr-review.md の後に PR 番号を入力 (例: /pr-review.md 42)
  3. Careti がPR情報を取得・分析し結果を提示
💡Tip

gh pr view のようなコマンド実行後に Careti が止まる場合は、Proceed While Running をクリックして続行してください。

その他の利用例

これは一例です。次のようなワークフローも作成できます:

  • コンポーネント作成: React コンポーネントや API エンドポイントの雛形作成
  • テスト実行: テストを実行して結果を要約
  • デプロイ自動化: dockerkubectl を活用
  • リファクタリング支援: 複雑なリファクタリングを段階的に実施

繰り返し作業を見つけて、効率的な Careti ワークフローに変えていきましょう。