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