Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Connect LocalWP CLI — Agent Skill

An agent skill that enables AI coding agents to run WP-CLI, MySQL, Composer, and PHP commands against WordPress sites managed by LocalWP on macOS.

The Problem

LocalWP runs each WordPress site in an isolated environment with its own PHP runtime, MySQL instance, and configuration files. Running bare commands fails because the system environment doesn't know about these private resources, resulting in database connection errors or wrong PHP/MySQL versions.

The Solution

This skill provides a single, zero-config helper script (localwp-cli.sh) that connects any command to the correct LocalWP environment automatically. It supports a dual-mode lookup:

  1. Mode A (Fast): Sources LocalWP's generated ssh-entry script, dynamically stripping the interactive exec $SHELL statement.
  2. Mode B (Fallback): If the site shell script hasn't been created yet, it parses sites.json using python3 to resolve the site metadata, paths, PHP, and MySQL versions, generating the exact environment on the fly.

Requirements

  • macOS only (Apple Silicon and Intel).
  • LocalWP installed.
  • The target WordPress site must be running (started in LocalWP).

Quick Start

# Execute db check from your WordPress directory:
path/to/scripts/localwp-cli.sh wp db check

# Run from a different directory by passing the project path first:
path/to/scripts/localwp-cli.sh /path/to/wordpress/project wp plugin list

Project Structure

connect-localwp-cli/
├── SKILL.md                        # Main agent instructions
├── README.md                       # This file (for humans)
├── LICENSE                         # MIT License
├── .gitignore
├── agents/
│   └── openai.yaml                 # OpenAI Codex agent metadata
└── scripts/
    └── localwp-cli.sh              # Zero-config wrapper script

Tutorial

Step 1 — Copy the skill into your project

Copy the connect-localwp-cli/ directory into your project's agent skills directory (e.g., .agents/skills/ or .claude/skills/).

Step 2 — Run commands

Navigate to your WordPress site directory and run:

.agents/skills/connect-localwp-cli/scripts/localwp-cli.sh wp db check

Or run any other utility like composer or mysql in that environment:

.agents/skills/connect-localwp-cli/scripts/localwp-cli.sh composer info

License

MIT

About

Enables AI agents and developers to run WP-CLI, mysql, and composer in LocalWP site environments on macOS with zero configuration.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages