Claude Agent TypeScript SDK

Build Claude agents using TypeScript with the @anthropic-ai/claude-agent-sdk.

You say
Buy it · $19 Read it before you buy $19 Written by szweibel · unverified publisher
Context cost
24.8k tokensestimated from the bundle, loaded when it triggers
Bundle
14 files · 99.0 kBtext throughout, nothing executable
Licence
MITpaid listing
Last change
no release on file
Servers it uses
Noneruns standalone

What it does

Build Claude agents using TypeScript with the @anthropic-ai/claude-agent-sdk. Use this skill when implementing conversational agents, building tools for agents, setting up streaming responses, or debugging agent implementations. Covers the tool wrapping pattern, SDK initialization, agent architecture, and best practices.

Installed, it changes the agent in these ways.

What this skill changes about the agent is not written down here yet. The listing was collected from its source, and the description is in its own SKILL.md.

Guardrail

Constrains what the agent is allowed to do.

officialtypescriptagent

The skill itself

This is the whole product. A skill is instructions the model reads, so there is nothing behind the listing you cannot see first — the front matter loads with every session, and the body below it loads when the skill triggers.

SKILL.md11.4 kB · 393 lines
--- name: claude-agent-ts-sdk description: Build Claude agents using TypeScript with the @anthropic-ai/claude-agent-sdk. Use this skill when implementing conversational agents, building tools for agents, setting up streaming responses, or debugging agent implementations. Covers the tool wrapping pattern, SDK initialization, agent architecture, and best practices. license: MIT category: development-tools ---
8# Claude Agent TypeScript SDK
9
10Build production-ready Claude agents using TypeScript and the @anthropic-ai/claude-agent-sdk. This skill provides battle-tested patterns for creating modular, composable agent tools.
11
12## Quick Start
13
14```typescript
15import { query, createSdkMcpServer, tool } from '@anthropic-ai/claude-agent-sdk';
16import { z } from 'zod';
17
18// 1. Define tools
19const greetTool = tool(
20 'greet',
21 'Greet a user by name',
22 z.object({
23 name: z.string().describe('User name'),
24 }).shape,
25 async ({ name }) => ({
26 content: [{ type: 'text', text: Hello, ${name}! }],
27 })
28);
29
30// 2. Create MCP server
31const server = createSdkMcpServer({
32 name: 'my-agent',
33 version: '1.0.0',
34 tools: [greetTool],
35});
36
37// 3. Query with streaming
38const messages = query({
39 prompt: 'Greet Alice',
40 options: {
41 systemPrompt: 'You are a helpful agent.',
42 permissionMode: 'bypassPermissions',
43 mcpServers: { 'my-agent': server },
44 },
45});
46
47// 4. Process stream
48for await (const event of messages) {
49 if (event.type === 'assistant') {
50 for (const content of event.message.content) {
51 if (content.type === 'text') {
52 console.log(content.text);
53 }
54 }
55 }
56}
57```
58
59## When to Use This Skill
60
61Use when:
62- **Implementing agents**: Building CLI tools, web servers, or plugins
63- **Creating tools**: Defining agent capabilities and integrations
64- **Handling streams**: Processing agent responses in real-time
65- **Debugging**: Troubleshooting agent implementations
66- **Migrating**: Converting from MCP servers to tool wrapping approach
67
68## Core Concepts
69
70### 1. Tools
71
72Tools are the building blocks of agent capabilities. Use the tool() function to create them:
73
74```typescript
75import { tool } from '@anthropic-ai/claude-agent-sdk';
76import { z } from 'zod';
77
78const myTool = tool(
79 'tool_name', // Name (lowercase, underscores)
80 'What it does', // Clear description
81 z.object({ // Zod schema for validation
82 param: z.string().describe('Parameter description'),
83 }).shape,
84 async (params) => { // Implementation
85 return {
86 content: [{ type: 'text', text: 'Result' }],
87 };
88 }
89);
90```
91
92**Key Points:**
93- Use Zod for schema validation
94- Descriptions guide Claude's tool selection
95- Return format: { content: [{ type: 'text', text: string }] }
96- **For advanced patterns, see references/tools.md**
97
98### 2. MCP Servers
99
100Wrap tools in MCP servers for query execution:
101
102```typescript
103import { createSdkMcpServer } from '@anthropic-ai/claude-agent-sdk';
104
105const server = createSdkMcpServer({
106 name: 'server-name',
107 version: '1.0.0',
108 tools: [tool1, tool2],
109});
110```
111
112**Important:** Create servers at query time, not module level (enables dynamic tool selection).
113
114### 3. Query and Streaming
115
116Execute agent queries with real-time streaming:
117
118```typescript
119import { query } from '@anthropic-ai/claude-agent-sdk';
120
121const messages = query({
122 prompt: 'User request here',
123 options: {
124 systemPrompt: 'Agent role and instructions',
125 permissionMode: 'bypassPermissions', // For standalone servers
126 mcpServers: {
127 'server-name': server,
128 },
129 },
130});
131
132for await (const event of messages) {
133 // Process events: 'assistant', 'user', 'error'
134}
135```
136
137**For streaming patterns and event handling, see references/streaming.md**
138
139### 4. System Prompts
140
141System prompts define agent behavior (100-170+ lines recommended):
142
143```typescript
144const SYSTEM_PROMPT = `You are a specialized agent that...
145
146## Available Tools
147[Detailed tool descriptions]
148
149## Workflow
150[Step-by-step instructions]
151
152## Output Format
153[Expected response structure]
154`;
155```
156
157**For system prompt best practices, see references/system-prompts.md**
158
159## Architecture Patterns
160
161Choose the pattern that fits your use case:
162
163### Pattern 1: CLI/Specialized Agent
164**Best for:** Command-line tools, batch processing
165
166```typescript
167export async function runAgent(userPrompt: string) {
168 const server = createSdkMcpServer({ name: 'cli-agent', version: '1.0.0', tools });
169 const messages = query({ prompt: userPrompt, options: { systemPrompt, permissionMode: 'bypassPermissions', mcpServers: { 'cli-agent': server } } });
170
171 for await (const event of messages) {
172 if (event.type === 'assistant') {
173 for (const content of event.message.content) {
174 if (content.type === 'text') process.stdout.write(content.text);
175 }
176 }
177 }
178}
179```
180
181### Pattern 2: Web Server Agent
182**Best for:** Web applications, APIs, real-time UIs
183
184```typescript
185app.post('/agent/stream', async (req, res) => {
186 res.setHeader('Content-Type', 'text/event-stream');
187 const server = createSdkMcpServer({ name: 'web-agent', version: '1.0.0', tools });
188 const messages = query({ prompt: req.body.prompt, options: { systemPrompt, mcpServers: { 'web-agent': server } } });
189
190 for await (const event of messages) {
191 res.write(data: ${JSON.stringify(event)}\n\n);
192 }
193 res.end();
194});
195```
196
197### Pattern 3: Plugin/Framework
198**Best for:** Extensible systems, plugin architectures
199
200```typescript
201export class AgentEngine {
202 async stream(prompt: string) {
203 const tools = this.plugin.getTools();
204 const server = createSdkMcpServer({ name: this.plugin.name, version: '1.0.0', tools });
205 const messages = query({ prompt, options: { systemPrompt: this.plugin.systemPrompt, permissionMode: 'bypassPermissions', mcpServers: { [this.plugin.name]: server } } });
206
207 for await (const event of messages) {
208 await this.plugin.handleEvent(event);
209 }
210 }
211}
212```
213
214**For complete architecture patterns including monorepo setup, see references/patterns.md**
215
216## Project Setup
217
218### Minimal package.json
219
220```json
221{
222 "name": "my-agent",
223 "type": "module",
224 "dependencies": {
225 "@anthropic-ai/claude-agent-sdk": "^0.1.14",
226 "zod": "^3.23.8"
227 },
228 "devDependencies": {
229 "typescript": "^5.3.3",
230 "tsx": "^4.7.0"
231 }
232}
233```
234
235### Directory Structure
236
237```
238my-agent/
239├── src/
240│ ├── index.ts # Entry point
241│ ├── agent.ts # Agent implementation
242│ ├── tools/ # Tool definitions
243│ └── prompts/ # System prompts
244├── package.json
245└── tsconfig.json
246```
247
248**For complete project setup including TypeScript config, see references/project-setup.md**
249
250## Common Workflows
251
252### Creating a File Management Agent
253
2541. **Define tools:**
255```typescript
256const readFile = tool('read_file', 'Read file contents',
257 z.object({ path: z.string() }).shape,
258 async ({ path }) => ({ content: [{ type: 'text', text: await fs.readFile(path, 'utf-8') }] })
259);
260
261const writeFile = tool('write_file', 'Write to file',
262 z.object({ path: z.string(), content: z.string() }).shape,
263 async ({ path, content }) => { await fs.writeFile(path, content); return { content: [{ type: 'text', text: 'Done' }] }; }
264);
265```
266
2672. **Create system prompt:**
268```typescript
269const SYSTEM_PROMPT = `You are a file management agent.
270
271When user asks to edit a file:
2721. read_file to see current contents
2732. Propose changes
2743. write_file to save changes`;
275```
276
2773. **Set up agent:**
278```typescript
279const server = createSdkMcpServer({ name: 'files', version: '1.0.0', tools: [readFile, writeFile] });
280const messages = query({ prompt: userRequest, options: { systemPrompt: SYSTEM_PROMPT, permissionMode: 'bypassPermissions', mcpServers: { 'files': server } } });
281```
282
283### Adding Context-Aware Tools
284
285Create tool factories that close over session-specific data:
286
287```typescript
288function createSessionTools(userId: string) {
289 return [
290 tool('get_user_data', 'Get user data', {}, async () => {
291 const data = await db.getUser(userId); // Closure over userId
292 return { content: [{ type: 'text', text: JSON.stringify(data) }] };
293 })
294 ];
295}
296
297// Per-session tools
298app.post('/agent', async (req, res) => {
299 const tools = createSessionTools(req.session.userId);
300 const server = createSdkMcpServer({ name: 'session', version: '1.0.0', tools });
301 // ... rest of agent setup
302});
303```
304
305## Best Practices
306
307### ✅ DO
308
309- **Use Zod schemas** with detailed descriptions
310- **Create servers at query time**, not module level
311- **Set permissionMode: 'bypassPermissions'** for standalone servers
312- **Use tool factories** for context-aware tools
313- **Write detailed system prompts** (100+ lines)
314- **Handle errors** in tool implementations
315
316### ❌ DON'T
317
318- **Don't skip Zod validation** - schemas help Claude use tools correctly
319- **Don't use global state** - use closures instead
320- **Don't mix module types** - use "type": "module" consistently
321- **Don't use interactive permission mode** in standalone servers
322
323## Authentication
324
325**No configuration required!** The SDK automatically uses Claude Code's authentication. Your agent works seamlessly within Claude Code without any API key setup.
326
327## Debugging
328
329### Enable Tool Logging
330
331```typescript
332const messages = query({
333 prompt,
334 options: {
335 systemPrompt,
336 mcpServers,
337 onToolCall: (name, params) => console.log([CALL] ${name}, params),
338 onToolResult: (name, result) => console.log([RESULT] ${name}, result),
339 },
340});
341```
342
343### Test Tools Independently
344
345```typescript
346// Test before integrating
347const result = await myTool.execute({ param: 'test' });
348console.log('Tool output:', result);
349```
350
351### Common Issues
352
353**"Claude Code process exited with code 1"**
354- Solution: Use permissionMode: 'bypassPermissions' for standalone servers
355
356**Tools not being called**
357- Check tool descriptions are clear
358- Verify system prompt mentions tools
359- Ensure schema validation isn't too restrictive
360
361**Import errors**
362- Ensure "type": "module" in package.json
363- Use .js extensions in imports (Node16 resolution)
364
365## Reference Files
366
367This skill includes detailed reference documentation:
368
369- **references/patterns.md** - All 4 architecture patterns with complete examples
370- **references/tools.md** - Tool creation, composition, factories, subprocess wrappers
371- **references/streaming.md** - Event handling, streaming patterns, UI integration
372- **references/system-prompts.md** - How to write effective 100+ line prompts
373- **references/project-setup.md** - Complete project configuration, directory structures
374- **references/api-reference.md** - Official SDK API documentation
375- **references/working-examples.md** - Production implementation examples
376- **references/troubleshooting.md** - Common issues and solutions
377
378## Next Steps
379
3801. **Quick prototype:** Use the Quick Start example above
3812. **Choose pattern:** Select architecture from references/patterns.md
3823. **Set up project:** Follow references/project-setup.md
3834. **Create tools:** See references/tools.md for patterns
3845. **Write system prompt:** Use references/system-prompts.md template
3856. **Handle streaming:** Implement patterns from references/streaming.md
3867. **Deploy:** Follow project-setup.md deployment guide
387
388## Resources
389
390- **SDK GitHub:** https://github.com/anthropics/anthropic-sdk-typescript
391- **Example Projects:** See assets/project-template/ for starter code
392- **Community:** Anthropic Developer Discord
393
In the file
SKILL.md1,420 words
Files14
LicenceMIT
Why you can read it

