Agent Skill · WordPress

wp-rest-api

Use when building, extending, or debugging WordPress REST API endpoints/routes: register_rest_route, WP_REST_Controller/controller classes, schema/argument validation, permission_callback/authentication, response shaping, register_rest_field/register_meta, or exposing CPTs/taxonomies via show_in_rest.

Provider: WordPress Path in repo: skills/wp-rest-api/SKILL.md

Skill body

WP REST API

When to use

Use this skill when you need to:

Inputs required

Procedure

0) Triage and locate REST usage

  1. Run triage:
    • node skills/wp-project-triage/scripts/detect_wp_project.mjs
  2. Search for existing REST usage:
    • register_rest_route
    • WP_REST_Controller
    • rest_api_init
    • show_in_rest, rest_base, rest_controller_class

If this is a full site repo, pick the specific plugin/theme before changing code.

1) Choose the right approach

2) Register routes safely (namespaces, methods, permissions)

Read references/routes-and-endpoints.md.

3) Validate/sanitize request args

Read references/schema.md.

Read references/responses-and-fields.md.

5) Authentication and authorization

Read references/authentication.md.

6) Client-facing behavior (discovery, pagination, embeds)

Read references/discovery-and-params.md.

Verification

Failure modes / debugging

Escalation

If version support or behavior is unclear, consult the REST API Handbook and core docs before inventing patterns.

Skill frontmatter

compatibility: Targets WordPress 6.9+ (PHP 7.2.24+). Filesystem-based agent with bash + node. Some workflows require WP-CLI.