How to Build Your First AI Agent in 15 Minutes
You don't need a framework, a course, or a PhD. You need Node.js, the Anthropic SDK, and 25 lines of TypeScript. This tutorial builds a real, working agent — a structured content summarizer you can deploy to Cloudflare in the same session. The only prerequisite is a free API key.
Every Wednesday. 28,400+ operators. Zero fluff.
✓ Check your inbox — click the confirmation link to complete sign-up.
✓ You're subscribed!
✓ You're already on the list.
Table of contents
Open Table of contents
- Why most “build an AI agent” tutorials fail you
- What you’re building
- Prerequisites (2 minutes)
- Step 1: Create the project (2 minutes)
- Step 2: Write the agent (5 minutes)
- Step 3: Run it (1 minute)
- Step 4: Customize it for your use case
- Step 5: Deploy to production
- What to build next
- The operator’s bottom line
Why most “build an AI agent” tutorials fail you
They either use Python (fine for ML engineers, friction for everyone else), hide the real code behind a framework like LangChain, or build something too abstract to connect to your actual work.
This tutorial does three things differently:
- TypeScript only — if you’ve ever written JavaScript, you can follow this
- No framework — you’ll see every line of code that touches the model
- A useful output — you’ll build a structured summarizer you can actually use on customer emails, reviews, or meeting notes
What you’re building
A content summarizer agent: paste any block of text, get back a structured summary in a consistent format. One HTTP request in, one clean summary out.
Why this as a first project: the pattern — system prompt + user input → structured output — is the foundation of every agent I run. Swap the system prompt and you have a question-answerer, a tone rewriter, a classifier, or a draft generator. Learn this once and you’ve learned 80% of what production agents actually do.
Prerequisites (2 minutes)
- Node.js 18+ — check with
node --version. Install from nodejs.org if needed. - An Anthropic API key — sign up at Claude, grab a key from the console. The free tier works.
- A terminal and a text editor.
No Docker. No virtual environment. No pip install anything.
Step 1: Create the project (2 minutes)
mkdir my-first-agent && cd my-first-agent
npm init -y
npm install @anthropic-ai/sdk
npm install -D tsx typescriptAdd a script to package.json so you can run the agent easily:
{
"scripts": {
"agent": "tsx agent.ts"
}
}Step 2: Write the agent (5 minutes)
Create agent.ts and paste this:
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: process.env.ANTHROPIC_API_KEY,
});
const SYSTEM_PROMPT = `You are a precise content summarizer. When given any block of text, return a structured summary in this exact format:
**One-line summary:** <the core point in one sentence>
**Key points:**
- <point 1>
- <point 2>
- <point 3 if applicable>
**Action item (if any):** <one concrete next step, or "None">
Be specific. No filler. Under 150 words total.`;
async function summarize(text: string): Promise<string> {
const message = await client.messages.create({
model: "claude-haiku-4-5",
max_tokens: 512,
system: SYSTEM_PROMPT,
messages: [{ role: "user", content: text }],
});
const block = message.content[0];
if (block.type !== "text") throw new Error("Unexpected response type");
return block.text;
}
const sample = `
Hey team — following up on the Q2 review meeting.
We agreed to push the launch to July 15th instead of June 30th
due to the payment integration delay. Marketing needs the new
landing page copy by June 20th or we can't start the email campaign.
Budget for the launch campaign is confirmed at $8,000.
Please confirm receipt.
`;
const result = await summarize(sample);
console.log(result);Step 3: Run it (1 minute)
ANTHROPIC_API_KEY=sk-ant-... npm run agentExpected output:
**One-line summary:** Launch pushed to July 15th due to payment delay; landing page copy needed by June 20th to unblock email campaign.
**Key points:**
- Launch date moved from June 30th to July 15th
- Landing page copy deadline: June 20th (blocks email campaign)
- Campaign budget confirmed at $8,000
**Action item (if any):** Confirm receipt and deliver landing page copy by June 20th.That’s a working AI agent. Real input, custom system prompt, structured output. The whole thing is 30 lines of code.
Step 4: Customize it for your use case
The system prompt is the only thing that makes this agent yours. Here are three drop-in alternatives:
Customer review classifier:
Classify this customer review as POSITIVE, NEGATIVE, or MIXED.
Then extract the main complaint or praise in one sentence.
Format: SENTIMENT: <label>
RESUME: <one sentence>Meeting transcript → action items:
Extract all action items from this meeting transcript.
Format each as: [OWNER if mentioned] [ACTION] by [DEADLINE if mentioned]
If owner or deadline is not stated, leave those fields blank.
Return a numbered list. No preamble.Tone rewriter for social:
Rewrite this text in a direct, confident, first-person tone for LinkedIn.
Remove hedging language ("I think", "maybe", "sort of").
Keep it under 200 words. Return only the rewritten text, no commentary.Each of these is the same 30-line agent with a different system prompt. You don’t need a new project for each — just update SYSTEM_PROMPT and re-run.
Step 5: Deploy to production
A local script is a prototype. A production agent runs on a schedule or in response to events. The path I use: Cloudflare Workers.
Workers are free up to 100k requests/day, deploy in seconds, and give you cron triggers, KV storage, and queues without managing any infrastructure.
Install Wrangler and scaffold a Worker:
npm install -g wrangler
wrangler init my-agent-worker --template worker-typescript
cd my-agent-worker
npm install @anthropic-ai/sdkStore your API key as a secret (never in code):
wrangler secret put ANTHROPIC_API_KEYReplace src/index.ts with:
import Anthropic from "@anthropic-ai/sdk";
export default {
async fetch(request: Request, env: Env): Promise<Response> {
const { text } = await request.json<{ text: string }>();
const client = new Anthropic({ apiKey: env.ANTHROPIC_API_KEY });
const message = await client.messages.create({
model: "claude-haiku-4-5",
max_tokens: 512,
system: YOUR_SYSTEM_PROMPT,
messages: [{ role: "user", content: text }],
});
const block = message.content[0];
if (block.type !== "text") return Response.json({ error: "Bad response" }, { status: 500 });
return Response.json({ summary: block.text });
},
};Deploy:
wrangler deployYou now have a live API endpoint at https://my-agent-worker.<your-subdomain>.workers.dev. Call it from Zapier, a Google Sheets script, a mobile app — anywhere that can make an HTTP request.
What to build next
Once you have the basic pattern working, complexity comes in three flavors:
Tool use — let the model decide when to call external APIs. Instead of always running the same logic, the model chooses which tool to invoke based on the input. This is how you build agents that search, write to databases, or send notifications.
Chaining — pass one agent’s output as another agent’s input. A classifier routes to a responder; a summarizer feeds a translator. Most of the agents I run in production are two- or three-step chains, not single calls.
Cron triggers — add [triggers] crons = ["0 8 * * *"] to wrangler.toml and your agent runs on a schedule. No polling, no always-on server. This is how the content pipeline I use to run this site works.
I covered all three patterns with full TypeScript code in The Agent Stack I Use to Run 30+ Production Agents — that post picks up where this one ends.
The operator’s bottom line
The gap between “thinking about building an agent” and “having a deployed agent” is about 15 minutes and 30 lines of code. The system prompt is the product — spend your energy there, not on picking a framework. If the agent saves you one hour a week, that’s 50 hours a year. Build the simple version first, see if it earns its keep, then add complexity only when the use case demands it.
Every Wednesday. 28,400+ operators. Zero fluff.
✓ Check your inbox — click the confirmation link to complete sign-up.
✓ You're subscribed!
✓ You're already on the list.
Get the AI playbook in your inbox
Every Wednesday. 28,400+ operators. Zero fluff.
Check your inbox.
We sent you a confirmation email — click the link inside to complete your subscription. Check spam if you don't see it within a minute.
You're subscribed.
Welcome — the next edition lands in your inbox soon.
You're already on the list — look for it every Wednesday.