wp-wpcli-and-ops

作者: wordpress

透過WP-CLI進行WordPress操作與自動化,支援安全搜尋取代、資料庫管理及多站點功能。涵蓋網域遷移的搜尋取代、資料庫匯出/匯入、外掛/主題/使用者管理、排程檢查與快取清除。內建防護機制:環境確認、試跑驗證及破壞性操作前的備份流程。支援多站點操作,可針對特定站點(--url)或全網路(--network)執行。啟用...

npx skills add https://github.com/wordpress/agent-skills --skill wp-wpcli-and-ops

WP-CLI and Ops

When to use

Use this skill when the task involves WordPress operational work via WP-CLI, including:

  • wp search-replace (URL changes, domain migrations, protocol switch)
  • DB export/import, resets, and inspections (wp db *)
  • plugin/theme install/activate/update, language packs
  • cron event listing/running
  • cache/rewrite flushing
  • multisite operations (wp site *, --url, --network)
  • building repeatable scripts (wp-cli.yml, shell scripts, CI jobs)

Inputs required

  • Where WP-CLI will run (local dev, staging, production) and whether it’s safe to run.
  • How to target the correct site root:
    • --path=<wordpress-root> and (multisite) --url=<site-url>
  • Whether this is multisite and whether commands should run network-wide.
  • Any constraints (no downtime, no DB writes, maintenance window).

Procedure

0) Guardrails: confirm environment and blast radius

WP-CLI commands can be destructive. Before running anything that writes:

  1. Confirm environment (dev/staging/prod).
  2. Confirm targeting (path/url) so you don’t hit the wrong site.
  3. Make a backup when performing risky operations.

Read:

  • references/safety.md

1) Inspect WP-CLI and site targeting (deterministic)

Run the inspector:

  • node skills/wp-wpcli-and-ops/scripts/wpcli_inspect.mjs --path=<path> [--url=<url>]

If WP-CLI isn’t available, fall back to installing it via the project’s documented tooling (Composer, container, or system package), or ask for the expected execution environment.

2) Choose the right workflow

A) Safe URL/domain migration (search-replace)

Follow a safe sequence:

  1. wp db export (backup)
  2. wp search-replace --dry-run (review impact)
  3. Run the real replace with appropriate flags
  4. Flush caches/rewrite if needed

Read:

  • references/search-replace.md

B) Plugin/theme operations

Use wp plugin * / wp theme * and confirm you’re acting on the intended site (and network) first.

Read:

  • references/packages-and-updates.md

C) Cron and queues

Inspect cron state and run individual events for debugging rather than “run everything blindly”.

Read:

  • references/cron-and-cache.md

D) Multisite operations

Multisite changes can affect many sites. Always decide whether you’re operating:

  • on a single site (--url=), or
  • network-wide (--network / iterating sites)

Read:

  • references/multisite.md

3) Automation patterns (scripts + wp-cli.yml)

For repeatable ops, prefer:

  • wp-cli.yml for defaults (path/url, PHP memory limits)
  • shell scripts that log commands and stop on error
  • CI jobs that run read-only checks by default

Read:

  • references/automation.md

Verification

  • Re-run wpcli_inspect after changes that could affect targeting or config.
  • Confirm intended side effects:
    • correct URLs updated
    • plugins/themes in expected state
    • cron/caches flushed where needed
  • If there’s a health check endpoint or smoke test suite, run it after ops changes.

Failure modes / debugging

  • “Error: This does not seem to be a WordPress installation.”
    • wrong --path, wrong container, or missing wp-config.php
  • Multisite commands affecting the wrong site
    • missing --url or wrong URL
  • Search-replace causes unexpected serialization issues
    • wrong flags or changing serialized data unsafely

See:

  • references/debugging.md

Escalation

  • If you cannot confirm environment safety, do not run write operations.
  • If the repo uses containerized tooling (Docker/wp-env) but you can’t access it, ask for the intended command runner or CI job.

來自 wordpress 的更多技能

blueprint
wordpress
在建立、編輯或檢視 WordPress Playground 的 blueprint JSON 檔案時使用。當提及 blueprints、playground 設定或相關請求時觸發。
official
wordpress-router
wordpress
分類WordPress程式碼庫,並將外掛、主題、區塊及核心檢出導向正確的工作流程。執行自動化專案分類,識別儲存庫類型(外掛、主題、區塊主題、Gutenberg區塊、WP核心)及可用工具。根據使用者意圖與專案類型,輸出分類結果與決策樹路由至特定領域技能。需要儲存庫根目錄存取權限及bash/Node檔案系統操作;部分工作流程需使用WP-CLI。目標為WordPress 6.9+搭配PHP 7.2.24+;...
official
wp-abilities-api
wordpress
WordPress Abilities API 註冊、REST 公開及客戶端使用,適用於 WordPress 6.9+。使用 wp_register_ability() 和 wp_register_ability_category() 在 PHP 中註冊能力與類別,需包含穩定的 ID、標籤及中繼資料。透過設定 meta.show_in_rest: true,將能力經由 /wp-json/wp-abilities/v1/ REST 端點公開給客戶端。使用 @wordpress/abilities 套件在 JavaScript 中存取能力並進行權限檢查。需要 WordPress 6.9+...
official
wp-abilities-audit
wordpress
稽核 WordPress 外掛的 REST 介面,並產生標準化的稽核文件,提出 Abilities API 註冊建議。產生包含 YAML… 的 markdown 文件。
official
wp-abilities-verify
wordpress
Verify a WordPress plugin's Abilities API registrations: enumerate abilities, check that callback behavior matches each annotation's claim (the adversarial…
official
wp-block-development
wordpress
WordPress 區塊開發(Gutenberg):元資料、註冊、渲染與建置流程。涵蓋區塊建立、block.json 設定、靜態與動態渲染,以及使用 register_block_type_from_metadata() 進行伺服器端 PHP 註冊。強制使用 apiVersion: 3 以相容 WordPress 6.9+,包含 iframe 編輯器支援與樣式隔離。處理屬性序列化、棄用/遷移以避免「無效區塊」錯誤,以及內部區塊組合。包含…
official
wp-block-themes
wordpress
WordPress 區塊佈景主題開發:theme.json、範本、樣式及網站編輯器疑難排解。涵蓋 theme.json 編輯(預設值、設定、各區塊樣式)、範本與範本部分、樣式,以及 WordPress 6.9 以上版本的樣式變化。包含用於偵測佈景主題根目錄與區塊佈景主題結構的篩選腳本,以及建立新佈景主題或轉換傳統佈景主題的引導流程。提供樣式階層問題、使用者自訂覆蓋及網站編輯器相關的除錯工作流程。
official
wp-interactivity-api
wordpress
用於建置或除錯 WordPress Interactivity API 功能(data-wp-* 指令、@wordpress/interactivity store/state/actions、區塊 viewScriptModule…)
official