All posts

Revolutionize Your WordPress Writing with AI: Building a Free, Powerful Local Writing Environment

Tired of tedious tagging and SEO chores? This guide shows you how to combine Gemini CLI and WpAiCli into a completely free, fully featured AI writing environment that runs on Windows, Mac, and Linux.

"Can't come up with article ideas," "tagging and SEO tweaks eat all my time," "the WordPress editor is clunky…"

If any of that sounds familiar, this post is for you. Here I'll walk you through connecting Google's powerful AI, Gemini, with my own WordPress management tool, WpAiCli, to build a completely free, fully featured AI writing environment that changes your writing experience at its roots.

This setup runs on Windows, macOS, and Linux, so you're never locked to a particular OS — anyone can get AI assistance in their favorite environment. Leave the tedious work to the AI and focus on "writing," the most creative part of the job.


Three Benefits This Environment Brings You

Why bother building a local writing environment at all? Because it gives you a writing experience that leaves the WordPress admin screen far behind.

1. AI Becomes a Capable Writing Assistant

You can invoke Google's powerful Gemini AI with a single command. Even the free tier allows 1,000 requests per day and handles roughly 20,000 characters (32,000 tokens) at once, so you can hand off tasks like:

  • Brainstorming article ideas and outlines
  • Rewriting or summarizing long articles
  • Auto-generating SEO keywords, excerpts, and tags
  • Checking every article for typos

2. Write Comfortably with Your Favorite Tools

This environment doesn't tie you to any specific OS or editor.

  • Editor freedom: Write in the editor you already know (such as Visual Studio Code). With VS Code you can preview Markdown in real time while you write, or talk to the AI directly from the terminal — completely seamless.
  • Multi-platform: Build the same environment on Windows, macOS, or Linux.

3. Safe, Reliable Version Control with Git

I strongly recommend managing the article cache folder that `WpAiCli` creates with Git. That gives you:

  • Change history: Every edit to every article is recorded, so you can restore any previous state at any time.
  • Safe backups: Push to a remote repository like GitHub and your articles survive even a dead hard drive.

Setting Up Your AI Writing Environment

Let's build it, step by step.

Step 1: Prepare WordPress

First, get your WordPress site ready to talk to WpAiCli.

Generate an Application Password (recommended)

WpAiCli uses the WordPress REST API. For authentication, use the easy and secure Application Password.

  1. Go to "Users" > "Profile" in the WordPress admin.
  2. In the "Application Passwords" section, type a recognizable name such as WpAiCli into "New Application Password Name" and click "Add New Application Password."
  3. The generated password (e.g. xxxx xxxx xxxx xxxx xxxx xxxx) is displayed. It is shown only once, so copy it and store it somewhere safe.
  4. Important: Remove all spaces from the copied password so it becomes one continuous string (e.g. xxxxxxxxxxxxxxxxxxxxxxxx).
WordPress application password generation screen

Enable Markdown Editing (optional)

If you want to write articles in Markdown, install the dedicated plugin.

  1. Export the plugin: Run wpai export-plugin in your terminal to generate mu-plugins.zip.
  2. What the plugin does: The zip contains markdown-meta.php, which lets the AI read and write Markdown, and md-source-sync.php, which keeps Markdown in sync even when you edit in the WordPress admin.
  3. Install on the server:

Connect to your server with an FTP client and create a mu-plugins directory inside wp-content (if it doesn't already exist).

  1. Unzip mu-plugins.zip and upload all its files to wp-content/mu-plugins/.

> About the risk: Adding files to your server may feel unsettling. Please evaluate and proceed at your own responsibility.

Step 2: Install the Required Tools

Next, install what you need on your local machine.

  1. Node.js (version 18 or later): Download and install from the official site.
  2. Gemini CLI: Run the following in your terminal.

npm install -g @google/gemini-cli

You'll need to authenticate with your Google account on first run.

  1. .NET SDK (version 9.0 or later): Download and install from the .NET official site.
  2. WpAiCli: Run the following in your terminal.

dotnet tool install --global WpAiCli

Step 3: Let AI Do the Initial Configuration

Now ask the AI to set things up for you.

  1. First, create a folder on your computer to manage your articles and move into it in the terminal (e.g. cd ~/Documents/MyBlog).
  2. Type gemini to start a conversation with the AI.
  3. Send the following prompt so the AI learns how the tool works:

Use the wpai -h command to learn this program's specification.

  1. Finally, describe your blog and have it generate the connection command. Rewrite the {} placeholders with your own information before sending:

Please add a connection for me.

  • Blog name: {any name that identifies your blog}
  • Endpoint: {your WordPress site URL}/wp-json
  • Username: {your WordPress username}
  • Password: {the space-stripped application password from Step 1}

Run the wpai connections add ... command the AI generates, and the connection is complete.

Step 4: Set Up Version Control with Git

Let's put your writing under Git for safety.

  1. Initialize a Git repository: In your article folder (e.g. MyBlog), wpai creates a cache folder (e.g. wp-cache). That wp-cache directory is what you'll manage with Git.

`bash

cd wp-cache

git init

`

  1. Create a `.gitignore`: To keep junk out of the repository, create a .gitignore file directly inside the wp-cache directory with the following contents:

`

# Exclude cache folders of other blogs

another-blog/

# Exclude files auto-generated by the OS

.DS_Store

# Exclude the database file used by WpAiCli

**/wp-ai-cache.db

# Exclude images; track only metadata (.yaml)

sample-blog/media/*.png

sample-blog/media/*.jpg

sample-blog/media/*.jpeg

sample-blog/media/*.gif

`

Verify It Works

Run wpai posts sync. If Markdown files for your articles appear inside the wp-cache folder, setup is a success!


A Practical AI Workflow: Auto-Generating Excerpts for All Your Drafts

To get comfortable with this environment, let's try a task that's simple but high-impact: make the AI write and set excerpts for every draft you've been putting off.

1. Ask the AI

In the Gemini CLI conversation, send this prompt:

Load every draft article in the posts/draft/ directory.
For each article, summarize the body and generate an excerpt (about 120 characters) that makes it as appealing as possible.
Write the generated excerpt into the `excerpt:` field of each file and save the changes.

2. What the AI Does

Given this instruction, the AI (Gemini) works like this:

  1. Finds every Markdown file in the specified posts/draft/ directory.
  2. Opens each file and reads the frontmatter (metadata) delimited by --- plus the body.
  3. Understands and summarizes the body, then generates an excerpt designed to hook readers and search engines.
  4. Replaces the excerpt: '' placeholder in each original file with the generated excerpt and saves the file.

Meanwhile, all you have to do is wait.

3. Push the Changes Back to WordPress

When the AI has finished updating every file, tell it to run — or run yourself:

wpai posts push --all

This single command applies the changes the AI made to all your draft articles to your WordPress site in one batch.

By delegating tedious, repetitive work to the AI like this, you can concentrate on the creative act of writing.


Accelerate Your Blogging Even Further with AI

Now that your setup is complete, you've gained a powerful partner called AI. Here are a few more ideas to get you going:

  • Automated SEO: Have the AI generate and set SEO keywords and meta descriptions for all your articles.
  • Category & tag optimization: Let the AI review every article, fix misclassifications, and bulk-apply new tags.
  • Automatic internal linking: Have the AI find past articles related to a new post and propose internal links.
  • Series support: Ask the AI to draft roundup or table-of-contents articles from a group of related posts.
  • Multilingual translation: Have the AI translate existing articles into your target languages as the first step toward a multilingual site.
  • Site-wide typo checks: Let the AI scan all published articles for typos and inconsistent wording, and list suggested fixes.

Enjoy your AI-powered writing life!

Author

  • aroooy

Discussion

No comments yet