Claude API
loulanyue/awesome-claude-notes
Anthropic Claude API 的 Python 和 TypeScript 使用模式。涵盖 Messages API、流式处理、工具使用、视觉功能、扩展思维、批量处理、提示缓存和 Claude Agent SDK。适用于使用 Claude API 或 Anthropic SDK 构建应用程序的场景。
Apply production-ready Anthropic SDK patterns for TypeScript and Python.
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill anth-sdk-patterns -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install jeremylongshore/tons-of-skills-marketplace anth-sdk-patterns --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/saas-packs/anthropic-pack/skills/anth-sdk-patterns .claude/skills/anth-sdk-patterns && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "anth-sdk-patterns" agent skill from https://github.com/jeremylongshore/tons-of-skills-marketplace/tree/main/plugins/saas-packs/anthropic-pack/skills/anth-sdk-patterns into .claude/skills/anth-sdk-patterns/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "anth-sdk-patterns", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/jeremylongshore/tons-of-skills-marketplace/tree/main/plugins/saas-packs/anthropic-pack/skills/anth-sdk-patternsType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill anth-sdk-patterns -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install jeremylongshore/tons-of-skills-marketplace anth-sdk-patterns --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .agents/skills && cp -r skills-src/plugins/saas-packs/anthropic-pack/skills/anth-sdk-patterns .agents/skills/anth-sdk-patterns && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "anth-sdk-patterns" agent skill from https://github.com/jeremylongshore/tons-of-skills-marketplace/tree/main/plugins/saas-packs/anthropic-pack/skills/anth-sdk-patterns into .agents/skills/anth-sdk-patterns/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "anth-sdk-patterns", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill anth-sdk-patterns -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install jeremylongshore/tons-of-skills-marketplace anth-sdk-patterns --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/plugins/saas-packs/anthropic-pack/skills/anth-sdk-patterns .cursor/skills/anth-sdk-patterns && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "anth-sdk-patterns" agent skill from https://github.com/jeremylongshore/tons-of-skills-marketplace/tree/main/plugins/saas-packs/anthropic-pack/skills/anth-sdk-patterns into .cursor/skills/anth-sdk-patterns/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "anth-sdk-patterns", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/jeremylongshore/tons-of-skills-marketplace.git --path plugins/saas-packs/anthropic-pack/skills/anth-sdk-patterns--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill anth-sdk-patterns -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install jeremylongshore/tons-of-skills-marketplace anth-sdk-patterns --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/plugins/saas-packs/anthropic-pack/skills/anth-sdk-patterns .gemini/skills/anth-sdk-patterns && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "anth-sdk-patterns" agent skill from https://github.com/jeremylongshore/tons-of-skills-marketplace/tree/main/plugins/saas-packs/anthropic-pack/skills/anth-sdk-patterns into .gemini/skills/anth-sdk-patterns/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "anth-sdk-patterns", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install jeremylongshore/tons-of-skills-marketplace anth-sdk-patternsInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill anth-sdk-patterns -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .github/skills && cp -r skills-src/plugins/saas-packs/anthropic-pack/skills/anth-sdk-patterns .github/skills/anth-sdk-patterns && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "anth-sdk-patterns" agent skill from https://github.com/jeremylongshore/tons-of-skills-marketplace/tree/main/plugins/saas-packs/anthropic-pack/skills/anth-sdk-patterns into .github/skills/anth-sdk-patterns/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "anth-sdk-patterns", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill anth-sdk-patterns -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install jeremylongshore/tons-of-skills-marketplace anth-sdk-patterns --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/plugins/saas-packs/anthropic-pack/skills/anth-sdk-patterns .opencode/skills/anth-sdk-patterns && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "anth-sdk-patterns" agent skill from https://github.com/jeremylongshore/tons-of-skills-marketplace/tree/main/plugins/saas-packs/anthropic-pack/skills/anth-sdk-patterns into .opencode/skills/anth-sdk-patterns/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "anth-sdk-patterns", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
anth-sdk-patternsApply production-ready Anthropic SDK patterns for TypeScript and Python.
Anth SDK Patterns is an agent skill from jeremylongshore/tons-of-skills-marketplace. 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".
Its SKILL.md is about 1.9k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts. Compatibility notes: Designed for Claude Code
It sits in AI & LLM Engineering, covering LLM API integration and Code quality. It works with Anthropic API, Python and TypeScript. The repository describes itself as: Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com. The licence is MIT.
Read from SKILL.md and the folder at commit 23ea8d4. It shows what the files ask for, not the result of running them.
Pre-approves these tools, so the agent can use them without asking each time:
ReadWriteEditFrom allowed-tools in the SKILL.md frontmatter.
No scripts in the folder and no shell commands in SKILL.md (its code samples are python and typescript).
From the folder's file list and the shell code blocks in SKILL.md.
Links to these hosts (documentation or services it may open):
platform.claude.comFrom URLs in SKILL.md, links to its own repository left out.
Names these keys or tokens, usually read from environment variables:
ANTHROPIC_API_KEYFrom names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Designed for Claude Code
From compatibility in the SKILL.md frontmatter.
Anth SDK Patterns loads about 1.9k tokens when it runs. Until then it costs about 88 tokens; SKILL.md has 339 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from jeremylongshore/tons-of-skills-marketplace at commit 23ea8d4, republished under its MIT licence (© jeremylongshore). 339 words, ~1,884 tokens.
.claude/skills/anth-sdk-patterns/SKILL.md (or your agent's skills folder).Production-ready patterns for the Anthropic SDK covering client management, error handling, type safety, and multi-tenant configurations.
anth-install-auth setupimport Anthropic from '@anthropic-ai/sdk';
import type { Message, MessageCreateParams } from '@anthropic-ai/sdk/resources/messages';
class ClaudeService {
private client: Anthropic;
constructor(apiKey?: string) {
this.client = new Anthropic({
apiKey: apiKey || process.env.ANTHROPIC_API_KEY,
maxRetries: 3, // SDK handles 429 + 5xx automatically
timeout: 60_000,
});
}
async complete(
prompt: string,
options: Partial<MessageCreateParams> = {}
): Promise<string> {
const message = await this.client.messages.create({
model: options.model || 'claude-sonnet-4-20250514',
max_tokens: options.max_tokens || 1024,
messages: [{ role: 'user', content: prompt }],
...options,
});
const textBlock = message.content.find((b) => b.type === 'text');
if (!textBlock || textBlock.type !== 'text') {
throw new Error(`No text in response: ${message.stop_reason}`);
}
return textBlock.text;
}
async *stream(prompt: string, model = 'claude-sonnet-4-20250514'): AsyncGenerator<string> {
const stream = this.client.messages.stream({
model,
max_tokens: 4096,
messages: [{ role: 'user', content: prompt }],
});
for await (const event of stream) {
if (event.type === 'content_block_delta' && event.delta.type === 'text_delta') {
yield event.delta.text;
}
}
}
}import anthropic
from dataclasses import dataclass, field
@dataclass
class Conversation:
client: anthropic.Anthropic = field(default_factory=anthropic.Anthropic)
model: str = "claude-sonnet-4-20250514"
system: str = ""
messages: list = field(default_factory=list)
max_tokens: int = 4096
def say(self, user_message: str) -> str:
self.messages.append({"role": "user", "content": user_message})
response = self.client.messages.create(
model=self.model,
max_tokens=self.max_tokens,
system=self.system,
messages=self.messages,
)
assistant_text = response.content[0].text
self.messages.append({"role": "assistant", "content": assistant_text})
return assistant_text
@property
def token_count(self) -> int:
"""Estimate total tokens in conversation."""
return sum(len(str(m["content"])) // 4 for m in self.messages)
# Usage
conv = Conversation(system="You are a helpful coding assistant.")
print(conv.say("What is a closure in JavaScript?"))
print(conv.say("Can you show me an example?")) # Has full contextimport json
import anthropic
client = anthropic.Anthropic()
def extract_structured(text: str, schema_description: str) -> dict:
"""Force JSON output using assistant prefill technique."""
message = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=1024,
messages=[
{"role": "user", "content": f"Extract data from this text as JSON.\n\nSchema: {schema_description}\n\nText: {text}"},
{"role": "assistant", "content": "{"} # Prefill forces JSON output
]
)
json_str = "{" + message.content[0].text
return json.loads(json_str)
# Usage
data = extract_structured(
"John Smith, 35, lives in NYC and works at Google as a PM.",
'{"name": str, "age": int, "city": str, "company": str, "role": str}'
)
# {"name": "John Smith", "age": 35, "city": "NYC", "company": "Google", "role": "PM"}const clients = new Map<string, Anthropic>();
export function getClientForTenant(tenantId: string): Anthropic {
if (!clients.has(tenantId)) {
const apiKey = getApiKeyForTenant(tenantId); // From your secret store
clients.set(tenantId, new Anthropic({ apiKey }));
}
return clients.get(tenantId)!;
}# Use the Token Counting API to pre-check request size
count = client.messages.count_tokens(
model="claude-sonnet-4-20250514",
messages=[{"role": "user", "content": long_document}],
system="You are a summarizer."
)
print(f"Input will use {count.input_tokens} tokens")
# Adjust max_tokens to stay within budget
remaining_budget = 200_000 - count.input_tokens
max_tokens = min(4096, remaining_budget)Choose one pattern for the integration boundary instead of copying all of them into a single client. Start with the typed wrapper for a service that returns text, add the conversation manager only when the application owns turn history, and use token counting before submitting large documents. Keep tenant keys in a server-side secret store and make the factory key its cache by tenant identity; never accept or persist a customer key in browser code. Test the selected wrapper with a mocked SDK response before enabling live requests.
The selected pattern yields a stable application-level interface: a text value or stream for an interactive request, a JSON object that has passed parsing for structured extraction, or a tenant-scoped client whose credentials remain isolated. Failures are surfaced as explicit SDK errors or a missing-text/JSON parsing error rather than silently returning partial data.
For a support API, instantiate one ClaudeService at process startup and call
complete() from the server route; return its string only after the wrapper has
confirmed a text block. For a document import, call count_tokens() first,
reduce the requested output to the remaining budget, then pass the bounded
request to the wrapper. In a multi-tenant service, resolve the tenant's key
from the secret store and use getClientForTenant() so one customer's retry or
usage state cannot be confused with another's.
| Pattern | Use Case | Benefit |
|---|---|---|
SDK maxRetries | 429 / 5xx errors | Built-in exponential backoff |
| Prefill technique | Force JSON output | No regex parsing needed |
| Token counting | Long documents | Prevent context overflow |
| Client factory | Multi-tenant SaaS | Key isolation per customer |
Apply patterns in anth-core-workflow-a for tool use workflows.
© jeremylongshore, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
Just SKILL.md in plugins/saas-packs/anthropic-pack/skills/anth-sdk-patterns of jeremylongshore/tons-of-skills-marketplace.
Open the folder on GitHubat commit 23ea8d4
Anth SDK Patterns next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Anth SDK Patterns this skilljeremylongshore/tons-of-skills-marketplace | 2.8k | — | ~1.9k | Automated safety check: Pass | MIT | |
| Claude APIloulanyue/awesome-claude-notes | 272 | 1 repos | ~1.9k | Automated safety check: Pass | MIT | |
| Claude APImajiayu000/claude-skill-registry | 666 | 3 repos | ~2.1k | Automated safety check: Pass | MIT | |
| Claude Cookbooks Reference2025Emma/vibe-coding-cn | 23k | 1 repos | ~2.2k | Automated safety check: Pass | MIT | |
| Claude APIKocoro-lab/Kocoro | 414 | 8 repos | ~4.5k | Automated safety check: Pass | Apache-2.0 | |
| Gemini API Devgoogle-gemini/gemini-skills | 4.3k | — | ~5.1k | Automated safety check: Pass | Apache-2.0 |
loulanyue/awesome-claude-notes
Anthropic Claude API 的 Python 和 TypeScript 使用模式。涵盖 Messages API、流式处理、工具使用、视觉功能、扩展思维、批量处理、提示缓存和 Claude Agent SDK。适用于使用 Claude API 或 Anthropic SDK 构建应用程序的场景。
majiayu000/claude-skill-registry
Anthropic Claude API patterns for Python and TypeScript. An agent skill from majiayu000/claude-skill-registry.
2025Emma/vibe-coding-cn
Reference of Claude API examples and guides covering tool use, vision, RAG, classification, summarization, text-to-SQL, prompt caching and agent patterns.
Kocoro-lab/Kocoro
Build apps with the Claude API or Anthropic SDK. An agent skill from Kocoro-lab/Kocoro.
google-gemini/gemini-skills
A skill your agent uses when writing code that calls the Gemini API for text generation, multi-turn chat, multimodal understanding, image generation, video generation, speech generation (TTS), voice…
google-gemini/gemini-skills
A skill your agent uses when building real-time, bidirectional streaming applications with the Gemini Live API, or migrating legacy Live models (2.0/2.5/3.1) to Gemini 3.8 Live.
jeremylongshore/tons-of-skills-marketplace
Execute this skill enables AI assistant to conduct a security-focused code review using the security-agent plugin.
jeremylongshore/tons-of-skills-marketplace
Execute this skill enables AI assistant to perform natural language processing and text analysis using the nlp-text-analyzer plugin.
jeremylongshore/tons-of-skills-marketplace
Execute this skill allows AI assistant to construct and configure neural network architectures using the neural-network-builder plugin.
jeremylongshore/tons-of-skills-marketplace
Process identify anomalies and outliers in datasets using machine learning algorithms.
jeremylongshore/tons-of-skills-marketplace
Build this skill enables AI assistant to provide interpretability and explainability for machine learning models.
jeremylongshore/tons-of-skills-marketplace
Execute this skill optimizes prompts for large language models (llms) to reduce token usage, lower costs, and improve performance.
Works with
Apply production-ready Anthropic SDK patterns for TypeScript and Python. Anth SDK Patterns is an agent skill from jeremylongshore/tons-of-skills-marketplace. Apply production-ready Anthropic SDK patterns for TypeScript and Python.
Anth SDK Patterns fits situations like: implementing Claude integrations; building reusable wrappers; establishing team coding standards for the Messages API; with phrases like anthropic SDK patterns.
Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill anth-sdk-patterns -a claude-code`. Or copy the skill folder (plugins/saas-packs/anthropic-pack/skills/anth-sdk-patterns in jeremylongshore/tons-of-skills-marketplace) into .claude/skills/anth-sdk-patterns in your project. Claude Code loads it when a task matches its description.
Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill anth-sdk-patterns -a codex`. Or copy the skill folder (plugins/saas-packs/anthropic-pack/skills/anth-sdk-patterns in jeremylongshore/tons-of-skills-marketplace) into .agents/skills/anth-sdk-patterns in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill anth-sdk-patterns -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/anth-sdk-patterns, .gemini/skills/anth-sdk-patterns, .github/skills/anth-sdk-patterns and .opencode/skills/anth-sdk-patterns in your project.
Going by SKILL.md and its folder, Anth SDK Patterns needs credentials named ANTHROPIC_API_KEY. Our summary lists: Python 3; A credential in ANTHROPIC_API_KEY. Its frontmatter pre-approves these tools: Read, Write, Edit. Compatibility (from SKILL.md): Designed for Claude Code.
SKILL.md names 1 domain. As links in the text: platform.claude.com. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
Anth SDK Patterns is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.
About 1.9k tokens (SKILL.md is roughly 7.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.
Skills that share tags, products or a category with Anth SDK Patterns: Claude API (loulanyue/awesome-claude-notes, 272 stars), Claude API (majiayu000/claude-skill-registry, 666 stars), Claude Cookbooks Reference (2025Emma/vibe-coding-cn, 23k stars) and Claude API (Kocoro-lab/Kocoro, 414 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
jeremylongshore (a GitHub user) maintains it in jeremylongshore/tons-of-skills-marketplace, which has 2,821 GitHub stars. The repository holds 3,342 skills in this directory. The repository was last updated on October 8, 2026.
Source: jeremylongshore/tons-of-skills-marketplace on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.