wp-execute-php
Skill1 starsChanged 6 months agoMITView on GitHub
Run a PHP payload inside the live WordPress request lifecycle via the companion endpoint. Phase = Power. Requires companion + ROLEPOD_WPLAB_PROFILE=power + non-production target + AST-clean payload + confirm:true.
In this repository14 other files it gives its agents.
- wp-changesSkill
- wp-connectSkill
- wp-contentSkill
- wp-diagnoseSkill
- wp-edit-designSkill
- wp-edit-pluginSkill
- wp-edit-themeSkill
- wp-fullSkill
- wp-health-checkSkill
- wp-introspectSkill
- wp-migrateSkill
- wp-pair-setupSkill
- wp-recoverySkill
- wp-scaffoldSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 3 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 16
NEVER call rolepod_wp_execute_php if the same outcome is reachable through wp-content (REST), wp-edit-plugin (adapter REST), wp-introspect …
- Very specific: line 17
NEVER pass confirm: true automatically on the user's behalf — the flag exists so the user accepts personal responsibility for the payload.
- Very specific: line 18
ALWAYS read the AST blocklist in references/ast-rules.md before composing a payload.
- Distinctive: line 55
When a task genuinely needs the power surface and the site is guarded, hand the user a decision, not an instruction.
- Distinctive: line 70
If the user declines: stop.
- Very specific: line 89
Check the payload against references/ast-rules.md.
- Very specific: line 120
No durable artifact in the MCP.
- Distinctive: line 124
Read EVERY time before composing a new payload — the good/bad contrast catches the most common attack-surface mistakes:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
WP Execute PHP
Last-resort power tool. Bypasses every safer layer (REST, wp-cli, introspect) to run arbitrary PHP in the WP request lifecycle. Five-layer safety chain. Audit-logged. Production-blocked unconditionally.
Iron Rule
<EXTREMELY-IMPORTANT>
1. NEVER call `rolepod_wp_execute_php` if the same outcome is reachable through `wp-content` (REST), `wp-edit-plugin` (adapter REST), `wp-introspect` (read), or `wp-execute-php`'s sibling `wp_cli_run`. Power tool = last resort.
2. NEVER pass `confirm: true` automatically on the user's behalf — the flag exists so the user accepts personal responsibility for the payload; auto-confirming defeats it.
3. ALWAYS read the AST blocklist in `references/ast-rules.md` before composing a payload. `eval`, `system`, `shell_exec`, `proc_open`, `popen`, dynamic include, out-of-scope file ops, pcntl_*, dl, backtick — all are forbidden on both sides and the screen catches them up front.
4. NEVER ask the user to flip the AI Full Control toggle as a bare instruction. Run the request protocol below: say WHAT needs it and WHY, deliver the warning (the AI gets full control of a live site), and offer `rolepod_wp_backup_create` FIRST — it works in guarded mode, so the backup exists before the power surface opens.
</EXTREMELY-IMPORTANT>When to use
- "Fire
do_action('save_post', 42)and observe what happens" — runtime hook trigger. - "Instantiate WC_Order(123) and dump its meta" — internal API call.
- "Set a transient programmatically for testing" — read/write the cache layer.
- "Run
wp_schedule_eventto register a cron" — internal scheduler call. - Any case where REST/wp-cli/adapter does not expose the surface and a small PHP snippet is the cleanest fix.
Skip when:
- The work is post/option/user →
wp-content. - The work is a plugin's config →
wp-edit-plugin. - The work is "just look at state" →
wp-introspect. - The work is a wp-cli command → call
wp_cli_run(companion's wp-cli endpoint via the same bridge, no need for execute-php).
Boundary
Owns:
rolepod_wp_execute_phpwith the full safety chain.- AST screen interpretation (Node side, mirrored on companion side).
- Production guard surfacing.
- Audit-id reporting to user.
Does not own:
- Any non-power workflow — those go to their own skill.
- wp-cli — even though wp-cli routes through companion now, that's
wp_cli_runnotexecute_php.
Return / hand off:
- AST screen rejected the payload → go back to the user with the specific forbidden token; do not "work around" by encoding/obfuscation.
- Power profile not set → hand off to user: "set
ROLEPOD_WPLAB_PROFILE=powerenv and reconnect." - Site in guarded mode (
FULL_ACCESS_REQUIRED/execute_phpcapability absent) → STOP and run the "Requesting Full Access" protocol below. The toggle is the owner's decision — never pressure, never proceed without it.
Requesting Full Access
When a task genuinely needs the power surface and the site is guarded, hand the user a decision, not an instruction. One message, four parts:
- What + why — the exact task and why no guarded tool covers it (Iron Rule 1 already forced this answer).
- The warning — plain words: "เปิดแล้ว AI จะควบคุมเว็บนี้ได้เต็มรูปแบบ — รัน PHP, แก้ไฟล์, สั่ง wp-cli แบบ destructive ได้ ถ้าเว็บนี้เป็นเว็บจริง ความผิดพลาดอาจทำให้เว็บล่ม" (match the user's language).
- Backup first — offer
rolepod_wp_backup_createBEFORE they flip the toggle; it works in guarded mode. Wait for it to finish (action=status) and confirm the backup id before proceeding. - The switch + the way back — where: wp-admin → Rolepod WP → Settings → AI Full Control → ON. And say up front that you will remind them to turn it back OFF when the task is done — then actually do that.
If the user declines: stop. Suggest the nearest guarded-mode alternative or manual steps they can run themselves. Declining is a valid outcome, not an obstacle to argue with.
Inputs to gather
- target_id.
payload(the PHP snippet).confirm: true(mandatory).timeout_ms(default 5000).
Workflow
1. Justify the power tool
State why no safer skill solves this. If you cannot answer in one sentence → STOP, use the safer skill.
2. AST pre-screen mentally
Check the payload against references/ast-rules.md. If any forbidden token appears → STOP, rewrite without it.
3. Confirm preconditions
ROLEPOD_WPLAB_PROFILE=powerenv present.- Site is in Full Access mode (companion advertises
execute_php). Guarded → run the "Requesting Full Access" protocol first. - User explicitly OK'd
confirm: true.
4. Run
rolepod_wp_execute_php { target_id, payload, confirm: true, timeout_ms? }. The call returns return_value, stdout, php_warnings, duration_ms, audit_id.
5. Surface
State the return_value, php_warnings count, duration, audit_id. The audit_id is the user's reference if anything went wrong server-side.
If a matching Rolepod agent is available
rolepod:debug-issuefor the broader debug context this fits into.rolepod:rolepod-builderfor PHP-level investigation.
If no matching agent is available
- Justify in one sentence why power tool.
- Pre-screen payload against AST rules.
- Confirm prereqs.
- Run with
confirm: true. - Surface result + audit_id.
Output
No durable artifact in the MCP. The companion writes an audit entry under wp-content/uploads/rolepod-wp-audit/<audit_id>.log (mode 0600) AND a row in wp_options.rolepod_wp_audit_log. The user owns the audit trail.
Examples
Read EVERY time before composing a new payload — the good/bad contrast catches the most common attack-surface mistakes:
examples/php-examples.md— good vs bad payloads for a transient set + for a runtime hook dispatch.
References
Load when composing the FIRST payload of a session, or when the AST screen rejects something:
references/ast-rules.md— the full forbidden-token list, the reason for each, the alternative if one exists.
Hard stops
- AST screen rejects (Node OR PHP side) → STOP, surface
AST_REJECTEDwith the forbidden token; do not retry with obfuscation. POWER_PROFILE_REQUIRED→ STOP, user must set env + reconnect.PRODUCTION_BLOCKED→ STOP, no override.confirm: truemissing → STOP, ask user.- Payload size > 100 KB → STOP, refactor into smaller calls or use
wp_cli_runfor file-level ops.
Full Rolepod enhancement
Full Rolepod adds session-token-aware persistent eval (php_session endpoint) for multi-call scripts that share variables. Standalone, each execute-php call is independent.
Next phase
- Result is data → use it as input to the next skill (e.g. found IDs →
wp-contentto update). - Result is a side effect (transient set, hook fired) →
wp-health-checkto confirm the system stayed healthy. - Result is failure →
wp-diagnosefor the broader picture.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

