embedded-agents-messages-api
БесплатноЗапускает вложенные скриптыНе проверенBuilding, adding or wiring up an agent or an agent chat inside a Next.js app: embed Claude agents on the Messages API, the default way.
от sickn33★ 50 670 звёзд на GitHubОб этом скилле
Embedded agents — Claude API
Operational boundaries
Keep the scope, sandbox, credentials and approval settings supplied by the user or host. Obtain authorization before delegating, exposing project files to another provider, enabling connectors or hooks, using paid services or deploying. Use synthetic or redacted inputs for examples. Keep security reviews static and defensive, with findings and fixes grounded in source inspection.
When to Use
Building, adding or wiring up an agent or an agent chat inside a Next.js app: embed Claude agents on the Messages API, the default way.
Use the Messages API by default for a new product. The Anthropic SDK's tool runner (client.beta.messages.toolRunner) drives the loop inside the app's process. The agent has exactly the wrapper's tools, with nothing built in. Both embedded-agent skills run the same agent directories, which move between them unchanged (playbook § 10). Apply embedded-agents-agent-sdk only when the agent needs what only the Claude Code engine has, or when the product already runs it. That SDK starts the engine as a subprocess, provides built-in file and shell tools, and needs a long-lived Node host.
Read the product's own agent instructions before changing its embedded agents. Start with its root AGENTS.md or CLAUDE.md, and tell any subagent spawned for this work to read it too. Its rules on secrets, environment variables, validation, callers, tests and release apply here. Read reference/playbook.md before changing the wrapper's contract or explaining it in depth. It holds the full playbook and the measurement behind every choice.
Keep request, caller, storage and UI ownership in the app. The agent owns reasoning and tool choice. An agent is a directory, .claude/agents/<name>/, with AGENTS.md as its whole system prompt. It may also hold knowledge/, agent-local skills in .claude/skills/, and .mcp.json. One wrapper function, askAgent, runs any agent. No agent name appears in code.
1. First use: install the wrapper
Search for askAgent before installing another wrapper. If it exists, skip to § 2. If it imports @anthropic-ai/claude-agent-sdk, the product uses the other skill; migration is in playbook § 10. Otherwise:
Create only the smallest requested app when none exists. Use Next.js App Router in TypeScript, which these files target. Add nothing unasked for: no database, sign-in or billing for a local prototype.
Install the missing dependencies. Run
npm i @anthropic-ai/sdk @modelcontextprotocol/sdk zod server-onlyandnpm i -D vitest. Pin exact versions: the tool runner is marked beta in the TypeScript SDK, so an upgrade is re-tested, not assumed.Copy the wrapper, route and tests, changing only import paths.
From this skill To the app templates/agent.tssrc/lib/agent.ts— the wrappertemplates/agent-mcp.tssrc/lib/agent-mcp.ts— an agent's MCP servers, opened per runtemplates/route.tssrc/app/api/agents/route.ts—GETlists agents,POSTstreams onetemplates/agent.test.tstests/unit/agent.test.ts— the contract, insidenpm test, no model calltemplates/agents.live.test.tstests/live/agents.live.test.ts— every agent against the real modelThe tests import
@/lib/agentand@/lib/agent-mcp, so Vitest needs the same@alias astsconfig.json. The live test gets its own Vitest config (includetests/live/**/*.live.test.ts,testTimeout: 180_000,fileParallelism: false, andprocess.loadEnvFile('.env')in atry) and a script,agents:live. It costs money, so it stays out ofnpm testand the gate.Set each required secret per environment and never commit it. Set
ANTHROPIC_API_KEYand every secret referenced by an agent's.mcp.json; applyenvironments. On a developer's machine the SDK also reads a profile fromant auth login; a deployed product always uses the key.Keep the contract. Every choice in
agentRequest()andaskAgent()is pinned by the unit test and explained in the playbook (§ 3, § 7). Change one only after re-measuring it.
2. Add an agent
- Create the agent directory and write its complete instructions. Run
node <skill dir>/scripts/new-agent.mjs <name> [--knowledge] [--mcp], then fill inAGENTS.md: role, sources, output format, refusals. It is the agent's whole system prompt, with no product preset underneath. A fixed sign-off line is the cheapest live-test proof that the instructions are in force. - Confine knowledge tools to knowledge and load skills as instructions. Put files in
knowledge/, and tell the agent inAGENTS.mdto answer only from them. It getslist_files,search_filesandread_file, confined toknowledge/(playbook § 5). Name those tools inAGENTS.md, not Claude Code's Read/Glob/Grep. Put agent-local skills in.claude/agents/<name>/.claude/skills/<skill>/SKILL.md, with `descript
Установить embedded-agents-messages-api в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл embedded-agents-messages-api?
Building, adding or wiring up an agent or an agent chat inside a Next.js app: embed Claude agents on the Messages API, the default way.
Как установить скилл embedded-agents-messages-api?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл embedded-agents-messages-api запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic