jpskill.com
🛠️ 開発・MCP コミュニティ

agent-elements

React 19とTailwind v4で構築されたプロジェクトで、エージェントチャットやツール呼び出しUIを開発・修正するSkill。

📜 元の英語説明(参考)

Use whenever the user wants to build or modify a chat, agent, or tool-calling UI in a React 19 + Tailwind v4 project — especially if the code imports from `@/components/agent-elements/*` or the project has that folder on disk. Triggers: "agent chat", "tool call UI", "streaming chat", "plan approval", "AgentChat", "InputBar", "tool renderer", mentions of Agent Elements, or requests to add a new agent surface with shadcn. Do NOT use for plain chat UIs that don't need tool/plan/approval cards, or for projects already committed to a different agent UI kit.

🇯🇵 日本人クリエイター向け解説

一言でいうと

React 19とTailwind v4で構築されたプロジェクトで、エージェントチャットやツール呼び出しUIを開発・修正するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-17
取得日時
2026-05-17
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Agent Elements スキル

Agent Elements を使用してチャットおよびエージェント UI を構築するための、プロジェクトを意識したコンテキストです。Agent Elements は、https://agent-elements.21st.dev にあるオープンソースの shadcn レジストリです。

このスキルで得られるもの

このスキルがロードされると、以下のことがわかります。

  1. レジストリは shadcn と互換性があります。 すべてのコンポーネントは npx shadcn@latest add https://agent-elements.21st.dev/r/<component>.json でインストールされます。ファイルは components/agent-elements/ の下に配置されます(ライブラリの内部 components/ プレフィックスは削除されます。下記の「パス」を参照してください)。
  2. API は Vercel AI SDK を中心に型付けされています。 メッセージは ai からの UIMessage[] であり、ステータスは ChatStatus です。useChat() が直接プラグインされます。
  3. API の形状と構成ルールを含む完全なコンポーネントカタログ(下記のセクションを参照してください)。
  4. テーマ設定のガードレール — Agent Elements が依存する Tailwind トークン。

検出

以下のいずれかが当てはまる場合、このプロジェクトは「Agent Elements 対応」と見なされます。

  • components/agent-elements/ がディスク上に存在する
  • components.json に Agent Elements へのエイリアスまたはレジストリ参照が含まれている
  • package.json の依存関係に ai + @tabler/icons-react が含まれており、ユーザーが Agent Elements に言及している

フォルダがまだ存在しない場合は、オンデマンドで以下のようにインストールします。

npx shadcn@latest add https://agent-elements.21st.dev/r/agent-chat.json

agent-chat は、registryDependencies を介して必要な他のすべてのコンポーネント(MessageList、InputBar、ツールレンダラー、共有ユーティリティ)を推移的にプルします。

パス(インストール後のレイアウト)

shadcn add の後、ファイルは @/components/agent-elements/ の下に以下の形状で配置されます。

components/agent-elements/
  agent-chat.tsx
  message-list.tsx
  input-bar.tsx
  markdown.tsx
  user-message.tsx
  error-message.tsx
  text-shimmer.tsx
  spiral-loader.tsx
  input/
    attachment-button.tsx
    send-button.tsx
    file-attachment.tsx
    suggestions.tsx
    model-picker.tsx
    mode-selector.tsx
  tools/
    bash-tool.tsx
    edit-tool.tsx
    search-tool.tsx
    todo-tool.tsx
    plan-tool.tsx
    tool-group.tsx
    subagent-tool.tsx
    mcp-tool.tsx
    thinking-tool.tsx
    generic-tool.tsx
  question/
    question-tool.tsx
  hooks/use-tool-complete.ts
  utils/cn.ts
  types.ts

インポートルール: 常に正確なファイルからインポートし、バレルからはインポートしないでください。

// ✅
import { AgentChat } from "@/components/agent-elements/agent-chat";
import { BashTool } from "@/components/agent-elements/tools/bash-tool";

// ❌ — バレルは存在しません
import { AgentChat } from "@/components/agent-elements";

コンポーネントカタログ

