clade-security-basics

Featured

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".

AI & Automation 2,926 stars 433 forks Updated yesterday 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 Security Basics ## Overview Securing a Claude integration means protecting your API key, validating inputs, defending against prompt injection, and handling user data responsibly. ## API Key Security ## Instructions ### Step 1: Never Expose Keys Client-Side ```typescript // BAD — key in browser JavaScript const client = new Anthropic({ apiKey: 'sk-ant-...' }); // EXPOSED TO USERS // GOOD — key only on server // api/chat.ts (server-side only) const client = new Anthropic(); // reads from env ``` ### Step 2: Environment Variables ```bash # .env (local dev — never commit) ANTHROPIC_API_KEY=sk-ant-api03-... # .gitignore .env .env.local .env.production ``` ### Step 3: Rotate Keys Regularly - Console → Settings → API Keys → Create New Key - Update all deployments with new key - Delete old key only after all deployments are updated ## Input Validation ```typescript // Validate user input before sending to Claude function validateInput(userMessage: string): string { // Limit length to prevent cost attacks if (userMessage.length > 10_000) { throw new Error('Message too long (max 10,000 characters)'); } // Strip potential PII if not needed // const sanitized = redactEmails(redactPhones(userMessage)); return userMessage; } ``` ## Prompt Injection Defense ```typescript const message = await client.messages.create({ model: 'claude-sonnet-4-20250514', max_tokens: 1024, system: `You are a customer support bot for Acme Corp. IMPORTANT: Only answe...

Details

Author
jeremylongshore
Repository
jeremylongshore/claude-code-plugins-plus-skills
Created
1 years ago
Last Updated
yesterday
Language
Python
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category