Skip to content

LocalWP Assistant — VS Code Chat Participant

A GitHub Copilot Chat participant (@localwp) that lets you query and manage your Local by Flywheel WordPress sites directly from VS Code.

  • Auto-detects the active site from your open file or workspace root
  • Direct MySQL connection — no WP-CLI overhead for read queries
  • WP-CLI for everything else, using Local’s bundled PHP and MySQL binaries
  • LM-powered answers — free-form questions are answered in human-readable Markdown, not raw JSON
  • Follow-up suggestions after every response
  • Remembers your site — pick once, reuse for the session
  • Cross-platform — macOS, Windows, and Linux

Install from the VS Code Marketplace, or search for LocalWP Assistant in VS Code Extensions.

Terminal window
git clone https://github.com/soderlind/localwp-assistant
cd localwp-assistant
npm install
npm run compile

Press F5 in VS Code to launch the Extension Development Host, or package with vsce package.

Open Copilot Chat and type @localwp followed by your question.

CommandDescription
@localwp /sitesList all Local sites with running status
@localwp /pluginsList active plugins (fast — direct DB)
@localwp /options siteurlFetch options matching a pattern
@localwp /db SELECT ...Run a raw read-only SQL query
@localwp What plugins are active?
@localwp What is the siteurl?
@localwp List all users
@localwp What WordPress version is running?
@localwp Show me all transients matching _site_transient_%
@localwp --site=my-other-site What theme is active?

If multiple sites are running, the extension auto-detects from your open file. To override:

@localwp --site=my-site-name What plugins are active?

If auto-detection can’t determine the site, a QuickPick will appear. Your choice is remembered for the session — subsequent messages reuse the last selected site automatically. Use --site=<name> to switch.

src/
├── extension.ts ← Registers the chat participant
├── localwp/
│ ├── sites.ts ← Reads sites.json + site-statuses.json
│ ├── mysql.ts ← Direct MySQL connection via socket/TCP
│ └── wpcli.ts ← Runs WP-CLI via Local's bundled PHP
└── participant/
├── handler.ts ← Routes requests to MySQL or WP-CLI
└── siteSelector.ts ← Auto-detects or QuickPicks the target site

On macOS/Linux, Local exposes a MySQL Unix socket per site. On Windows, it exposes a TCP port. Connecting directly with mysql2 is much faster than spinning up a PHP process for WP-CLI — especially for simple reads like listing plugins or fetching options.

WP-CLI is still used for write operations and anything that needs WordPress context (hooks, filters, PHP eval).

MIT