Skip to content

phuryn/product-engineering / app-stack/skills/embedded-agents-agent-sdk

embedded-agents-agent-sdk

Verified

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.

scripts/new-agent.mjs

View on GitHub
#!/usr/bin/env node
// Scaffold an embedded agent: .claude/agents/<name>/AGENTS.md, plus knowledge/ or .mcp.json on request.
// Run from the repo root:
//   node <skill dir>/scripts/new-agent.mjs <name> [--knowledge] [--mcp]
// The wrapper finds the agent by its directory; no code or UI change is needed to route to it.
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
import { join, resolve } from 'node:path';

const args = process.argv.slice(2);
const name = args.find((a) => !a.startsWith('--'));
if (!name || !/^[a-z0-9][a-z0-9-]*$/.test(name)) {
  console.error('Usage: new-agent.mjs <name> [--knowledge] [--mcp]   (name: lowercase letters, digits, hyphens)');
  process.exit(2);
}
const dir = resolve(process.cwd(), '.claude', 'agents', name);
if (existsSync(join(dir, 'AGENTS.md'))) {
  console.error(`${name} already exists at ${dir}`);
  process.exit(1);
}

const title = name.split('-').map((w) => w[0].toUpperCase() + w.slice(1)).join(' ');
mkdirSync(dir, { recursive: true });
writeFileSync(join(dir, 'AGENTS.md'), `You are the **${title}**. <One sentence: who you answer and what you do for them.>

## Sources

<Where every answer comes from — files in \`knowledge/\`, a named MCP tool, or general knowledge — and which of them is authoritative.>

## Output format

<The shape of every answer.>

## Refusals

<What you decline, and the exact sentence you answer with.>
`);
const made = ['AGENTS.md'];

if (args.includes('--knowledge')) {
  mkdirSync(join(dir, 'knowledge'), { recursive: true });
  made.push('knowledge/');
}
if (args.includes('--mcp')) {
  writeFileSync(join(dir, '.mcp.json'), `${JSON.stringify({
    mcpServers: {
      '<server>': { type: 'stdio', command: 'npx', args: ['-y', '<package>'], env: { '<KEY>': '${<KEY>}' }, allowedTools: [] },
    },
  }, null, 2)}\n`);
  made.push('.mcp.json');
}
console.log(`Created .claude/agents/${name}/: ${made.join(', ')}. Fill in the <placeholders>.`);
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall