/kivo-wise:acorn-routes-apifrom kivo-wise
Helps add or fix HTTP endpoints in Acorn projects, covering both Laravel-style routes (web.php, api.php, controllers, middleware) and WordPress REST API (register_rest_route, permission_callback, nonces).
Ships in kivo-wise. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Two native mechanisms serve HTTP in an Acorn project. Pick one per endpoint before writing code:
register_rest_route() on rest_api_init, served under /wp-json/<namespace>/…, with WordPress authentication (cookie plus wp_rest nonce, application passwords), argument schemas and permission_callback. Behaviour verified in wp-includes/rest-api.php and wp-includes/rest-api/class-wp-rest-server.php.withRouting(...) on Application::configure(). Laravel middleware, validation, controllers, container injection and Blade responses, at any path outside wp-admin, the login page and /wp-json.Runner placeholders ({{runner.wp}}, {{runner.acorn}}, {{runner.test}}, {{runner.cache}}) come from the session context; on Lando they default to lando wp, lando wp acorn, the project's test tooling and its cache-clear tooling.
Not for: Livewire's own endpoints (acorn-livewire), WordPress admin screens (add_menu_page), content URLs that belong to the template hierarchy.
withRouting(...) arguments (web, api, apiPrefix, wordpress) and any withMiddleware(...) callback.AGENTS.md or guidelines say so.| Need | Use |
|---|---|
Called by the block editor, apiFetch, wp-admin JS, or must appear in /wp-json discovery | register_rest_route |
| Must authenticate with application passwords or the REST cookie + nonce flow | register_rest_route |
| Laravel validation, controllers with DI, middleware stacks, Blade or redirect responses | Acorn route |
| A virtual page with its own URL rendered by Blade | Acorn route (Route::view or a controller) |
| Same codebase already standardised on one style | follow the project |
| Item | sage-theme | acorn-mu-plugin | radicle-app |
|---|---|---|---|
| Where routing is enabled | withRouting(...) in the theme's functions.php | withRouting(...) in the plugin's boot or configurator class | the tracked Acorn boot mu-plugin, web: route file only by default (write-guarded: show the diff) |
| Route files | routes/web.php in the theme (picked up automatically when it exists) | files passed to web: / api: (paths inside the plugin) | routes/web.php at the root |
| API style by default | none; add api: or REST | often an api: file with a custom apiPrefix | register_rest_route() from a service provider listed in composer.json extra.acorn.providers |
| Controllers and middleware | app/Http/Controllers, app/Http/Middleware under App\ | same folders under the plugin namespace | same folders under App\ |
withRouting(web: …, api: …, apiPrefix: 'api', wordpress: …): web routes get the web middleware group; api routes get the api group and the apiPrefix (default api); wordpress: true also routes every unmatched front-end request through the kernel under the wordpress group. List what exists: {{runner.acorn}} route:list.{{runner.acorn}} make:controller Api/LeadController --api, {{runner.acorn}} make:middleware EnsureApiKey.$request->validate([...]); return response()->json() with explicit status codes.auth, can, guest and verified aliases, and its web group has no CSRF middleware. For logged-in browser calls, current_user_can() works (the user resolves from the auth cookie) but nothing stops cross-site requests: verify a WordPress nonce (wp_verify_nonce) or enable ValidateCsrfToken through withMiddleware(). Patterns: references/middleware-auth.md.parse_request and exits, so init has run but template_redirect, wp_head and SEO plugin output do not run. Set title, canonical and sitemap entries yourself for virtual pages.rest_api_init from a service provider's boot() (never at file load), with a namespace and version (vendor/v1).permission_callback; use __return_true only for truly public reads, and say so in a comment.args with type, required, sanitize_callback and validate_callback; return WP_REST_Response or WP_Error with a status.X-WP-Nonce (wp_create_nonce('wp_rest')); without it WordPress treats the request as anonymous.wp-rest-api skill.HandleCors; configure config/cors.php (publish with {{runner.acorn}} vendor:publish --tag=acorn-configs if missing). Rate limiting: the throttle alias exists and needs a working cache store.{{runner.cache}} (or {{runner.acorn}} route:clear and optimize:clear). If the deploy runs route:cache, every route file must be loadable at cache time.{{runner.acorn}} route:list --path=<prefix> shows method, URI, name and middleware as intended. For REST, request /wp-json/<namespace> and read its routes index.curl -si the endpoint: unauthenticated, authenticated, invalid input. Expect 401/403, 200/201, and for bad input 422 (Acorn validation, when the request sends Accept: application/json; otherwise Laravel redirects back) or 400 (rest_invalid_param).{{runner.test}}: controller or middleware unit tests, plus HTTP-level tests if the project has them.| Symptom | Cause | Fix |
|---|---|---|
Target class [auth] does not exist | Acorn's default aliases omit auth, can, guest, verified | Use your own middleware class (capability check), or define the alias in withMiddleware() |
| Route listed but the URL serves WordPress (or 404) | Path under wp-admin, the login page, /wp-json, or ending in .php; Acorn skips those | Move the route; for /wp-json use register_rest_route |
| A WordPress page vanished | An Acorn route matches the same path and wins | Prefix Acorn routes; check route:list against the page tree |
/api/... returns 404 | api: file not passed to withRouting, or a custom apiPrefix | Read the boot call; call the prefixed URL |
| Route missing after editing a route file | Route cache from a deploy or an earlier optimize | {{runner.acorn}} route:clear |
| POST from a logged-in browser works from any site | No CSRF check on Acorn's web group | Verify a WordPress nonce or enable ValidateCsrfToken |
| REST call from the front end acts as logged out | Missing X-WP-Nonce header; rest_cookie_check_errors resets the user to 0 | Send wp_create_nonce('wp_rest') as X-WP-Nonce |
_doing_it_wrong notice for register_rest_route | No permission_callback, or called before rest_api_init | Add the callback; register inside rest_api_init |
Rate limiter [api] is not defined | throttleApi() or throttle:api without RateLimiter::for('api', …) | Define the limiter in a provider, or use throttle:60,1 |
Session-dependent code fails on api routes | The api group has no session middleware | Use web routes for session needs, or token auth |
acorn-data. Long work behind the endpoint: acorn-background (queue it).What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
25 skills in this plugin
/acf-nativeUse when building or reviewing ACF field behaviour or the post save flow - validate before publish, required/maxlength settings, hiding a field (conditional_logic), dynamic choices, running code after save - acf/validate_value, acf/load_field, acf/prepare_field, acf/save_post, acf.getField, wp_insert_post_data, save_post - including projects where ACF may not be installed (Radicle). Maps each need to the native mechanism verified in local source. For ACF Composer scaffolding use acorn-scaffolding; for escaping ACF output use wp-security-escaping./acorn-backgroundUse when work must run outside the request, on a schedule, or be logged in an Acorn project - WP-Cron vs Action Scheduler vs Laravel queues (make:job, ShouldQueue, queue:work, failed_jobs), console commands (make:command, wp acorn <command>), Schedule::command and schedule:run from system cron, Laravel Redis and Cache vs transients, logging channels (Log::, LOG_CHANNEL, stderr, storage/logs). For tables use acorn-data; for object cache tuning use wp-performance./acorn-dataUse when storing or querying data through Acorn's database layer - Eloquent models (app/Models, models over wp_posts, postmeta, users), custom tables, migrations (make:migration, migrate --force on deploy), seeders and factories, the DB facade, table prefix errors ("Table wp_wp_x doesn't exist"), and choosing post meta vs options vs a post type vs a custom table. For queues use acorn-background; for endpoints use acorn-routes-api; for post type registration use acorn-scaffolding.npx claudepluginhub hekivo/kivo-wise --plugin kivo-wiseOther plugins' skills for the same job