Token导航 LogoToken导航

Agent Skill · AI 工具

claude-api(Claude API 控制)

用于辅助 API 设计、接口文档、请求响应结构和服务集成说明。它适合让 Agent 梳理 endpoint、生成 OpenAPI 草稿、检查字段命名、整理错误码或辅助前后端联调。使用时需要确认真实业务语义、鉴权方式、分页和错误处理规则;涉及生成接口文档时,应避免凭空补字段,最好从现有代码、schema 或接口样例中提取事实。

claude-api 是AI 工具类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证为 MIT,第三方扫描有提醒项,按安装量在AI 工具类的 2,536 个 Skill 里排第 1,252。

总安装 936周安装 39GitHub Stars 37下载 312核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
MIT

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:claude-api(Claude API 控制)
来源仓库:https://github.com/ovachiever/droid-tings
仓库路径:skills/claude-api
安装命令:
npx skills add https://github.com/ovachiever/droid-tings --skill claude-api
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/ovachiever/droid-tings --skill claude-api

这个 Skill 是做什么的

AI 工具类 Skill 用来扩展助手本身的能力,例如接模型、接检索、接外部服务。

claude-api 用于辅助 API 设计、接口文档和请求响应结构的梳理。适合生成 OpenAPI 草稿、检查字段命名或辅助前后端联调。使用时需确认真实业务语义和鉴权方式,避免凭空补字段。涉及接口文档生成时应优先从现有代码或样例中提取事实。建议在沙箱环境验证接口逻辑后再部署至生产。

claude-api 属于AI 工具类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/claude-api

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/ovachiever/droid-tings --skill claude-api;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

claude-api 怎么安装?

在终端执行 npx skills add https://github.com/ovachiever/droid-tings --skill claude-api。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

claude-api 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

claude-api 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

claude-api 是免费的吗?

来源标注的许可证是 MIT。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

claude-api 用的人多吗?

公开数据是累计安装 936 次,近一周安装 39 次,下载 312 次,GitHub 37 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

claude-api 安全吗?

第三方扫描有提醒项,说明存在需要人工确认的行为。安装前请打开源码看清它读了什么、联网到哪里。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 3 个目录同时收录,说明这个 Skill 流传比较广。
  • 许可证明确为 MIT,商用和分发边界好判断。

先想清楚的地方

  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理AI 工具类任务、又不想每次都手写提示词的人。

不太适合

  • 需要厂商级技术支持和 SLA 的生产系统。

AI 工具类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
executing-plans

执行计划 · Codex、Claude

1,515,336173,110只读MIT通过
verification-before-completion

完成前的验证 · Codex、Claude

1,319,472173,121权限未标注MIT通过
subagent-driven-development

子 Agent 驱动开发 · Codex、Claude

1,312,416173,138只读MIT通过
copy-editing

复制编辑 · Codex、Claude

1,209,57625,632只读MIT通过
paywall-upgrade-cro

付费专区升级 cro · Codex、Claude

1,030,17625,617只读MIT通过
claude-api

Claude API 控制 · 本页

93637需要联网MIT有提醒

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Claude API - Structured Outputs & Error Prevention Guide

Package: @anthropic-ai/sdk@0.70.1 (Nov 20, 2025) Breaking Changes: Oct 2025 - Claude 3.5/3.7 models retired, Nov 2025 - Structured outputs beta Last Updated: 2025-11-22


What's New in v0.69.0+ (Nov 2025)

Major Features:

1. Structured Outputs (v0.69.0, Nov 14, 2025) - CRITICAL ⭐

Guaranteed JSON schema conformance - Claude's responses strictly follow your JSON schema with two modes:

JSON Outputs (output_format) - For data extraction and formatting:

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

const anthropic = new Anthropic({
  apiKey: process.env.ANTHROPIC_API_KEY,
});

const message = await anthropic.messages.create({
  model: 'claude-sonnet-4-5-20250929',
  max_tokens: 1024,
  messages: [{ role: 'user', content: 'Extract contact info: John Doe, john@example.com, 555-1234' }],
  betas: ['structured-outputs-2025-11-13'],
  output_format: {
    type: 'json_schema',
    json_schema: {
      name: 'Contact',
      strict: true,
      schema: {
        type: 'object',
        properties: {
          name: { type: 'string' },
          email: { type: 'string' },
          phone: { type: 'string' }
        },
        required: ['name', 'email', 'phone'],
        additionalProperties: false
      }
    }
  }
});

// Guaranteed valid JSON matching schema
const contact = JSON.parse(message.content[0].text);
console.log(contact.name); // "John Doe"

Strict Tool Use (strict: true) - For validated function parameters:

const message = await anthropic.messages.create({
  model: 'claude-sonnet-4-5-20250929',
  max_tokens: 1024,
  messages: [{ role: 'user', content: 'Get weather for San Francisco' }],
  betas: ['structured-outputs-2025-11-13'],
  tools: [{
    name: 'get_weather',
    description: 'Get current weather',
    input_schema: {
      type: 'object',
      properties: {
        location: { type: 'string' },
        unit: { type: 'string', enum: ['celsius', 'fahrenheit'] }
      },
      required: ['location'],
      additionalProperties: false
    },
    strict: true  // ← Guarantees schema compliance
  }]
});

Requirements:

  • Beta header: structured-outputs-2025-11-13 (via betas array)
  • Models: Claude Sonnet 4.5, Claude Opus 4.1 only
  • SDK: v0.69.0+ required

Limitations:

  • ❌ No recursive schemas
  • ❌ No numerical constraints (minimum, maximum)
  • ❌ Limited regex support (no backreferences/lookahead)
  • ❌ Incompatible with citations and message prefilling
  • ⚠️ Grammar compilation adds latency on first request (cached 24hrs)

When to Use:

  • Data extraction from unstructured text
  • API response formatting
  • Agentic workflows requiring validated tool inputs
  • Eliminating JSON parse errors

2. Model Changes (Oct 2025) - BREAKING

Retired (return errors):

  • ❌ Claude 3.5 Sonnet (all versions)
  • ❌ Claude 3.7 Sonnet - DEPRECATED (Oct 28, 2025)

Active Models (Nov 2025):

ModelIDContextBest ForCost (per MTok)
Claude Sonnet 4.5claude-sonnet-4-5-20250929200kBalanced performance$3/$15 (in/out)
Claude Opus 4claude-opus-4-20250514200kHighest capability$15/$75
Claude Haiku 4.5claude-3-5-haiku-20241022200kNear-frontier, fast$1/$5

3. Context Management (Oct 28, 2025)

Clear Thinking Blocks - Automatic thinking block cleanup:

const message = await anthropic.messages.create({
  model: 'claude-sonnet-4-5-20250929',
  max_tokens: 4096,
  messages: [{ role: 'user', content: 'Solve complex problem' }],
  betas: ['clear_thinking_20251015']
});
// Thinking blocks automatically managed

4. Agent Skills API (Oct 16, 2025)

Pre-built skills for Office files (PowerPoint, Excel, Word, PDF):

const message = await anthropic.messages.create({
  model: 'claude-sonnet-4-5-20250929',
  max_tokens: 1024,
  messages: [{ role: 'user', content: 'Analyze this spreadsheet' }],
  betas: ['skills-2025-10-02'],
  // Requires code execution tool enabled
});

📚 Docs: https://platform.claude.com/docs/en/build-with-claude/structured-outputs


Streaming Responses (SSE)

CRITICAL Error Pattern - Errors occur AFTER initial 200 response:

const stream = anthropic.messages.stream({
  model: 'claude-sonnet-4-5-20250929',
  max_tokens: 1024,
  messages: [{ role: 'user', content: 'Hello' }],
});

stream
  .on('error', (error) => {
    // Error can occur AFTER stream starts
    console.error('Stream error:', error);
    // Implement fallback or retry logic
  })
  .on('abort', (error) => {
    console.warn('Stream aborted:', error);
  });

Why this matters: Unlike regular HTTP errors, SSE errors happen mid-stream after 200 OK, requiring error event listeners


Prompt Caching (⭐ 90% Cost Savings)

CRITICAL Rule - cache_control MUST be on LAST block:

const message = await anthropic.messages.create({
  model: 'claude-sonnet-4-5-20250929',
  max_tokens: 1024,
  system: [
    {
      type: 'text',
      text: 'System instructions...',
    },
    {
      type: 'text',
      text: LARGE_CODEBASE, // 50k tokens
      cache_control: { type: 'ephemeral' }, // ← MUST be on LAST block
    },
  ],
  messages: [{ role: 'user', content: 'Explain auth module' }],
});

// Monitor cache usage
console.log('Cache reads:', message.usage.cache_read_input_tokens);
console.log('Cache writes:', message.usage.cache_creation_input_tokens);

Minimum requirements:

  • Claude Sonnet 4.5: 1,024 tokens minimum
  • Claude Haiku 4.5: 2,048 tokens minimum
  • 5-minute TTL (refreshes on each use)
  • Cache shared only with IDENTICAL content