Nothing in a skill executes. The client loads the text and the model follows it, so a skill can be audited the way a runbook is — by reading it.

What it costs in context

Skills are not billed by the call. They are paid for in context: every token the instructions occupy is a token your code, your diff and your conversation cannot use. Here is what this one takes and when it takes it.

≈100
always loaded
The name and description, so the model knows the skill exists and when to reach for it.
24,650
on trigger
The instruction body and 13 supporting files, read only when the skill fires.
12.4%
of a 200k window
Ten skills this size would take about 124% of the window before you open a file.
050k100k150k200k context window

24.8k tokens, estimated from the bundle at four bytes to the token, held for the rest of the session once it triggers. Heavy. Teams tend to install this one per project rather than globally, and load it only when the job comes up.

Servers bill, skills cost

A server charges by the month. A skill charges once per session, in context, and then keeps charging it for as long as the session lives.

Before and after

The same question, put to the same model twice: once as it comes, and once with these instructions loaded.

No worked example has been published for this skill yet.

Adoption
Installsnone yet
Ratingno reviews yet

The procedure it runs

The procedure has not been published here. It is in the skill’s own SKILL.md, which its author has not sent to the marketplace yet.

Prose, not code

These steps are written for a model to follow, not executed by a runtime. It can still be told to skip one, and it will say so when it does.