チャットサーフェス

  • AgentChat — 完全なチャットシェルです。MessageList + InputBar をレンダリングし、toolRenderers を介してツール呼び出しを処理し、オプションの suggestions を使用して空の状態を表示します。Props: messages, status, onSend, onStop, toolRenderers?, suggestions?, attachments?, classNames?, slots?
  • MessageList — トランスクリプトのみです。入力バーを別の場所で必要とする場合に使用します。toolRenderersshowCopyToolbar を受け入れます。
  • UserMessage / ErrorMessage / Markdown — 低レベルのメッセージピースです。Markdown は安全にストリーミングされます(外部リンクにはデフォルトで rel="noreferrer" が付与されます)。

入力

  • InputBar — コンポーザーです。Props: status, onSend({ content }), onStop, value? + onChange? (制御された)、attachedImages/attachedFiles とそれらの削除ハンドラー、leftActions/rightActions スロット、suggestions?, questionBar?, infoBar?
  • Suggestions — 空の状態またはインライン用のクイックプロンプトチップです。
  • ModelPicker / ModeSelectorleftActions にドロップするように設計されています。どちらもシンプルな { id, name, version? } / { id, label, icon?, description? } の形状を受け入れます。CLAUDE_MODELS は削除されたためインポートしないでください。独自の配列を提供してください。
  • SendButton / AttachmentButton / FileAttachment — カスタムコンポーザーを構築している場合、スタンドアロンで使用できます。

ツールカード

