AD

add-ai-endpoint

Quickly generates AI-powered API routes using Claude, including schema validation, system prompts, and usage monitoring.

Install

mkdir -p .claude/skills/add-ai-endpoint && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/16707" && unzip -o skill.zip -d .claude/skills/add-ai-endpoint && rm skill.zip

Installs to .claude/skills/add-ai-endpoint

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Scaffold a Claude API powered endpoint with system prompt, structured output, token tracking, and rate limiting. Use when adding AI features like chatbot, matching, or text generation.
184 chars✓ has a “when” trigger
Intermediate

Key capabilities

  • Scaffold a Claude API powered endpoint
  • Handle system prompt design
  • Implement structured output parsing
  • Track token usage
  • Add per-user rate limiting

How it works

The skill scaffolds a new API endpoint by creating a route file, designing a system prompt, adding rate limiting, and registering the route.

Inputs & outputs

You give it
Feature name, input shape, output shape, system prompt context, and model choice
You get back
A new AI-powered API endpoint with system prompt, structured output, token tracking, and rate limiting

When to use add-ai-endpoint

  • Adding chatbot endpoints
  • Generating AI-based content
  • Implementing AI-driven scoring

About this skill

add-ai-endpoint

Scaffolds a new AI-powered API endpoint backed by the Anthropic Claude API. Handles system prompt design, structured output parsing, token usage tracking, and per-user rate limiting.

Inputs to gather

  • Feature name — e.g., "property-description-generator", "lead-scorer", "followup-writer"
  • Input shape — what the endpoint receives (e.g., leadId, propertyId, free text)
  • Output shape — what it returns (e.g., generated text, score object, match list)
  • System prompt context — domain knowledge the AI needs (Saudi real estate, Arabic language, REGA rules)
  • Model — claude-sonnet-4-6 (fast/cheap) or claude-opus-4-6 (best quality)

Steps

  1. Check AI service layer exists. Read apps/api/libs/ai-service.ts. If it doesn't exist, create it:

    // Anthropic client singleton, retry logic, token tracker
    import Anthropic from "@anthropic-ai/sdk";
    const client = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });
    
  2. Create the route file at apps/api/routes/ai-{feature}.ts:

    • Import authenticateToken middleware
    • Validate input with zod
    • Build messages array with system prompt + user content
    • Call client.messages.create() with structured output
    • Parse response, return JSON
    • Track token usage: prompt_tokens, completion_tokens in ai_usage table
  3. Design the system prompt. Must include:

    • Role: "You are a Saudi real estate expert assistant for عقاركم platform"
    • Language: "Always respond in Saudi Arabic (العربية السعودية)"
    • Domain constraints: REGA compliance, FAL license awareness, SAR currency
    • Output format: specify JSON schema if structured output needed
  4. Add rate limiting. In the route:

    • Check ai_usage table: user's token count today
    • If > daily limit (default 50K tokens), return 429
    • Track usage after successful call
  5. Register the route in apps/api/index.ts:

    import aiFeatureRoutes from "./routes/ai-{feature}";
    app.use("/api/ai", aiFeatureRoutes);
    
  6. Create react-query hook using /add-react-query for the frontend.

  7. Add API key to .env:

    ANTHROPIC_API_KEY=sk-ant-...
    

Verification checklist

  • Endpoint returns correct structured output
  • System prompt produces Arabic responses
  • Token usage is tracked per request
  • Rate limiting rejects over-limit requests with 429
  • Error handling: API timeout, invalid response, rate limit
  • /typecheck passes

Anti-patterns

  • Don't hardcode API keys — always use environment variables
  • Don't stream responses for simple endpoints — use non-streaming for structured output
  • Don't skip token tracking — you'll have no cost visibility
  • Don't use opus for high-volume endpoints — use sonnet for speed/cost
  • Don't let unauthenticated users hit AI endpoints (except chatbot)

When not to use it

  • When the AI service layer already exists and is configured
  • When not using Anthropic Claude API
  • When not needing structured output or token tracking

Prerequisites

ANTHROPIC_API_KEY in .env

Limitations

  • Requires Anthropic Claude API
  • Token usage is tracked per request
  • Rate limiting rejects over-limit requests with 429

How it compares

This workflow automates the setup of an AI endpoint with specific features like token tracking and rate limiting, which would otherwise require manual configuration and integration.

Compared to similar skills

add-ai-endpoint side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
add-ai-endpoint (this skill)04moReviewIntermediate
telegram-mini-app626moReviewAdvanced
stripe-integration483moNo flagsAdvanced
nodejs-backend-patterns123moNo flagsIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

telegram-mini-app

davila7

Expert in building Telegram Mini Apps (TWA) - web apps that run inside Telegram with native-like experience. Covers the TON ecosystem, Telegram Web App API, payments, user authentication, and building viral mini apps that monetize. Use when: telegram mini app, TWA, telegram web app, TON app, mini app.

62163

stripe-integration

wshobson

Implement Stripe payment processing for robust, PCI-compliant payment flows including checkout, subscriptions, and webhooks. Use when integrating Stripe payments, building subscription systems, or implementing secure checkout flows.

48165

nodejs-backend-patterns

wshobson

Build production-ready Node.js backend services with Express/Fastify, implementing middleware patterns, error handling, authentication, database integration, and API design best practices. Use when creating Node.js servers, REST APIs, GraphQL backends, or microservices architectures.

1246

agent-dev-backend-api

ruvnet

Agent skill for dev-backend-api - invoke with $agent-dev-backend-api

318

shopify-apps

alinaqi

Shopify app development - Remix, Admin API, checkout extensions

19

ccxt-typescript

ccxt

CCXT cryptocurrency exchange library for TypeScript and JavaScript developers (Node.js and browser). Covers both REST API (standard) and WebSocket API (real-time). Helps install CCXT, connect to exchanges, fetch market data, place orders, stream live tickers/orderbooks, handle authentication, and manage errors. Use when working with crypto exchanges in TypeScript/JavaScript projects, trading bots, arbitrage systems, or portfolio management tools. Includes both REST and WebSocket examples.

15

Search skills

Search the agent skills registry