Skip to content

Examples Playbook

Build confidence by running the examples in order. Each example introduces exactly one new concept and builds on everything before it.

Start here — 5 minutes to your first agent

bash
npm install personaforge
ts
import { agent } from 'personaforge';

const bot = agent('You are a helpful assistant. Be concise.');

const { text } = await bot.run('What is 2+2?');
console.log(text); // "4"

That's it. No config. No boilerplate. One call, working agent.

Example map — pick your starting point

#ExampleTimeWhat you learn
01Hello World2 minCreate and run your first agent
02First Custom Tool5 minBuild a tool that calls a real API
03Tool with Approval5 minAsk human before executing risky actions
04Extend & Wrap Tools8 minAdd middleware, caching, auth to any tool
05RAG Knowledge Base10 minAnswer questions from your own documents
06Persistent Memory8 minRemember users across conversations
07Storage Patterns8 minCache, state, and config in agents
08Multi-Agent Team10 minSpecialized agents working together
09Supervisor Workflow10 minOne agent delegates to many specialists
10Database Analyst12 minQuery SQL databases with natural language
11Customer Support Bot15 minFull bot: sessions + guardrails + handoff
12Observability & Hooks10 minLog, trace, and measure every agent step
13Production Resilience12 minCircuit breakers, retries, fallbacks
14MCP Filesystem Agent12 minUse Model Context Protocol tools
15Full-Stack App20 minHTTP API + agent + RAG + storage
16Intelligent LLM Router10 minAuto-route to right model by task/cost/speed
17Full Framework Showcase25 minEvery module in one real-world story
18Meridian Platform30 min6 personas, triage, supervisor, consensus
19Incident Triage Bot15 minChain-of-thought reasoning loops
20Scheduled Agent Jobs10 minCron scheduling with handler registry
21Code Review Pipeline15 minCompose, pipe, conditional handoff, hooks
22Eval Regression Guard12 minEval suites, baseline saving, CI exit codes

Learning paths

Path A: Build a real bot (examples 01 → 06 → 11 → 13)

Start with a hello-world agent, add memory so it remembers users, wire it into a full support bot with guardrails and handoff, then wrap it in production resilience.

Path B: Master multi-agent systems (examples 01 → 08 → 09 → 18)

From a single agent to a team of specialists, to a supervisor that delegates, to a full platform with routing, consensus, and triage.

Path C: Hardened production (examples 01 → 12 → 13 → 22)

From a working agent through observability and hooks, to circuit breakers and rate limits, to CI-based eval regression detection.

Path D: Knowledge & retrieval (examples 01 → 02 → 05 → 10)

From a simple chat agent to custom tools, to RAG from your documents, to querying real databases.

Runnable counterparts

These TypeScript files in the examples/ directory can be run directly:

bash
bun run example:simple          # One agent, one tool
bun run example:showcase        # Full framework tour
bun run example:meridian        # Orchestration-heavy platform demo
bun run example:reasoning       # Explicit reasoning loops
bun run example:scheduled       # Scheduled agents
bun run example:code-review     # Staged review pipelines
bun run example:eval            # Regression-style evaluation
bun run example:multi-agent     # Supervisor, pipeline, consensus, graph
bun run example:durability      # Durable execution with checkpoints
bun run example:graph           # DAG workflows with branching + parallelism

Quickstart snippets (run these in 30 seconds)

Run any of these in the examples/quickstart/ directory:

bash
bun examples/quickstart/01-hello.ts     # One agent, one message
bun examples/quickstart/02-tool.ts      # Agent with a custom tool
bun examples/quickstart/03-memory.ts    # Agent that remembers
bun examples/quickstart/04-session.ts   # Multi-turn conversation
bun examples/quickstart/05-resume.ts    # Resume from a checkpoint

Environment setup

bash
# Required for most examples
OPENAI_API_KEY=sk-...

# Optional, adds more provider options
ANTHROPIC_API_KEY=sk-ant-...
GOOGLE_AI_API_KEY=...
TAVILY_API_KEY=tvly-...

Skill levels

LevelBest for
🟢 BeginnerFirst contact with the framework or agent authoring in general
🟡 IntermediateTool-backed, retrieval-backed, or observable agents
🔴 AdvancedOrchestration, production runtime controls, evaluation-heavy systems

After the examples

Released under the MIT License.