これは、なにをしたくて書いたもの?
前にこういうエントリーを書きました。
Claude Codeのスキルに関するドキュメントを見直す - CLOVER🍀
ここでスキルの実行をサブエージェントに任せるもの、サブエージェントの実行時にスキルを使って知識を
与える方法の2つを見てみましたが、これを実際に使って試しておこうかなと。
やりたいこと
スキルにはリファレンスコンテンツとタスクコンテンツの2種類があるという話でした。
- リファレンスコンテンツ … エージェントに知識を与えるもの
- タスクコンテンツ … エージェントにデプロイのようなある手続きに沿ってタスクを実行させるもの
これらとサブエージェントの組み合わせを試してみます。
つまり、こういうことになります。
- リファレンスコンテンツのスキルを作成し、サブエージェントに
skillsでプリロードする - タスクコンテンツのスキルを作成し、サブエージェントで実行する
これを試していきます。
環境
今回の環境はこちら。
$ claude --version 2.1.29 (Claude Code) $ ccr version claude-code-router version: 2.0.0
Claude Code RouterはGeminiを使うように設定しています。
$HOME/.claude-code-router/config.json
{ "Providers": [ { "name": "gemini", "api_base_url": "https://generativelanguage.googleapis.com/v1beta/models/", "api_key": "xxxxx", "models": ["gemini-2.5-flash", "gemini-2.5-flash-lite", "gemini-2.5-pro"], "transformer": { "use": ["gemini"] } } ], "Router": { "default": "gemini,gemini-2.5-flash", "think": "gemini,gemini-2.5-flash", "webSearch": "gemini,gemini-2.5-flash" } }
タスクコンテンツをサブエージェントで実行する
まずはタスクコンテンツをサブエージェントで実行してみましょう。
こんなスキルを用意。
.claude/skills/random/SKILL.md
--- name: random description: 使ってランダムな値を生成します disable-model-invocation: true context: fork allowed-tools: Bash(uuidgen) --- `uuidgen`コマンドを使って、ランダムな値を生成して返してください。
ポイントはcontext: forkを指定していることで、これでこのスキルはサブエージェントが実行します。
agentを指定していないので組み込みのgeneral-purposeサブエージェントが動作することになります。
実行してみます。
❯ /random ⎿ A random value has been generated: b6aed0d9-a5d9-4ab7-8a01-2f2b00bf4873
この時のClaude Codeのトランスクリプトログを確認してみます。メインの会話のログはこちら。
$ cat ~/.claude/projects/-home-user-project/03530fdd-add0-42e7-9303-37d4f7d92464.jsonl | jq { "type": "file-history-snapshot", "messageId": "26dffce0-8dbd-4bac-9260-654240d90186", "snapshot": { "messageId": "26dffce0-8dbd-4bac-9260-654240d90186", "trackedFileBackups": {}, "timestamp": "2026-02-01T11:21:50.034Z" }, "isSnapshotUpdate": false } { "parentUuid": null, "isSidechain": false, "userType": "external", "cwd": "/home/user/project", "sessionId": "03530fdd-add0-42e7-9303-37d4f7d92464", "version": "2.1.29", "gitBranch": "", "type": "user", "message": { "role": "user", "content": "<local-command-caveat>Caveat: The messages below were generated by the user while running local commands. DO NOT respond to these messages or otherwise consider them in your response unless the user explicitly asks you to.</local-command-caveat>" }, "isMeta": true, "uuid": "b9cfdc52-e301-4245-bd14-755dc249c311", "timestamp": "2026-02-01T11:21:50.034Z" } { "parentUuid": "b9cfdc52-e301-4245-bd14-755dc249c311", "isSidechain": false, "userType": "external", "cwd": "/home/user/project", "sessionId": "03530fdd-add0-42e7-9303-37d4f7d92464", "version": "2.1.29", "gitBranch": "", "type": "user", "message": { "role": "user", "content": "/random" }, "uuid": "26dffce0-8dbd-4bac-9260-654240d90186", "timestamp": "2026-02-01T11:21:50.034Z" } { "parentUuid": "26dffce0-8dbd-4bac-9260-654240d90186", "isSidechain": false, "userType": "external", "cwd": "/home/user/project", "sessionId": "03530fdd-add0-42e7-9303-37d4f7d92464", "version": "2.1.29", "gitBranch": "", "type": "user", "message": { "role": "user", "content": "<local-command-stdout>\nA random value has been generated: b6aed0d9-a5d9-4ab7-8a01-2f2b00bf4873\n</local-command-stdout>" }, "uuid": "bcd67dae-d031-4a68-af43-250eaa04bc84", "timestamp": "2026-02-01T11:21:50.034Z" }
いきなり結果が現れていますが、Taskツールを使ったことがわかりませんね…?
ただ、サブエージェントのログは出力されているので、サブエージェントがタスクを実行したことがわかります。
cat ~/.claude/projects/-home-user-project/03530fdd-add0-42e7-9303-37d4f7d92464/subagents/agent-a71ca5e.jsonl | jq { "parentUuid": null, "isSidechain": true, "userType": "external", "cwd": "/home/user/project", "sessionId": "03530fdd-add0-42e7-9303-37d4f7d92464", "version": "2.1.29", "gitBranch": "", "agentId": "a71ca5e", "type": "user", "message": { "role": "user", "content": "Base directory for this skill: /home/user/project/.claude/skills/random\n\n`uuidgen`コマンドを使って、ランダムな値を生成して返してください。\n" }, "uuid": "3eeb091f-9d5d-4264-a4a9-8b2e1e464198", "timestamp": "2026-02-01T11:21:46.266Z" } { "parentUuid": "3eeb091f-9d5d-4264-a4a9-8b2e1e464198", "isSidechain": true, "userType": "external", "cwd": "/home/user/project", "sessionId": "03530fdd-add0-42e7-9303-37d4f7d92464", "version": "2.1.29", "gitBranch": "", "agentId": "a71ca5e", "message": { "id": "msg_1769944908191", "type": "message", "role": "assistant", "content": [ { "type": "thinking", "thinking": "(no content)", "signature": "CiQBcsjafGs44o6wUT+Zg3IV2kloKf4iw7gy1jBi7D7vnfZ1vjIKaQFyyNp8Y9NOphY6EPxo/wWJEIrmvjCM6dxmBrm+faYUslvn54cHd+o3G3pi+j8GfGMYqIs2nfoDKczApCKVAaEnQOrn1Ob88BLUXXGlV0qgBlkKly3OMNGMLwRBWVLxCCNdySmwyyK8qQprAXLI2nymSuJUNlRCfEE5AFUMWieIdzg7mgoPTSpgxCKkIuW6+YYAOlrAOkmTcYIItZF5oKmw8XL18salPH39g0MVPFDACYuSAjZ8pH4XAc1nCcsBiWKTONwBKLf9agDBA/jjm+fHk/uiWlc=" } ], "model": "gemini-2.5-flash", "stop_reason": null, "stop_sequence": null, "usage": { "input_tokens": 0, "output_tokens": 0 } }, "type": "assistant", "uuid": "24add4c5-08e8-4422-8ff2-df054aca4474", "timestamp": "2026-02-01T11:21:48.196Z" } { "parentUuid": "24add4c5-08e8-4422-8ff2-df054aca4474", "isSidechain": true, "userType": "external", "cwd": "/home/user/project", "sessionId": "03530fdd-add0-42e7-9303-37d4f7d92464", "version": "2.1.29", "gitBranch": "", "agentId": "a71ca5e", "message": { "id": "msg_1769944908191", "type": "message", "role": "assistant", "content": [ { "type": "text", "text": "(no content)" } ], "model": "gemini-2.5-flash", "stop_reason": null, "stop_sequence": null, "usage": { "input_tokens": 0, "output_tokens": 0 } }, "type": "assistant", "uuid": "a001868a-8cfd-4a8d-b9af-5c9b6bf8ed77", "timestamp": "2026-02-01T11:21:48.199Z" } { "parentUuid": "a001868a-8cfd-4a8d-b9af-5c9b6bf8ed77", "isSidechain": true, "userType": "external", "cwd": "/home/user/project", "sessionId": "03530fdd-add0-42e7-9303-37d4f7d92464", "version": "2.1.29", "gitBranch": "", "agentId": "a71ca5e", "message": { "id": "msg_1769944908191", "type": "message", "role": "assistant", "content": [ { "type": "tool_use", "id": "ccr_tool_7mwocxb5tou", "name": "Bash", "input": { "command": "uuidgen", "description": "Generate a UUID using uuidgen command" } } ], "model": "gemini-2.5-flash", "stop_reason": null, "stop_sequence": null, "usage": { "input_tokens": 0, "output_tokens": 0 } }, "type": "assistant", "uuid": "331ad5e0-1d9f-47d1-8ff4-3b5c3c9b2f49", "timestamp": "2026-02-01T11:21:48.217Z" } { "parentUuid": "331ad5e0-1d9f-47d1-8ff4-3b5c3c9b2f49", "isSidechain": true, "userType": "external", "cwd": "/home/user/project", "sessionId": "03530fdd-add0-42e7-9303-37d4f7d92464", "version": "2.1.29", "gitBranch": "", "agentId": "a71ca5e", "type": "user", "message": { "role": "user", "content": [ { "tool_use_id": "ccr_tool_7mwocxb5tou", "type": "tool_result", "content": "b6aed0d9-a5d9-4ab7-8a01-2f2b00bf4873", "is_error": false } ] }, "uuid": "0cdeab9b-4c97-435c-84b1-b615c0bae780", "timestamp": "2026-02-01T11:21:48.423Z", "sourceToolAssistantUUID": "331ad5e0-1d9f-47d1-8ff4-3b5c3c9b2f49" } { "parentUuid": "0cdeab9b-4c97-435c-84b1-b615c0bae780", "isSidechain": true, "userType": "external", "cwd": "/home/user/project", "sessionId": "03530fdd-add0-42e7-9303-37d4f7d92464", "version": "2.1.29", "gitBranch": "", "agentId": "a71ca5e", "message": { "id": "msg_1769944909723", "type": "message", "role": "assistant", "content": [ { "type": "text", "text": "A random value has been generated: b6aed0d9-a5d9-4ab7-8a01-2f2b00bf4873" } ], "model": "gemini-2.5-flash", "stop_reason": null, "stop_sequence": null, "usage": { "input_tokens": 0, "output_tokens": 0 } }, "type": "assistant", "uuid": "5d112c6d-6a30-4c82-b797-4887557257ec", "timestamp": "2026-02-01T11:21:49.752Z" }
サブエージェントが実行するタスクはSKILL.mdの内容が渡されるということでしたが、こちらですね。
"message": { "role": "user", "content": "Base directory for this skill: /home/user/project/.claude/skills/random\n\n`uuidgen`コマンドを使って、ランダムな値を生成して返してください。\n" },
Extend Claude with skills / Advanced patterns / Run skills in a subagent
context: forkで、メインのコンテキストがforkされている効果は今回は確認できませんでした…。
サブエージェントを実行する時にリファレンスコンテンツを使って知識を与える
次はサブエージェントを実行する時にリファレンスコンテンツを使ってみます。
リファレンスコンテンツとしてのスキルはこちらにしました。このブログのことですね。
.claude/skills/clover/SKILL.md
--- name: clover description: CLOVERという単語の意味を答えます user-invocable: false --- 「CLOVER」とは、以下の特徴を持つ技術ブログのことです。 - https://kazuhira-r.hatenablog.com/ で運営されている - 最低月に1回は更新される - 筆者のやったことがメモとして書かれている 最新の投稿のURLは https://kazuhira-r.hatenablog.com/entry/2026/01/31/180359 です。
サブエージェントはこちら。
.claude/agents/blog-latest-entry-title-getter.md
--- name: blog-latest-entry-title-getter description: 指定されたWebページのタイトルを取得します context: fork disable-model-invocation: true skills: - clover --- あなたは以下の作業を行います。 1. 指定されたWebページのタイトルを抽出する 2. タイトルを作業の結果をとして返す
ちょっと強引な感じですが…。
リファレンスコンテンツをスキルとして指定しています。
skills:
- clover
実行。
❯ blog-latest-entry-title-getterサブエージェントを使って、CLOVERというブログの最新投稿のタイトルを取得してください。 CLOVERの情報はblog-latest-entry-title-getterサブエージェント自身に探してもらってください。 ● blog-latest-entry-title-getter(CLOVERブログの最新投稿タイトルを取得) ⎿ Done (1 tool use · 0 tokens · 9s) ● CLOVERブログの最新投稿のタイトルは「Claude Codeの(カスタム)スラッシュコマンドがスキルに統合されたという話」です。
結果が返ってきました。合っています。CLOVERの情報はサブエージェントに探してもらってと書いていますが、
これがないとメインのエージェントがCLOVERについて確認を求めてくるので…。
メインのエージェントのトランスクリプトログ。
$ cat ~/.claude/projects/-home-user-project/3ca3eb0f-f7ab-4d93-b3c1-45685107f547.jsonl | jq { "type": "file-history-snapshot", "messageId": "6c7e4589-feb9-4222-8873-4c425a97e01e", "snapshot": { "messageId": "6c7e4589-feb9-4222-8873-4c425a97e01e", "trackedFileBackups": {}, "timestamp": "2026-02-01T12:11:48.781Z" }, "isSnapshotUpdate": false } { "parentUuid": null, "isSidechain": false, "userType": "external", "cwd": "/home/user/project", "sessionId": "3ca3eb0f-f7ab-4d93-b3c1-45685107f547", "version": "2.1.29", "gitBranch": "", "type": "user", "message": { "role": "user", "content": "blog-latest-entry-title-getterサブエージェントを使って、CLOVERというブログの最新投稿のタイトルを取得してください。\nCLOVERの情報はblog-latest-entry-title-getterサブエー ジェント自身に探してもらってください。" }, "uuid": "6c7e4589-feb9-4222-8873-4c425a97e01e", "timestamp": "2026-02-01T12:11:48.779Z", "thinkingMetadata": { "maxThinkingTokens": 31999 }, "todos": [], "permissionMode": "default" } { "parentUuid": "6c7e4589-feb9-4222-8873-4c425a97e01e", "isSidechain": false, "userType": "external", "cwd": "/home/user/project", "sessionId": "3ca3eb0f-f7ab-4d93-b3c1-45685107f547", "version": "2.1.29", "gitBranch": "", "message": { "id": "msg_1769947911336", "type": "message", "role": "assistant", "content": [ { "type": "thinking", "thinking": "**Extracting Blog Title**\n\nI'm now focused on using the `blog-latest-entry-title-getter` subagent. The prompt clearly indicates a need to fetch the latest blog post title from the \"CLOVER\" blog. I am confident that the `Task` tool is the correct method for initiating this subagent's execution, according to my understanding of the environment and its capabilities. The subagent description provides a strong basis for its intended usage.\n\n\n**Refining Agent Instructions**\n\nI'm now refining the instructions for the `blog-latest-entry-title-getter` subagent. The subagent needs to locate the \"CLOVER\" blog URL independently, as instructed by the user. I'll need to update the prompt for the `Task` tool to reflect this requirement. I'm focusing on crafting a prompt that concisely guides the subagent to autonomously find and extract the blog title.\n\n\n", "signature": "CiQBcsjafEOCKyPAsyEVqZY7CZsUQegD9iL5UN17p81l1OvngnEKcwFyyNp8z3YO+DmWGPCfN4mg+x7P9YYr778ymdAQttF7pKn/y0M+WlT1WN3SuKj732L9tyfXRXg3fXMkj+L6X9Z+mYK5iOsx9i7s+jep2mF4FxvsDWoBtc+EdghFfCD2J6ZcdLt2CP2To9PjszojmcN6Hj8K/AEBcsjafHTMk6CW8If6kOUYuY98lPKrZPr+8AeYvOWY1rqKNB+SVVMJY/R3VV8UunJ3BwVw+zzwd//qZoAsGP+N0YkCqpmqrcmD4CdSUD3NpdzE5k7c+oJpLsJ607bj4XYpPx+WX+HF+8qB+1hGeiKQ4HX1iRL5wukjLVf92ROlfIW68K9X+vQMUUnePMhQ6MN89eZEYa/qIii5/vfkDK8Wac5sX5qTpgKn1OWha95WPqKZAUtGMbsNnYN1/NpP1iYJqaF/VIZZd3ayzZ7EBECgvUb9CVD31tjqwDlVYv+fuK8hGMaLCpQpQ3DRt/ZtNWZlfMg+6GlMfYvW7Y8K0QEBcsjafKbjJ5BmSjTfkxB4/ythCLdf6C4Fm67NDTOK2SwqlAT72O9vgTTUfH7qbT2r4HSJWA11xVff7qUPR+t9kJRgRyzp3Gt/6bED3ht744Mmi60DzITDQc9OT6a2HS0YGxcsUbx/hzJwZY2ySngbdxZKXiJqiJLfypdeyz7YU9wZm4i7SgpT69DZ3iwDXD8viEIps1g6ZzsGzsTYsVnsb8MlYj9qB5NgMVGGtU1MPZ32iR9ndp+FTbF3pZbHBVU/eUV8zY3aj/oNx1bxKp/FcArcAQFyyNp8hvFD01eU9D7ujQlTEjTw32bir2Y44l6i62dCbw0MLVheW4kVOHCTLU4dm1/N6yt+XzAZ5mt78ZxFOqkoVBt7iYH2seiyBWun5Gqh66fIgSNHSfqYJAaKfGRFYDJFqos+J2T0Kj9TBk8oHtkAgjUzl1k0Adin7GT5CKN4UJBJ+YsWJCgYsU/2t+9fH3mokoSz68UbdXnwTbnwYXNixIBUzoHYa+stmieOhfDtuJnFUnAXeJkGuG51zeoin5GpEfdgwJcSahX4rcAfzSBsNg+yCE0TeadxphAKgAIBcsjafDiYJwxEW7h50vM62SnGZKOJNvSIn9adx8ewPlqgARYz9AwAn6CCb+oKL+Rs53iJ9ig1SCeEYI9xmvYYAq34KPhg5tR7ANlmklol/zMvZWwQ0UFcIT1qmNMIA+FNS8DuY9MVkHx4t/MxmCI9GrYoTmuG5vnlHAzysZwEsi1qsO6CCmgM51snMVowoobTeCyk4il6BvLDoPDCQVQWa608P9S8jyZcair7yhi4vhow9m7ssRPjvf484vOZW1EKY2j1Ut8t4tgLCRA6mFZOoponjbZ+W/5iJ5Tal6FjUPRU0QByblhnzNlq/o0B3sqAkhMPg/qLW7aPkN8nTqT5" } ], "model": "gemini-2.5-flash", "stop_reason": null, "stop_sequence": null, "usage": { "input_tokens": 0, "output_tokens": 0 } }, "type": "assistant", "uuid": "20f4dba7-b6af-4d5b-94c7-dc980e4dbb8b", "timestamp": "2026-02-01T12:11:52.076Z" } { "parentUuid": "20f4dba7-b6af-4d5b-94c7-dc980e4dbb8b", "isSidechain": false, "userType": "external", "cwd": "/home/user/project", "sessionId": "3ca3eb0f-f7ab-4d93-b3c1-45685107f547", "version": "2.1.29", "gitBranch": "", "message": { "id": "msg_1769947911336", "type": "message", "role": "assistant", "content": [ { "type": "text", "text": "(no content)" } ], "model": "gemini-2.5-flash", "stop_reason": null, "stop_sequence": null, "usage": { "input_tokens": 0, "output_tokens": 0 } }, "type": "assistant", "uuid": "5744994a-169d-4375-9bd1-50c1467c4b90", "timestamp": "2026-02-01T12:11:52.076Z" } { "parentUuid": "5744994a-169d-4375-9bd1-50c1467c4b90", "isSidechain": false, "userType": "external", "cwd": "/home/user/project", "sessionId": "3ca3eb0f-f7ab-4d93-b3c1-45685107f547", "version": "2.1.29", "gitBranch": "", "message": { "id": "msg_1769947911336", "type": "message", "role": "assistant", "content": [ { "type": "tool_use", "id": "ccr_tool_slqadl33zv9", "name": "Task", "input": { "description": "CLOVERブログの最新投稿タイトルを取得", "prompt": "CLOVERという名前のブログのURLを見つけ、そのブログの最新投稿のタイトルを取得してください。", "subagent_type": "blog-latest-entry-title-getter" } } ], "model": "gemini-2.5-flash", "stop_reason": null, "stop_sequence": null, "usage": { "input_tokens": 0, "output_tokens": 0 } }, "type": "assistant", "uuid": "8c213a9e-6917-4203-b913-dad737f33d77", "timestamp": "2026-02-01T12:11:52.077Z" } { "parentUuid": "8c213a9e-6917-4203-b913-dad737f33d77", "isSidechain": false, "userType": "external", "cwd": "/home/user/project", "sessionId": "3ca3eb0f-f7ab-4d93-b3c1-45685107f547", "version": "2.1.29", "gitBranch": "", "type": "progress", "data": { "message": { "type": "user", "message": { "role": "user", "content": [ { "type": "text", "text": "CLOVERという名前のブログのURLを見つけ、そのブログの最新投稿のタイトルを取得してください。" } ] }, "uuid": "fde4958f-fcee-4681-ad19-bd57b7fe7cc1", "timestamp": "2026-02-01T12:11:52.378Z" }, "normalizedMessages": [], "type": "agent_progress", "prompt": "CLOVERという名前のブログのURLを見つけ、そのブログの最新投稿のタイトルを取得してください。", "agentId": "aee55c1" }, "toolUseID": "agent_msg_1769947911336", "parentToolUseID": "ccr_tool_slqadl33zv9", "uuid": "ac95ac51-ff59-4561-9177-781b1ba875a4", "timestamp": "2026-02-01T12:11:52.379Z" } { "parentUuid": "ac95ac51-ff59-4561-9177-781b1ba875a4", "isSidechain": false, "userType": "external", "cwd": "/home/user/project", "sessionId": "3ca3eb0f-f7ab-4d93-b3c1-45685107f547", "version": "2.1.29", "gitBranch": "", "type": "progress", "data": { "message": { "type": "assistant", "timestamp": "2026-02-01T12:11:54.294Z", "message": { "id": "msg_1769947914267", "type": "message", "role": "assistant", "content": [ { "type": "tool_use", "id": "ccr_tool_2pfg7sw5l1h", "name": "WebFetch", "input": { "url": "https://kazuhira-r.hatenablog.com/entry/2026/01/31/180359", "prompt": "Extract the title of this web page." } } ], "model": "gemini-2.5-flash", "stop_reason": null, "stop_sequence": null, "usage": { "input_tokens": 0, "output_tokens": 0 }, "context_management": null }, "uuid": "8d5c8e19-f27f-479a-bc20-52fd8ede93f6" }, "normalizedMessages": [], "type": "agent_progress", "prompt": "CLOVERという名前のブログのURLを見つけ、そのブログの最新投稿のタイトルを取得してください。", "agentId": "aee55c1" }, "toolUseID": "agent_msg_1769947911336", "parentToolUseID": "ccr_tool_slqadl33zv9", "uuid": "b633e245-190e-4aa0-8042-39f210fa2272", "timestamp": "2026-02-01T12:11:54.298Z" } { "parentUuid": "b633e245-190e-4aa0-8042-39f210fa2272", "isSidechain": false, "userType": "external", "cwd": "/home/user/project", "sessionId": "3ca3eb0f-f7ab-4d93-b3c1-45685107f547", "version": "2.1.29", "gitBranch": "", "type": "progress", "data": { "message": { "type": "user", "message": { "role": "user", "content": [ { "tool_use_id": "ccr_tool_2pfg7sw5l1h", "type": "tool_result", "content": "The title of the web page is \"Claude Codeの(カスタム)スラッシュコマンドがスキルに統合されたという話\"." } ] }, "uuid": "2313e2ef-442b-41c3-ad02-9786691c8a01", "timestamp": "2026-02-01T12:12:00.047Z" }, "normalizedMessages": [], "type": "agent_progress", "prompt": "CLOVERという名前のブログのURLを見つけ、そのブログの最新投稿のタイトルを取得してください。", "agentId": "aee55c1" }, "toolUseID": "agent_msg_1769947911336", "parentToolUseID": "ccr_tool_slqadl33zv9", "uuid": "2a92c543-8851-47cc-aff0-ca7e01a18e88", "timestamp": "2026-02-01T12:12:00.057Z" } { "parentUuid": "8c213a9e-6917-4203-b913-dad737f33d77", "isSidechain": false, "userType": "external", "cwd": "/home/user/project", "sessionId": "3ca3eb0f-f7ab-4d93-b3c1-45685107f547", "version": "2.1.29", "gitBranch": "", "type": "user", "message": { "role": "user", "content": [ { "tool_use_id": "ccr_tool_slqadl33zv9", "type": "tool_result", "content": [ { "type": "text", "text": "CLOVERブログの最新投稿のタイトルは「Claude Codeの(カスタム)スラッシュコマンドがスキルに統合されたという話」です。" }, { "type": "text", "text": "agentId: aee55c1 (for resuming to continue this agent's work if needed)" } ] } ] }, "uuid": "ecf13d44-df43-477b-a80e-6fe4a5ac9dd1", "timestamp": "2026-02-01T12:12:01.568Z", "toolUseResult": { "status": "completed", "prompt": "CLOVERという名前のブログのURLを見つけ、そのブログの最新投稿のタイトルを取得してください。", "agentId": "aee55c1", "content": [ { "type": "text", "text": "CLOVERブログの最新投稿のタイトルは「Claude Codeの(カスタム)スラッシュコマンドがスキルに統合されたという話」です。" } ], "totalDurationMs": 9207, "totalTokens": 0, "totalToolUseCount": 1, "usage": { "input_tokens": 0, "output_tokens": 0 } }, "sourceToolAssistantUUID": "8c213a9e-6917-4203-b913-dad737f33d77" } { "parentUuid": "ecf13d44-df43-477b-a80e-6fe4a5ac9dd1", "isSidechain": false, "userType": "external", "cwd": "/home/user/project", "sessionId": "3ca3eb0f-f7ab-4d93-b3c1-45685107f547", "version": "2.1.29", "gitBranch": "", "message": { "id": "msg_1769947922802", "type": "message", "role": "assistant", "content": [ { "type": "text", "text": "CLOVERブログの最新投稿のタイトルは「Claude Codeの(カスタム)スラッシュコマンドがスキルに統合されたという話」です。" } ], "model": "gemini-2.5-flash", "stop_reason": null, "stop_sequence": null, "usage": { "input_tokens": 0, "output_tokens": 0 } }, "type": "assistant", "uuid": "41521bda-59bd-476a-a44d-bcd02c9caded", "timestamp": "2026-02-01T12:12:02.811Z" }
こちらがTaskツールでサブエージェントを呼び出している箇所です。
{ "parentUuid": "5744994a-169d-4375-9bd1-50c1467c4b90", "isSidechain": false, "userType": "external", "cwd": "/home/user/project", "sessionId": "3ca3eb0f-f7ab-4d93-b3c1-45685107f547", "version": "2.1.29", "gitBranch": "", "message": { "id": "msg_1769947911336", "type": "message", "role": "assistant", "content": [ { "type": "tool_use", "id": "ccr_tool_slqadl33zv9", "name": "Task", "input": { "description": "CLOVERブログの最新投稿タイトルを取得", "prompt": "CLOVERという名前のブログのURLを見つけ、そのブログの最新投稿のタイトルを取得してください。", "subagent_type": "blog-latest-entry-title-getter" } } ], "model": "gemini-2.5-flash", "stop_reason": null, "stop_sequence": null, "usage": { "input_tokens": 0, "output_tokens": 0 } }, "type": "assistant", "uuid": "8c213a9e-6917-4203-b913-dad737f33d77", "timestamp": "2026-02-01T12:11:52.077Z" }
その後にagentIdというフィールドが入ったログが続き、サブエージェントの実行結果を待っていることが
わかります。
{ "parentUuid": "8c213a9e-6917-4203-b913-dad737f33d77", "isSidechain": false, "userType": "external", "cwd": "/home/user/project", "sessionId": "3ca3eb0f-f7ab-4d93-b3c1-45685107f547", "version": "2.1.29", "gitBranch": "", "type": "progress", "data": { "message": { "type": "user", "message": { "role": "user", "content": [ { "type": "text", "text": "CLOVERという名前のブログのURLを見つけ、そのブログの最新投稿のタイトルを取得してください。" } ] }, "uuid": "fde4958f-fcee-4681-ad19-bd57b7fe7cc1", "timestamp": "2026-02-01T12:11:52.378Z" }, "normalizedMessages": [], "type": "agent_progress", "prompt": "CLOVERという名前のブログのURLを見つけ、そのブログの最新投稿のタイトルを取得してください。", "agentId": "aee55c1" }, "toolUseID": "agent_msg_1769947911336", "parentToolUseID": "ccr_tool_slqadl33zv9", "uuid": "ac95ac51-ff59-4561-9177-781b1ba875a4", "timestamp": "2026-02-01T12:11:52.379Z" } { "parentUuid": "ac95ac51-ff59-4561-9177-781b1ba875a4", "isSidechain": false, "userType": "external", "cwd": "/home/user/project", "sessionId": "3ca3eb0f-f7ab-4d93-b3c1-45685107f547", "version": "2.1.29", "gitBranch": "", "type": "progress", "data": { "message": { "type": "assistant", "timestamp": "2026-02-01T12:11:54.294Z", "message": { "id": "msg_1769947914267", "type": "message", "role": "assistant", "content": [ { "type": "tool_use", "id": "ccr_tool_2pfg7sw5l1h", "name": "WebFetch", "input": { "url": "https://kazuhira-r.hatenablog.com/entry/2026/01/31/180359", "prompt": "Extract the title of this web page." } } ], "model": "gemini-2.5-flash", "stop_reason": null, "stop_sequence": null, "usage": { "input_tokens": 0, "output_tokens": 0 }, "context_management": null }, "uuid": "8d5c8e19-f27f-479a-bc20-52fd8ede93f6" }, "normalizedMessages": [], "type": "agent_progress", "prompt": "CLOVERという名前のブログのURLを見つけ、そのブログの最新投稿のタイトルを取得してください。", "agentId": "aee55c1" }, "toolUseID": "agent_msg_1769947911336", "parentToolUseID": "ccr_tool_slqadl33zv9", "uuid": "b633e245-190e-4aa0-8042-39f210fa2272", "timestamp": "2026-02-01T12:11:54.298Z" } { "parentUuid": "b633e245-190e-4aa0-8042-39f210fa2272", "isSidechain": false, "userType": "external", "cwd": "/home/user/project", "sessionId": "3ca3eb0f-f7ab-4d93-b3c1-45685107f547", "version": "2.1.29", "gitBranch": "", "type": "progress", "data": { "message": { "type": "user", "message": { "role": "user", "content": [ { "tool_use_id": "ccr_tool_2pfg7sw5l1h", "type": "tool_result", "content": "The title of the web page is \"Claude Codeの(カスタム)スラッシュコマンドがスキルに統合されたという話\"." } ] }, "uuid": "2313e2ef-442b-41c3-ad02-9786691c8a01", "timestamp": "2026-02-01T12:12:00.047Z" }, "normalizedMessages": [], "type": "agent_progress", "prompt": "CLOVERという名前のブログのURLを見つけ、そのブログの最新投稿のタイトルを取得してください。", "agentId": "aee55c1" }, "toolUseID": "agent_msg_1769947911336", "parentToolUseID": "ccr_tool_slqadl33zv9", "uuid": "2a92c543-8851-47cc-aff0-ca7e01a18e88", "timestamp": "2026-02-01T12:12:00.057Z" }
サブエージェントのログを見てみましょう。
ログは2つあって、ひとつはスキルを実行したログのようです。
skillsで指定されたスキルの実行もサブエージェントになるのでしょうか?
$ cat ~/.claude/projects/-home-user-project/3ca3eb0f-f7ab-4d93-b3c1-45685107f547/subagents/agent-aprompt_suggestion-27b028.jsonl | jq { "parentUuid": "41521bda-59bd-476a-a44d-bcd02c9caded", "isSidechain": true, "userType": "external", "cwd": "/home/user/project", "sessionId": "3ca3eb0f-f7ab-4d93-b3c1-45685107f547", "version": "2.1.29", "gitBranch": "", "agentId": "aprompt_suggestion-27b028", "type": "user", "message": { "role": "user", "content": "[SUGGESTION MODE: Suggest what the user might naturally type next into Claude Code.]\n\nFIRST: Look at the user's recent messages and original request.\n\nYour job is to predict what THEY would type - not what you think they should do.\n\nTHE TEST: Would they think \"I was just about to type that\"?\n\nEXAMPLES:\nUser asked \"fix the bug and run tests\", bug is fixed → \"run the tests\"\nAfter code written → \"try it out\"\nClaude offers options → suggest the one the user would likely pick, based on conversation\nClaude asks to continue → \"yes\" or \"go ahead\"\nTask complete, obvious follow-up → \"commit this\" or \"push it\"\nAfter error or misunderstanding → silence (let them assess/correct)\n\nBe specific: \"run the tests\" beats \"continue\".\n\nNEVER SUGGEST:\n- Evaluative (\"looks good\", \"thanks\")\n- Questions (\"what about...?\")\n- Claude-voice (\"Let me...\", \"I'll...\", \"Here's...\")\n- New ideas they didn't ask about\n- Multiple sentences\n\nStay silent if the next step isn't obvious from what the user said.\n\nFormat: 2-12 words, match the user's style. Or nothing.\n\nReply with ONLY the suggestion, no quotes or explanation." }, "uuid": "eb7949fd-4621-436a-ba07-a0249a1cb32a", "timestamp": "2026-02-01T12:12:03.113Z" } { "parentUuid": "eb7949fd-4621-436a-ba07-a0249a1cb32a", "isSidechain": true, "userType": "external", "cwd": "/home/user/project", "sessionId": "3ca3eb0f-f7ab-4d93-b3c1-45685107f547", "version": "2.1.29", "gitBranch": "", "agentId": "aprompt_suggestion-27b028", "message": { "id": "msg_1769947999010", "type": "message", "role": "assistant", "content": [ { "type": "text", "text": "CLOVERという単語の意味を教えてください" } ], "model": "gemini-2.5-flash", "stop_reason": null, "stop_sequence": null, "usage": { "input_tokens": 0, "output_tokens": 0 } }, "type": "assistant", "uuid": "4881538e-0e46-4915-b32c-1581a9ef32bf", "timestamp": "2026-02-01T12:13:19.014Z" }
今回作成したサブエージェントのログ。
$ cat ~/.claude/projects/-home-user-project/3ca3eb0f-f7ab-4d93-b3c1-45685107f547/subagents/agent-aee55c1.jsonl | jq { "parentUuid": null, "isSidechain": true, "userType": "external", "cwd": "/home/user/project", "sessionId": "3ca3eb0f-f7ab-4d93-b3c1-45685107f547", "version": "2.1.29", "gitBranch": "", "agentId": "aee55c1", "type": "user", "message": { "role": "user", "content": "CLOVERという名前のブログのURLを見つけ、そのブログの最新投稿のタイトルを取得してください。" }, "uuid": "fde4958f-fcee-4681-ad19-bd57b7fe7cc1", "timestamp": "2026-02-01T12:11:52.378Z" } { "parentUuid": "fde4958f-fcee-4681-ad19-bd57b7fe7cc1", "isSidechain": true, "userType": "external", "cwd": "/home/user/project", "sessionId": "3ca3eb0f-f7ab-4d93-b3c1-45685107f547", "version": "2.1.29", "gitBranch": "", "agentId": "aee55c1", "type": "user", "message": { "role": "user", "content": [ { "type": "text", "text": "<command-message>clover</command-message>\n<command-name>clover</command-name>\n<skill-format>true</skill-format>" }, { "type": "text", "text": "Base directory for this skill: /home/user/project/.claude/skills/clover\n\n「CLOVER」とは、以下の特徴を持つ技術ブログのことです。\n\n- https://kazuhira-r.hatenablog.com/ で運営されている\n- 最低月に1回は更新される\n- 筆者のやったことがメモとして書かれている\n\n最新の投稿のURLは https://kazuhira-r.hatenablog.com/entry/2026/01/31/180359 です。\n" } ] }, "uuid": "bbaa3758-95cf-43f9-98ed-a6fb61106854", "timestamp": "2026-02-01T12:11:52.380Z" } { "parentUuid": "bbaa3758-95cf-43f9-98ed-a6fb61106854", "isSidechain": true, "userType": "external", "cwd": "/home/user/project", "sessionId": "3ca3eb0f-f7ab-4d93-b3c1-45685107f547", "version": "2.1.29", "gitBranch": "", "agentId": "aee55c1", "message": { "id": "msg_1769947914267", "type": "message", "role": "assistant", "content": [ { "type": "thinking", "thinking": "(no content)", "signature": "CiQBcsjafEVHV58XSOTEIJBx/wzzOhNDPMu0AVUnwo7H4v0x8M0KbQFyyNp8haXA/fXu660mWrYqbV+sQj8p02ROmfGMOr9U9UsalCvGe+PsakOmUm4NfiDrmw8L8O5EkjeDIrhgyoHiAPNzNJowEprvHvYpQL/wFdJVtav+WEp8iDpkEbzPYAAKqh3gPZQPQbK19y0KiQEBcsjafACdKNCRnbd2rGO8Pm2u8nxssK0OEkCe7XQCM4GnfOkBADVuraSXW5lP/4bh0CWMi3lII2V6QncK88nm2E8V1BWIgpoihje5oDK/cnJNbGuELJZIq5JK2UruVhdd996WJmVzMenQnPmjKJ23lCyzIkAEiBCLXBmgjCpSxs8PwOwDnsr6FArIAQFyyNp8Z/g97iXj+5l9fmrFDC0p4boaY3IH4ZQmSUQVOcN8am/z68CNZvZGLFQJ3MRjbe6eCBExypSyK6i0bSYfoTxZyb8E7asXA8PlHwxJUkAXu28sCS4uKKVMTQotLOzLk6djmGsSU6kYmFbb64rB9edKZ62nMT2lSeb1idyu9E2AQeiTbA2gN7S/FdE8Sh22DedMqoyE6j/wG/9sSixHVeudr71k9eYrE0eagPtIUYKBlzoSjMW7NuK6fBhxT0LJhL9biyaO" } ], "model": "gemini-2.5-flash", "stop_reason": null, "stop_sequence": null, "usage": { "input_tokens": 0, "output_tokens": 0 } }, "type": "assistant", "uuid": "9a69d1e6-78c1-4b8b-a62d-c02d72987f28", "timestamp": "2026-02-01T12:11:54.280Z" } { "parentUuid": "9a69d1e6-78c1-4b8b-a62d-c02d72987f28", "isSidechain": true, "userType": "external", "cwd": "/home/user/project", "sessionId": "3ca3eb0f-f7ab-4d93-b3c1-45685107f547", "version": "2.1.29", "gitBranch": "", "agentId": "aee55c1", "message": { "id": "msg_1769947914267", "type": "message", "role": "assistant", "content": [ { "type": "text", "text": "(no content)" } ], "model": "gemini-2.5-flash", "stop_reason": null, "stop_sequence": null, "usage": { "input_tokens": 0, "output_tokens": 0 } }, "type": "assistant", "uuid": "649ba8e6-e05e-4340-9956-ab6af35060d4", "timestamp": "2026-02-01T12:11:54.287Z" } { "parentUuid": "649ba8e6-e05e-4340-9956-ab6af35060d4", "isSidechain": true, "userType": "external", "cwd": "/home/user/project", "sessionId": "3ca3eb0f-f7ab-4d93-b3c1-45685107f547", "version": "2.1.29", "gitBranch": "", "agentId": "aee55c1", "message": { "id": "msg_1769947914267", "type": "message", "role": "assistant", "content": [ { "type": "tool_use", "id": "ccr_tool_2pfg7sw5l1h", "name": "WebFetch", "input": { "url": "https://kazuhira-r.hatenablog.com/entry/2026/01/31/180359", "prompt": "Extract the title of this web page." } } ], "model": "gemini-2.5-flash", "stop_reason": null, "stop_sequence": null, "usage": { "input_tokens": 0, "output_tokens": 0 } }, "type": "assistant", "uuid": "8d5c8e19-f27f-479a-bc20-52fd8ede93f6", "timestamp": "2026-02-01T12:11:54.294Z" } { "parentUuid": "8d5c8e19-f27f-479a-bc20-52fd8ede93f6", "isSidechain": true, "userType": "external", "cwd": "/home/user/project", "sessionId": "3ca3eb0f-f7ab-4d93-b3c1-45685107f547", "version": "2.1.29", "gitBranch": "", "agentId": "aee55c1", "type": "user", "message": { "role": "user", "content": [ { "tool_use_id": "ccr_tool_2pfg7sw5l1h", "type": "tool_result", "content": "The title of the web page is \"Claude Codeの(カスタム)スラッシュコマンドがスキルに統合されたという話\"." } ] }, "uuid": "2313e2ef-442b-41c3-ad02-9786691c8a01", "timestamp": "2026-02-01T12:12:00.047Z", "sourceToolAssistantUUID": "8d5c8e19-f27f-479a-bc20-52fd8ede93f6" } { "parentUuid": "2313e2ef-442b-41c3-ad02-9786691c8a01", "isSidechain": true, "userType": "external", "cwd": "/home/user/project", "sessionId": "3ca3eb0f-f7ab-4d93-b3c1-45685107f547", "version": "2.1.29", "gitBranch": "", "agentId": "aee55c1", "message": { "id": "msg_1769947921506", "type": "message", "role": "assistant", "content": [ { "type": "thinking", "thinking": "(no content)", "signature": "CnUBcsjafEdlqOtsaQ7nX7kvByJrUUnaQoNBGtJA+VSoGcBxz++MFVKO3qmqf1bdiuf3mXi32YeTZx32jOjnNsa2Bb8KxO8ZASEO2LFChvkmcjoZhXNpSPNg4TEnfTBEb9r7O9MOZv1WmExz5LbAydk9MoFOGSEK6QEBcsjafAXt6uoImVt4X0NjcR46OFVPE3CtuCFWKeio5noPmNZFQSd+3Q/QF2cYJtL+/n9cdrFx9hyqsFWUWFW8IDwPz7It29xrOEjB2UV7jJ/3G+URYL0OjUtJfL2i74rkUqEITppjecNeoQ5nqz4rT23lMucnQ4pJcZQ0rdbhbhriYXJ2NtUFaROYvW/JxPRADMtBE4cb0n6SG5yxVlyEJCBtZrOVlo5wIZDj4TL0+VMhQmj3wYnIG5Tl3varvM/S8b+VbVpFtzQBw33OjfnAI/cxQkjtJvd6KJT1ktcHeGBtotBXlBDmAg==" } ], "model": "gemini-2.5-flash", "stop_reason": null, "stop_sequence": null, "usage": { "input_tokens": 0, "output_tokens": 0 } }, "type": "assistant", "uuid": "12c93fed-f320-458a-9f82-8a05466204a5", "timestamp": "2026-02-01T12:12:01.515Z" } { "parentUuid": "12c93fed-f320-458a-9f82-8a05466204a5", "isSidechain": true, "userType": "external", "cwd": "/home/user/project", "sessionId": "3ca3eb0f-f7ab-4d93-b3c1-45685107f547", "version": "2.1.29", "gitBranch": "", "agentId": "aee55c1", "message": { "id": "msg_1769947921506", "type": "message", "role": "assistant", "content": [ { "type": "text", "text": "CLOVERブログの最新投稿のタイトルは「Claude Codeの(カスタム)スラッシュコマンドがスキルに統合されたという話」です。" } ], "model": "gemini-2.5-flash", "stop_reason": null, "stop_sequence": null, "usage": { "input_tokens": 0, "output_tokens": 0 } }, "type": "assistant", "uuid": "735c744b-7cd4-43c5-84a5-1472b4201f6f", "timestamp": "2026-02-01T12:12:01.523Z" }
こちらはメインエージェントからの指示ですね。
{ "parentUuid": null, "isSidechain": true, "userType": "external", "cwd": "/home/user/project", "sessionId": "3ca3eb0f-f7ab-4d93-b3c1-45685107f547", "version": "2.1.29", "gitBranch": "", "agentId": "aee55c1", "type": "user", "message": { "role": "user", "content": "CLOVERという名前のブログのURLを見つけ、そのブログの最新投稿のタイトルを取得してください。" }, "uuid": "fde4958f-fcee-4681-ad19-bd57b7fe7cc1", "timestamp": "2026-02-01T12:11:52.378Z" }
そして次にスキルの内容が渡されています。
{ "parentUuid": "fde4958f-fcee-4681-ad19-bd57b7fe7cc1", "isSidechain": true, "userType": "external", "cwd": "/home/user/project", "sessionId": "3ca3eb0f-f7ab-4d93-b3c1-45685107f547", "version": "2.1.29", "gitBranch": "", "agentId": "aee55c1", "type": "user", "message": { "role": "user", "content": [ { "type": "text", "text": "<command-message>clover</command-message>\n<command-name>clover</command-name>\n<skill-format>true</skill-format>" }, { "type": "text", "text": "Base directory for this skill: /home/user/project/.claude/skills/clover\n\n「CLOVER」とは、以下の特徴を持つ技術ブログのことです。\n\n- https://kazuhira-r.hatenablog.com/ で運営されている\n- 最低月に1回は更新される\n- 筆者のやったことがメモとして書かれている\n\n最新の投稿のURLは https://kazuhira-r.hatenablog.com/entry/2026/01/31/180359 です。\n" } ] }, "uuid": "bbaa3758-95cf-43f9-98ed-a6fb61106854", "timestamp": "2026-02-01T12:11:52.380Z" }
よさそうですね。
これで今回見てみたかったものは確認できました。
おわりに
前に書いたエントリーの理解を確認するために、Claude Codeのスキルとサブエージェントの組み合わせを
実際に試してみました。
context: forkの挙動などちょっと確認しきれなかったものもあるのですが、動かしている環境的に仕方ない
ところです…。
ひとまず使い方は確認できた気がするので、これでよしとしましょう。