claude-agent-sdk-agent-creation
$
npx mdskill add TheBushidoCollective/han/claude-agent-sdk-agent-creationInitialize and configure Claude AI agents using the Agent SDK with TypeScript.
- Helps developers set up agents with system prompts and tool permissions.
- Integrates with the Claude Agent SDK and uses tools like Read, Write, and Bash.
- Relies on configuration options like model selection and setting sources for setup.
- Delivers results through initialized agent instances ready for task execution.
SKILL.md
.github/skills/claude-agent-sdk-agent-creationView on GitHub ↗
---
name: claude-agent-sdk-agent-creation
user-invocable: false
description: Use when creating or configuring Claude AI agents using the Agent SDK. Covers agent initialization, configuration, and basic setup patterns.
allowed-tools:
- Read
- Write
- Edit
- Bash
- Grep
- Glob
---
# Claude Agent SDK - Agent Creation
Creating and configuring AI agents using the Claude Agent SDK with TypeScript.
## Core Agent Initialization
### Basic Agent Creation
```typescript
import { Agent } from '@anthropic-ai/claude-agent-sdk';
const agent = new Agent({
model: 'claude-3-5-sonnet-20241022', // Latest model
systemPrompt: 'You are a helpful assistant specialized in...',
settingSources: ['project'], // Load .claude/CLAUDE.md from project
allowedTools: ['read_file', 'write_file', 'list_files'],
});
```
## Configuration Options
### System Prompts
```typescript
// Direct system prompt
const agent = new Agent({
systemPrompt: 'You are an expert code reviewer...',
});
// Load from CLAUDE.md
const agent = new Agent({
settingSources: ['project'], // Loads ./.claude/CLAUDE.md
});
// User-level memory
const agent = new Agent({
settingSources: ['user'], // Loads ~/.claude/CLAUDE.md
});
```
### Tool Permissions
```typescript
// Allow specific tools
const agent = new Agent({
allowedTools: [
'read_file',
'write_file',
'list_files',
'grep',
'bash',
],
});
// Block specific tools
const agent = new Agent({
disallowedTools: ['bash', 'web_search'],
});
// Permission modes
const agent = new Agent({
permissionMode: 'strict', // Require explicit approval
});
```
## Agent Directory Structure
### Required Structure
```
project/
├── .claude/
│ ├── CLAUDE.md # Project memory
│ ├── agents/
│ │ └── specialist.md # Subagent definitions
│ ├── skills/
│ │ └── my-skill/
│ │ └── SKILL.md # Skill definitions
└── src/
└── index.ts # Your code
```
## Authentication
### Environment Variables
```bash
# Anthropic API (primary)
export ANTHROPIC_API_KEY="sk-ant-..."
# Alternative providers
export AWS_ACCESS_KEY_ID="..."
export AWS_SECRET_ACCESS_KEY="..."
export AWS_REGION="us-east-1"
# Google Vertex AI
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/credentials.json"
# Azure
export AZURE_OPENAI_API_KEY="..."
export AZURE_OPENAI_ENDPOINT="..."
```
### SDK Configuration
```typescript
// Anthropic direct
const agent = new Agent({
apiKey: process.env.ANTHROPIC_API_KEY,
});
// Amazon Bedrock
const agent = new Agent({
provider: 'bedrock',
model: 'anthropic.claude-3-5-sonnet-20241022-v2:0',
});
```
## Best Practices
### Always Specify Model
```typescript
// Good
const agent = new Agent({
model: 'claude-3-5-sonnet-20241022',
});
// Avoid: relying on default model
const agent = new Agent({});
```
### Use Explicit Setting Sources
```typescript
// Good
const agent = new Agent({
settingSources: ['project'],
});
// Avoid: unclear memory source
const agent = new Agent({
systemPrompt: '...',
});
```
### Separate Project and User Memory
```typescript
// Project-specific context
const projectAgent = new Agent({
settingSources: ['project'],
});
// User preferences
const userAgent = new Agent({
settingSources: ['user'],
});
```
## Anti-Patterns
### Don't Hardcode API Keys
```typescript
// Bad
const agent = new Agent({
apiKey: 'sk-ant-hardcoded-key',
});
// Good
const agent = new Agent({
apiKey: process.env.ANTHROPIC_API_KEY,
});
```
### Don't Mix Conflicting Permissions
```typescript
// Bad: contradictory permissions
const agent = new Agent({
allowedTools: ['read_file', 'write_file'],
disallowedTools: ['read_file'], // Conflict!
});
// Good: clear permissions
const agent = new Agent({
allowedTools: ['read_file'],
});
```
## Related Skills
- **tool-integration**: Working with tools and MCP servers
- **context-management**: Managing agent context and memory
More from TheBushidoCollective/han
- absinthe-resolversUse when implementing GraphQL resolvers with Absinthe. Covers resolver patterns, dataloader integration, batching, and error handling.
- absinthe-schemaUse when designing GraphQL schemas with Absinthe. Covers type definitions, interfaces, unions, enums, and schema organization patterns.
- absinthe-subscriptionsUse when implementing real-time GraphQL subscriptions with Absinthe. Covers Phoenix channels, PubSub, and subscription patterns.
- act-docker-setupUse when configuring Docker environments for act, selecting runner images, managing container resources, or troubleshooting Docker-related issues with local GitHub Actions testing.
- act-local-testingUse when testing GitHub Actions workflows locally with act. Covers act CLI usage, Docker configuration, debugging workflows, and troubleshooting common issues when running workflows on your local machine.
- act-workflow-syntaxUse when creating or modifying GitHub Actions workflow files. Provides guidance on workflow syntax, triggers, jobs, steps, and expressions for creating valid GitHub Actions workflows that can be tested locally with act.
- ameba-configurationUse when configuring Ameba rules and settings for Crystal projects including .ameba.yml setup, rule management, severity levels, and code quality enforcement.
- ameba-custom-rulesUse when creating custom Ameba rules for Crystal code analysis including rule development, AST traversal, issue reporting, and rule testing.
- ameba-integrationUse when integrating Ameba into development workflows including CI/CD pipelines, pre-commit hooks, GitHub Actions, and automated code review processes.
- analyze-performanceAnalyze performance metrics and identify slow transactions in Sentry