Communitygithub.com

REST API 設計

REST API サーフェスを設計します。リソースの命名、HTTP メソッドとステータスコードのセマンティクス、エラー構造、ページネーション、フィルタリングを定義し、コンシューマが質問せずに構築できるエンドポイント仕様を提供します。

REST API 設計 とは?

このスキルは、開発者や AI エージェントが一貫性があり、堅牢で、コンシューマにとって直感的な REST API を設計するための包括的なガイドを提供します。データベーススキーマではなく、コンシューマのメンタルモデルを優先し、リソースの命名、HTTP メソッドの選択、ステータスコードのセマンティクス、エラー構造、カーソルベースのページネーション、フィルタリング戦略など、API 設計のあらゆる側面をカバーします。このスキルは、API の内部一貫性を確保し、コンシューマがドキュメントなしでクライアントを実装できるようにするために、Claude Code、Cursor、Codex などの開発者ツールで使用することを想定しています。動作手順は、入力の収集から始まり、リソースの命名、メソッドとステータスコードの割り当て、エラーとページネーションの契約の修正、そしてパフォーマンス予算の適用へと進みます。結果として、エンドポイント仕様が生成され、依存関係を最小限に抑え、将来の変更に対する回復力を高めるための「やってはいけないこと」のリストも含まれています。

対応~Claude Code~Codex CLI✓Cursor
npx skills add https://github.com/SkillMedev/skills/tree/HEAD/skills/api-design

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

REST API 設計 は何をしますか?

API はプロダクトです。コンシューマのメンタルモデルが、データベーススキーマではなく、構造を決定します。このスキルが防ぐ高コストなミスは、一貫性のないサーフェス(命名の混在、間違ったステータスコード、増大するテーブルに対するオフセットページネーション)を出荷してしまい、すべてのコンシューマがそれをハードコードし、統合後は事実上修正不可能になることです。

行動手順

この順序で作業します。リソースはメソッドに先行します。なぜなら、メソッドのセマンティクスはリソースの種類に依存するからです。エラーとページネーションの契約は、仕様が書かれる前に修正します。後付けで修正するとコンシューマが壊れるからです。

ステップ 1: インプットを収集する

設計前に収集します。推測にはすべてラベルを付けます。

  1. コンシューマ: 内部サービス、ファーストパーティクライアント、または外部開発者。外部コンシューマは一貫性のハードルを上げます。不明な場合は外部をデフォルトとします。
  2. ドメインのコア名詞と、どの名詞がどの名詞を所有するか(ネスト構造を決める)。
  3. 想定されるコレクションサイズと成長。約 10,000 行を超える可能性のあるリストは、オフセットページネーションを除外します。
  4. エンドポイントごとの読み取り/書き込み比率とレイテンシ期待値。
  5. 認証モデル(401 と 403 の正確性に影響します)。

ステップ 2: リソースを命名する

  • 複数形名詞: /users, /orders, /products。
  • 所有関係のために1レベルネストする: /users/{id}/orders。2レベルより深くネストしないでください。代わりにフィルタで平坦化します (/orders?user_id=... は /users/{id}/orders/{oid}/items/{iid} より優れています)。
  • パスに動詞を含めないでください。HTTP メソッドが動詞です。CRUD 動詞に当てはまらない真のアクション(例: 請求書の送信)については、サブリソースへの POST としてモデル化します: POST /invoices/{id}/send-attempts。
  • 一貫したケース: 複数単語のパスセグメントにはケバブケース、JSON フィールドにはスネークケース - 一度選択したら、すべてに適用します。

ステップ 3: メソッドとステータスコードを割り当てる

  • GET: 読み取り、べき等、リクエストボディなし。200 とボディを返します。
  • POST: 作成。201 と新しいリソースを指す Location ヘッダーを返します。クライアントが後続の GET をスキップできるように、作成された表現をボディで返します。
  • PUT: 完全置換、べき等。欠落フィールドは「保持」ではなく「クリア」を意味します。
  • PATCH: 部分更新(JSON Merge Patch または JSON Patch - 仕様でどちらかを明記します)。
  • DELETE: 削除、べき等、204 を返します。既に削除されたリソースの削除は 204 または 404 を返します - 1つを選択して文書化します。
  • エラー: 不正な入力には 400、資格情報の欠落/無効には 401、有効な資格情報だが権限がない場合は 403、リソース不在には 404(存在を明かすことが漏洩となる場合は 403 の代わりに 404 も使用)、状態の競合には 409、形式は正しいが意味的に無効な入力には 422、レート制限には 429(Retry-After 付き)、サーバー障害には 500 - スタックトレースや内部識別子を決して公開しないでください。

ステップ 4: エラー契約を修正する

すべてのエラーに対して1つの構造、機械可読なコードを最初に:

{
  "error": "validation_error",
  "message": "Email is required",
  "field": "email",
  "request_id": "req_abc123"
}

request_id はサーバー側でログに記録され、サポートが関連付けできるようにする必要があります。人間向けメッセージは開発者がログを読むためのものであり、エンドユーザー表示用ではありません。

ステップ 5: ページネーションとフィルタリングを修正する

  • 成長するコレクションにはカーソルベースのページネーション: 不透明なカーソルと has_more フラグを返します。オフセットページネーションは、小さく、境界があり、管理画面向けのリストにのみ許容されます。これは線形に劣化し、同時書き込みの下で行をスキップ/重複します。
  • デフォルトのページサイズは 25、最大は 100。最大を超えるページサイズは 400 で拒否し、静かにクランプしないでください。
  • フィルタリングとソートはクエリパラメータ経由: ?status=active&sort=created_at:desc。どのフィールドがフィルタリング可能かを文書化します。不明なフィルタパラメータは無視するのではなく 400 で拒否します(静かな無視はクライアントのバグを隠します)。

ステップ 6: パフォーマンスとペイロード予算を適用する

  • p95 レイテンシ予算: インタラクティブエンドポイントは 300 ミリ秒、レポート/エクスポートは 1 秒。操作が 1 秒を満たせない場合は、非同期にします: 202 Accepted とポーリング用のステータスリソースを返します。
  • レスポンスペイロード予算: 典型的なレスポンスは 100 KB 未満に保ちます。1 MB を超えるものは、ページネーション、フィールド選択 (?fields=)、または専用のエクスポートフローが必要です。
  • 破壊的変更は URL パス (/v1/) でバージョン管理します。追加的な変更(新しいオプションフィールド)はバージョンアップを必要としません。非推奨のタイムライン自体は api-versioning-strategist に委ねます。

対比例

悪い例:

POST /getUserOrders?userId=42&page=3
→ 200 { "data": [...], "error": null }

パスに動詞、POST に GET のセマンティクス、オフセットページング、200 でエラーフィールドをラップしているため、クライアントは呼び出しが失敗したかどうかを知るためにボディを解析する必要があります。

良い例:

GET /users/42/orders?status=shipped&limit=25&cursor=eyJpZCI6OTh9
→ 200 { "orders": [...], "next_cursor": "eyJpZCI6MTIzfQ", "has_more": true }
→ 404 { "error": "not_found", "message": "User 42 does not exist", "request_id": "req_9f2" }

名詞パス、所有権のネスト、カーソルページング、ステータスコードが結果を伝えます。

成果物

以下の内容を含むエンドポイント仕様を作成します: リソーステーブル(パス、メソッド、メソッドごとのステータスコード)、共有エラー構造、ページネーション契約(カーソル形式、デフォルト、最大値)、フィルタリングホワイトリスト、エンドポイントごとのレイテンシ/ペイロード予算。

やってはいけないこと

  • API でデータベーススキーマをミラーリングしないでください。コンシューマは変更したくなる内部構造に結合されます。
  • エラーボディを持つ失敗に対して 200 を返さないでください。クライアントと監視はどちらもステータスコードをキーにします。
  • 無制限のコレクションにオフセットページネーションを使用しないでください。書き込み下で行を重複・スキップし、線形に劣化します。
  • パスを 2 レベルより深くネストしないでください。深いネストは1つのアクセスパスをエンコードし、他のすべてを禁止します。
  • 不明なクエリパラメータを静かに無視しないでください。フィルタのタイプミスがフィルタリングされていないデータを返すのは、データ漏洩クラスのバグです。

品質基準

  • コンシューマが質問せずに仕様からクライアントを実装できること。
  • すべてのエンドポイントがエラーケースを含むステータスコードを明記していること。
  • すべてのコレクションエンドポイントが1つのページネーション契約を共有し、すべてのエラーが1つの構造を共有していること。
  • 同一の概念がすべてのパスとペイロードで同一の名前を持っていること。
  • 各エンドポイントに明示的なレイテンシ予算があり、1 秒を超えるものは非同期であること。

Individual skills in this repo

This repo contains 19 individual skills — each has its own dedicated page.

SkillMedev/skills

Produce an accurate, properly timed caption track (SRT or WebVTT) from a video's audio - transcribing or aligning to the voiceover script, timing cues to speech, and enforcing line-length and reading-speed rules so captions are readable and in sync. Use when someone says "generate captions", "make subtitles from the audio", "transcribe and caption this", "export an SRT or VTT", "the captions are out of sync", or "the subtitles flash by too fast to read". Do NOT use to burn-in, style, reframe, or position an existing caption track for a platform (9:16, brand styling, safe areas) - that is social-video-formatter; do NOT use to animate text word-by-word as a motion graphic - that is kinetic-typography; do NOT use to write the spoken script in the first place - that is narration-script.

SkillMedev/skills

Turns data and charts into a decision-driving narrative structured as headline finding, trend, implication, and recommended action - with finding-led chart titles, context for every number, annotation guidance, and honest flags on any conclusion the data cannot support. Use when someone says "turn these numbers into a story", "what's the takeaway from this data", "help me present these results to leadership", or has charts but no narrative. Do NOT use for compressing a long document into a one-pager - use executive-summary instead - or for running the analysis that produces the findings - use eda-playbook instead.

SkillMedev/skills

Use when a task needs live or historical money data - "convert USD to EUR", "current/past exchange rate", "FX rate on this date / over this range", or "current price of Bitcoin/Ethereum, market cap, 24h change". Frankfurter (ECB reference rates, no key) is the FX default; CoinGecko's free keyless tier covers crypto. Do NOT use for stock quotes or equities - no keyless stock API survives verification, say so instead of guessing; do NOT use for country economic indicators like GDP or inflation series - use government-open-data instead; if the request is a vague "I need live data", route through public-data-api-picker.

SkillMedev/skills

Builds a driver-based FP&A operating model linking business inputs to P&L, balance sheet, and cash flow outputs. Use when building an annual plan, preparing investor materials, running scenario analysis, or stress-testing the business.

SkillMedev/skills

Use when a task needs live geographic lookups - "geocode this address", "what's at these coordinates" (reverse geocoding), "lat/lon for this city", "which country/state is this ZIP or postal code in", or "country facts: capital, currency, population, flag". Nominatim (OpenStreetMap) is the geocoding default; Zippopotam for postal codes; APICountries for country facts. All keyless. Do NOT use for weather at a location - use weather-climate instead; do NOT use for country-level statistics over time (GDP, population trends) - use government-open-data instead; if the request is a vague "I need live data", route through public-data-api-picker.

SkillMedev/skills

Runs the full Getting Things Done loop - capture, clarify, organize, reflect, engage - building a trusted system of context lists, a projects list with defined next actions, and a weekly review habit. Use when someone says "I'm overwhelmed and things are slipping through the cracks", "set up GTD for me", "help me do a brain dump and organize it", or "my to-do list is a mess". Do NOT use for just running the weekly review ritual itself - use weekly-review instead - or for clearing an email backlog - use inbox-zero.

SkillMedev/skills

Processes any email backlog to zero using the 4Ds - Delete, Delegate, Defer, Do - with a mass-archive strategy for the obvious, a touch-each-email-once discipline, and a keep-it-clear system of batched processing windows, ruthless unsubscribing, filters, and a minimal folder setup. Use when someone says "I have 5,000 unread emails", "help me get to inbox zero", "email is eating my whole day", or treats their inbox as a to-do list. Do NOT use for drafting the reply emails themselves or prioritization rules for an ongoing support queue - use email-triage instead - or for protecting focus time around the email windows - use deep-work-planner instead.

SkillMedev/skills

Write landing-page copy section by section - hero, social proof, features-as-benefits, objections, CTA - leading with one promise and proving it down the page. Use when someone asks "write my landing page", "improve my hero headline", "what should the homepage say", "turn these features into benefits", or is shipping a new page for a launch or campaign. Do NOT use for testing and optimizing an existing page's conversion rate - use landing-page-cro instead; for the one-line claim itself use positioning-statement; for the full message ladder use messaging-hierarchy.

SkillMedev/skills

Improves an existing landing page's conversion rate through evidence-first CRO - audit heatmaps and recordings, write structured hypotheses, prioritize with ICE scoring, and run one-variable tests to statistical significance. Use when someone asks "why isn't my landing page converting", "audit this page before we scale spend", "which A/B test should we run first", or after a CVR drop or ahead of a paid-traffic push. Do NOT use for writing a new landing page from scratch - use landing-page-copy instead. Do NOT use for auditing the ad accounts sending the traffic - use paid-acquisition-audit instead. Do NOT use for reading the results of a finished experiment - use ab-test-analyzer instead.

SkillMedev/skills

Runs structured coaching sessions using values clarification and the GROW model, ending every session with one committed action, a deadline, and an if-then plan for the likely obstacle. Use when someone says "I feel stuck in my life", "help me figure out what I want", "hold me accountable to my goals", or "coach me through this decision". Do NOT use for building a stress toolkit - use stress-management instead - or a journaling practice - use journal-framework; for a standing goal-tracking system, use goals-accountability. Coaching, not therapy: signs of clinical distress route to a licensed professional.

SkillMedev/skills

Adapts English content for a target language and region - swapping idioms, setting the right formality register, replacing cultural references, converting dates, units, and currency - and delivers the localized text with a notes column explaining each adaptation and flagging what needs a native reviewer. Use when someone asks "localize this copy for the Japanese market", "adapt our marketing copy for the Mexican market", "make this translation sound native instead of literal", or a literal translation reads foreign, stiff, or risky. Do NOT use for auditing in-product UI text quality - use ux-writing-audit instead.

SkillMedev/skills

Turns a natural-language video brief into a complete, ready-to-preview Remotion composition - extracts duration, scenes, brand colors, aspect ratio, and real copy; plans the frame budget; and writes data-driven React/TypeScript using useCurrentFrame, interpolate, spring, AbsoluteFill, and Sequence, registered in Root.tsx. Use when someone says "build a 20-second product demo video", "animate a feature walkthrough", "write the Remotion code for this marketing clip", or wants a scene-by-scene composition they can scrub in Studio. Do NOT use for rendering, iterating, or batching the finished MP4 - use remotion-render instead - or for installing and scaffolding the project - use remotion-setup instead.

SkillMedev/skills

Scaffolds a new Remotion video project wired for Claude Code Agent Skills - Node check, create-video scaffold, skills install, folder conventions, Google Fonts, and a smoke-test render. Use whenever someone wants to start making videos with Remotion and Claude, even just "make product videos with Claude.

SkillMedev/skills

Classifies incident severity (SEV1-4) using impact, scope, and urgency signals and decides who to page. Use when an alert fires or a report comes in and a severity call must be made quickly.

SkillMedev/skills

Use the Skill Me catalog from inside any conversation - discover, install, and manage Claude skills through the Skill Me MCP, and load installed skills automatically each session.

SkillMedev/skills

Write one platform-native caption from a topic and brand voice, with a front-loaded hook, native length, and a single earned CTA. Use when the user gives a topic (and optionally brand voice or a described image/video) and asks for an Instagram, LinkedIn, X/Twitter, or TikTok caption. Do NOT use when the user wants a dedicated standalone LinkedIn post - use linkedin-post-writer instead; or a multi-post X thread - use tweet-thread-builder instead; or to adapt one existing piece of content into versions for several channels - use cross-platform-reformatter instead.

SkillMedev/skills

Reframe and export a finished video for social platforms - 9:16 ↔ 16:9 cropping, burned-in captions, a platform-native first frame, loop design, and per-platform specs (aspect, length, safe areas) for TikTok, Reels, Shorts, X, and LinkedIn. Use when someone says "make this vertical", "crop to 9:16", "format for TikTok/Reels/Shorts", "add captions/subtitles", "why is my video cut off on mobile", "resize for Instagram", or "export for social". Do NOT use when the question is about the storyboard or shot order before any video exists (use video-storyboard); the animation craft of how elements move (use motion-design-principles); animated word-by-word caption styling (use kinetic-typography); palette, contrast, or lighting (use motion-color-and-light); directing the product-demo content and screen choreography (use product-demo-director); or scoring, beat-syncing, or audio (use sound-and-music-sync) - this is the craft layer that decides WHAT to format for the feed, then hands a concrete spec to remotion-compo...

SkillMedev/skills

Writes and tunes PySpark jobs - join strategy and broadcast size limits, shuffle-partition sizing, skew diagnosis and salting, UDF avoidance, caching, and output file layout - with concrete size and skew thresholds. Use when someone asks "why is my Spark job slow", "should I broadcast this join", "one task takes forever while the rest finish", "my job OOMs during a join", or is writing a new PySpark ETL job. Do NOT use for Kafka topic, consumer-group, or streaming-pipeline design - use kafka-pipelines instead; do NOT use for single-machine dataframe work that fits in memory - use pandas-expert instead.

SkillMedev/skills

Builds clean, performant, accessible SwiftUI views with correct state ownership, scoped invalidation, and smooth list scrolling, and reviews existing SwiftUI code against a concrete frame-time and re-render budget. Use when someone asks "why does my SwiftUI list stutter", "should this be @State or @Observable", "my whole screen re-renders when one row changes", "how do I animate this transition", or wants a SwiftUI view built or refactored. Do NOT use for cross-platform React Native apps - use react-native-pro instead; do NOT use for Flutter widget trees - use flutter-widget-architect instead; do NOT use for Android Compose UIs - use jetpack-compose-builder instead.

関連スキル