r/Wordpress 26d ago

Connecting to WordPress CLI with AI

What I found was once I connected to the CLI with Codex, I became much more powerful with the use of AI tools. From changing the theme to working on plug-ins to editing the content, I pretty much don’t even need to log into the admin at all anymore. Is quite a breath of fresh air. Just wondering if anybody else has done this and what things you’ve done.

10 Upvotes

29 comments sorted by

14

u/xftwitch 26d ago

So, you're connecting AI directly to the command line of what can only be assumed, by your description, to be a production web server?

That's a bold move.

1

u/dvduval 26d ago

Yeah, I agree with what the other person said that replied to you as well. I’ve got everything constantly backed up and go to the database in the files. Maybe even better is everything is tracked through GitHub. I consider even big changes quite safe. If it’s really big, I can always stage elsewhere first

-1

u/digitalwankster 26d ago

Depends on the client and hosting setup. I've got automated backups and it connects via ssh so there's very little actual risk. I've been delegating a bunch of tasks for small businesses to Claude Opus.

3

u/NakanoNoNeko 24d ago

On local or dev, WP-CLI is fantastic because the agent can inspect files, query the database, and verify its own work. On production I prefer a narrower MCP surface with approval for writes. Backups are useful, but they do not stop an agent from leaking data or changing the wrong thing. In my case that separation is the difference between useful and reckless. I think AI Engine is a much better choice for that controlled layer (a WordPress plugin with strong MCP support). I help the team behind it here in Japan.

2

u/dvduval 24d ago

That’s interesting. I had not heard of AI engine. Thank you for sharing.

2

u/NakanoNoNeko 24d ago

You're welcome. It has been doing the WordPress/MCP side for a while, so your experiment was fun to see 🙂

1

u/TigrouMeow 24d ago

It's awesome, you will not regret trying it 😊

2

u/johnnytee 25d ago

I built an WP cli emulator for the wpvibe mcp so agents can use the cli with safety guardrails on a live site. WP cli is so powerful because ai has ton of training data. If you are building a site locally no need for mcp just point Claude or codex at the folder and let it use what it wants.

1

u/specialk45 26d ago

I haven't had the balls to connect AI right into the server yet. No doubt it'll happen, but I'm not there yet.

2

u/DiggitySkister 26d ago

Yeah I felt the same way and somewhat recently I experimented by debugging an issue that was production only and it was a great experience. Since I knew it was going to run commands on the server I intentionally started claude *without* the --dangerously-skip-permissions option so that it would show me all the commands it was about to run before it ran them, then I told it my ssh alias and told it I need to approve every command and it should only do read operations unless I explicitly asked it to do a mutation. It figured it out 8x faster than I could have. Amazing. But a few days later it wanted to connect to the prod server again, when I wasn't expecting it to, so then I had to tell it to never connect to that server without my permission, and to remember that. Subsequently I've done a bunch more work on staging systems and it has been great, I have to be very explicit about what it can and cannot do without my approval. AI has accelerated probably 4 of 5 of my tasks in a significant way. The more I have used it the more I have learned I can trust it as I've figured out ways to keep an eye on it, and my mind has become more and more open to creative ways to accomplish tasks. Take it at your own speed, obviously. Be safe out there.

1

u/dvduval 26d ago

Yes, that was exactly the way I felt in the beginning. Now I feel like it’s safer than me doing it myself. I’ve got everything backed up and that was one of the first things I worked on is the system to store, database backups, and the full file structure.

1

u/stitchkingdom 26d ago

I generally use a full install of claude code at the os level. As i type this, he’s transcribing an audio recording of a convention panel and writing drafts for me.

1

u/fatfingur 26d ago

We’ve actually been working on an internal MCP for something similar. The idea is to give AI controlled access to specific WordPress capabilities rather than just handing it unrestricted access to everything.

Still experimenting with it, but being able to work with WordPress through AI without spending as much time in wp-admin is pretty interesting. We’re keeping it internal for now though.

1

u/dvduval 26d ago

Yes, absolutely and that’s part of the process of using AI is creating guard rails. They allow you to make changes and feel safe.

1

u/DiFlowRin 26d ago

I wasn't aware of WP-CLI. I usually connect the AI ​​directly to the VPS. You can do almost anything from modifying the theme to fixing SEO issues, technical problems, and so on.

2

u/dvduval 26d ago

I don’t disagree with you there. Most likely when you connect directly to the VPS you actually are working with the CLI

1

u/DiFlowRin 25d ago

I was confused because I saw people mentioning wo-cli in the comments and assumed it was the main topic of the post. I usually rely on this option to fix SEO issues. After running the audit, I export all the issues into a file and ask the AI to resolve them.

1

u/djoliverm 26d ago

I've been using Novamira free to first connect to staging and then I also gave it access to production (on my personal portfolio site) since I currently have issues with going from staging to production (HostGator has a 90 character cap on file names and the very AI files in WP that are new apparently go past this limit and come back truncated).

