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?

ClaudeCodeでサブエージェントを作って使ってみた

Posted at

概要

Claude Codeのサブエージェントが良さげとの情報を聞いたので試してみる。
以下の記事を参考に試した結果を記載しています。

公式

サブエージェント設定

Claude Codeを起動し/agentsを入力することで設定追加・確認ができる。

以下はサブエージェントが何も設定されていない状態で/agentsを入力した場合

Create new agentを選択

Create new agentを選択してEnter

image.png

今回は現在のプロジェクト配下のみに適用するサブエージェントを設定するため、1. Project(.claude/agents/)を選択した。
2を選択するとどこで作業した場合もそのサブエージェントが使える。サブエージェントの機能によって使い分けても良いと思う。
image.png

Generate with Claudeを選択

1. Generate with Claudeを選択する。自分でサブエージェント設定をすることもできるらしいが、Claudeに生成してもらうのが推奨されているらしい。
image.png

サブエージェント設定の生成

サブエージェント設定をClaude Code 側に生成してもらう。

image.png

設定に必要な情報を提供する。今回はgithubのPRを作成するためのエージェントを作成する。
image.png

ClaudeCodeに提供した内容

GitHub のリポジトリにプルリクエストを作成するエージェントを作成してください。
プルリクエストを作成する際には以下の手順に従ってください。
 
1. 変更内容を確認する
2. 新しいブランチを作成する
3. タスク単位で変更をコミットする
4. プルリクエストを作成する

commitメッセージは以下のルールに従ってください。

1. prefixをつける

feat: A new feature
fix: A bug fix
docs: Documentation only changes 
style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
refactor: A code change that neither fixes a bug nor adds a feature
perf: A code change that improves performance
test: Adding missing or correcting existing tests
chore: Changes to the build process or auxiliary tools and libraries such as documentation generation

2. メッセージには理由を書く

「YYのためXXを追加・変更した」という形で"なぜ"に焦点をあててメッセージを記載してください。

これはContinueでよいと思います
image.png
image.png

サブエージェントの作業で使用するモデルを選択。今回はgithubのPRを作成するのみでそこまでハイスペックなモデルはいらないのでSonnetにしておきます。
image.png

エージェントが起動したときの色も選択できるそう。今回は緑を選択した。
image.png

この設定でよければEnter
image.png

github-pr-createrが追加されている。
image.png

設定を確認することも可能。
image.png

確認すると説明、色、システムプロンプトなど設定されているのがわかる
image.png

サブエージェントを使ってみる

サブエージェントを使用するには明示的にサブエージェントを使用する旨を指示したほうが良いらしい。次のプロンプトで指示してみた。

サブエージェントを使用して差分をgit管理してPR作成して

github-pr-createrがというエージェントを使用してgithubのPRを作成してくれているのがわかる
image.png

コミットメッセージなども当初指示した内容となっている
image.png

感想

これまでCLAUDE.mdに記載していたルールを守ってくれないことが多々あったが、エージェントを呼び出すことでルールを守ってくれそうだと感じた

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?