Build Agent Skill
Turn a description like "an agent that writes commit messages" into a working,
tested NanoCodana agent. NanoCodana is a coding-agent framework on the Vercel AI
SDK: an agent is created with NodeAgent({ ... }) and run with
agent.generate({ prompt }) or agent.stream({ messages }).
Template — a minimal runnable agent
Write a file like this to the current working directory (adapt the name, model, system prompt, and tools to the request). It reads the API key from the environment — no dotenv needed, because it inherits the parent process's env.
import { NodeAgent } from '@nanocodana/nodejs'
import { createAnthropic } from '@ai-sdk/anthropic'
const model = createAnthropic({ apiKey: process.env.ANTHROPIC_API_KEY })(
'claude-sonnet-4-5',
)
const agent = NodeAgent({
model,
workingDirectory: process.cwd(),
systemPrompt: `<one paragraph describing this agent's single job>`,
// Optional: gate or restrict tools for safety, e.g.
// needsApproval: ['Write', 'Edit', 'Delete'],
})
// The task comes in as the first CLI arg (fallback for a quick smoke test).
const task = process.argv[2] ?? '<a representative default task>'
const result = await agent.generate({ prompt: task })
console.log(result.text)
If OPENAI_API_KEY is set instead of ANTHROPIC_API_KEY, use
createOpenAI(...)('gpt-4o') from @ai-sdk/openai.
Steps
- Clarify the agent's single purpose, its model, and which tools it needs. Keep the scope to one clear job.
- Write the agent script to
<name>.mjsin the current working directory. - (Optional) Write a skill at
.agents/skills/<name>/SKILL.mdif the agent needs reusable, loadable instructions — then have the generated agent load it (omitskillsto let it auto-discover from its working dir). - Test it by running it with the host shell and a representative task:
(Use Bash withnode <name>.mjs "a representative task for this agent"host: true— running Node needs the real shell.) - Read the output. If the agent misbehaves, fix the script or its system prompt / skill and run it again. Don't stop until it produces a sensible result.
- Summarize what you built: the file(s) created, the agent's purpose, and the exact command to run it.
Rules
- Keep generated agents minimal — only
@nanocodana/nodejsplus one AI SDK provider. No extra dependencies. - Default to safe tools. Do not enable host Bash or destructive tools in a generated agent unless the user explicitly asks.
- Always test before declaring done.
- Do NOT build an agent whose job is to build other agents (no recursion).