Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

api-examples

БесплатноБез исполняемых скриптовНе проверен

Generate API usage examples and tutorials from code analysis

diegosouzapwот diegosouzapw★ 68 звёзд на GitHub

Об этом скилле

API Examples & Tutorial Generator

I'll analyze your API and generate comprehensive usage examples, code snippets, and tutorials for developers.

Arguments: $ARGUMENTS - specific API focus or language (e.g., "REST", "GraphQL", "python", "javascript")

Strategic Planning Process

Effective API examples require understanding:
  1. API Analysis

    • What type of API? (REST, GraphQL, gRPC, WebSocket)
    • What endpoints/operations exist?
    • What's the authentication method?
    • What are common use cases?
    • What error handling is needed?
  2. Audience Consideration

    • Who are the API consumers? (internal, external, partners)
    • What languages do they use?
    • What's their experience level?
    • What examples will be most valuable?
  3. Example Types

    • Quick start / Getting started
    • Authentication examples
    • CRUD operation examples
    • Complex workflow examples
    • Error handling patterns
    • Best practices and anti-patterns
  4. Format & Organization

    • Code snippets for common operations
    • Complete working examples
    • Interactive tutorials
    • SDK usage examples
    • cURL/HTTP examples for testing

Token Optimization

Status: ✅ Fully Optimized (Phase 2 Batch 4B, 2026-01-27)

Target: 65-80% reduction (3,500-5,000 → 900-1,500 tokens)

Core Strategy: Cache-Based Example Generation

Generate API usage examples efficiently by reusing cached API schemas and pre-built templates instead of analyzing implementation code.

Optimization Impact:

  • Before: 3,500-5,000 tokens (full API analysis + schema reading + example generation)
  • After: 900-1,500 tokens (cache lookup + template rendering + targeted examples)
  • Savings: 65-80% reduction

1. Cached API Schema (75% savings)

Pattern: Reuse OpenAPI/GraphQL schema from /api-validate, /api-docs-generate cache

# Instead of analyzing route files (HIGH COST):
# Read: src/routes/*.js (2,000+ tokens)
# Read: src/controllers/*.js (2,000+ tokens)
# Analyze request/response schemas (1,000+ tokens)

# Use cached schema (LOW COST):
cat .claude/cache/api/api_schema.json  # 200 tokens

Cache Structure:

{
  "schema_version": "1.0",
  "api_type": "REST",
  "framework": "express",
  "base_url": "/api/v1",
  "endpoints": [
    {
      "path": "/users",
      "methods": ["GET", "POST"],
      "auth_required": true,
      "request_schema": {...},
      "response_schema": {...}
    }
  ],
  "auth_methods": ["Bearer", "API Key"],
  "last_updated": "2026-01-27T10:00:00Z"
}

Implementation:

# Check cache first
if [ -f .claude/cache/api/api_schema.json ]; then
  echo "✓ Using cached API schema"
  ENDPOINTS=$(jq -r '.endpoints[] | "\(.methods[]) \(.path)"' .claude/cache/api/api_schema.json)
  AUTH_TYPE=$(jq -r '.auth_methods[0]' .claude/cache/api/api_schema.json)
else
  echo "⚠ Cache miss - suggest running /api-validate first"
  # Fallback to minimal discovery
fi

Savings: 2,000-3,000 tokens avoided per invocation

2. Template-Based Examples (70% savings)

Pattern: Use pre-built language templates instead of generating from scratch

# Instead of generating examples from scratch (HIGH COST):
# Analyze endpoint parameters (500+ tokens)
# Generate JavaScript example (400+ tokens)
# Generate Python example (400+ tokens)
# Generate cURL example (300+ tokens)

# Use cached templates (LOW COST):
cat .claude/cache/api/example_templates.json  # 150 tokens
# Fill in endpoint-specific data (100 tokens)

Template Cache:

{
  "templates": {
    "rest_get_js": "async function get{Resource}(id) {\n  const response = await fetch(`${API_BASE}/{resource}/${id}`, {\n    headers: { 'Authorization': 'Bearer {token}' }\n  });\n  return response.json();\n}",
    "rest_post_js": "async function create{Resource}(data) {\n  const response = await fetch(`${API_BASE}/{resource}`, {\n    method: 'POST',\n    headers: { 'Authorization': 'Bearer {token}', 'Content-Type': 'application/json' },\n    body: JSON.stringify(data)\n  });\n  return response.json();\n}",
    "rest_get_py": "def get_{resource}(id):\n    response = requests.get(f'{API_BASE}/{resource}/{id}', headers={'Authorization': f'Bearer {token}'})\n    response.raise_for_status()\n    return response.json()",
    "graphql_query_js": "const {QUERY_NAME} = gql`\n  query {QueryName}($id: ID!) {\n    {resource}(id: $id) {\n      {fields}\n    }\n  }\n`;"
  },
  "languages": ["javascript", "python", "curl", "typescript"],
  "patterns": ["CRUD", "authentication", "pagination", "error_handling"]
}

Implementation:

# Generate examples from templates
ENDPOINT="/users"
METHOD="GET"
RESOURCE="User"

# Lookup and fill template
TEMPLATE=$(jq -r '.templates.rest_get_js' .claude/cache/api/example_templates.json)
echo "$TEMPLATE" | sed "s/{Resource}/$RESOURCE/g" | sed "s|{resource}|${ENDPOINT#/}|g"

Savings: 1,000-1,500 tokens per language set

3. Grep for Endpoints (8

Полный SKILL.md на GitHub

Установить api-examples в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

metadata.json

FAQ

Что делает скилл api-examples?

Generate API usage examples and tutorials from code analysis

Как установить скилл api-examples?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл api-examples запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить api-examples с