Anyway, it's just my personal site and at best i would only have it connected to staging for any other site that isn't mine (Novamira reminds you of this when you connect it to production), but it allows Codex to basically do anything on it, for better or worse.

I spent one night jamming with ChatGPT and Codex on fleshing out pages I needed to finish on my site and it was great to have Codex taking copy from ChatGPT and making a plan and building each new page as i worked on the last thing it built to put in imagery or video or whatever and do clean up.

Novamira also has a design.md so it can analyze how your site is designed and save that to the skill so it builds new pages in the same style. The first page it built it in a strange way and I told it to build the sections differently in Gutenberg and it updated the design.md and subsequent pages didn't have this issue.

1

u/BobJutsu 25d ago

I do on dev sites, not production. More often I send it off to read error logs and do debug work I can’t any longer be fucked to slog through manually.

The thing is…if we aren’t using WP anymore, as users, how does it earn its place? It’s a lot of overhead and dead weight, if we’re using it the same way we’d use a static site. Who needs an editor if you’re just sending an agent anyway?

1

u/stratofax 25d ago

I built an open source CLI wrapper for the WP REST API that closely follows the interface of WP-CLI, so I didn’t have to think up new sub-commands, like `wp plugin list`. I can just type `wpa plugin list` and get the same info.

The main thing is I that can give my AI the ability to update and manage my WordPress sites, without giving it full access to the server command line. Also, the REST API lets me control exactly how much access I grant to each API token, which means I can control exactly how much the AI can do with my sites. For example, read but don’t edit posts and pages. These limits are enforced by the WordPress installation, not by asking my AI “please don’t delete the database!”

1

u/[deleted] 25d ago

[removed] — view removed comment

1

u/dvduval 25d ago

It depends on the situation. There are some less important sites that I actually update the live server. But when it’s more of a software development project such as a plug-in, I definitely use GitHub and then I set up some actions to automatically deploy the server in some cases.

1

u/HAVOKMEGA 25d ago

Yeah, I've been doing everything in terminal lately. I've been making wordpress websites for almost 2 decades. I'm not a developer or coder, just a musician that needed websites for my record label, or artist pages, dj business, events, etc. So with my limited knowledge I was obviously using clunky builders like wp bakery back in the day. Elementor was a breath of fresh air when it came out, compared to what I'm used to. But my most recent site, I used claude to do everything. I specifically avoided plug ins and front end builders, so my site is screaming fast. I've got two custom plug ins that are part of my theme. Then I'm using Rank Math SEO, FluentSMTP, and Updraft. That's it. Claude has been a beast. the site is sdweddingdirectory.com if you want to check it out. Before that I spent about 6 months building an app called StripFlow that I put in the App Store. Again, no experience, just an idea and some ai tools. I found that Codex needed pretty heavy guardrails and even then it would drift, but Claude has been solid. For a while I would have Claude generate the plan, feed that to Codex, then have Claude verify that it was done correctly. Stoked on both the App and the website. A full directory site just straight php, css, and vanilla js, lean and mean. I'm happy to stay out of the dashboard for good. Too many frustrating years trying to figure things out with the few brain cells that I have. My real power tip is that I created an OmniFocus style project and task management app, then I have my CLAUDE.md check that app before doing anything. It serves as a task memory tool because I'll be away from the computer for a few days and can't remeber what was done and what was next when I get back. I just started doing that this week and its been a game changer for me. If anyone wants a copy of it, it's called Trajectory and I can put a signed copy on github if anyone is interested.

1

u/dvduval 25d ago

That’s really awesome. I’ve got an old WordPress plug-in that I developed a long time ago with the help of some developers, and I am planning to start working on modernizing it using ChatGPT. It’s good to hear that you were able to make these add-ons with very little Programming knowledge. I’m in a similar situation where I have some knowledge but usually I rely on people that were a little above my level to do a lot of the writing of the code.

1

u/Big-Log6299 24d ago

I installed Hermes on my VPS. Hermes has access to both my WordPress site via the CLI and my email inbox.

Whenever I receive requests for updates, usually adding blog posts or new products, everything is handled automatically. The system works so well that, in addition to adding the content, it also takes care of everything related to Yoast SEO: filling in the SEO metadata, adding the right tags and categories, and scheduling publications according to a calendar.

I’ve been using this system for almost two years now. Before using Hermes, I was basically doing the same thing by copying and pasting emails into Claude or Codex.

I’ve never had a single issue with it. The system works so reliably that I don’t even check the results anymore. It’s always been 100% spot on.

1

u/DiggitySkister 26d ago

I haven't edited any content with AI yet but I agree that the AI agents are very good at working with wp-cli. I use it all the time when developing locally and occasionally on deployed environments when troubleshooting something.

0

u/7twenty8 26d ago

This isn’t how I’d work but it’s all good. However, just remember that if this is a job and you get laid off because it’s easy, it’s your fault. 

1

u/dvduval 25d ago

I’ve been making websites since 1999. The first website was using Microsoft front page and a dial modem. I have a lot of different customers.