Przejdź do treści
Biblioteka skilli
Programowanie · Przegląd i audyt

wp-rest-api-development

/wp-rest-api-development

Przegląda własne trasy REST API WordPressa: permission_callback, schemat odpowiedzi, uwierzytelnianie, wersjonowanie i kontrolery.

Licencja
MIT
Ostatnia zmiana repozytorium
07.06.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
3
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 07.06.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Przegląda własne trasy REST API WordPressa: permission_callback, schemat odpowiedzi, uwierzytelnianie, wersjonowanie i kontrolery.

Wyzwalacze z opisu

REST API reviewregister_rest_routepermission_callbackWP_REST_RequestREST endpointcustom APIAPI schemaREST controller
Oryginalny opis (EN)

WordPress REST API review and development guidance. Use when reviewing custom REST routes, permission_callback logic, schema design, WP_REST_Request handling, response structure, versioning, controller classes, nonce or auth usage, or when user mentions "REST API review", "register_rest_route", "permission_callback", "WP_REST_Request", "REST endpoint", "custom API", "API schema", "REST controller", "headless WordPress", or "API auth". Detects route registration issues, authorization mistakes, schema drift, input validation gaps, and response design problems in WordPress REST API code.

Jak działa

  1. Overview
  2. When to Use
  3. Code Review Workflow
  4. File-Type Specific Checks
  5. Search Patterns for Quick Detection (API-21)
  6. Reference Files
  7. Output Format (API-23)
Sekcje z nagłówków SKILL.md, w oryginale · 145 linii, 652 słów
Podgląd SKILL.md
---
name: wp-rest-api-development
description: WordPress REST API review and development guidance. Use when reviewing custom REST routes, permission_callback logic, schema design, WP_REST_Request handling, response structure, versioning, controller classes, nonce or auth usage, or when user mentions "REST API review", "register_rest_route", "permission_callback", "WP_REST_Request", "REST endpoint", "custom API", "API schema", "REST controller", "headless WordPress", or "API auth". Detects route registration issues, authorization mistakes, schema drift, input validation gaps, and response design problems in WordPress REST API code.
---

# WordPress REST API Development Skill

## Overview

Systematic REST API review for WordPress plugins, themes, and custom code. **Core principle:** Every route needs a clear contract, explicit authorization, validated input, and predictable output. Review covers route registration, controller patterns, request parsing, schema and argument validation, response formatting, caching implications, and compatibility concerns. Report findings with line numbers, severity labels, and BAD/GOOD code pairs where helpful.

## When to Use

**Use when:**
- Reviewing `register_rest_route()` usage
- Auditing custom API endpoints or controller classes
- Checking `permission_callback` logic
- Validating `WP_REST_Request` input handling
- Reviewing response shape, status codes, and schema
- Designing versioned endpoints for headless or block-driven apps

**Don't use for:**
- General plugin architecture without REST focus (use wp-plugin-development)
- Security-only review across the whole plugin (use wp-security-review)
- Full WooCommerce endpoint review (use wp-woocommerce-dev when WC-specific)
- GraphQL-specific guidance

## Code Review Workflow

1. **Identify REST context**
   - Route callbacks in plugin bootstrap
   - Controller classes extending `WP_REST_Controller`
   - Headless frontend integration
   - Internal admin-only API usage

2. **Check route registration first**
   - Namespace and version format
   - HTTP methods match operation intent
   - `permission_callback` present and specific
   - `args` definitions for request validation

3. **Review request handling**
   - Use `$request->get_param()` or typed getters instead of raw globals
   - Validate and sanitize all user input
   - Reject malformed input with meaningful `WP_Error`

4. **Review response design**
   - Consistent response shape
   - Proper status codes
   - `rest_ensure_response()` where helpful
   - Avoid leaking internal details

5. **Check for CRITICAL/WARNING/INFO patterns**
   - **CRITICAL:** Missing `permission_callback`, write routes with `__return_true`, raw globals, unsanitized DB queries
   - **WARNING:** Inconsistent schema, weak validation, mixed response shapes, missing pagination info
   - **INFO:** Could use controller class, schema reuse, versioning cleanup

6. **Report with cross-references**
   - If auth or nonce issues dominate, suggest `/wp-sec-review`
   - If route logic is plugin-architecture-heavy, suggest `/wp-plugin-review`

