claude-scaffold: Skill for Claude Code

.claude/skills/claude-api-patterns/SKILL.md

claude-api-patterns is a skill for Claude Code from pyramidheadshark/claude-scaffold. It costs 0 tokens per session (975 once invoked), scanned A, original, MIT.

A set of coding patterns for Anthropic’s Claude API, the service used to send messages to Claude and receive responses. It covers the Anthropic SDK, streaming, batches, and tool use.

In plain words
What is it for?
Use it when writing Claude API requests, system prompts, streamed responses, message batches, or tool-calling integrations.
Why use it?
It helps avoid common mistakes when connecting an application to Claude, such as exposing API keys or handling streamed responses incorrectly.

Skill for Claude Code

Written for Claude Code: installed under .claude/.

This is pyramidheadshark/claude-scaffold's own configuration. It tells Claude Code how to work on claude-scaffold itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything claude-scaffold configures →

Reuse

Borrowing it

Nothing to install: this file belongs to pyramidheadshark/claude-scaffold. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/pyramidheadshark/claude-scaffold/main/.claude/skills/claude-api-patterns/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/pyramidheadshark/claude-scaffold

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for claude-api-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/pyramidheadshark/claude-scaffold/claude-api-patterns.svg)](https://agentmods.dev/skills/pyramidheadshark/claude-scaffold/claude-api-patterns)
Your own site
<a href="https://agentmods.dev/skills/pyramidheadshark/claude-scaffold/claude-api-patterns"><img src="https://agentmods.dev/badge/skills/pyramidheadshark/claude-scaffold/claude-api-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 975 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00975
Opus 5 $0.00000 $0.00487
Sonnet 5 $0.00000 $0.00195
Haiku 4.5 $0.00000 $0.00097

Measured 7d ago against content hash ff1c8426ccd1, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

claude-api-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 7d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/claude-api-patterns/SKILL.md · 161 lines

How it starts

The opening of the file, as written. The whole thing — 161 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Claude API Patterns

When to Load This Skill

Load when working with: Anthropic SDK, anthropic package, Claude API, tool use, streaming responses, message batches, MessageCreate, @anthropic-ai/sdk.

SDK Setup

import anthropic

client = anthropic.Anthropic(api_key=settings.ANTHROPIC_API_KEY)

Never hardcode the API key. Always use environment variables validated at startup.

Basic Message

message = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    messages=[{"role": "user", "content": prompt}],
)
return message.content[0].text

System Prompt

message = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=2048,
    system=system_prompt,
    messages=[{"role": "user", "content": user_message}],
)

Keep system prompts in separate .txt or .md files, not inline strings. Version them.

Streaming

with client.messages.stream(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    messages=[{"role": "user", "content": prompt}],
) as stream:
    for text in stream.text_stream:
        yield text

Use streaming for: long responses, real-time UX, progress indication.

Tool Use (Function Calling)

from pydantic import BaseModel

class SearchInput(BaseModel):
    query: str
    max_results: int = 10

tools = [{
    "name": "search",
    "description": "Search for information",
    "input_schema": SearchInput.model_json_schema(),
}]

response = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    tools=tools,
    messages=[{"role": "user", "content": "Find recent papers on RAG"}],
)

Always define tool schemas with Pydantic — never write raw JSON schemas by hand.

Tool Result Loop

messages = [{"role": "user", "content": user_message}]

while True:
    response = client.messages.create(
        model="claude-sonnet-4-6",
        max_tokens=4096,
        tools=tools,
        messages=messages,
    )

    if response.stop_reason == "end_turn":
        break

    if response.stop_reason == "tool_use":
        tool_results = []
        for block in response.content:
            if block.type == "tool_use":
                result = dispatch_tool(block.name, block.input)
                tool_results.append({
                    "type": "tool_result",
                    "tool_use_id": block.id,
                    "content": result,
                })

        messages.append({"role": "assistant", "content": response.content})
        messages.append({"role": "user", "content": tool_results})

Read the full file on GitHub · 161 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 7d ago First seen · 161 lines · 0 tokens per session scan A ff1c8426ccd1

Subscribe to this mod's changes

claude-api-patterns is a skill published in the GitHub repository pyramidheadshark/claude-scaffold (4 stars, last pushed 4mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 975 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

bun-file-io

Use this when you are working on file operations like reading, writing, scanning, or deleting files. It summarizes the preferred file APIs and patterns used in this repo. It also notes when to use filesystem helpers for directories.

synthetic-sciences/openscience · 49 tokens

protocolsio-integration

Integration with protocols.io API for managing scientific protocols. This skill should be used when working with protocols.io to search, create, update, or publish protocols; manage protocol steps and materials; handle discussions and comments; organize workspaces; upload and manage files; or integrate protocols.io…

synthetic-sciences/openscience · 85 tokens

genai-sdk

Guides the usage of Gemini API on Google Cloud Vertex AI with the Gen AI SDK. Use when the user asks about using Gemini in an enterprise environment or explicitly mentions Vertex AI. Covers SDK usage (Python, JS/TS, Go, Java, C#), capabilities like Live API, tools, multimedia generation, caching, and batch prediction.

GoogleCloudPlatform/vertex-ai-samples · 73 tokens

liveapi-service

Generates a LiveAPI client service class in the user's chosen programming language. Use when the user wants to build, scaffold, or integrate a client that connects to the Gemini LiveAPI websocket endpoint (Gemini Enterprise or non-Gemini Enterprise), handles session setup/resumption, bearer token refresh, and…

GoogleCloudPlatform/vertex-ai-samples · 80 tokens

healthchain

Use when building, debugging, or deploying a Python service that touches FHIR resources, EHR APIs, CDS Hooks, clinical documents, or patient data — including writing model or agent output back into a patient record, connecting to Epic/Cerner/Medplum, or serving FHIR tools to an agent over MCP or LangChain.

healthchainai/HealthChain · 71 tokens

spinnaker

Spinnaker CD platform integration for investigating pipeline executions, application health, and triggering rollbacks during RCA.

Arvo-AI/aurora · 24 tokens