Skip to content

Commit 516014a

Browse files
committed
[#214] Agent Skills
1 parent 9e9830f commit 516014a

316 files changed

Lines changed: 21652 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/skills/blueprint/SKILL.md

Lines changed: 417 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
name: wordpress-router
3+
description: "Use when the user asks about WordPress codebases (plugins, themes, block themes, Gutenberg blocks, WP core checkouts) and you need to quickly classify the repo and route to the correct workflow/skill (blocks, theme.json, REST API, WP-CLI, performance, security, testing, release packaging)."
4+
compatibility: "Targets WordPress 6.9+ (PHP 7.2.24+). Filesystem-based agent with bash + node. Some workflows require WP-CLI."
5+
---
6+
7+
# WordPress Router
8+
9+
## When to use
10+
11+
Use this skill at the start of most WordPress tasks to:
12+
13+
- identify what kind of WordPress codebase this is (plugin vs theme vs block theme vs WP core checkout vs full site),
14+
- pick the right workflow and guardrails,
15+
- delegate to the most relevant domain skill(s).
16+
17+
## Inputs required
18+
19+
- Repo root (current working directory).
20+
- The user’s intent (what they want changed) and any constraints (WP version targets, WP.com specifics, release requirements).
21+
22+
## Procedure
23+
24+
1. Run the project triage script:
25+
- `node skills/wp-project-triage/scripts/detect_wp_project.mjs`
26+
2. Read the triage output and classify:
27+
- primary project kind(s),
28+
- tooling available (PHP/Composer, Node, @wordpress/scripts),
29+
- tests present (PHPUnit, Playwright, wp-env),
30+
- any version hints.
31+
3. Route to domain workflows based on user intent + repo kind:
32+
- For the decision tree, read: `skills/wordpress-router/references/decision-tree.md`.
33+
4. Apply guardrails before making changes:
34+
- Confirm any version constraints if unclear.
35+
- Prefer the repo’s existing tooling and conventions for builds/tests.
36+
37+
## Verification
38+
39+
- Re-run the triage script if you create or restructure significant files.
40+
- Run the repo’s lint/test/build commands that the triage output recommends (if available).
41+
42+
## Failure modes / debugging
43+
44+
- If triage reports `kind: unknown`, inspect:
45+
- root `composer.json`, `package.json`, `style.css`, `block.json`, `theme.json`, `wp-content/`.
46+
- If the repo is huge, consider narrowing scanning scope or adding ignore rules to the triage script.
47+
48+
## Escalation
49+
50+
- If routing is ambiguous, ask one question:
51+
- “Is this intended to be a WordPress plugin, a theme (classic/block), or a full site repo?”
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Router decision tree (v1)
2+
3+
This is a lightweight routing guide. It assumes you can run `wp-project-triage` first.
4+
5+
## Step 1: classify repo kind (from triage)
6+
7+
Use `triage.project.kind` and the strongest signals:
8+
9+
- `wp-core` → treat as WordPress core checkout work (core patches, PHPUnit, build tools).
10+
- `wp-site` → treat as a full site repo (wp-content present; changes might be theme + plugins).
11+
- `wp-block-theme` → theme.json/templates/patterns workflows.
12+
- `wp-theme` → classic theme workflows (templates PHP, `functions.php`, `style.css`).
13+
- `wp-block-plugin` → Gutenberg block development in a plugin (block.json, build pipeline).
14+
- `wp-plugin` / `wp-mu-plugin` → plugin workflows (hooks, admin, settings, cron, REST, security).
15+
- `gutenberg` → Gutenberg monorepo workflows (packages, tooling, docs).
16+
17+
If multiple kinds match, prefer the most specific:
18+
`gutenberg` > `wp-core` > `wp-site` > `wp-block-theme` > `wp-block-plugin` > `wp-theme` > `wp-plugin`.
19+
20+
## Step 2: route by user intent (keywords)
21+
22+
Route by intent even if repo kind is broad (like `wp-site`):
23+
24+
- **Interactivity API / data-wp-* directives / @wordpress/interactivity / viewScriptModule**
25+
- Route → `wp-interactivity-api`.
26+
- **Abilities API / wp_register_ability / wp-abilities/v1 / @wordpress/abilities**
27+
- Route → `wp-abilities-api`.
28+
- **Playground / run-blueprint / build-snapshot / @wp-playground/cli / playground.wordpress.net**
29+
- Route → `wp-playground`.
30+
- **Blocks / block.json / registerBlockType / attributes / save serialization**
31+
- Route → `wp-block-development`.
32+
- **theme.json / Global Styles / templates/*.html / patterns/**
33+
- Route → `wp-block-themes`.
34+
- **Plugins / hooks / activation hook / uninstall / Settings API / admin pages**
35+
- Route → `wp-plugin-development`.
36+
- **REST endpoint / register_rest_route / permission_callback**
37+
- Route → `wp-rest-api`.
38+
- **WP-CLI / wp-cli.yml / commands**
39+
- Route → `wp-wpcli-and-ops`.
40+
- **Build tooling / @wordpress/scripts / webpack / Vite / npm scripts**
41+
- Route → `wp-build-tooling` (planned).
42+
- **Testing / PHPUnit / wp-env / Playwright**
43+
- Route → `wp-testing` (planned).
44+
- **PHPStan / static analysis / phpstan.neon / phpstan-baseline.neon**
45+
- Route → `wp-phpstan`.
46+
- **Performance / caching / query profiling / editor slowness**
47+
- Route → `wp-performance`.
48+
- **Security / nonces / capabilities / sanitization/escaping / uploads**
49+
- Route → `wp-security` (planned).
50+
51+
## Step 3: guardrails checklist (always)
52+
53+
- Verify detected tooling before suggesting commands (Composer vs npm/yarn/pnpm).
54+
- Prefer existing lint/test scripts if present.
55+
- If version constraints aren’t detectable, ask for target WP core and PHP versions.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
name: wp-abilities-api
3+
description: "Use when working with the WordPress Abilities API (wp_register_ability, wp_register_ability_category, /wp-json/wp-abilities/v1/*, @wordpress/abilities) including defining abilities, categories, meta, REST exposure, and permissions checks for clients."
4+
compatibility: "Targets WordPress 6.9+ (PHP 7.2.24+). Filesystem-based agent with bash + node. Some workflows require WP-CLI."
5+
---
6+
7+
# WP Abilities API
8+
9+
## When to use
10+
11+
Use this skill when the task involves:
12+
13+
- registering abilities or ability categories in PHP,
14+
- exposing abilities to clients via REST (`wp-abilities/v1`),
15+
- consuming abilities in JS (notably `@wordpress/abilities`),
16+
- diagnosing “ability doesn’t show up” / “client can’t see ability” / “REST returns empty”.
17+
18+
## Inputs required
19+
20+
- Repo root (run `wp-project-triage` first if you haven’t).
21+
- Target WordPress version(s) and whether this is WP core or a plugin/theme.
22+
- Where the change should live (plugin vs theme vs mu-plugin).
23+
24+
## Procedure
25+
26+
### 1) Confirm availability and version constraints
27+
28+
- If this is WP core work, check `signals.isWpCoreCheckout` and `versions.wordpress.core`.
29+
- If the project targets WP < 6.9, you may need the Abilities API plugin/package rather than relying on core.
30+
31+
### 2) Find existing Abilities usage
32+
33+
Search for these in the repo:
34+
35+
- `wp_register_ability(`
36+
- `wp_register_ability_category(`
37+
- `wp_abilities_api_init`
38+
- `wp_abilities_api_categories_init`
39+
- `wp-abilities/v1`
40+
- `@wordpress/abilities`
41+
42+
If none exist, decide whether you’re introducing Abilities API fresh (new registrations + client consumption) or only consuming.
43+
44+
### 3) Register categories (optional)
45+
46+
If you need a logical grouping, register an ability category early (see `references/php-registration.md`).
47+
48+
### 4) Register abilities (PHP)
49+
50+
Implement the ability in PHP registration with:
51+
52+
- stable `id` (namespaced),
53+
- `label`/`description`,
54+
- `category`,
55+
- `meta`:
56+
- add `readonly: true` when the ability is informational,
57+
- set `show_in_rest: true` for abilities you want visible to clients.
58+
59+
Use the documented init hooks for Abilities API registration so they load at the right time (see `references/php-registration.md`).
60+
61+
### 5) Confirm REST exposure
62+
63+
- Verify the REST endpoints exist and return expected results (see `references/rest-api.md`).
64+
- If the client still can’t see the ability, confirm `meta.show_in_rest` is enabled and you’re querying the right endpoint.
65+
66+
### 6) Consume from JS (if needed)
67+
68+
- Prefer `@wordpress/abilities` APIs for client-side access and checks.
69+
- Ensure build tooling includes the dependency and the project’s build pipeline bundles it.
70+
71+
## Verification
72+
73+
- `wp-project-triage` indicates `signals.usesAbilitiesApi: true` after your change (if applicable).
74+
- REST check (in a WP environment): endpoints under `wp-abilities/v1` return your ability and category when expected.
75+
- If the repo has tests, add/update coverage near:
76+
- PHP: ability registration and meta exposure
77+
- JS: ability consumption and UI gating
78+
79+
## Failure modes / debugging
80+
81+
- Ability never appears:
82+
- registration code not running (wrong hook / file not loaded),
83+
- missing `meta.show_in_rest`,
84+
- incorrect category/ID mismatch.
85+
- REST shows ability but JS doesn’t:
86+
- wrong REST base/namespace,
87+
- JS dependency not bundled,
88+
- caching (object/page caches) masking changes.
89+
90+
## Escalation
91+
92+
- If you’re uncertain about version support, confirm target WP core versions and whether Abilities API is expected from core or as a plugin.
93+
- For canonical details, consult:
94+
- `references/rest-api.md`
95+
- `references/php-registration.md`
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# PHP registration quick guide
2+
3+
Key concepts and entrypoints for the WordPress Abilities API:
4+
5+
- Register ability categories and abilities in PHP.
6+
- Use the Abilities API init hooks to ensure registration occurs at the right lifecycle time.
7+
8+
## Hook order (critical)
9+
10+
**Categories must be registered before abilities.** Use the correct hooks:
11+
12+
1. `wp_abilities_api_categories_init` — Register categories here first.
13+
2. `wp_abilities_api_init` — Register abilities here (after categories exist).
14+
15+
**Warning:** Registering abilities outside `wp_abilities_api_init` triggers `_doing_it_wrong()` and the registration will fail.
16+
17+
```php
18+
// 1. Register category first
19+
add_action( 'wp_abilities_api_categories_init', function() {
20+
wp_register_ability_category( 'my-plugin', [
21+
'label' => __( 'My Plugin', 'my-plugin' ),
22+
] );
23+
} );
24+
25+
// 2. Then register abilities
26+
add_action( 'wp_abilities_api_init', function() {
27+
wp_register_ability( 'my-plugin/get-info', [
28+
'label' => __( 'Get Site Info', 'my-plugin' ),
29+
'description' => __( 'Returns basic site information.', 'my-plugin' ),
30+
'category' => 'my-plugin',
31+
'execute_callback' => 'my_plugin_get_info_callback',
32+
'meta' => [ 'show_in_rest' => true ],
33+
] );
34+
} );
35+
```
36+
37+
## Common primitives
38+
39+
- `wp_register_ability_category( $category_id, $args )`
40+
- `wp_register_ability( $ability_id, $args )`
41+
42+
## Key arguments for `wp_register_ability()`
43+
44+
| Argument | Description |
45+
|----------|-------------|
46+
| `label` | Human-readable name for UI (e.g., command palette) |
47+
| `description` | What the ability does |
48+
| `category` | Category ID (must be registered first) |
49+
| `execute_callback` | Function that executes the ability |
50+
| `input_schema` | JSON Schema for expected input (enables validation) |
51+
| `output_schema` | JSON Schema for returned output |
52+
| `permission_callback` | Optional function to check if current user can execute |
53+
| `meta.show_in_rest` | Set `true` to expose via REST API |
54+
| `meta.readonly` | Set `true` if ability is informational only |
55+
56+
## Recommended patterns
57+
58+
- Namespace IDs (e.g. `my-plugin:feature.edit`).
59+
- Treat IDs as stable API; changing IDs is a breaking change.
60+
- Use `input_schema` and `output_schema` for validation and to help AI agents understand usage.
61+
- Always include a `permission_callback` for abilities that modify data.
62+
63+
## References
64+
65+
- Abilities API handbook: https://developer.wordpress.org/apis/abilities-api/
66+
- Dev note: https://make.wordpress.org/core/2025/11/10/abilities-api-in-wordpress-6-9/
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# REST API quick guide (`wp-abilities/v1`)
2+
3+
The Abilities API exposes endpoints under the REST namespace:
4+
5+
- `wp-abilities/v1/abilities`
6+
- `wp-abilities/v1/categories`
7+
8+
Debug checklist:
9+
10+
- Confirm the route exists under `wp-json/wp-abilities/v1/...`.
11+
- Verify the ability/category shows in REST responses.
12+
- If missing, confirm `meta.show_in_rest` is enabled for that ability.
13+

0 commit comments

Comments
 (0)