agentleFS
Rikinshah787Rikinshah787/agent-skills-production-skills/skills/anthropic/SKILL.md

anthropic

Skill2 starsChanged 4 months agoMITView on GitHub

Use to build with Claude through the Messages API, including streaming, system prompts, token controls, and schema-validated tool use.

  • Reads credentials
  • Installs packages

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. JustinPerea/nebula-nodes★ 18same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository20 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 4 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use when: adding Claude for generation, analysis, coding, document work, or agentic tool use.

    line 22
  2. Distinctive:

    Use when: you need long-form streaming and explicit client/server tool execution boundaries.

    line 23
  3. Distinctive:

    Don't use for: deterministic transformations or rules that ordinary code can perform reliably.

    line 24
  4. Very specific:

    When handling raw events, accept new/unknown event types gracefully and handle stream error events, including overloaded_error (HTTP 529 …

    line 75
  5. Very specific:

    Never expose ANTHROPIC_API_KEY in client code, logs, repositories, or public environment variables.

    line 149
  6. Very specific:

    Treat Claude output and tool_use.input as untrusted.

    line 150
  7. Distinctive:

    Avoid sending credentials, regulated personal data, or unnecessary private content in prompts and logs.

    line 151

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Anthropic API - Skillship

Build Claude-powered applications with the stateless Messages API, typed content blocks, streaming, token accounting, and tools that run either in your application or on Anthropic's infrastructure.

🧭 When to use this skill

  • Use when: adding Claude for generation, analysis, coding, document work, or agentic tool use.
  • Use when: you need long-form streaming and explicit client/server tool execution boundaries.
  • Don't use for: deterministic transformations or rules that ordinary code can perform reliably.

⚡ Quickstart

1. Install

npm install @anthropic-ai/sdk

2. Configure (server only)

ANTHROPIC_API_KEY=sk-ant-...
ANTHROPIC_MODEL=claude-sonnet-5

The SDK reads ANTHROPIC_API_KEY and sends required API headers automatically.

3. Create a message

import "server-only";
import Anthropic from "@anthropic-ai/sdk";

const anthropic = new Anthropic();

const message = await anthropic.messages.create({
  model: process.env.ANTHROPIC_MODEL ?? "claude-sonnet-5",
  max_tokens: 1024,
  system: "Answer accurately and say when you do not know.",
  messages: [{ role: "user", content: "Explain vector databases in two sentences." }],
});

const text = message.content.find((block) => block.type === "text");
if (text?.type === "text") console.log(text.text);

The API is stateless: send the relevant conversation history in messages on each request. Put system instructions in the top-level system field, not in a system message role.

🧩 Common recipes

Recipe: Stream text and retain the final typed message

const stream = anthropic.messages
  .stream({
    model: process.env.ANTHROPIC_MODEL ?? "claude-sonnet-5",
    max_tokens: 1024,
    messages: [{ role: "user", content: "Write a short launch announcement." }],
  })
  .on("text", (text) => process.stdout.write(text));

const finalMessage = await stream.finalMessage();
console.log(finalMessage.stop_reason, finalMessage.usage);

When handling raw events, accept new/unknown event types gracefully and handle stream error events, including overloaded_error (HTTP 529 outside a stream).

Recipe: Define and execute a client tool

import Anthropic from "@anthropic-ai/sdk";

const tools: Anthropic.Tool[] = [{
  name: "get_weather",
  description: "Get current weather for a city and country.",
  strict: true,
  input_schema: {
    type: "object",
    properties: { location: { type: "string" } },
    required: ["location"],
  },
}];

const messages: Anthropic.MessageParam[] = [
  { role: "user", content: "What is the weather in Paris?" },
];

const response = await anthropic.messages.create({
  model: process.env.ANTHROPIC_MODEL ?? "claude-sonnet-5",
  max_tokens: 1024,
  tools,
  messages,
});

const toolUse = response.content.find(
  (block): block is Anthropic.ToolUseBlock => block.type === "tool_use",
);

if (toolUse) {
  // Validate input and authorize before running your implementation.
  const result = await getWeather(toolUse.input);
  messages.push(
    { role: "assistant", content: response.content },
    {
      role: "user",
      content: [{ type: "tool_result", tool_use_id: toolUse.id, content: result }],
    },
  );

  const finalResponse = await anthropic.messages.create({
    model: process.env.ANTHROPIC_MODEL ?? "claude-sonnet-5",
    max_tokens: 1024,
    tools,
    messages,
  });
}

Client tools run in your code. Claude returns stop_reason: "tool_use"; you execute the operation and send back a matching tool_result. Server tools run on Anthropic's infrastructure.

Recipe: Preflight token usage

const count = await anthropic.messages.countTokens({
  model: process.env.ANTHROPIC_MODEL ?? "claude-sonnet-5",
  messages: [{ role: "user", content: "A potentially large prompt..." }],
});

console.log(count.input_tokens);

🚀 Ship to production

  • API keys stay server-side; use expiring keys or workload identity where supported.
  • Model ID and max_tokens are explicit and configurable.
  • stop_reason, content block types, usage, request IDs, and stream errors are handled.
  • Retries use exponential backoff for transient 429, 529, and network failures.
  • Tool inputs are schema-validated and each action is authorized before execution.
  • Token/latency/cost metrics and evals gate prompt or model changes.

🔐 Security & secrets

  • Never expose ANTHROPIC_API_KEY in client code, logs, repositories, or public environment variables.
  • Treat Claude output and tool_use.input as untrusted. Validate inputs, apply least privilege, and require approval for destructive actions.
  • Avoid sending credentials, regulated personal data, or unnecessary private content in prompts and logs.

🐛 Common errors & fixes

SymptomLikely causeFix
401 authentication_errorMissing/expired keySet the server env var and verify key/workspace access
Invalid system roleSystem prompt placed in messagesUse the top-level system field
Output prints [object Object]content is an array of typed blocksNarrow by block type and read .text
Tool loop stops after tool_useNo matching result was returnedAppend assistant content, then a tool_result with the same ID
429 or 529Rate limit or overloaded serviceBack off with jitter and honor retry guidance

💰 Pricing gotchas

  • Tool definitions, tool calls, and tool results all consume tokens; server tools can add separate usage charges. Message Batches can reduce asynchronous bulk-processing cost.

📚 Sources

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.