Tool Use (Function Calling)

CRITICAL Patterns:

Strict Tool Use (with structured outputs):

const message = await anthropic.messages.create({
  model: 'claude-sonnet-4-5-20250929',
  max_tokens: 1024,
  betas: ['structured-outputs-2025-11-13'],
  tools: [{
    name: 'get_weather',
    description: 'Get weather data',
    input_schema: {
      type: 'object',
      properties: {
        location: { type: 'string' },
        unit: { type: 'string', enum: ['celsius', 'fahrenheit'] }
      },
      required: ['location'],
      additionalProperties: false
    },
    strict: true  // ← Guarantees schema compliance
  }],
  messages: [{ role: 'user', content: 'Weather in NYC?' }]
});

Tool Result Pattern - tool_use_id MUST match:

const toolResults = [];
for (const block of response.content) {
  if (block.type === 'tool_use') {
    const result = await executeToolFunction(block.name, block.input);

    toolResults.push({
      type: 'tool_result',
      tool_use_id: block.id,  // ← MUST match tool_use block id
      content: JSON.stringify(result),
    });
  }
}

messages.push({
  role: 'user',
  content: toolResults,
});

Error Handling - Handle tool execution failures:

try {
  const result = await executeToolFunction(block.name, block.input);
  toolResults.push({
    type: 'tool_result',
    tool_use_id: block.id,
    content: JSON.stringify(result),
  });
} catch (error) {
  // Return error to Claude for handling
  toolResults.push({
    type: 'tool_result',
    tool_use_id: block.id,
    is_error: true,
    content: `Tool execution failed: ${error.message}`,
  });
}

Vision (Image Understanding)

CRITICAL Rules:

  • Formats: JPEG, PNG, WebP, GIF (non-animated)
  • Max size: 5MB per image
  • Base64 overhead: ~33% size increase
  • Context impact: Images count toward token limit
  • Caching: Consider for repeated image analysis

Format validation - Check before encoding:

const validFormats = ['image/jpeg', 'image/png', 'image/webp', 'image/gif'];
if (!validFormats.includes(mimeType)) {
  throw new Error(`Unsupported format: ${mimeType}`);
}

Extended Thinking Mode

⚠️ Model Compatibility:

  • ❌ Claude 3.7 Sonnet - DEPRECATED (Oct 28, 2025)
  • ❌ Claude 3.5 Sonnet - RETIRED (not supported)
  • ✅ Claude Sonnet 4.5 - Extended thinking supported
  • ✅ Claude Opus 4 - Extended thinking supported

CRITICAL:

  • Thinking blocks are NOT cacheable
  • Requires higher max_tokens (thinking consumes tokens)
  • Check model before expecting thinking blocks

Rate Limits

CRITICAL Pattern - Respect retry-after header with exponential backoff:

async function makeRequestWithRetry(
  requestFn: () => Promise<any>,
  maxRetries = 3,
  baseDelay = 1000
): Promise<any> {
  for (let attempt = 0; attempt < maxRetries; attempt++) {
    try {
      return await requestFn();
    } catch (error) {
      if (error.status === 429) {
        // CRITICAL: Use retry-after header if present
        const retryAfter = error.response?.headers?.['retry-after'];
        const delay = retryAfter
          ? parseInt(retryAfter) * 1000
          : baseDelay * Math.pow(2, attempt);

        console.warn(`Rate limited. Retrying in ${delay}ms...`);
        await new Promise(resolve => setTimeout(resolve, delay));
      } else {
        throw error;
      }
    }
  }
  throw new Error('Max retries exceeded');
}

Rate limit headers:

  • anthropic-ratelimit-requests-limit - Total RPM allowed
  • anthropic-ratelimit-requests-remaining - Remaining requests
  • anthropic-ratelimit-requests-reset - Reset timestamp

Error Handling

Common Error Codes:

StatusError TypeCauseSolution
400invalid_request_errorBad parametersValidate request body
401authentication_errorInvalid API keyCheck env variable
403permission_errorNo access to featureCheck account tier
404not_found_errorInvalid endpointCheck API version
429rate_limit_errorToo many requestsImplement retry logic
500api_errorInternal errorRetry with backoff
529overloaded_errorSystem overloadedRetry later

CRITICAL:

  • Streaming errors occur AFTER initial 200 response
  • Always implement error event listeners for streams
  • Respect retry-after header on 429 errors
  • Have fallback strategies for critical operations

