spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / plugins / agent-sdk-dev / commands / new-sdk-app.md
177 lines · 7.7 KBPreviewCodeRaw
1---
2description: Create and setup a new Claude Agent SDK application
3argument-hint: [project-name]
4model: sonnet-4.5
5---
6
7You are tasked with helping the user create a new Claude Agent SDK application. Follow these steps carefully:
8
9## Reference Documentation
10
11Before starting, review the official documentation to ensure you provide accurate and up-to-date guidance. Use WebFetch to read these pages:
12
131. **Start with the overview**: https://docs.claude.com/en/api/agent-sdk/overview
142. **Based on the user's language choice, read the appropriate SDK reference**:
15 - TypeScript: https://docs.claude.com/en/api/agent-sdk/typescript
16 - Python: https://docs.claude.com/en/api/agent-sdk/python
173. **Read relevant guides mentioned in the overview** such as:
18 - Streaming vs Single Mode
19 - Permissions
20 - Custom Tools
21 - MCP integration
22 - Subagents
23 - Sessions
24 - Any other relevant guides based on the user's needs
25
26**IMPORTANT**: Always check for and use the latest versions of packages. Use WebSearch or WebFetch to verify current versions before installation.
27
28## Gather Requirements
29
30IMPORTANT: Ask these questions one at a time. Wait for the user's response before asking the next question. This makes it easier for the user to respond.
31
32Ask the questions in this order (skip any that the user has already provided via arguments):
33
341. **Language** (ask first): "Would you like to use TypeScript or Python?"
35
36 - Wait for response before continuing
37
382. **Project name** (ask second): "What would you like to name your project?"
39
40 - If $ARGUMENTS is provided, use that as the project name and skip this question
41 - Wait for response before continuing
42
433. **Agent type** (ask third, but skip if #2 was sufficiently detailed): "What kind of agent are you building? Some examples:
44
45 - Coding agent (SRE, security review, code review)
46 - Business agent (customer support, content creation)
47 - Custom agent (describe your use case)"
48 - Wait for response before continuing
49
504. **Starting point** (ask fourth): "Would you like:
51
52 - A minimal 'Hello World' example to start
53 - A basic agent with common features
54 - A specific example based on your use case"
55 - Wait for response before continuing
56
575. **Tooling choice** (ask fifth): Let the user know what tools you'll use, and confirm with them that these are the tools they want to use (for example, they may prefer pnpm or bun over npm). Respect the user's preferences when executing on the requirements.
58
59After all questions are answered, proceed to create the setup plan.
60
61## Setup Plan
62
63Based on the user's answers, create a plan that includes:
64
651. **Project initialization**:
66
67 - Create project directory (if it doesn't exist)
68 - Initialize package manager:
69 - TypeScript: `npm init -y` and setup `package.json` with type: "module" and scripts (include a "typecheck" script)
70 - Python: Create `requirements.txt` or use `poetry init`
71 - Add necessary configuration files:
72 - TypeScript: Create `tsconfig.json` with proper settings for the SDK
73 - Python: Optionally create config files if needed
74
752. **Check for Latest Versions**:
76
77 - BEFORE installing, use WebSearch or check npm/PyPI to find the latest version
78 - For TypeScript: Check https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk
79 - For Python: Check https://pypi.org/project/claude-agent-sdk/
80 - Inform the user which version you're installing
81
823. **SDK Installation**:
83
84 - TypeScript: `npm install @anthropic-ai/claude-agent-sdk@latest` (or specify latest version)
85 - Python: `pip install claude-agent-sdk` (pip installs latest by default)
86 - After installation, verify the installed version:
87 - TypeScript: Check package.json or run `npm list @anthropic-ai/claude-agent-sdk`
88 - Python: Run `pip show claude-agent-sdk`
89
904. **Create starter files**:
91
92 - TypeScript: Create an `index.ts` or `src/index.ts` with a basic query example
93 - Python: Create a `main.py` with a basic query example
94 - Include proper imports and basic error handling
95 - Use modern, up-to-date syntax and patterns from the latest SDK version
96
975. **Environment setup**:
98
99 - Create a `.env.example` file with `ANTHROPIC_API_KEY=your_api_key_here`
100 - Add `.env` to `.gitignore`
101 - Explain how to get an API key from https://console.anthropic.com/
102
1036. **Optional: Create .claude directory structure**:
104 - Offer to create `.claude/` directory for agents, commands, and settings
105 - Ask if they want any example subagents or slash commands
106
107## Implementation
108
109After gathering requirements and getting user confirmation on the plan:
110
1111. Check for latest package versions using WebSearch or WebFetch
1122. Execute the setup steps
1133. Create all necessary files
1144. Install dependencies (always use latest stable versions)
1155. Verify installed versions and inform the user
1166. Create a working example based on their agent type
1177. Add helpful comments in the code explaining what each part does
1188. **VERIFY THE CODE WORKS BEFORE FINISHING**:
119 - For TypeScript:
120 - Run `npx tsc --noEmit` to check for type errors
121 - Fix ALL type errors until types pass completely
122 - Ensure imports and types are correct
123 - Only proceed when type checking passes with no errors
124 - For Python:
125 - Verify imports are correct
126 - Check for basic syntax errors
127 - **DO NOT consider the setup complete until the code verifies successfully**
128
129## Verification
130
131After all files are created and dependencies are installed, use the appropriate verifier agent to validate that the Agent SDK application is properly configured and ready for use:
132
1331. **For TypeScript projects**: Launch the **agent-sdk-verifier-ts** agent to validate the setup
1342. **For Python projects**: Launch the **agent-sdk-verifier-py** agent to validate the setup
1353. The agent will check SDK usage, configuration, functionality, and adherence to official documentation
1364. Review the verification report and address any issues
137
138## Getting Started Guide
139
140Once setup is complete and verified, provide the user with:
141
1421. **Next steps**:
143
144 - How to set their API key
145 - How to run their agent:
146 - TypeScript: `npm start` or `node --loader ts-node/esm index.ts`
147 - Python: `python main.py`
148
1492. **Useful resources**:
150
151 - Link to TypeScript SDK reference: https://docs.claude.com/en/api/agent-sdk/typescript
152 - Link to Python SDK reference: https://docs.claude.com/en/api/agent-sdk/python
153 - Explain key concepts: system prompts, permissions, tools, MCP servers
154
1553. **Common next steps**:
156 - How to customize the system prompt
157 - How to add custom tools via MCP
158 - How to configure permissions
159 - How to create subagents
160
161## Important Notes
162
163- **ALWAYS USE LATEST VERSIONS**: Before installing any packages, check for the latest versions using WebSearch or by checking npm/PyPI directly
164- **VERIFY CODE RUNS CORRECTLY**:
165 - For TypeScript: Run `npx tsc --noEmit` and fix ALL type errors before finishing
166 - For Python: Verify syntax and imports are correct
167 - Do NOT consider the task complete until the code passes verification
168- Verify the installed version after installation and inform the user
169- Check the official documentation for any version-specific requirements (Node.js version, Python version, etc.)
170- Always check if directories/files already exist before creating them
171- Use the user's preferred package manager (npm, yarn, pnpm for TypeScript; pip, poetry for Python)
172- Ensure all code examples are functional and include proper error handling
173- Use modern syntax and patterns that are compatible with the latest SDK version
174- Make the experience interactive and educational
175- **ASK QUESTIONS ONE AT A TIME** - Do not ask multiple questions in a single response
176
177Begin by asking the FIRST requirement question only. Wait for the user's answer before proceeding to the next question.