You need a small WordPress plugin: a custom post type for client testimonials, a settings page, and a shortcode to display them. Writing it by hand means hours of boilerplate, hook lookups, and security checks. Asking an AI coding assistant to "just build it" often gives you code that runs but skips nonces, escaping, or sensible file structure.
This guide goes past the quick answer. It walks through the build in order, from project setup to prompting Claude Code in small, reviewable steps, then covers integration tips and best practices for keeping the plugin secure, maintainable, and ready to run on a real site.
What users report
Users in WordPress and Claude communities generally describe Claude Code as capable of building plugins, with the best results coming from small, structured steps. The evidence here is limited to a handful of Reddit threads, so treat it as anecdotal.
What works
- One user in Returning to WP after 5 years. Tried says Claude is quite good at plugin and theme code when built in small-ish increments.
- A user in Throwing a Website Claude Made into Wordpress? reports that Claude Code created a custom database editing plugin for a convoluted paid inventory plugin, and that it works.
- Another thread, Can I use Claude to debug and, notes that the CLI tool can work directly with WordPress files on a server over SSH once pointed at a theme or plugin directory.
Tips users share
- Work in small increments rather than asking for a whole plugin at once.
- For custom blocks, one user suggests generating the block's JSON and PHP wrapper first, then dropping HTML into the render callback.
- Another user recommends starting from a clean framework such as WP-Rig, because Claude picks up its conventions quickly.
- A user suggests installing helper skills through skills.sh.
Gotchas
The threads lean toward success stories, and the main caution is implicit: large, unstructured requests are less reliable than incremental ones. Build tooling also trips people up, as a Stack Overflow question about running npm init and build inside a plugin shows. Review generated code and test on a staging site before activating anything on a live one.
What is Claude Code and How Does It Work?
Claude Code is Anthropic's AI coding assistant that runs in your terminal and works directly with the files in your project. You describe a task in plain language, and it reads your codebase, proposes changes, edits files and can run commands on your behalf.
Unlike a chat window where you paste snippets back and forth, it operates inside your working directory. That means it can see how your files relate to each other before it writes anything.
How it fits with WordPress
Claude Code has no special WordPress connection built in. WordPress plugins are ordinary PHP, JavaScript and CSS files, so any tool that can read and edit code can work on them. You point Claude Code at your plugin folder, typically inside wp-content/plugins, and it works with the files there.
That makes it useful for the usual plugin tasks:
- Scaffolding the main plugin file, header comment and folder structure
- Registering hooks, actions and filters
- Creating custom post types, settings pages and shortcodes
- Adding input sanitization, escaping and nonce checks
- Refactoring code to follow WordPress coding standards
Extending the workflow
Claude Code can be extended with additional tooling, and claude code plugins are one way developers add reusable capabilities to their setup. This is separate from the WordPress plugin you are building, so keep the two ideas apart.
You stay responsible for review. Generated code should be tested on a local or staging site, and security-sensitive parts such as database queries and user input handling deserve a careful read before anything ships.
Why Build a WordPress Plugin with Claude Code?
Claude Code speeds up the repetitive parts of plugin development by working directly in your codebase and terminal, so you spend more time on logic and less on boilerplate. You still review and own the result, but the first draft arrives faster.
WordPress plugins involve a lot of predictable structure: a main plugin file with a header, hooks and filters, settings pages, nonces, capability checks, sanitization and escaping. An AI coding agent can generate that scaffolding from a plain-language description and then adjust it as requirements change.
Advantages
- Faster scaffolding: Plugin headers, activation hooks, custom post types and admin pages can be drafted from a short brief.
- Codebase awareness: Because it works with your project files, it can edit several files in one pass rather than producing isolated snippets.
- Lower barrier to entry: Developers who know PHP but not every WordPress API can ask for the right hook or function instead of searching documentation.
- Iteration through conversation: Refactoring, renaming and adding features can be done by describing the change.
Compared with traditional methods
| Task | Traditional approach | With Claude Code |
|---|---|---|
| Starting a plugin | Copy a boilerplate or write from scratch | Describe the plugin and generate a structure |
| Finding the right API | Read the Plugin Handbook and Codex pages | Ask, then verify against official docs |
| Refactoring | Manual edits across files | Describe the change, review the diff |
| Security review | Manual checklist | Ask for a review, then confirm yourself |
The tradeoff is that generated code can be wrong or insecure. Treat output like a junior developer's pull request: read it, test it on a staging site, and check escaping, sanitization and permissions before release.
How to Set Up Your Development Environment for Claude Code
To set up your development environment for plugin development, you will need a few essential tools. These tools will help streamline your workflow and ensure that you can effectively build and test your WordPress plugin.
Required Tools
- Local Server Environment: A local server like XAMPP or MAMP allows you to run WordPress on your machine.
- Code Editor: Choose a code editor such as Visual Studio Code or Sublime Text for writing your plugin code.
- Version Control System: Git is recommended for tracking changes and collaborating with others.
- Browser: A modern web browser like Chrome or Firefox for testing your plugin.
Installation Steps
- Install a Local Server: Download and install XAMPP or MAMP. Follow the setup instructions to configure your local server.
- Download WordPress: Obtain the latest version of WordPress from the official website and extract it into the local server's root directory.
- Set Up Database: Use the local server's control panel to create a new database for your WordPress installation.
- Configure WordPress: Open your browser and navigate to your local WordPress installation. Follow the prompts to connect to the database and complete the installation.
- Install Code Editor: Download your preferred code editor and install it on your machine.
- Set Up Git: Install Git and create a repository for your plugin project to manage your code effectively.
By following these steps, you will have a functional development environment ready for building your WordPress plugin. For additional resources, consider exploring Free Claude Code Tools that can assist you in your development journey.
How to Build a WordPress Plugin with Claude Code: Step-by-Step
To build a WordPress plugin with Claude Code, define the plugin's purpose in a short spec, let Claude Code scaffold the files, then iterate: generate a feature, review the diff, test in a local WordPress install, and repeat. The steps below use a simple example plugin that adds a "reading time" label to posts.
Step 1: Create the plugin folder and a spec
Inside wp-content/plugins/, create a folder and a CLAUDE.md file that Claude Code reads as project context. Keep it specific.
# Project: reading-time
A WordPress plugin that shows estimated reading time above post content.
- Follow WordPress Coding Standards
- Prefix all functions with rt_
- Escape all output, sanitize all input
- Text domain: reading-time
Step 2: Ask Claude Code to scaffold the plugin
Start Claude Code in the folder and give it a clear prompt:
Create the main plugin file with a proper header, an ABSPATH check, and a class-based structure. Add an includes/ folder and a readme.txt.
Expect a main file similar to this:
<?php
/**
* Plugin Name: Reading Time
* Description: Shows estimated reading time on posts.
* Version: 0.1.0
* Text Domain: reading-time
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
require_once __DIR__ . '/includes/class-rt-display.php';
add_action( 'plugins_loaded', array( 'RT_Display', 'init' ) );
Step 3: Build the feature with hooks
Prompt: "Add a filter on the_content that prepends estimated reading time for single posts, assuming 200 words per minute."
class RT_Display {
public static function init() {
add_filter( 'the_content', array( __CLASS__, 'prepend_time' ) );
}
public static function prepend_time( $content ) {
if ( ! is_singular( 'post' ) || ! in_the_loop() ) {
return $content;
}
$words = str_word_count( wp_strip_all_tags( $content ) );
$minutes = max( 1, (int) ceil( $words / 200 ) );
$label = sprintf(
/* translators: %d: minutes */
_n( '%d minute read', '%d minutes read', $minutes, 'reading-time' ),
$minutes
);
return '<p class="rt-time">' . esc_html( $label ) . '</p>' . $content;
}
}
Step 4: Add a settings page
Ask Claude Code to register a setting for words per minute using the Settings API, with sanitize_callback set to absint and a manage_options capability check on the page. Request that it use register_setting(), add_options_page(), and settings_fields() rather than custom form handling.
Step 5: Review every change
Claude Code shows proposed edits before applying them. Check each one for:
- Escaping: output wrapped in
esc_html(),esc_attr()oresc_url() - Sanitization: input cleaned before saving
- Nonces and capabilities: present on any form or AJAX action
- Prefixes: no generic function names that could collide with other plugins
Step 6: Test locally and fix errors
Activate the plugin in a local WordPress site with WP_DEBUG enabled in wp-config.php. If a notice or fatal error appears, paste it into Claude Code and ask for a fix. You can also have it run PHP_CodeSniffer with the WordPress ruleset:
phpcs --standard=WordPress reading-time/
Step 7: Add tests, then package
Ask Claude Code to write PHPUnit tests for the word-count logic and to complete readme.txt. Once tests pass, zip the folder for installation or submission.
Tips for better results
- Work in small prompts: one hook or feature at a time.
- Commit to Git after each working step so you can revert.
- Name the WordPress APIs you want used, so the output follows core conventions.
- Never test on a production site first.
If you want pre-built specialist roles for this kind of work, Agentsforce: Claude Code, fully staffed offers a team of ready-made specialists for Claude Code, including developers and WordPress experts, and it works within Claude Code without a new app.
How to Test Your WordPress Plugin Built with Claude Code?
Test it the same way you would test any WordPress plugin: combine automated tests (unit and integration), static analysis, and manual checks in a real WordPress install. Code generated by an AI assistant deserves the same scrutiny as code written by hand, so review and run it before it reaches a live site.
Testing tools
| Tool | What it covers |
|---|---|
| PHPUnit | Unit and integration tests for PHP logic |
| WordPress test suite (via WP-CLI scaffolding) | Tests that load WordPress core, hooks, and the database |
| PHP_CodeSniffer with WordPress Coding Standards | Style, security, and escaping rules |
| PHPStan or Psalm | Static analysis for type errors and undefined variables |
| Plugin Check | Checks against WordPress.org plugin guidelines |
| Playwright or Cypress | Browser tests for admin screens and front-end behavior |
| WP_DEBUG and Query Monitor | Surfacing notices, warnings, slow queries, and hook issues |
Best practices for testing
- Write tests alongside the code. Ask Claude Code to produce tests for each function or class it writes, then read them to confirm they check real behavior and not just trivial cases.
- Run tests after every change. Let the assistant run your test command and linting, and feed failures back so it can fix them.
- Check security basics manually. Verify nonce checks, capability checks, input sanitization, output escaping, and prepared database queries.
- Test on a staging site or local install. Never try new plugin code first on production.
- Cover different environments. Try supported PHP versions, the current WordPress release, and common themes and other plugins to catch conflicts.
- Enable debugging. Turn on WP_DEBUG and review the log for deprecated functions and warnings.
- Test uninstall and deactivation. Confirm the plugin cleans up options and tables as intended.
- Review the diff. Read generated code before committing, and use version control so you can roll back a bad change.
Automated checks catch regressions, while manual review catches logic that technically runs but does the wrong thing. Using both gives you the most reliable result.
Common Challenges When Building Plugins with Claude Code
Building plugins with Claude Code can present several challenges. Common pitfalls include not fully understanding the API, overlooking compatibility issues with WordPress versions, and failing to optimize for performance.
Common Pitfalls
- API Misunderstandings: Developers may misinterpret the functionality of certain API calls, leading to unexpected behavior in their plugins.
- Compatibility Issues: Not all plugins work seamlessly with every version of WordPress. It's crucial to test for compatibility to avoid conflicts.
- Performance Optimization: Failing to optimize code can result in slow-loading plugins, which can frustrate users and lead to poor reviews.
How to Troubleshoot
To address these issues, consider the following strategies:
- Read Documentation Thoroughly: Familiarize yourself with the API documentation to avoid misunderstandings. This can help clarify how to implement features correctly.
- Conduct Compatibility Tests: Regularly test your plugin with different WordPress versions to identify and resolve compatibility issues early.
- Optimize Your Code: Use profiling tools to identify bottlenecks in your plugin. Make use of caching and efficient coding practices to enhance performance.
Additionally, engaging with the community can provide insights and solutions. Many developers share their experiences and solutions online, making it easier to find answers to common challenges. Utilizing the best claude code subagents can also streamline the development process and improve plugin quality. For more detailed guidance, check out How to Use Claude Code Effectively: Best Practices.
What Users Report About Building Plugins with Claude Code
Developers who build WordPress plugins with an AI coding assistant tend to describe a mixed but useful experience: faster scaffolding and boilerplate, balanced against the need for careful review. Public discussion on developer forums and social channels is the main source of this feedback, and individual experiences vary widely.
Themes commonly raised in community discussion
- Speed on repetitive work. Developers often mention that scaffolding a plugin structure, registering custom post types, and writing settings pages are tasks an assistant can draft quickly.
- Value of clear instructions. Many report that specific prompts, with the plugin's purpose, required hooks, and coding standards stated up front, lead to more usable output than vague requests.
- Review is still necessary. A recurring point is that generated code should be checked for security basics such as input sanitization, output escaping, nonces, and capability checks, which WordPress plugin guidelines expect.
- Context matters. Users commonly note that results improve when the assistant can read the existing project files rather than working from a single pasted snippet.
- Iterating in small steps. Building one feature at a time and testing each is frequently recommended over requesting a whole plugin in one pass.
How to read this feedback
Community reports are anecdotal. They reflect different skill levels, project sizes, and expectations, so treat them as signals of what to watch for rather than guarantees of results.
If you are evaluating this workflow, a sensible approach is to start with a small, low-risk plugin, review every change, and test on a staging site before anything reaches production.
Related articles
- How to Run a SEO Audit on WordPress with Claude Code
- How to Use Claude Code Effectively
- How to Set Up Claude Code Subagents for a Team
Try Agentsforce today to streamline your WordPress plugin development with Claude Code!
Frequently asked questions
Can Claude Code build a WordPress site?
Yes, Claude Code can help build a WordPress site. It works in your project folder, so it can write theme files, custom plugins and configuration code that you then run on a local or staging WordPress install. You still review the output and decide what goes live.
How to integrate Claude Code into WordPress?
Claude Code does not install into WordPress itself. You integrate it by running it in the directory that holds your WordPress code, typically the plugin or theme folder, and giving it clear instructions and project context. The code it writes then uses standard WordPress hooks, such as actions and filters, to connect with the platform.
Is the Claude Code plugin available for WordPress?
Yes, plugins and tools exist that connect Claude Code or similar AI assistants to WordPress workflows. Their features and quality vary, so check each one's documentation, update history and compatibility with your WordPress version before using it on a live site.
How to make plugins for Claude Code?
Follow the structured approach in the step-by-step section above: define what the plugin should do, set up a local environment, ask Claude Code to scaffold the files, then iterate in small steps. Review each change and commit your work often so you can roll back mistakes.
What are the best practices for building a WordPress plugin?
Thorough testing and adherence to coding standards matter most. In practice, that means: Follow the official WordPress coding standards for PHP, HTML, CSS and JavaScript. Sanitize and validate input, escape output, and use nonces and capability checks. Prefix functions, classes and options to avoid naming conflicts. Test on a staging site with debugging enabled before release. Use version control and keep the plugin compatible with current WordPress and PHP versions. These rules apply equally to code you write by hand and code an AI assistant generates.