WordPress WP-CLI Admin
Use this skill when a WordPress task belongs in wp, not /wp-json.
The point of this skill is not to memorize every command. The point is to get to the right command family, attach the right global flags, inspect the target install first, and avoid reckless write operations.
Use This Skill For
- - checking whether a target install is healthy and reachable with INLINECODE2
- plugin and theme management
- users, roles, comments, posts, pages, terms, and media operations
- options, transients, rewrites, cron, and cache-related site work
- core version, update, checksum, and maintenance tasks
- database export, import, and search-replace work
- multisite-aware administration when
--url matters
Do Not Use This Skill For
- - REST-only integrations where the caller has HTTP access but not shell access
- building custom WP-CLI commands or packages
- blind destructive operations without a read-first pass or backup path
Workflow
1. Inspect The Install First
Start with:
CODEBLOCK0
This checks that wp exists, confirms the path looks like a WordPress install, and prints useful status for core, URLs, plugins, and themes.
If you need the live command tree:
CODEBLOCK1
2. Choose The Right Command Family
Read references/command-families.md.
Default mapping:
- - core health or updates: INLINECODE5
- installed code:
plugin, theme, INLINECODE8 - content and taxonomy:
post, page, comment, term, category, INLINECODE14 - accounts and permissions:
user, role, cap, INLINECODE18 - config and runtime:
option, transient, cron, rewrite, INLINECODE23 - database and migration:
db, INLINECODE25 - multisite:
site, network, INLINECODE28
3. Attach The Right Global Flags
Read references/global-flags-and-safety.md.
Common flags:
- - INLINECODE29
- INLINECODE30
- INLINECODE31
- INLINECODE32
- INLINECODE33
- INLINECODE34
- INLINECODE35
- INLINECODE36
- INLINECODE37
- INLINECODE38
4. Prefer Read-First Commands
Examples:
CODEBLOCK2
Only then move to write operations such as plugin update, search-replace, option update, or db import.
5. Treat High-Risk Operations As Change Windows
Before destructive work:
- - export the database
- use
search-replace --dry-run when available - verify the target URL in multisite
- avoid running broad updates without confirming versions and dependencies
Files
- -
scripts/inspect-install.sh: inspect a target WordPress path with WP-CLI - INLINECODE45 : print
wp help or wp help <group> for live command discovery - INLINECODE48 : command family cheat sheet for common WordPress admin tasks
- INLINECODE49 : global arg patterns, remote execution, and destructive-operation rules
WordPress WP-CLI 管理
当WordPress任务属于wp而非/wp-json时,使用此技能。
此技能的目的并非记住每条命令,而是找到正确的命令族、附加正确的全局标志、先检查目标安装环境,并避免鲁莽的写入操作。
适用场景
- - 使用wp检查目标安装是否健康且可访问
- 插件和主题管理
- 用户、角色、评论、文章、页面、分类和媒体操作
- 选项、瞬态、重写、定时任务和缓存相关的站点工作
- 核心版本、更新、校验和维护任务
- 数据库导出、导入和搜索替换工作
- 当--url参数重要时的多站点管理
不适用场景
- - 仅限REST的集成场景(调用方有HTTP访问权限但无Shell访问权限)
- 构建自定义WP-CLI命令或包
- 未经先读取或备份路径的盲目破坏性操作
工作流程
1. 先检查安装环境
从以下命令开始:
bash
scripts/inspect-install.sh --path /srv/www/site
scripts/inspect-install.sh --path /srv/www/site --url https://example.com
这会检查wp是否存在,确认路径看起来像WordPress安装目录,并打印核心、URL、插件和主题的有用状态信息。
如需实时命令树:
bash
scripts/list-commands.sh
scripts/list-commands.sh --group plugin
2. 选择正确的命令族
阅读 references/command-families.md。
默认映射:
- - 核心健康或更新:core
- 已安装代码:plugin、theme、language
- 内容和分类:post、page、comment、term、category、tag
- 账户和权限:user、role、cap、super-admin
- 配置和运行时:option、transient、cron、rewrite、cache
- 数据库和迁移:db、search-replace
- 多站点:site、network、super-admin
3. 附加正确的全局标志
阅读 references/global-flags-and-safety.md。
常用标志:
- - --path=<路径>
- --url=<网址>
- --user=<登录名>
- --ssh=<目标>
- --http=<网址>
- --skip-plugins
- --skip-themes
- --debug
- --quiet
- --format=json
4. 优先使用只读命令
示例:
bash
wp plugin list --format=table
wp theme list --format=table
wp option get home
wp core version
wp cron event list
之后再执行写入操作,如plugin update、search-replace、option update或db import。
5. 将高风险操作视为变更窗口
在执行破坏性操作前:
- - 导出数据库
- 尽可能使用search-replace --dry-run
- 验证多站点中的目标URL
- 在未确认版本和依赖关系前,避免执行大规模更新
文件
- - scripts/inspect-install.sh:使用WP-CLI检查目标WordPress路径
- scripts/list-commands.sh:打印wp help或wp help <组>以发现实时命令
- references/command-families.md:常见WordPress管理任务的命令族速查表
- references/global-flags-and-safety.md:全局参数模式、远程执行和破坏性操作规则