Logo de Embedded Agents Agent Sdk

Embedded Agents Agent Sdk

Comunidade
phuryn
embedded-agents-agent-sdk

Only when the Agent SDK is asked for, an agent needs Claude Code's own tools, or the app already runs it: embed Claude agents in a Next.js app with the Agent SDK.

Visão geral

Publicado porphuryn
Repositórioproduct-engineering
Nome da habilidadeembedded-agents-agent-sdk
Estrelas
189
Forks
27
Arquivos incluídos
16
LicençaMIT
Links
  • Instruções em Markdown

    Um arquivo SKILL.md que o modelo carrega sob demanda, consumindo tokens apenas quando uma solicitação é realmente relevante para a habilidade.

  • Funciona com qualquer LLM

    Habilidades de IA são Markdown simples, não código específico de um provedor, por isso funcionam com GPT, Claude, Gemini, Grok ou um modelo local.

  • 16 arquivos incluídos

    Scripts, modelos de documentos e referências que o modelo pode ler enquanto trabalha. Os arquivos são somente leitura e nunca são executados.

  • Código aberto

    Publicada por phuryn no GitHub. Leia o conteúdo-fonte antes de instalar.

Instalação

Instale a habilidade de IA Embedded Agents Agent Sdk no TypingMind para usá-la com qualquer LLM ou adicione-a a outro agente que leia SKILL.md.

1

Instalar no TypingMind

O TypingMind instala uma habilidade diretamente da pasta dela no GitHub — lê o arquivo SKILL.md, reúne os arquivos de recursos em um pacote e armazena o resultado localmente.

  1. Abra o app e vá para Plugins → Habilidades.
  2. Escolha "Instalar do GitHub".
  3. Cole a URL da pasta da habilidade exibida abaixo e confirme.
    https://github.com/phuryn/product-engineering/tree/main/app-stack/skills/embedded-agents-agent-sdk
  4. Ative a habilidade em cada chat em que quiser disponibilizá-la.
Plugins → Habilidades → Nova habilidade → Via URL GitHub, depois cole a URL da pasta e pressione Continuar.
2

Instalar em outro agente

Qualquer agente que leia o formato Agent Skills pode usar esta habilidade — copie a pasta para o diretório de habilidades desse agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/phuryn/product-engineering.git /tmp/product-engineering
mkdir -p .claude/skills
cp -r /tmp/product-engineering/app-stack/skills/embedded-agents-agent-sdk .claude/skills/embedded-agents-agent-sdk
Reinicie Claude Code após copiar para que a nova habilidade seja reconhecida.

Use no TypingMind

Ative Embedded Agents Agent Sdk em qualquer chat do TypingMind e o modelo cuida do resto. O nome e a descrição da habilidade ficam no prompt do sistema e, assim que uma solicitação relevante aparece, o modelo carrega as instruções completas automaticamente — sem precisar de acionamento manual e sem consumir tokens até que ela seja realmente usada.

O modelo carrega Embedded Agents Agent Sdk automaticamente assim que uma solicitação é relevante para essa habilidade.

Funciona com qualquer modelo de IA

Habilidades de IA são instruções em Markdown simples, não código específico de um provedor. Por isso, Embedded Agents Agent Sdk não fica vinculada ao modelo para o qual foi criada. Instale-a uma vez no TypingMind e use-a com GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama ou um modelo local executado por conta própria — tudo com suas próprias chaves de API.

  • Carregada apenas quando necessário

    O prompt do sistema contém apenas o nome e a descrição. As instruções são buscadas na primeira solicitação relevante, então uma habilidade sem uso não gera custo.

  • Troque de modelo durante a conversa

    Como a habilidade é composta de instruções, não de código, trocar de modelo não afeta seu funcionamento — o próximo modelo lê o mesmo arquivo SKILL.md.

Instruções da habilidade

Este é o conteúdo de SKILL.md que o modelo carrega. Leia antes de instalar — uma habilidade é um conjunto de instruções que seu modelo seguirá.

Embedded agents — Claude Agent SDK

Which skill. Two skills run the same agent directories. This one runs them through the Claude Agent SDK, which starts the Claude Code engine as a subprocess: built-in file and shell tools, Claude Code's own system prompt, its skill and MCP loading, and a long-lived Node host to run on. The embedded-agents-messages-api skill runs them on the Claude API with the Anthropic SDK's tool runner, in the app's own process: only the tools the wrapper gives the agent, no subprocess, any Node host. It is the default for a new product. Use this one when the agent needs what only the engine has, or when the product already runs it.

Read the product's own agent instructions first (its root AGENTS.md or CLAUDE.md), and tell any subagent you spawn for this work to read them too: their rules on secrets, environment variables, validation, callers, tests and release apply to everything here. This skill adds how to run Claude agents inside the app. reference/playbook.md is the full playbook, with the measurement behind every option — read it before changing the wrapper's contract or explaining it in depth.

