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.zipInstalls 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.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
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
-
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 }); -
Create the route file at
apps/api/routes/ai-{feature}.ts:- Import
authenticateTokenmiddleware - 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_tokensinai_usagetable
- Import
-
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
-
Add rate limiting. In the route:
- Check
ai_usagetable: user's token count today - If > daily limit (default 50K tokens), return 429
- Track usage after successful call
- Check
-
Register the route in
apps/api/index.ts:import aiFeatureRoutes from "./routes/ai-{feature}"; app.use("/api/ai", aiFeatureRoutes); -
Create react-query hook using
/add-react-queryfor the frontend. -
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
-
/typecheckpasses
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
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.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| add-ai-endpoint (this skill) | 0 | 4mo | Review | Intermediate |
| telegram-mini-app | 62 | 6mo | Review | Advanced |
| stripe-integration | 48 | 3mo | No flags | Advanced |
| nodejs-backend-patterns | 12 | 3mo | No flags | Intermediate |
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.
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.
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.
agent-dev-backend-api
ruvnet
Agent skill for dev-backend-api - invoke with $agent-dev-backend-api
shopify-apps
alinaqi
Shopify app development - Remix, Admin API, checkout extensions
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.