clade-known-pitfalls

Featured

Common mistakes when building with the Anthropic API and how to avoid them. Use when working with known-pitfalls patterns. Trigger with "anthropic mistakes", "claude pitfalls", "anthropic gotchas", "common claude errors", "anthropic anti-patterns".

AI & Automation 2,266 stars 315 forks Updated today MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Anthropic Known Pitfalls ## Overview Ten common mistakes when building with the Anthropic API and how to avoid them: forgetting `max_tokens` (required), system prompt in messages array (wrong), non-alternating messages, unchecked `stop_reason`, creating client per request, no 529 handling, hardcoded model IDs, expensive output tokens, no streaming, and unnecessary PII. ## 1. Forgetting `max_tokens` Unlike OpenAI, `max_tokens` is **required**. Omitting it returns a 400 error. ```typescript // BAD await client.messages.create({ model: 'claude-sonnet-4-20250514', messages }); // GOOD await client.messages.create({ model: 'claude-sonnet-4-20250514', max_tokens: 1024, messages }); ``` ## 2. System Prompt in Messages Array Claude uses a top-level `system` parameter, not a system message in the array. ```typescript // BAD — this sends "system" as a user message role, which will error messages: [{ role: 'system', content: '...' }, { role: 'user', content: '...' }] // GOOD system: 'You are helpful.', messages: [{ role: 'user', content: '...' }] ``` ## 3. Non-Alternating Messages Messages must strictly alternate between user and assistant. ```typescript // BAD — two user messages in a row messages: [ { role: 'user', content: 'Hello' }, { role: 'user', content: 'How are you?' }, // ERROR ] // GOOD — combine into one or add assistant between messages: [ { role: 'user', content: 'Hello. How are you?' }, ] ``` ## 4. Not Checking `stop_reason` If `stop_reason === 'max_token...

Details

Author
jeremylongshore
Repository
jeremylongshore/claude-code-plugins-plus-skills
Created
7 months ago
Last Updated
today
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Featured

anth-known-pitfalls

Identify and avoid common Claude API anti-patterns and integration mistakes. Use when reviewing code, onboarding developers, or debugging subtle issues with Anthropic integrations. Trigger with phrases like "anthropic pitfalls", "claude anti-patterns", "claude mistakes", "anthropic common issues", "claude gotchas".

2,266 Updated today
jeremylongshore
AI & Automation Featured

clade-common-errors

Diagnose and fix Anthropic API errors — authentication, rate limits, Use when working with common-errors patterns. overloaded, context length, and content policy issues. Trigger with "anthropic error", "claude 429", "claude overloaded", "anthropic not working", "debug claude api".

2,266 Updated today
jeremylongshore
AI & Automation Featured

anth-sdk-patterns

Apply production-ready Anthropic SDK patterns for TypeScript and Python. Use when implementing Claude integrations, building reusable wrappers, or establishing team coding standards for the Messages API. Trigger with phrases like "anthropic SDK patterns", "claude best practices", "anthropic code patterns", "production claude code".

2,266 Updated today
jeremylongshore
AI & Automation Featured

anth-common-errors

Diagnose and fix Anthropic Claude API errors by HTTP status code. Use when encountering API errors, debugging failed requests, or troubleshooting authentication, rate limiting, or input validation issues. Trigger with phrases like "anthropic error", "claude api error", "fix anthropic 429", "claude not working", "debug claude api".

2,266 Updated today
jeremylongshore
AI & Automation Featured

clade-security-basics

Secure your Anthropic integration — API key management, input validation, Use when working with security-basics patterns. prompt injection defense, and data privacy. Trigger with "anthropic security", "claude api key security", "anthropic prompt injection", "secure claude integration".

2,266 Updated today
jeremylongshore