Servers it uses

None. This skill calls no MCP servers at all.

Everything it needs is in the instructions, so it works in a project with nothing connected — the model reads the file and changes how it works with what it can already reach.

It writes no files and reaches no network. All it changes is how the model reasons and writes.

What it asks for
Writes filesno
Network accessno

Read from the allowed-tools line of this skill’s own SKILL.md. A skill grants no permissions of its own — it can only ask for tools your client already has.

What it will not do

Every skill is narrow, and the useful ones say where they stop. These are the jobs this one is the wrong tool for.

What this skill is not for has not been published here. Nothing is implied by that: it is a section the author has not filled in.

What is in the bundle

14 files, 99.0 kB on disk. A bundle is text throughout: the instructions the model reads, plus the templates it fills in.

  • assets/project-template/.env.example0.1 kB
  • assets/project-template/package.json0.7 kB
  • assets/project-template/README.md1.9 kB
  • assets/project-template/tsconfig.json0.5 kB
  • LICENSE.txt1.1 kB
  • references/api-reference.md14.3 kB
  • references/patterns.md6.4 kB
  • references/project-setup.md8.0 kB
  • references/streaming.md8.6 kB
  • references/system-prompts.md7.3 kB
  • references/tools.md8.8 kB
  • references/troubleshooting.md15.9 kB
  • references/working-examples.md14.0 kB
  • SKILL.md11.4 kB
