Back to .md Directory
Claude API Integration Skill
You are a Claude API expert with deep knowledge of Anthropic's Claude models, prompt engineering, and AI safety best practices.
ai agent rag prompt claude workflow safety
View sourceClaude API Integration Skill
You are a Claude API expert with deep knowledge of Anthropic's Claude models, prompt engineering, and AI safety best practices.
Core Capabilities
- Integrate Claude Sonnet, Opus, and Haiku models
- Implement extended context conversations (200K tokens)
- Use tool calling for function execution
- Implement vision capabilities with Claude
- Create effective prompts with XML tags
- Handle streaming responses
- Implement conversation memory management
- Apply AI safety and content filtering
- Optimize for cost and performance
- Build agentic workflows with Claude
Best Practices
- Use XML tags to structure prompts clearly
- Leverage Claude's long context window effectively
- Implement streaming for better UX
- Use Haiku for simple tasks, Sonnet for balance, Opus for complex reasoning
- Always include safety guidelines in system prompts
- Handle rate limits with exponential backoff
- Cache frequently used context with prompt caching
- Monitor token usage and costs
- Test prompts thoroughly before production
- Implement proper error handling
Code Patterns
Basic Claude Integration
import Anthropic from '@anthropic-ai/sdk';
const anthropic = new Anthropic({
apiKey: process.env.ANTHROPIC_API_KEY,
});
export class ClaudeService {
async chat(messages: Array<{ role: string; content: string }>) {
const response = await anthropic.messages.create({
model: 'claude-sonnet-4-5-20250929',
max_tokens: 1024,
messages,
});
return response.content[0].text;
}
async *streamChat(messages: Array<{ role: string; content: string }>) {
const stream = await anthropic.messages.stream({
model: 'claude-sonnet-4-5-20250929',
max_tokens: 1024,
messages,
});
for await (const chunk of stream) {
if (chunk.type === 'content_block_delta' &&
chunk.delta.type === 'text_delta') {
yield chunk.delta.text;
}
}
}
async analyzeImage(imageData: string, prompt: string) {
const response = await anthropic.messages.create({
model: 'claude-sonnet-4-5-20250929',
max_tokens: 1024,
messages: [
{
role: 'user',
content: [
{
type: 'image',
source: {
type: 'base64',
media_type: 'image/jpeg',
data: imageData,
},
},
{
type: 'text',
text: prompt,
},
],
},
],
});
return response.content[0].text;
}
async useTools(userMessage: string) {
const tools = [
{
name: 'get_weather',
description: 'Get the current weather for a location',
input_schema: {
type: 'object',
properties: {
location: {
type: 'string',
description: 'The city and state, e.g. San Francisco, CA',
},
},
required: ['location'],
},
},
];
const response = await anthropic.messages.create({
model: 'claude-sonnet-4-5-20250929',
max_tokens: 1024,
tools,
messages: [{ role: 'user', content: userMessage }],
});
return response;
}
}
Structured Prompting with XML
function createStructuredPrompt(task: string, context: string, constraints: string[]) {
return `
<task>
${task}
</task>
<context>
${context}
</context>
<constraints>
${constraints.map(c => `<constraint>${c}</constraint>`).join('\n')}
</constraints>
Please analyze the task carefully and provide a detailed response.
`;
}
// Usage
const prompt = createStructuredPrompt(
'Analyze customer feedback',
'Customer reviews from Q4 2024',
[
'Focus on product quality issues',
'Identify top 3 concerns',
'Provide actionable recommendations'
]
);
Resources
Related Documents
SKILL.md
AI Artist — Engineering Specification
name: ai-artist-engineering-spec
aiagentllm
1
9
pikakitSKILL.md
Image Generation Skill
name: image-generation
aipromptopenai
0
9
garri333SKILL.md
Skill: Google Stitch for Content Visuals (MCP-Integrated)
name: google-stitch-content
aiagentprompt
0
5
denish12SKILL.md
Manage After Effects
description: Manage After Effects from Claude — create configs, build compositions, render videos, diagnose issues, and optionally generate AI content via Prompture
aipromptclaude
0
4
jhd3197