Known Issues Prevention

This skill prevents 12 documented issues:

Issue #1: Rate Limit 429 Errors Without Backoff

Error: 429 Too Many Requests: Number of request tokens has exceeded your per-minute rate limit Source: https://docs.claude.com/en/api/errors Why It Happens: Exceeding RPM, TPM, or daily token limits Prevention: Implement exponential backoff with retry-after header respect

Issue #2: Streaming SSE Parsing Errors

Error: Incomplete chunks, malformed SSE events Source: Common SDK issue (GitHub #323) Why It Happens: Network interruptions, improper event parsing Prevention: Use SDK stream helpers, implement error event listeners

Issue #3: Prompt Caching Not Activating

Error: High costs despite cache_control blocks Source: https://platform.claude.com/docs/en/build-with-claude/prompt-caching Why It Happens: cache_control placed incorrectly (must be at END) Prevention: Always place cache_control on LAST block of cacheable content

Issue #4: Tool Use Response Format Errors

Error: invalid_request_error: tools[0].input_schema is invalid Source: API validation errors Why It Happens: Invalid JSON Schema, missing required fields Prevention: Validate schemas with JSON Schema validator, test thoroughly

Issue #5: Vision Image Format Issues

Error: invalid_request_error: image source must be base64 or url Source: API documentation Why It Happens: Incorrect encoding, unsupported formats Prevention: Validate format (JPEG/PNG/WebP/GIF), proper base64 encoding

Issue #6: Token Counting Mismatches for Billing

Error: Unexpected high costs, context window exceeded Source: Token counting differences Why It Happens: Not accounting for special tokens, formatting Prevention: Use official token counter, monitor usage headers

Issue #7: System Prompt Ordering Issues

Error: System prompt ignored or overridden Source: API behavior Why It Happens: System prompt placed after messages array Prevention: ALWAYS place system prompt before messages

Issue #8: Context Window Exceeded (200k)

Error: invalid_request_error: messages: too many tokens Source: Model limits Why It Happens: Long conversations without pruning Prevention: Implement message history pruning, use caching

Issue #9: Extended Thinking on Wrong Model

Error: No thinking blocks in response Source: Model capabilities Why It Happens: Using retired/deprecated models (3.5/3.7 Sonnet) Prevention: Only use extended thinking with Claude Sonnet 4.5 or Claude Opus 4

Issue #10: API Key Exposure in Client Code

Error: CORS errors, security vulnerability Source: Security best practices Why It Happens: Making API calls from browser Prevention: Server-side only, use environment variables

Issue #11: Rate Limit Tier Confusion

Error: Lower limits than expected Source: Account tier system Why It Happens: Not understanding tier progression Prevention: Check Console for current tier, auto-scales with usage

Issue #12: Message Batches Beta Headers Missing

Error: invalid_request_error: unknown parameter: batches Source: Beta API requirements Why It Happens: Missing anthropic-beta header Prevention: Include anthropic-beta: message-batches-2024-09-24 header


Official Documentation


Package Versions

Latest: @anthropic-ai/sdk@0.70.1 (Nov 20, 2025)

{
  "dependencies": {
    "@anthropic-ai/sdk": "^0.70.1"
  },
  "devDependencies": {
    "@types/node": "^20.0.0",
    "typescript": "^5.3.0",
    "zod": "^3.23.0"
  }
}

Token Efficiency:

  • Without skill: ~8,000 tokens (basic setup, streaming, caching, tools, vision, errors)
  • With skill: ~4,200 tokens (knowledge gaps + error prevention + critical patterns)
  • Savings: ~48% (~3,800 tokens)

Errors prevented: 12 documented issues with exact solutions Key value: Structured outputs (v0.69.0+), model deprecations (Oct 2025), prompt caching edge cases, streaming error patterns, rate limit retry logic


Last verified: 2025-11-22 | Skill version: 2.0.0 | Changes: Added structured outputs (v0.69.0), updated model table (retired 3.5/3.7), context management, agent skills API. Removed basic tutorials (~380 lines). Focused on knowledge gaps + error prevention + advanced patterns.

平台分布

Claude Code

29.85%
按下载量换算93

Antigravity

24.9%
按下载量换算78

Gemini CLI

16.91%
按下载量换算53

OpenCode

13.53%
按下载量换算42

github-copilot

7.23%
按下载量换算23

Codex

3.19%
按下载量换算10

安全审计

Gen Agent Trust Hub

可疑

Socket

通过

Snyk

可疑

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。

继续浏览同类 Skills