The model: the app owns the request, the caller, storage and the UI; the agent owns reasoning and tools. An agent is a directory, .claude/agents/<name>/, holding AGENTS.md (its instructions — its only instruction file), and optionally knowledge/, agent-local skills in .claude/skills/, and .mcp.json. One wrapper function, askAgent, runs any of them. No agent name appears in code.

1. First use: install the wrapper

Search the code for askAgent. If it exists, skip to § 2. Otherwise:

  1. No app yet? Create the smallest Next.js App Router app in TypeScript (what this skill's files are written for) and nothing the user did not ask for — no database, sign-in or billing for a local prototype.

  2. Install what is missing: npm i @anthropic-ai/claude-agent-sdk zod server-only and npm i -D vitest.

  3. Copy, changing only import paths:

    From this skillTo the app
    templates/agent.tssrc/lib/agent.ts — the wrapper
    templates/route.tssrc/app/api/agents/route.ts — GET lists agents, POST streams one
    templates/agent.test.tstests/unit/agent.test.ts — the contract, inside npm test, no model call
    templates/agents.live.test.tstests/live/agents.live.test.ts — every agent against the real model

    The tests import @/lib/agent, so Vitest needs the same @ alias as tsconfig.json. The live test gets its own Vitest config (include tests/live/**/*.live.test.ts, testTimeout: 180_000, fileParallelism: false) and a script, agents:live. It costs money, so it stays out of npm test and the gate.

  4. Environment: ANTHROPIC_API_KEY, plus every secret an agent's .mcp.json references, each set per environment and never committed (the environments skill). On a developer's laptop the SDK falls back to their own Claude login when the key is absent; a deployed product always uses the key.

  5. Keep the contract. Every option in agentOptions() exists because an SDK default failed a measurement (playbook § 9). Change one only after re-measuring it.

2. Add an agent

  1. node <skill dir>/scripts/new-agent.mjs <name> [--knowledge] [--mcp], then fill in AGENTS.md: role, sources, output format, refusals. A fixed sign-off line is the cheapest proof, in a live test, that the instructions are in force.
  2. Knowledge: files in knowledge/*.md, and AGENTS.md says to answer only from them. Agent-local skills: .claude/agents/<name>/.claude/skills/<skill>/SKILL.md; found automatically.
  3. MCP: servers in .mcp.json, secrets as ${VAR}, never literal. Run node --env-file=.env <skill dir>/scripts/discover-mcp-tools.mjs <name> to list what each server offers, then put in that server's allowedTools only what the agent's job needs. Anything unlisted is denied. The agent's .mcp.json holds no secrets and is committed: if git check-ignore reports it ignored, the repo's .gitignore has an unanchored .mcp.json rule meant for the root file — anchor it as /.mcp.json.
  4. Routing needs nothing: listAgents() finds the directory, GET /api/agents returns it, and — when users choose between agents — the UI's picker shows it. A UI that hardcodes the list is the bug to fix.
  5. The instruction file is always AGENTS.md. Asked for another name, create AGENTS.md and say why: the wrapper loads only AGENTS.md, and the SDK loads some other instruction files on its own, which would give the agent two sets of instructions.
  6. When the agent makes a promise worth pinning — it cites, it refuses, it answers only from its files — add a live test for it beside the generic one.

3. Examples — only when asked

examples/ holds two finished agents. Use them when the user asks for examples, or describes one of them: an agent that answers only from local product-management knowledge files (knowledge-agent), or one that researches the live web through Perplexity with citations (research-agent). Copy examples/<name>/ to .claude/agents/<name>/ and examples/<name>.live.test.ts to tests/live/. research-agent needs PERPLEXITY_API_KEY. Otherwise, never copy them.

4. The chat UI

Product-specific, so there is no template. What it must do:

  • When users choose between agents, fill the picker from GET /api/agents. A product may run one front agent and show no picker; the route still checks the name against listAgents().
  • POST { agent, prompt, history } to /api/agents and read server-sent events: { text } chunks, then { done, agent, metadata } or { error, agent }. The parser is in playbook § 5.
  • Store the agent on every message and, when there is more than one, show it on each reply, so the reader always knows which agent answered. History is the conversation so far, kept in client state unless the product asks to persist it.
  • Render agent output as plain text or sanitized markdown, never raw HTML: it is untrusted text, like anything a user typed. Show an error event instead of spinning forever.

5. Explaining routing and the tool boundary

Routing: UI → POST /api/agents { agent } → the route validates the body and requires the name to be in listAgents() → askAgent → agentOptions() accepts only a plain directory name and resolves .claude/agents/<agent>/ → query() starts the Claude Code engine with that directory as cwd and its AGENTS.md appended to the system prompt → events stream back.

Boundary — each layer measured (playbook § 9):

  1. tools: only the built-ins on the allowlist exist — Read, Glob, Grep by default. Bash, Write, Edit and WebFetch do not.
  2. permissionMode: 'dontAsk' with allowedTools: an MCP tool runs only if its server's allowedTools in .mcp.json lists it.
  3. strictMcpConfig: only the agent's own .mcp.json servers load — nothing from the developer's or the server's user configuration.
  4. skills: only the agent's own skills are listed.
  5. The PreToolUse guard blocks any path outside the agent's directory, and any .env file.
  6. maxTurns (10 by default) and maxBudgetUsd cap a run.

6. Before it leaves localhost

  • Hosting. The SDK runs the Claude Code engine as a subprocess, so an agent cannot run in a serverless function such as a Netlify Function (playbook § 7). A product whose site deploys there needs a second, long-lived Node host (a container or VM, such as Railway), chosen before the agent goes beyond localhost; write its deploy procedure into the product's docs the first time it is used. next dev needs nothing.
  • History is a client claim. templates/route.ts accepts history from the client, assistant turns included, and composePrompt turns it into a "Previous conversation" preamble — so a client can forge earlier turns, the agent's own included. That is acceptable for a read-only agent, which can only be talked into saying something to the person forging it. Before any tool acts on the caller's behalf, keep the transcript on the server and stop reading it from the request.
  • Caller and cost: before anyone but the developer can reach the route, resolve the caller there (who they are, which workspace, which permission: saas-authorization) and set a per-actor limit and a maxBudgetUsd.
  • Release: run npm run agents:live before any release that adds or changes an agent, its prompt or its model, record the run in the product's test-coverage map (which test proves what, and when it last passed), and describe each agent in its automation doc: what it may read, the exact tools it may call, and what the app enforces around it (shipping-artifacts).

How you can tell it worked

The agent runs on the deployed host, not only on localhost, uses only the tools it was given, and the live agent suite passes against the real model.

Running the scripts

Run them from the app's repository root: <skill dir> is wherever this skill is installed (a plugin, ~/.claude/skills/, or the repo's own .claude/skills/), and the scripts write into the current directory.

Arquivos incluídos

O modelo lê esses arquivos sob demanda enquanto a habilidade está carregada. Eles são disponibilizados para leitura e nunca são executados.

Perguntas frequentes

O que a habilidade de IA Embedded Agents Agent Sdk faz?

Only when the Agent SDK is asked for, an agent needs Claude Code's own tools, or the app already runs it: embed Claude agents in a Next.js app with the Agent SDK.

Por que usar Embedded Agents Agent Sdk no TypingMind?

Porque basta instalar uma vez para usar com qualquer modelo. Embedded Agents Agent Sdk é escrito em Markdown simples, e não em código específico de um provedor, então a mesma habilidade funciona com GPT-5, Claude, Gemini, Grok ou um modelo local — e é possível trocar de modelo no meio do chat sem que ela deixe de funcionar. O TypingMind usa suas próprias chaves de API, então o pagamento é feito diretamente aos provedores, em vez de uma assinatura por licença de usuário, e suas habilidades e chats permanecem no seu próprio armazenamento.

Como instalar Embedded Agents Agent Sdk no TypingMind?

Abra Plugins → Habilidades → Instalar do GitHub no TypingMind e cole https://github.com/phuryn/product-engineering/tree/main/app-stack/skills/embedded-agents-agent-sdk. O TypingMind lê o arquivo SKILL.md, reúne os arquivos da habilidade e a instala para que possa ser ativada em cada chat.

Quais modelos de IA podem usar Embedded Agents Agent Sdk?

Qualquer modelo conectado no TypingMind. As habilidades de IA são instruções em Markdown simples, e não código específico de um provedor. Assim, GPT, Claude, Gemini, Grok e modelos locais podem carregar esta habilidade quando uma solicitação corresponder a ela.

Quantos modelos de IA posso usar com Embedded Agents Agent Sdk?

Quantos quiser. Desde que o modelo ofereça suporte a habilidades, é possível usar Embedded Agents Agent Sdk com ele — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e outros — tudo no TypingMind com suas próprias chaves de API.

A habilidade de IA Embedded Agents Agent Sdk é gratuita?

Sim. A habilidade é publicada no GitHub por phuryn sob a licença MIT. O pagamento é feito apenas ao seu provedor de IA pelos tokens usados.

O que são habilidades de IA?

Uma habilidade de IA é um conjunto reutilizável de instruções que ensina um modelo de IA a realizar uma tarefa específica. Ela segue o formato aberto Agent Skills: um arquivo SKILL.md com nome e descrição, além de scripts, modelos de documento ou arquivos de referência de que o modelo possa precisar. O modelo lê as instruções apenas quando sua solicitação corresponde à habilidade, então uma habilidade instalada não gera custos até ser usada.

Qual é a diferença entre habilidades de IA e plugins ou servidores MCP?

Um plugin ou servidor MCP oferece ao modelo novas ferramentas para chamar — código que é executado em algum lugar e retorna um resultado. Já uma habilidade de IA fornece conhecimento e um processo ao modelo: como abordar uma tarefa, quais etapas seguir e como deve ser um bom resultado. As habilidades são escritas em Markdown simples, por isso não precisam de servidor, chave de API nem ambiente de execução, e funcionam com qualquer modelo.

Ver todos

Crie seu próprio espaço de IA agora

Inscreva-se na nossa newsletter para receber novidades sobre recursos e futuros sorteios 👇