.claude/skills/ts-anthropic-sdk/SKILL.md
Integrate Claude AI into applications with the Anthropic SDK. Use when a user asks to add Claude to an app, use Claude for text generation, build a chatbot with Claude, use Claude's long context window, implement tool use with Claude, stream Claude responses, use Claude for code generation, document analysis, or reasoning tasks. Covers Messages API, streaming, tool use, vision, system prompts, extended thinking, and batch processing.
npx skillsauth add eliferjunior/Claude anthropic-sdkInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
The Anthropic SDK provides access to Claude models (Opus, Sonnet, Haiku) for text generation, analysis, coding, and reasoning. Claude excels at long-context understanding (200K tokens), careful instruction following, code generation, and complex reasoning. This skill covers the Messages API, streaming, tool use (function calling), vision, extended thinking, system prompts, and best practices for prompt engineering with Claude.
# Node.js
npm install @anthropic-ai/sdk
# Python
pip install anthropic
// lib/anthropic.ts — Client initialization
import Anthropic from '@anthropic-ai/sdk'
const anthropic = new Anthropic({
apiKey: process.env.ANTHROPIC_API_KEY,
})
// chat.ts — Basic message creation
const message = await anthropic.messages.create({
model: 'claude-sonnet-4-20250514',
max_tokens: 1024,
system: 'You are a senior software engineer. Provide clear, production-ready code with comments.',
messages: [
{ role: 'user', content: 'Write a rate limiter middleware for Express.js using a sliding window algorithm.' },
],
})
console.log(message.content[0].type === 'text' ? message.content[0].text : '')
// message.usage: { input_tokens: 42, output_tokens: 512 }
# Python equivalent
import anthropic
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=1024,
system="You are a senior software engineer.",
messages=[
{"role": "user", "content": "Write a rate limiter for Express.js."}
],
)
print(message.content[0].text)
// stream.ts — Stream responses for real-time UI
const stream = anthropic.messages.stream({
model: 'claude-sonnet-4-20250514',
max_tokens: 1024,
messages: [{ role: 'user', content: 'Explain how B-trees work.' }],
})
for await (const event of stream) {
if (event.type === 'content_block_delta' && event.delta.type === 'text_delta') {
process.stdout.write(event.delta.text)
}
}
// Or using the helper
const stream2 = anthropic.messages.stream({
model: 'claude-sonnet-4-20250514',
max_tokens: 1024,
messages: [{ role: 'user', content: 'Explain B-trees.' }],
})
stream2.on('text', (text) => process.stdout.write(text))
await stream2.finalMessage()
// tools.ts — Let Claude call your functions
const tools: Anthropic.Tool[] = [
{
name: 'get_stock_price',
description: 'Get the current stock price for a ticker symbol. Use when the user asks about stock prices.',
input_schema: {
type: 'object',
properties: {
ticker: { type: 'string', description: 'Stock ticker symbol (e.g., AAPL, GOOGL)' },
},
required: ['ticker'],
},
},
{
name: 'execute_sql',
description: 'Execute a read-only SQL query against the analytics database.',
input_schema: {
type: 'object',
properties: {
query: { type: 'string', description: 'SQL SELECT query to execute' },
},
required: ['query'],
},
},
]
const response = await anthropic.messages.create({
model: 'claude-sonnet-4-20250514',
max_tokens: 1024,
tools,
messages: [{ role: 'user', content: 'What is Apple stock at right now?' }],
})
// Process tool use
if (response.stop_reason === 'tool_use') {
const toolUse = response.content.find(b => b.type === 'tool_use')!
const result = await executeFunction(toolUse.name, toolUse.input)
// Send result back to Claude
const finalResponse = await anthropic.messages.create({
model: 'claude-sonnet-4-20250514',
max_tokens: 1024,
tools,
messages: [
{ role: 'user', content: 'What is Apple stock at right now?' },
{ role: 'assistant', content: response.content },
{ role: 'user', content: [{ type: 'tool_result', tool_use_id: toolUse.id, content: JSON.stringify(result) }] },
],
})
}
// vision.ts — Analyze images with Claude
import { readFileSync } from 'fs'
// URL-based image
const response = await anthropic.messages.create({
model: 'claude-sonnet-4-20250514',
max_tokens: 1024,
messages: [{
role: 'user',
content: [
{ type: 'image', source: { type: 'url', url: 'https://example.com/chart.png' } },
{ type: 'text', text: 'Analyze this chart. What trends do you see?' },
],
}],
})
// Base64 image (from file)
const imageData = readFileSync('screenshot.png').toString('base64')
const response2 = await anthropic.messages.create({
model: 'claude-sonnet-4-20250514',
max_tokens: 1024,
messages: [{
role: 'user',
content: [
{ type: 'image', source: { type: 'base64', media_type: 'image/png', data: imageData } },
{ type: 'text', text: 'Extract all text and data from this screenshot.' },
],
}],
})
// thinking.ts — Enable extended thinking for complex reasoning tasks
const response = await anthropic.messages.create({
model: 'claude-sonnet-4-20250514',
max_tokens: 16000,
thinking: {
type: 'enabled',
budget_tokens: 10000, // tokens allocated for internal reasoning
},
messages: [{
role: 'user',
content: 'Analyze this codebase for security vulnerabilities and provide a prioritized remediation plan.',
}],
})
// Response contains both thinking blocks and text blocks
for (const block of response.content) {
if (block.type === 'thinking') {
console.log('Reasoning:', block.thinking)
} else if (block.type === 'text') {
console.log('Response:', block.text)
}
}
// conversation.ts — Maintain conversation history
const messages: Anthropic.MessageParam[] = []
async function chat(userMessage: string): Promise<string> {
messages.push({ role: 'user', content: userMessage })
const response = await anthropic.messages.create({
model: 'claude-sonnet-4-20250514',
max_tokens: 2048,
system: 'You are a helpful assistant for a project management app.',
messages,
})
const assistantContent = response.content
messages.push({ role: 'assistant', content: assistantContent })
return assistantContent.filter(b => b.type === 'text').map(b => b.text).join('')
}
User prompt: "Build a bot that reviews pull requests. It should analyze the diff, check for bugs, security issues, and style problems, then post inline comments."
The agent will:
User prompt: "Build a system where users upload contracts and ask questions about them. The AI should be able to search across multiple documents and cite specific sections."
The agent will:
search_documents tool that Claude can call.stop_reason field: end_turn means done, tool_use means Claude wants to call a function, max_tokens means the response was truncated.development
Expert guidance for Fireworks AI, the platform for running open-source LLMs (Llama, Mixtral, Qwen, etc.) with enterprise-grade speed and reliability. Helps developers integrate Fireworks' inference API, fine-tune models, and deploy custom model endpoints with function calling and structured output support.
development
Convert any website into clean, structured data with Firecrawl — API-first web scraping service. Use when someone asks to "turn a website into markdown", "scrape website for LLM", "Firecrawl", "extract website content as clean text", "crawl and convert to structured data", or "scrape website for RAG". Covers single-page scraping, full-site crawling, structured extraction, and LLM-ready output.
tools
Expert guidance for Firebase, Google's platform for building and scaling web and mobile applications. Helps developers set up authentication, Firestore/Realtime Database, Cloud Functions, hosting, storage, and analytics using Firebase's SDK and CLI.
development
When the user needs to build file upload functionality for a web application. Use when the user mentions "file upload," "image upload," "upload endpoint," "multipart upload," "presigned URL," "S3 upload," "file validation," "upload to cloud storage," or "accept user files." Handles upload endpoints, file validation (type, size, magic bytes), cloud storage integration, and upload status tracking. For image/video processing after upload, see media-transcoder.