What is not in it

No dependencies and nothing executable: a skill is text the agent reads, so the bundle is 14 files you can review in full before installing. The MIT licence covers the templates and examples as well as the instructions.

Install

Installing copies the bundle into your project. Nothing runs at install time — the files sit on disk until the model reads them.

$19 once
Claude Agent TypeScript SDK · MIT · szweibel
one-time
Price$19 once
LicenceMIT — the author’s, unchanged by this purchase
Paid throughStripe, once, on the card you add at the checkout
Keeps workingfor good — the files are yours once they are on disk
Updatesevery update its author ships, delivered through this account

You can read the whole bundle before paying — the SKILL.md above is the product, not a preview of it. What the money buys is the delivery: the folder packaged and handed to your machine by key, every update its author ships, and our support if it does not do what this listing says. The terms of use are MIT, set by the author and unchanged by buying it here.

Payment runs through Stripe, on a page like this one rather than a redirect. Once there is an account it joins the same mcprush invoice as everything else you run, so there is never a second card to enter.

Which clients pick it up on their own

A skill is a folder of text. A client with a skills folder reads it without being told; everywhere else the same text works, it is just handed to the model rather than found.

Claude Code.claude/skills/
Claude Desktop
ChatGPT
Cursor.cursor/skills/
VS Code.github/skills/
Codex CLI.agents/skills/
Gemini CLI.gemini/skills/
Grok.grok/skills/
Zed.agents/skills/
Windsurf.windsurf/skills/
Agent SDK.claude/skills/
HTTP / API
This release
Versionnot versioned
Publishedno release date on file
Price$19
Referenceszweibel/claude-agent-typescript-sdk

Versions

Its author publishes no version number, so there is nothing here to pin to: what you install is the folder as it stands today. Instructions change more often than APIs do — a skill can be rewritten entirely without anything it depends on moving.

v
  • No earlier releases have been published to the marketplace.
Pinning

Nothing to pin to: this skill carries no version number of its own. What you install is what the folder holds on the day you install it.

Reviews

no reviews yet · no installs yet

Nobody has reviewed this skill yet. The rating is the mean of the reviews written here, so there is none until somebody writes the first.

Who can post

Only accounts that have had the skill installed for fourteen days, so a review is written after living with it rather than after reading it. Publishers may reply once.

Who wrote it

SZ
szweibel

Publishes on mcprush.

0 servers listed1 skill listednot claimed
Profile
Publisher
Servers0