すべてのツールカードは、AI SDK からの Extract<UIMessage["parts"][number], { type: \tool-<Name>` }>型のpartプロップを受け入れます。AgentChat/MessageListtoolRenderers` を介して登録します。

<AgentChat
  toolRenderers={{
    Bash: BashTool,
    Edit: EditTool,
    Write: EditTool,      // Write は EditTool を再利用します
    Search: SearchTool,
    WebSearch: SearchTool,
    TodoWrite: TodoTool,
    PlanWrite: PlanTool,
    Task: SubagentTool,
    Thinking: ThinkingTool,
  }}
/>

利用可能なカード:

  • BashTool — コマンド + 標準出力、折りたたみ可能。
  • EditTool — 差分カード。input.old_string/input.new_string または output.structuredPatch、および input.approval を介した承認フッターをサポートします。
  • SearchTool — グループ化された検索結果。results を渡すか、output.results を使用します。
  • TodoToolinput.todosoutput.oldTodos の差分が取られた ToDo リスト。
  • PlanTool — 承認/拒否フッター付きの計画タイトル + 概要。
  • ToolGroup — 連続するツール呼び出しを1行にまとめます。
  • SubagentTool — ネストされたツールを持つサブエージェントタスク。
  • McpTool — 汎用 MCP ツール出力。@/components/agent-elements/tools/tool-registry から parseMcpToolType を使用して mcpInfo を取得します。
  • ThinkingTool — 折りたたみ可能な推論行。
  • GenericTool — 未知のツールのフォールバック。
  • QuestionTool — 単一/複数/テキスト回答の種類を持つ明確化の質問。

ストリーミング状態

  • TextShimmer — きらめくステータスラベル。
  • SpiralLoader — Lottie スパイラル。数秒かかるロード状態に使用します。

構成パターン

ツールレンダリング付きのフルチャット(最も一般的)

"use client";

import { AgentChat } from "@/components/agent-elements/agent-chat";
import { BashTool } from "@/components/agent-elements/tools/bash-tool";
import { EditTool } from "@/components/agent-elements/tools/edit-tool";
import { SearchTool } from "@/components/agent-elements/tools/search-tool";
import { useChat } from "@ai-sdk/react";

export default function Chat() {
  const { messages, status, sendMessage, stop } = useChat();
  return (
    <AgentChat
      messages={messages}
      status={status}
      onSend={({ content }) => sendMessage({ text: content })}
      on
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Agent Elements skill

Project-aware context for building chat and agent UIs with Agent Elements — an open-source shadcn registry at https://agent-elements.21st.dev.

What this skill gives you

When this skill loads, you know:

  1. The registry is shadcn-compatible. Every component is installed with npx shadcn@latest add https://agent-elements.21st.dev/r/<component>.json. Files land under components/agent-elements/ (the library's internal components/ prefix is stripped — see Paths below).
  2. The API is typed around the Vercel AI SDK. Messages are UIMessage[] from ai, status is ChatStatus. useChat() plugs in directly.
  3. The full component catalog with API shapes and composition rules (see sections below).
  4. Theming guardrails — the Tailwind tokens Agent Elements depends on.

Detection

Consider this project "Agent Elements-ready" if any of these are true:

  • components/agent-elements/ exists on disk
  • components.json includes an alias or registry reference to Agent Elements
  • package.json dependencies include ai + @tabler/icons-react and the user mentions Agent Elements

If the folder does not exist yet, install on demand with:

npx shadcn@latest add https://agent-elements.21st.dev/r/agent-chat.json

agent-chat transitively pulls every other component it needs via registryDependencies (MessageList, InputBar, tool renderers, shared utils).

Paths (post-install layout)

After shadcn add, files sit under @/components/agent-elements/ with this shape:

components/agent-elements/
  agent-chat.tsx
  message-list.tsx
  input-bar.tsx
  markdown.tsx
  user-message.tsx
  error-message.tsx
  text-shimmer.tsx
  spiral-loader.tsx
  input/
    attachment-button.tsx
    send-button.tsx
    file-attachment.tsx
    suggestions.tsx
    model-picker.tsx
    mode-selector.tsx
  tools/
    bash-tool.tsx
    edit-tool.tsx
    search-tool.tsx
    todo-tool.tsx
    plan-tool.tsx
    tool-group.tsx
    subagent-tool.tsx
    mcp-tool.tsx
    thinking-tool.tsx
    generic-tool.tsx
  question/
    question-tool.tsx
  hooks/use-tool-complete.ts
  utils/cn.ts
  types.ts

Import rule: always import from the exact file, never from a barrel.

// ✅
import { AgentChat } from "@/components/agent-elements/agent-chat";
import { BashTool } from "@/components/agent-elements/tools/bash-tool";

// ❌ — no barrel exists
import { AgentChat } from "@/components/agent-elements";

Component catalog

Chat surface

  • AgentChat — the full chat shell. Renders MessageList + InputBar, handles tool invocations via toolRenderers, shows an empty state with optional suggestions. Props: messages, status, onSend, onStop, toolRenderers?, suggestions?, attachments?, classNames?, slots?.
  • MessageList — transcript only. Use when you need the input bar somewhere else. Accepts toolRenderers and showCopyToolbar.
  • UserMessage / ErrorMessage / Markdown — low-level message pieces. Markdown streams safely (external links get rel="noreferrer" by default).

Input

  • InputBar — composer. Props: status, onSend({ content }), onStop, value? + onChange? (controlled), attachedImages/attachedFiles with their remove handlers, leftActions/rightActions slots, suggestions?, questionBar?, infoBar?.
  • Suggestions — quick-prompt chips for the empty state or inline.
  • ModelPicker / ModeSelector — designed to drop into leftActions. Both accept a simple { id, name, version? } / { id, label, icon?, description? } shape. Do not import CLAUDE_MODELS — it was removed; supply your own array.
  • SendButton / AttachmentButton / FileAttachment — usable standalone if you're building a custom composer.

Tool cards

All tool cards accept a part prop of type Extract<UIMessage["parts"][number], { type: \tool-<Name>` }>from the AI SDK. Register them viatoolRenderersonAgentChat/MessageList`:

<AgentChat
  toolRenderers={{
    Bash: BashTool,
    Edit: EditTool,
    Write: EditTool,      // Write reuses EditTool
    Search: SearchTool,
    WebSearch: SearchTool,
    TodoWrite: TodoTool,
    PlanWrite: PlanTool,
    Task: SubagentTool,
    Thinking: ThinkingTool,
  }}
/>

Cards available:

  • BashTool — command + stdout, collapsible.
  • EditTool — diff card. Supports input.old_string/input.new_string or output.structuredPatch, plus an approval footer via input.approval.
  • SearchTool — grouped search results. Pass results or use output.results.
  • TodoTool — diffed todo list from input.todos vs output.oldTodos.
  • PlanTool — plan title + summary with approve/reject footer.
  • ToolGroup — collapses consecutive tool calls into one row.
  • SubagentTool — sub-agent task with nested tools.
  • McpTool — generic MCP tool output; use parseMcpToolType from @/components/agent-elements/tools/tool-registry to get mcpInfo.
  • ThinkingTool — collapsible reasoning row.
  • GenericTool — fallback for unknown tools.
  • QuestionTool — clarifying question with single/multi/text answer kinds.

Streaming states

  • TextShimmer — shimmering status label.
  • SpiralLoader — Lottie spiral; use for multi-second loading states.

Composition patterns

Full chat with tool rendering (most common)

"use client";

import { AgentChat } from "@/components/agent-elements/agent-chat";
import { BashTool } from "@/components/agent-elements/tools/bash-tool";
import { EditTool } from "@/components/agent-elements/tools/edit-tool";
import { SearchTool } from "@/components/agent-elements/tools/search-tool";
import { useChat } from "@ai-sdk/react";

export default function Chat() {
  const { messages, status, sendMessage, stop } = useChat();
  return (
    <AgentChat
      messages={messages}
      status={status}
      onSend={({ content }) => sendMessage({ text: content })}
      onStop={stop}
      toolRenderers={{
        Bash: BashTool,
        Edit: EditTool,
        Write: EditTool,
        Search: SearchTool,
      }}
    />
  );
}

Composer with mode + model pickers

import { InputBar } from "@/components/agent-elements/input-bar";
import { ModeSelector } from "@/components/agent-elements/input/mode-selector";
import { ModelPicker } from "@/components/agent-elements/input/model-picker";
import { IconBulb, IconCursor } from "@tabler/icons-react";

const modes = [
  { id: "agent", label: "Agent", icon: IconCursor },
  { id: "plan", label: "Plan", icon: IconBulb },
];
const models = [
  { id: "sonnet", name: "Sonnet", version: "4.6" },
  { id: "opus", name: "Opus", version: "4.7" },
];

<InputBar
  status="ready"
  onSend={handleSend}
  onStop={handleStop}
  leftActions={
    <>
      <ModeSelector modes={modes} defaultValue="agent" />
      <ModelPicker models={models} defaultValue="sonnet" />
    </>
  }
/>

Custom tool renderer

toolRenderers values are React components that receive { part, chatStatus }. Return whatever UI you want; reuse GenericTool as a fallback shell.

Theming

Agent Elements reads these Tailwind CSS vars (shadcn-style). Do not remove or rename them in the consumer theme:

  • --an-foreground, --an-background, --an-primary-color
  • Standard shadcn tokens: --background, --foreground, --border, --muted, --muted-foreground, --accent, --primary, etc.

Customising a component is just editing the installed file. Prefer that over wrapping — the code is yours now.

When NOT to use Agent Elements

  • Projects using assistant-ui, ai-elements, copilotkit, or another kit — don't mix.
  • Pure chat UIs that never render tool calls or plans — InputBar + your own message rendering may be enough; skip AgentChat.
  • React < 19 or Tailwind < v4 — the components depend on both.

Quick answers for common asks

  • "Add Agent Elements to this project" → run npx shadcn@latest init if components.json is missing, then npx shadcn@latest add https://agent-elements.21st.dev/r/agent-chat.json.
  • "Switch the default SendButton look" → edit components/agent-elements/input/send-button.tsx directly. Tokens live on --an-* CSS vars.
  • "Render a custom tool" → map its type in toolRenderers; fall back to GenericTool for unknown tools.
  • "Use with useChat" → pass messages and status straight through, translate sendMessage/stop to onSend({ content })/onStop.

Registry reference

  • Index: https://agent-elements.21st.dev/r/index.json
  • Per-component: https://agent-elements.21st.dev/r/<id>.json
  • Full docs in one file: https://agent-elements.21st.dev/llms-full.txt