## File-Type Specific Checks

### Route Registration (`register_rest_route`)

- CRITICAL: Missing `permission_callback`
- CRITICAL: `'permission_callback' => '__return_true'` on write endpoints
- WARNING: Namespace without version segment
- WARNING: Route registered outside `rest_api_init`
- INFO: Repeated inline callbacks that should use controller methods

### Permission Callbacks

- CRITICAL: Capability checks missing on private data
- WARNING: Callback always returns true for admin-like actions
- WARNING: No ownership check for user-specific resources
- INFO: Could centralize repeated permission logic

### Request Args and Validation

- CRITICAL: Raw `$_GET`/`$_POST` used inside endpoint callback
- WARNING: Missing `sanitize_callback` or `validate_callback`
- WARNING: Missing enum/format constraints for known values
- INFO: Could define reusable item schema

### Response Handling

- WARNING: Mixed success response shape across routes
- WARNING: `wp_send_json()` inside REST callbacks instead of returning response data
- INFO: Could use `WP_REST_Response` for headers/status control

## Search Patterns for Quick Detection (API-21)

Use these `rg` commands for quick REST API scanning. Organized by severity.

### CRITICAL Patterns

```bash
# register_rest_route candidates
rg -n "register_rest_route\s*\(" . -g '*.php'

# permission_callback returning true
rg -n "permission_callback.*__return_true" . -g '*.php'

# Raw superglobals inside REST callbacks
rg -n "\$_GET|\$_POST|\$_REQUEST" . -g '*.php'
```

### WARNING Patterns

```bash
# WP_REST_Request usage without obvious validation helpers
rg -n "WP_REST_Request|get_param\s*\(" . -g '*.php'

# REST callbacks using wp_send_json
rg -n "wp_send_json|wp_send_json_success|wp_send_json_error" . -g '*.php'

# Route namespaces to inspect for versioning
rg -n "register_rest_route\s*\(\s*['\"][^'\"]+" . -g '*.php'
```

### INFO Patterns

```bash
# WP_REST_Controller classes
rg -n "extends\s+WP_REST_Controller" . -g '*.php'

# rest_ensure_response usage
rg -n "rest_ensure_response|new\s+WP_REST_Response" . -g '*.php'
```

## Reference Files

- `references/route-patterns.md` - Route registration, controller structure, and namespace design
- `references/schema-and-auth-guide.md` - Args schema, permission callbacks, input validation, and response design

## Output Format (API-23)

For each finding include:

1. Severity: `CRITICAL`, `WARNING`, or `INFO`
2. File and line number
3. Issue summary
4. Why it matters for WordPress REST API behavior
5. Recommended fix

If no issues are found, say so clearly and mention any residual gaps such as missing tests, inconsistent schema documentation, or limited versioning strategy.

Pliki w paczce (3)
  • SKILL.md 6 KB
  • references/route-patterns.md 1 KB
  • references/schema-and-auth-guide.md 1 KB

Wersje

W bazie nie ma innych skilli o nazwie wp-rest-api-development.

Migawka bazy z 28.10.2026 · wersja paczki 561ad586bc83 (skrót SHA-256 całej paczki)

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 90wp-rest-api
    Pomaga rozbudowywać i debugować trasy REST API WordPressa, w tym kontrolery, schematy, uwierzytelnianie oraz pola meta.
  • 90wp-rest-api
    Pomaga tworzyć i naprawiać endpointy REST API WordPressa: trasy, walidację argumentów, uprawnienia i ekspozycję typów wpisów.
  • 100wp-rest-api
    Tworzy i audytuje własne endpointy REST API wtyczek WordPress: permission_callback, autoryzacja na poziomie obiektu, walidacja argumentów, paginacja i kontrakty odpowiedzi.
  • 100rest-api-design
    Projektuje endpointy REST API z walidacją Zod i dokumentacją OpenAPI: trasy, schematy żądań i odpowiedzi, obsługa błędów i aktualizacja dokumentacji.
  • 100rest-api-design
    Projektuje endpointy REST API z walidacją Zod i dokumentacją OpenAPI: trasy, schematy żądań i odpowiedzi, obsługa błędów i aktualizacja dokumentacji.
  • 100design-api
    Projektuje API REST i GraphQL: nazewnictwo, wersjonowanie, kształt błędów i uwierzytelnianie.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.