Build your own coding agent in TypeScript.
createAgent() sends the prompt, runs the tools the model asks for and feeds back the results until the task is done.
import { createAgent } from 'zidane'
import { basic } from 'zidane/presets'
import { anthropic } from 'zidane/providers'
const agent = createAgent({
...basic,
provider: anthropic({ apiKey: process.env.ANTHROPIC_API_KEY }),
behavior: { codemode: true },
})
await agent.run({
model: 'claude-opus-5-5',
prompt: 'Retry GitHub calls that fail with a 502 or 503.',
})agent.run()Retry GitHub calls that fail with a 502 or 503.
HooksHooks
A hook on every turn.
Hooks see each text delta, tool call, MCP event and budget, and can change most. A tool:gate hook stops a shell command before it runs and tells the model why.
// Every delta, tool call and budget event is a hook.
agent.hooks.hook('tool:gate', (ctx) => {
if (ctx.name === 'shell' && /\brm -rf\b/.test(String(ctx.input.command))) {
ctx.block = true
ctx.reason = 'Destructive command: ask the user first.'
}
})
agent.hooks.hook('stream:text', ({ delta }) => process.stdout.write(delta))
agent.hooks.hook('turn:after', ({ usage }) => {
console.log(`${usage.input} in / ${usage.output} out`)
})Execution contextsExecution contexts
Choose where the tools run.
Shell and file tools run on your machine, in Docker, or in an E2B or Daytona sandbox. Locally, Seatbelt (macOS) or bubblewrap (Linux) can fence each command.
Run the server tests and tell me where they ran.
The loop
Parts of the loop you can replace.
ToolsShell, file and search tools. A hook can gate each call.MCPMCP servers over stdio or HTTP, with OAuth and tools loaded on demand.Sub-agentsChild agents with their own tools and budgets. Their events reach the parent.Sessions and compactionStores save each turn as it lands, so runs resume. autoCompact summarizes older turns past 85% of the window.Provider parityOther providers get client-side versions of Anthropic's server-side features, so you switch without rewriting the agent.Fault recoveryZidane coerces bad arguments, answers unknown tool names with a fallback and rewrites errors so the model can act on them.
Start with the quickstart.
Install the package, sign in to a provider and run your first agent.
Other surfaces