huangjia2019/claude-code-engineering / 04-Skills/projects/05-api-generator
api-generating
VerifiedGenerate API endpoint code and documentation from specifications. Use when the user wants to create new API endpoints, generate route handlers, scaffold REST APIs, or produce OpenAPI/Swagger specs from code.
| File | Kind | Size |
|---|---|---|
| EXAMPLES.md | markdown | 2.7 KB |
| PATTERNS.md | markdown | 1.6 KB |
| README.md | markdown | 2.2 KB |
| SKILL.md | skill md | 1.5 KB |
| STANDARDS.md | markdown | 1.7 KB |
| scripts/detect_routes.pyexecutable | script | 3.4 KB |
| scripts/validate_openapi.shexecutable | script | 2.2 KB |
| templates/endpoint.md | markdown | 873 B |
| templates/index.md | markdown | 881 B |
| templates/openapi.yaml | config | 1.6 KB |
scripts/detect_routes.py
View on GitHub#!/usr/bin/env python3
"""
API Route Detector
Scans source files and detects API route definitions.
Usage:
python detect_routes.py <source_directory> [--framework express|fastapi|spring|gin]
Output:
JSON array of detected routes with method, path, and source location.
"""
import os
import re
import json
import argparse
from pathlib import Path
# Framework-specific patterns
PATTERNS = {
'express': [
r'app\.(get|post|put|delete|patch)\s*\(\s*[\'"]([^\'"]+)[\'"]',
r'router\.(get|post|put|delete|patch)\s*\(\s*[\'"]([^\'"]+)[\'"]',
],
'fastapi': [
r'@app\.(get|post|put|delete|patch)\s*\(\s*[\'"]([^\'"]+)[\'"]',
r'@router\.(get|post|put|delete|patch)\s*\(\s*[\'"]([^\'"]+)[\'"]',
],
'spring': [
r'@(Get|Post|Put|Delete|Patch)Mapping\s*\(\s*[\'"]?([^\'")\s]+)',
r'@RequestMapping\s*\([^)]*value\s*=\s*[\'"]([^\'"]+)[\'"]',
],
'gin': [
r'\.(GET|POST|PUT|DELETE|PATCH)\s*\(\s*[\'"]([^\'"]+)[\'"]',
]
}
FILE_EXTENSIONS = {
'express': ['.js', '.ts'],
'fastapi': ['.py'],
'spring': ['.java'],
'gin': ['.go'],
}
def detect_routes(directory, framework=None):
"""Scan directory for API routes."""
routes = []
frameworks = [framework] if framework else PATTERNS.keys()
for fw in frameworks:
extensions = FILE_EXTENSIONS.get(fw, [])
patterns = PATTERNS.get(fw, [])
for root, dirs, files in os.walk(directory):
# Skip common non-source directories
dirs[:] = [d for d in dirs if d not in ['node_modules', '__pycache__', '.git', 'vendor']]
for file in files:
if any(file.endswith(ext) for ext in extensions):
filepath = os.path.join(root, file)
try:
with open(filepath, 'r', encoding='utf-8') as f:
content = f.read()
for pattern in patterns:
for match in re.finditer(pattern, content, re.IGNORECASE):
method = match.group(1).upper()
path = match.group(2)
line_num = content[:match.start()].count('\n') + 1
routes.append({
'method': method,
'path': path,
'file': filepath,
'line': line_num,
'framework': fw
})
except Exception as e:
print(f"Warning: Could not read {filepath}: {e}")
return routes
def main():
parser = argparse.ArgumentParser(description='Detect API routes in source code')
parser.add_argument('directory', help='Source directory to scan')
parser.add_argument('--framework', choices=['express', 'fastapi', 'spring', 'gin'],
help='Specific framework to detect')
parser.add_argument('--output', '-o', help='Output file (default: stdout)')
args = parser.parse_args()
routes = detect_routes(args.directory, args.framework)
output = json.dumps(routes, indent=2)
if args.output:
with open(args.output, 'w') as f:
f.write(output)
print(f"Found {len(routes)} routes, saved to {args.output}")
else:
print(output)
if __name__ == '__main__':
main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-changelog-updatemorluto/reaPrepare or rewrite REA release changelogs and GitHub release notes from pinned Git history, with verified contributor thanks and Release Please synchronization. | Stars: 467k | Updated | Claude CodeCodex | Verified | Install |
| academy-guideanthropics/skillsStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials, and use cases from Claude Academy (academy.claude.com), Anthropic's learning hub. Trigger on: "how do I", "how can I", "getting started with", "what can Claude do", "teach me", "learn to use"; questions about artifacts, projects, skills, plugins, connectors, MCP; requests about rolling Claude out to a team, class, or organization; and any ask for training materials, onboarding content, or learning resources. Use it when the user is learning how to use a feature or product — not when they are mid-task and just want the task done. This skill composes with other skills: after consulting product documentation to answer how a Claude feature works, also check here for a matching course or tutorial — a docs-grounded answer and an Academy recommendation belong together. Only recommend on a strong match; never invent Academy content. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| claude-apianthropics/skillsReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIRST if no provider named — don't Read the file). | Stars: 196k | Updated | Claude CodeCodex | Unverified | Install |
| doc-coauthoringanthropics/skillsGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |