Communityコーディング&開発github.com

FSWP API デベロッパー

WordPress REST API および Abilities API を扱うフルスタック WordPress 開発者向けスキルです。ルートの登録、スキーマ定義、引数バリデーション、パーミッションコールバック、コントローラークラス、カスタム投稿タイプやメタの公開、認証、ページネーション、エラー処理、さらには入出力スキーマと安全性アノテーションを備えたアビリティの登録をカバーします。プラグインやテーマでカスタムエンドポイントや機械可読な機能を実装する際に使用します。

FSWP API デベロッパー とは?

このスキルは、フルスタック WordPress 開発者が REST API と Abilities API を使用して安全で効率的なエンドポイントを実装するための包括的なガイドです。REST API ハンドブックを公式リファレンスとし、セキュリティエンジニアリングのルールをすべてのルートに適用します。ルート登録時の必須ルールとして、適切な名前空間とバージョン管理、厳格なパーミッションコールバック、型指定された引数宣言、正確な HTTP ステータスコードによるエラー応答、スキーマの実装、ページネーションのサポート、機密データの非返却などが定められています。また、複数ルートの場合は WP_REST_Controller クラスの拡張を推奨し、認証方式は同一サイト JS での Cookie 認証(ノンス使用)、外部アプリでのアプリケーションパスワードまたは OAuth、公開読み取りのみ認証なし、と明確に区分します。さらに、Abilities API を使用してエージェントが発見・呼び出し可能な機械可読な機能を登録する方法も詳細に説明し、読み取り専用と破壊的アノテーションの厳守、承認手続きを強調しています。このスキールは Cursor、Claude Code、Codex などの AI エージェント開発環境で活用できます。

対応~Claude Code~Codex CLI~Cursor
Part ofMobile
npx skills add https://github.com/syncwin/fswp-developer/tree/main/skills/fswp-api-developer

Installed? Explore more コーディング&開発 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

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

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

ドキュメント

FSWP API デベロッパー は何をしますか?

常時適用: fswp-developer/references/lean-coding.md(少なく書いて、再利用を優先)、fswp-developer/references/coding-standards.md(コーディング標準、ドキュメント、国際化、アクセシビリティ)、および fswp-security-engineer(入力、出力、認可)。

公式リファレンス: REST API ハンドブック(fswp-developer/references/official-docs.md)。fswp-security-engineer のセキュリティルールはすべてのルートに適用されます。

ルートの登録

function vp_register_routes() {
	register_rest_route( 'vendor-prefix/v1', '/items/(?P<id>\d+)', array(
		'methods'             => WP_REST_Server::READABLE,
		'callback'            => 'vp_get_item',
		'permission_callback' => function ( WP_REST_Request $r ) {
			return current_user_can( 'edit_post', (int) $r['id'] );
		},
		'args'                => array(
			'id' => array( 'type' => 'integer', 'required' => true, 'sanitize_callback' => 'absint' ),
		),
	) );
}
add_action( 'rest_api_init', 'vp_register_routes' );

ルール

  • 名前空間とバージョン: vendor-prefix/v1。コアの wp/v2 名前空間には決して登録しないでください。
  • permission_callback は必須です。 ログイン状態だけでなく、ケイパビリティチェックを返してください。完全に公開データの場合のみ __return_true を使用し、その理由をコメントで説明してください。リクエストに ID が含まれる場合は、オブジェクトレベルのアクセス権(edit_post、所有権)をチェックしてください。
  • args を宣言し、type、required、enum、minimum/maximum、validate_callback、sanitize_callback を指定してください。リクエストはバリデーション後も信頼できないため、$request->get_param() の値は型指定されたものとして使用してください。
  • データは rest_ensure_response() で返し、エラーは new WP_Error( 'vp_code', __( 'Message', 'text-domain' ), array( 'status' => 404 ) ) として返してください。正確なステータスコードを使用してください(400 不正、401 未認証、403 禁止、404 未検出、409 競合、413 大きすぎる)。
  • スキーマ: get_item_schema()(または schema コールバック)を実装して、クライアントとインデックスがリソースを記述できるようにし、prepare_item_for_response() でレスポンスを整形してください。
  • コレクション: ハードキャップ付きの page/per_page をサポートし、X-WP-Total と X-WP-TotalPages を設定し、無制限のリストを決して返さないでください。
  • 秘密、パスワードハッシュ、生のオプション、他のユーザーのプライベートデータを決して返さないでください。
  • コントローラー: ルートが 2、3 個を超える場合は、WP_REST_Controller を拡張し(register_routes、get_items、get_item、create_item、メソッドごとのパーミッションチェック)、クラスを一度だけ登録してください。
  • コアオブジェクトの公開: カスタム投稿タイプとタクソノミーは 'show_in_rest' => true(および rest_base)で公開し、メタは register_meta()/register_post_meta() で 'show_in_rest' => true に加えてスキーマと auth_callback を指定して公開してください。
  • キャッシュとパフォーマンス: GET ハンドラーは軽量に保ち、高コストな結果はキャッシュし(fswp-performance-engineer)、ループ内でのクエリは避けてください。

認証

クライアント方法
同一サイト JS(管理画面、ブロック、フロントエンド)Cookie 認証 + X-WP-Nonce ヘッダー(wp_create_nonce( 'wp_rest' )、または自動付与する wp_localize_script / @wordpress/api-fetch)
外部サーバーまたはアプリHTTPS 上のアプリケーションパスワード、または審査済み OAuth プラグイン
公開読み取りデータが公開されている場合のみ、認証不要

ノンスはケイパビリティチェックを代替しません。CORS: 認証済みルートで Access-Control-Allow-Origin: * を開放しないでください。

クライアントサイド

ブロックや管理画面では @wordpress/api-fetch を使用してください。エラーはテキスト解析ではなく、code と message で処理してください。

Abilities API

ツールや AI エージェントが発見・呼び出し可能な、個別の機械可読な機能(名前、入力スキーマ、出力スキーマ、パーミッションチェック、実行コールバック)を登録するためのコア API です。これは比較的新しい機能です。使用前に開発者ドキュメントで最低限必要な WordPress バージョンと正確な関数名を確認してください(「Abilities API」で検索)。PRD でエージェントが呼び出せる関数が必要な場合にのみ使用してください。通常のクライアント-サーバー呼び出しには通常の REST で十分です。

アビリティを登録する際は:

  • 最初にカテゴリを、次にアビリティを、ドキュメント化されたフックで登録してください。
  • 入力と出力に JSON スキーマを指定し、実際のケイパビリティをチェックする permission_callback を指定してください。
  • 安全性アノテーションを正直に設定してください。読み取り専用アビリティは書き込んではならず、破壊的アビリティはフラグを立てる必要があります。書き込みを行うコールバックに読み取り専用アノテーションが付いている場合は欠陥であり、fswp-reviewer はそれを欠陥として扱います。
  • リモートから呼び出せるべきものだけを REST 経由で公開してください。

監査と検証手順: references/abilities.md。

既存のエンドポイントをアビリティにすべき候補を提案する場合は、各ルートのメソッド、現在のパーミッションチェック、副作用、推奨アノテーションをリストアップし、承認されるまでは何も登録しないでください。

Individual skills in this repo

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

fswp-architect

Planning stage of Full-Stack WP Developer. Classifies the work (new plugin, new theme, update to an existing plugin or theme, add-on for another product, or WordPress Core patch), triages existing code with a bundled detection script, asks one round of essential questions, does competitive research, and produces one reviewable PRD or change brief with a single approval gate. Also covers Migration mode and multi-session handoff docs. Invoked by fswp-developer before any code is written; consult directly for PRD, change-brief, or handoff-doc questions.

fswp-block-developer

Domain skill for WordPress block editor work in Full-Stack WP Developer. Covers building custom Gutenberg blocks (block.json, static and dynamic rendering, attributes, supports, InnerBlocks, variations, deprecations, block bindings), block patterns, and the Interactivity API (data-wp directives, stores, server-side state), with the @wordpress/scripts build workflow. Use for any custom block, pattern, or front-end interactivity in a plugin or theme.

fswp-core-contributor

WordPress Core contribution stage of Full-Stack WP Developer. Guides a contributor through finding or filing a Trac ticket, setting up the wordpress-develop checkout and test environment, writing a patch or GitHub pull request that follows Core coding standards, inline documentation, backward compatibility and tests, and preparing the ticket comment; also routes block-editor changes to the Gutenberg repository and security reports to the private process. Invoked by fswp-developer for Core patches; consult directly for Core workflow questions.

fswp-devops-engineer

Domain skill for WordPress development tooling in Full-Stack WP Developer. Covers local environments (wp-env with Docker, WordPress Playground and Blueprints), command-line site operations (plugin and theme management, database export, search-replace, cron, scaffolding), coding standards and static analysis (PHPCS with WordPress standards, PHPStan with WordPress stubs), PHP and JS testing setup, and the @wordpress/scripts toolchain. Use when setting up, running, or automating a WordPress dev or test environment.

fswp-maintainer

Change stage for existing WordPress code in Full-Stack WP Developer. Updates, fixes, refactors, and upgrades existing plugins and themes without breaking them, and builds add-ons for products you do not own (WooCommerce extensions, page-builder elements, extensions of other plugins) using hooks instead of edits to third-party files. Covers reading before changing, parity lists, deprecation, host compatibility, upgrade paths, and patch delivery. Invoked by fswp-developer after an approved change brief; consult directly for safe-change or add-on questions.

fswp-qa-engineer

Verification stage of Full-Stack WP Developer. Runs the mechanical gate for plugins and themes (house-rule scripts, PHP lint, PHPCS with WordPress standards, PHP compatibility, PHPStan with WordPress stubs), the manual checklist, PRD or change-brief scenario tests, and the pre-release check. Reports PASS, FAIL, or NOT RUN and never implies a skipped check passed. Invoked by fswp-developer after a build and again before delivery; consult directly to audit any plugin or theme folder.

fswp-reviewer

Independent review stage of Full-Stack WP Developer. Reviews a finished WordPress plugin, theme, add-on, or Core patch through a security lens (WordPress-specific vulnerabilities, REST and AJAX authorization with an API risk map, AI-generated-code risks), a quality lens (error handling, data and upgrade safety, performance, i18n, accessibility, comment accuracy, test gaps, class and type design, scope), and an optional lean lens for trimming over-engineering, reporting only high-confidence findings in a fixed format. Invoked by fswp-developer after the verify gate, normally through the fswp-code-reviewer agent; consult directly to review or optimize any WordPress code.

fswp-theme-developer

Theme build stage of Full-Stack WP Developer. Builds custom WordPress themes - block themes (theme.json, templates, template parts, patterns, style variations), classic themes (template hierarchy, functions.php, theme supports), hybrids, and child themes - with accessibility, escaping, and directory readiness built in, plus a scaffold script. Invoked by fswp-developer after an approved PRD for a new theme; consult directly for a specific theme pattern. For changes to an existing theme use fswp-maintainer.

syncwin/fswp-plugin-developer

Plugin build stage of Full-Stack WP Developer. House standards and code templates for real WordPress plugins (not shortcode snippets) - folder anatomy, activation/uninstall lifecycle, custom post types and tables, admin UI tiers, front-end output on the Atomic Framework, REST and cron, i18n, distribution, and the Tier 3 React admin stack - plus a scaffold script. Also the base structure for add-ons. Invoked by fswp-developer after an approved PRD; consult directly for a specific plugin build pattern.

関連スキル