wp-cli-local
WP-CLI for Local by Flywheel
Section titled “WP-CLI for Local by Flywheel”Run WP-CLI commands against Local sites using the wrapper script bundled with this skill.
Never run bare wp commands. Always use the wrapper:
bash {{SKILL_DIR}}/scripts/wp <wp-cli-command...>Determinism checklist
Section titled “Determinism checklist”Apply DETERMINISM-CHECKLIST.md for this skill run.
Shell compatibility (zsh vs bash)
Section titled “Shell compatibility (zsh vs bash)”The default shell in macOS and VS Code terminals is zsh, which does not word-split unquoted variable expansions. A pattern like WP="bash .../wp" followed by $WP plugin list runs the whole string as a single command name in zsh and fails with no such file or directory.
To make examples work on the first try in both bash and zsh, either:
-
Invoke the wrapper as a full command (recommended for agents):
Terminal window bash "{{SKILL_DIR}}/scripts/wp" --site=my-site plugin list -
Or define a shell function wrapper that forwards arguments correctly in both shells:
Terminal window wp() { bash "{{SKILL_DIR}}/scripts/wp" "$@"; }wp plugin list
Do not use a bare $WP variable to hold the command. If a variable is truly required in zsh, force word-splitting with ${=WP} (e.g. ${=WP} plugin list).
Site Detection
Section titled “Site Detection”The wrapper auto-detects the site by matching the current working directory against site paths in Local’s sites.json. No site name argument is needed when the terminal is inside a Local site directory.
# Define a function wrapper (works in bash and zsh)wp() { bash "{{SKILL_DIR}}/scripts/wp" "$@"; }
# Auto-detect (CWD must be inside a Local site directory)wp plugin listwp core version
# Explicit site overridewp --site=my-site plugin list
# List all sites with running/halted statuswp --listIf auto-detection fails (CWD is not inside any Local site) and no --site= is given, the script prints available sites. Ask the user which site to target, or use --site=<name>.
Completion criterion: A target site is explicitly resolved by auto-detection or --site=<name> before mutating commands are run.
Requirements
Section titled “Requirements”- macOS (Apple Silicon or Intel)
- Local by Flywheel installed with sites in
~/Library/Application Support/Local/sites.json - WP-CLI installed and available in
PATH(e.g. viabrew install wp-cli) - The target site must be running in Local (the site-specific php.ini only exists at runtime)
Common Commands
Section titled “Common Commands”# Define a function wrapper (works in bash and zsh)wp() { bash "{{SKILL_DIR}}/scripts/wp" "$@"; }
# Plugin managementwp plugin listwp plugin activate <slug>wp plugin deactivate <slug>wp plugin status <slug>
# Cache / transientswp cache flushwp transient delete --all
# Optionswp option get <key>wp option update <key> <value>wp option list --search="<pattern>"
# Databasewp db query "SELECT * FROM wp_options WHERE option_name LIKE '<pattern>%' LIMIT 10;"wp db export backup.sqlwp db import backup.sql
# Eval PHPwp eval 'echo get_option("siteurl");'wp eval-file script.php
# Rewrites / cronwp rewrite flushwp cron event listwp cron event run <hook>
# User / site infowp user listwp option get siteurlwp core versionFailure modes / recovery
Section titled “Failure modes / recovery”WP-CLI not found: Verifywp --infoworks in PATH, then retry wrapper command.Site is not running: Start the Local site first, then rerun command.Auto-detection failed: Runwp --list(orbash "{{SKILL_DIR}}/scripts/wp" --list), then rerun with--site=<name>.Wrapper path issue: Use absolute wrapper path from{{SKILL_DIR}}/scripts/wpand retry.
Note: The AI agent should always use the wrapper script, not direnv. The direnv setup is a convenience for the user’s own interactive terminal sessions.
Completion criterion: Commands were executed through the wrapper, target site was explicit, and any failures were reported with the exact failing command.
📦 Source: soderlind/skills · Edit on GitHub