This is based on ChatGPT DeepResearch (2025-08-04)

August 2025 – WordPress Plugin & Theme Development with Copilot

GitHub Copilot’s latest agentic features can transform your WordPress development workflow. By combining Copilot’s autonomous Agent Mode and interactive Chat Mode across VS Code and GitHub, developers can offload routine tasks, generate code, and even have Copilot propose and execute changes. This guide outlines a best-practice setup for using Copilot in WordPress plugin and theme development – from configuring each environment to leveraging Copilot for WordPress-specific tasks like hooks, filters, template files, custom post types (CPTs), shortcodes, and more. We also cover prompt strategies, example tasks, verification techniques, and caveats to keep your AI pair-programmer effective and reliable.

Setting Up Copilot in Your Development Environments

To maximize Copilot’s utility, enable it everywhere you code – in your IDE and on GitHub. Below we detail setup steps for VS Code (desktop) and GitHub’s web interface, including the new Copilot Coding Agent (in preview).

VS Code (Desktop) – Copilot Chat and Agent Mode

  1. Install/Update Copilot Extensions: Ensure you have the latest GitHub Copilot extension (or the separate Copilot Chat extension if required) installed in VS Code . Sign in with your GitHub Copilot-enabled account (Copilot Free, Pro, or Enterprise). This gives you access to inline code completions and the Copilot Chat panel inside VS Code .
  2. Enable Copilot Chat: Open the Copilot Chat view (e.g. via the Copilot icon or using the keyboard shortcut). This will open a sidebar for AI conversations . If prompted, select a mode (e.g. Ask mode for Q&A or Agent mode for autonomous tasks). By August 2025, Copilot Chat is generally available in VS Code – no Insider build required if you have the latest version and an active subscription.
  3. Access Agent Mode: In the Copilot Chat panel, use the mode dropdown to select Agent (if not auto-selected) . Agent Mode allows Copilot to act autonomously on your workspace. Tip: If you don’t see Agent Mode, ensure you have updated VS Code. Initially it was in VS Code Insiders, but it’s now available in VS Code Stable . Enabling Agent mode might also require opting into preview features in VS Code settings.
  4. Configure Preferences: Optionally adjust Copilot settings. For example, set Custom Instructions to let Copilot know about your coding style or WordPress standards (e.g. “Follow WordPress Coding Standards and prefer core WP APIs”). Also make sure the Copilot extension has permission to run commands and access the workspace as needed for agent actions.
  5. Local WordPress Environment: Have a local WP development setup (e.g. using LocalWP or XAMPP) so you can run and test any generated plugin/theme code . Copilot’s agent can run commands like starting a PHP server or running tests if your environment is ready. Ensure WP-CLI or PHPUnit is installed if you plan to let Copilot run tests or other CLI tasks.

GitHub Web – PRs, Code Review, and Commit Integration

  1. Copilot on GitHub Web: GitHub has integrated Copilot into the web UI for pull requests and code browsing. Make sure Copilot is enabled for your account on GitHub.com. If you have Copilot for Business/Enterprise, an org admin may need to enable features like Copilot in PRs or Copilot Chat in GitHub (some features are still in beta as of 2025).
  2. Pull Request AI Assistant: When creating or viewing a PR on GitHub, use Copilot’s features to speed up reviews. You can ask Copilot to review your PR by adding it as a reviewer . Copilot will analyze the diff and leave comments highlighting potential issues or improvements . These comments often include suggested code changes that you can accept with a click . (Note: Copilot’s PR review is read-only from Copilot’s side – it won’t auto-merge or count as an approval) .
  3. Copilot Chat in the Browser: In file views or PRs, you may have access to Copilot Chat on the web (if you are in the Copilot Chat beta on GitHub). This lets you highlight code in a pull request or repository file and ask questions or for explanations. For example, you could select a piece of a WordPress plugin code on GitHub and ask, “Hey Copilot, explain what this function does and how it could be improved.” Copilot will respond in a chat panel with analysis or suggestions. (Ensure you’ve enabled the “Copilot Chat” feature flag on GitHub if available, as it’s gradually rolling out) .
  4. Commit Message Generation: Leverage Copilot to automate commit messages. In GitHub Desktop (v3.4.19+ Beta) or in VS Code’s source control panel, use the “Generate Commit Message” button to have Copilot draft a commit title and description based on your code changes . This uses AI to summarize diffs so you don’t have to write commit messages from scratch. Always review the generated message for accuracy and adjust if needed.
  5. Pull Request Descriptions: When opening a PR on GitHub, use Copilot to draft the PR description. For example, Visual Studio and VS Code integrations provide a “?” or sparkles icon to “Add AI Generated Pull Request Description” . Copilot will summarize the changes in the branch. This is very handy for WordPress projects where multiple files (PHP, CSS, JS) might have been modified – Copilot can list key changes (e.g. “added new shortcode class, updated template files, fixed bug in enqueue script”). You can then edit or refine this summary before posting.

GitHub Copilot Coding Agent (Preview via GitHub Actions)

  1. Enable the Coding Agent: GitHub’s Copilot Coding Agent is an autonomous AI that can be assigned tasks via GitHub issues (available for Copilot for Enterprise and Copilot Pro+ plans as of mid-2025) . To use it, enable the “Copilot agent” in your repository settings (and in organization settings if required). Once enabled, you’ll have an “Agents” tab in your repo or the ability to assign Copilot as a participant on issues.
  2. Trigger via Issue Assignment: Write a GitHub Issue describing the task (e.g. “Feature: Add a custom taxonomy filter to the Events CPT archive”) and assign the issue to Copilot . The Copilot agent will react with an ? emoji and begin working on the task in the background . It spins up a cloud VM (using GitHub Actions) and sets up the repo environment to implement the changes. Progress will be pushed to a draft pull request with iterative commits .
  3. Monitor & Guide the Agent: As the agent works, you can follow along via agent session logs (which show the AI’s reasoning, commands executed, and any errors) . The agent uses advanced context (e.g. repository code search and even images from issues) to understand the codebase . Once it’s done, it will tag you as a reviewer on the draft PR . You can then review the changes. If something isn’t right, you can leave PR review comments like “Please update this function to use WP_Query instead of a raw SQL query” – Copilot will pick up these comments and automatically revise the code to address them .
  4. Security and Controls: The coding agent only pushes to a new branch and requires human review to merge, so it won’t auto-deploy without approval . It also respects branch protections and lacks broad internet access (only whitelisted sites) . This is important for WordPress projects – you maintain control and can enforce code quality via required reviews or CI checks before anything goes live.
  5. Multi-IDE Access: As of mid-2025, you can activate agent mode tasks not only from VS Code but also from other IDEs like Xcode, JetBrains, etc., as long as you’re logged in with Copilot and your plan supports it . In VS Code specifically, you can also prompt the agent via chat command (e.g. “@github Open a pull request to refactor this metabox UI to use the Settings API”) – which will instruct the agent to create a PR with that refactoring.

Note: The Copilot agentic features are evolving rapidly. Copilot Workspace, an earlier experiment in cloud AI dev environments, was sunset in May 2025 . Its capabilities (like proposing a plan and letting you edit it) have influenced the current Agent Mode in VS Code and the GitHub Actions-based agent. Always check GitHub’s docs for any new setup requirements or policy changes for Copilot agents.

Copilot Chat vs Agent Mode: Choosing Your Workflow

GitHub Copilot provides two primary modes of interaction in the IDE: Chat (Ask Mode) and Agent Mode. Knowing when to use each will help you effectively tackle WordPress development tasks:

  • Ask Mode (Copilot Chat): Use this for quick, conversational help – similar to asking a colleague for advice or a code snippet. In Ask mode, Copilot won’t automatically edit files; it will answer questions, explain code, or suggest code which you can copy/paste. This is great for getting WordPress-specific guidance (e.g. “How do I register a shortcode in WordPress?” or “Explain how this WP filter is working”). It’s also useful for debugging (“What does this PHP error mean?”) or brainstorming (“What are best practices for enqueueing scripts in a theme?”). Ask Mode is fast and safe – Copilot only reads context (like the open file or your selected text) and gives suggestions .
  • Agent Mode: Use this when you want Copilot to perform multi-step coding tasks within your project. In Agent mode, Copilot can read and modify multiple files, generate new files, run commands, and essentially act as an “autonomous coder” under your supervision . This is ideal for more complex WordPress tasks like refactoring a feature across many files, setting up boilerplate code for a new module, or running tests and iterating on fixes. For example, “Add a new custom post type called Event with all necessary template files and admin menu” could be handled by Agent mode – it will create the CPT registration code, create template PHP files, update functions.php, etc., possibly in multiple passes. Agent mode is slower and more resource-intensive than simple suggestions , but it shines when you need automation across the codebase. (Copilot actually loops through plan?edit?run cycles in Agent mode to achieve the goal .)

In practice, you may mix these modes. For a given feature, you might start in Chat/Ask mode to explore approach options or get a code snippet, then switch to Agent mode to apply a large change. Conversely, if Agent mode gets stuck or is taking too long, you might revert to Chat to ask a specific question.

Tip: In VS Code, the Copilot Chat UI lets you toggle between Ask and Agent modes easily . Use Ask for guidance, and Agent for execution, as needed. In some cases, Agent mode might propose a plan that you want to adjust – don’t hesitate to intervene. You can cancel or undo an agent action and break the task into smaller prompts if it’s going off track (Copilot’s UI provides an “Undo Last Edit” if the agent’s change isn’t right ).

Effective Prompting Strategies for WordPress Tasks

Crafting good prompts is key to getting useful output from Copilot, whether in Chat or Agent mode. Here are best practices for prompt design in a WordPress context:

  • Be Specific and Incremental: Clearly describe the task and scope. Instead of a vague “Create a plugin,” specify the exact feature or outcome. For example: “Generate WordPress plugin code that registers a custom post type called Event, with fields start_date and end_date, and adds a settings page under Tools for a default location setting.” Each feature can be a separate prompt . This specificity helps Copilot understand WordPress nuances (CPT registration, admin menu placement, etc.) and produce better code. Break complex tasks into steps – you might first prompt to create the CPT, then another prompt to add meta boxes or settings, etc. .
  • Mention WordPress Context: Use WordPress terminology in your prompt so Copilot knows to apply WP conventions. Include keywords like “WordPress”, “plugin”, “theme”, “block editor”, “WP_Query”, “the_content filter”, etc., as appropriate. For example: “Add a WordPress shortcode that outputs a contact form, using WP nonce for security.” This ensures the AI doesn’t give a generic PHP answer but a WordPress-aware solution (like using add_shortcode, proper nonce creation, etc.). Copilot has been trained on a lot of WordPress code, so tapping into that by naming key functions (like add_action, register_post_type) can guide it.
  • Reference Specific Files or Code: When using Agent mode, you can explicitly provide context by referencing files. Copilot Agent allows adding files to the context via the syntax or the UI. For instance, you might say: “Refactor the code in inc/metabox.php to use the Settings API instead of add_meta_box (see for current code).” By doing this, you ensure Copilot looks at the correct file. In Chat mode, if you highlight a code snippet in VS Code and then ask a question, that snippet is included in the prompt automatically . This is very helpful when asking Copilot to fix or improve a specific function.
  • Use Step-by-Step Plan for Agents: For complex changes, you can literally outline steps for Copilot. For example, “To convert the shortcode to a block: (1) Create a new block registration PHP file in /blocks, (2) Register the block with register_block_type in PHP, (3) Write block front-end code (JavaScript) that replicates shortcode output, (4) Ensure old shortcode still works if called.” Copilot’s agent will then plan these steps. This approach is similar to how Copilot Workspace allowed editing the plan; while you can’t always edit the plan directly in Agent mode, you can implicitly give it a structured plan via your prompt.
  • Provide Examples or Criteria: If you expect a certain output format or function signature, mention it. E.g.: “The function should accept $post_id and return an array of image URLs” or “Follow WordPress Coding Standards (Yoda conditions, proper escaping)”. You can even ask Copilot to produce examples: “Generate a snippet and an example usage for get_posts with meta_query.” Copilot will then show you code plus a usage example, which confirms it understood your intent.
  • Avoid Ambiguity: Don’t use pronouns like “it” or “this” without clarity . For example, instead of “Fix this code,” say “Fix the SQL query in the get_events() function to use $wpdb->prepare for safety.” Ambiguity can confuse the model, especially when multiple files or previous responses are in play.

Prompt Example – Converting a Shortcode to a Block:

Bad: “Convert this shortcode to a block.”

Better: “Convert the shortcode implementation into an equivalent Gutenberg block. The shortcode is defined in gallery.php (it queries images from a post). Create a new block using register_block_type that outputs the same gallery markup. Ensure backward compatibility: if the shortcode is still used, it should fall back gracefully.”

By being specific, you’d get a much more usable result. Copilot might then generate a new PHP file registering the block, a block JSON config, and even some front-end JavaScript for the block – covering all aspects of the task.

Delegating WordPress Development Tasks to Copilot

With the right prompts and mode, Copilot can handle a variety of WordPress plugin/theme tasks. The table below gives examples of common tasks and how to leverage Copilot:

TaskHow to Instruct Copilot (Mode & Prompt)What Copilot Does
Scaffold a New Plugin or ThemeAgent Mode: “Create a new WordPress plugin called ‘My Events’. It should have a main PHP file with plugin header, an /includes folder, and default code to register an ‘event’ custom post type with title and date fields.”Copilot agent generates the plugin files – adds the header comment, CPT registration code, basic activation hooks, folder structure, etc. (It may propose a plan for file creation and then implement it.)
Add a Custom Post Type with TaxonomyChat or Agent: “In my plugin, add a custom post type Books (slug book) with support for author and thumbnail. Also add a custom taxonomy Genre.”Copilot suggests code using register_post_type(‘book’, …) and register_taxonomy(‘genre’, ‘book’, …), with appropriate labels and supports. In Agent mode, it might directly edit your plugin files to insert these registration calls.
Convert a Shortcode to a Gutenberg BlockAgent Mode (multi-file): “We have a shortcode defined in legacy-shortcodes.php called gallery_shortcode. Create an equivalent Block in the blocks/ folder using the block API. The block should output the same HTML as the shortcode. Update plugin init to register the block.”Copilot creates new files: e.g., blocks/gallery-block.php and maybe a gallery-block.js (if needed), registers the block with metadata. It may reuse the logic from the shortcode in the block render callback. It keeps the shortcode for backward compat. Developer can then build/webpack as needed.
Refactor Meta Box to Settings APIAgent Mode with file context: Add the meta box file to Copilot’s context, then: “Refactor the meta box defined in inc/metabox.php into a Settings page under Settings ? Events. Use the WordPress Settings API to add fields (Event Color and Event Message). Preserve existing functionality (saving those values).”Copilot reads inc/metabox.php, removes or deprecates the add_meta_box code, and creates code for add_options_page and related register_setting, add_settings_section, add_settings_field calls. It updates how data is saved (probably moving from post meta to an option). It might create a new file for settings page code. You review the changes and test that the new settings page appears and works.
Implement a Hook or FilterChat mode (quick snippet): “Write a function to filter the_content in WordPress to append an author bio at the end of posts. Use add_filter.”Copilot returns a PHP snippet with function add_author_bio($content) { … } and an add_filter(‘the_content’, ‘add_author_bio’); call, following WP best practices (like checking is_singular(‘post’)). You can paste this into your theme’s functions.php or plugin.
Generate Unit TestsAgent Mode or Chat: “Generate PHPUnit test cases for the Event_Manager class in my plugin (file includes/class-event-manager.php). Include tests for its create_event() and delete_event() methods.”Copilot (with context of that file) will produce a tests/test-event-manager.php class with methods to test the functionality. Agent mode might directly create the file in a tests directory. You’d still need to run phpunit to verify tests and possibly help Copilot iterate if some tests initially fail.

Table: Examples of WordPress development tasks delegated to Copilot, with suggested prompting approaches.

As shown, Agent Mode is powerful for substantial changes spanning multiple files, whereas Chat (Ask Mode) is quick for generating or explaining a single snippet. Always verify the output – e.g., ensure the CPT array has all required labels, the block code registers correctly, or the filter function uses proper conditional checks.

Notably, Copilot (especially GPT-4 based models) is aware of many WordPress APIs. It can write code for hooks, filters, WP_Query loops, template tags, and more from just natural language prompts . For instance, you could ask: “Write code to create a custom post type Books on WordPress init using add_action. Also, generate an add_filter to change the admin menu title for that post type.” – and you would get a correct example with add_action(‘init’, ‘register_books_cpt’) and a filter like add_filter(‘post_type_labels_book’, …) to adjust the menu text . Use this knowledge to your advantage and let Copilot handle boilerplate code while you focus on higher-level architecture.

Verifying and Testing Copilot-Generated Code

Copilot can accelerate coding, but you are still responsible for the quality of the code. Always follow up AI-generated or AI-modified code with verification steps:

  • Code Review the Changes: Treat Copilot as a junior developer who writes code for you – review every line it produces. Check for WordPress-specific best practices: e.g., proper escaping (esc_html, esc_attr), security nonces and capability checks on form handlers, using the correct API functions (no direct DB calls if WP provides a function), etc. Compare the output to official WordPress examples or the WP Developer Handbook to see if it aligns with recommended usage . If something looks off or unfamiliar, ask Copilot Chat why it chose that approach or consult the WordPress docs.
  • Test in a Safe Environment: Run the plugin or theme locally (or in a staging site) to ensure it actually works. Activate the plugin, load the relevant pages, and watch for errors. For complex agent-generated features, run your test suite if you have one. Copilot’s agent will try to run tests if you prompted it to, but you should run them again yourself. Use WordPress debugging (WP_DEBUG) to catch issues. If you see errors or warnings, you can copy them into Copilot Chat and ask for an explanation or a fix suggestion .
  • Use Linters and Standards: Integrate PHP linters or the WordPress Coding Standards (PHPCS) checks into your workflow. You can even ask Copilot to fix coding style issues: e.g., “Format this code according to WordPress PHP coding standards.” Copilot might not catch everything, but it can handle things like spacing and basic standards. Automating a code style check (for example, a pre-commit hook or CI job with phpcs –standard=WordPress rules) will help catch any stylistic or trivial issues in Copilot’s output. If the linter flags something, consider feeding that feedback to Copilot: “Fix these PHPCS errors… [paste]”.
  • Leverage Copilot Code Review: As mentioned, you can have Copilot review the code it just wrote by opening a PR with those changes on GitHub and adding Copilot as a reviewer. It might spot issues like missing sanitization, deprecated functions, or possible bugs and comment on them . This second pair of AI eyes can be useful, but don’t rely on it exclusively – it’s an assistant, not a guarantee.
  • Manual Testing & Edge Cases: Especially for WordPress, consider edge cases – different PHP versions, multisite, various user roles, etc. If Copilot wrote a database query or WP_Query for you, test it with no results, with many results, with special characters (to ensure proper escaping). If it generated a regex or string manipulation, test those thoroughly. You can ask Copilot to generate some unit tests for edge cases as we did above, or ask it to analyze “what could go wrong” with a snippet.

By verifying the code, you will often catch small mistakes. For example, Copilot might generate a meta box but forget to include wp_nonce_field() – something a human familiar with WP would notice. In such cases, you can prompt Copilot: “Add a nonce check to this form handler.” It will happily insert the needed code . Always loop back any fixes into your codebase and possibly into Copilot’s context so it learns your project’s patterns.

Caveats and Workarounds (Limitations of Copilot in Preview)

While GitHub Copilot is cutting-edge, there are some limitations and quirks to be aware of:

  • Preview-Stage Quirks: Agent Mode is still relatively new (as of 2025) and might sometimes produce irrelevant actions or get off track. It could try to run a command that isn’t applicable (e.g. running npm install in a PHP-only project). Luckily, in VS Code agent mode you must approve terminal commands before they run . If an agent suggestion looks wrong, decline it or undo the edit. You have full control to step in at any time – don’t assume Copilot is 100% correct. It’s designed for iterative refinement with the developer in the loop .
  • Context Limitations: The AI has a context window; it won’t read your entire project codebase at once. It creates a summarized view of the workspace structure and relevant files . This means if your WordPress project is huge, Copilot might miss something unless pointed to it. Workaround: explicitly add important files as context (using the “Add Files” in agent mode or by opening them in your editor for Chat) . For example, if you’re modifying a theme template that relies on a function in functions.php, have both files open or tell Copilot about functions.php. The new Model Context Protocol (MCP) features also allow extending context with external data – for instance, you could configure an MCP server to provide WordPress documentation or your project’s wiki to Copilot , though that’s an advanced usage.
  • WordPress Version Knowledge: Copilot might not always know about the absolute latest WordPress functions or deprecations if they came after its training cutoff. If your project uses cutting-edge WP 6.x features, double-check Copilot’s suggestions against the release notes. Conversely, it might use deprecated things (like the old register_sidebar signature or outdated hooks). If you notice that, instruct Copilot accordingly: “Use WP 6.3+ functions only (e.g., use wp_get_environment_type() instead of WP_ENVIRONMENT_TYPE constant)”. Keeping an eye on this will prevent introducing legacy practices.
  • Autonomous Missteps: In GitHub’s coding agent (issues -> PR flow), the agent might sometimes misinterpret the issue or implement in a way you didn’t intend. For example, if your issue description is not detailed, it might choose a simplistic approach or affect parts of the code you didn’t expect. Always review the draft PR it opens. If it’s off base, you can simply close it and refine your issue prompt with more details or acceptance criteria. This agent is best at “low-to-medium complexity tasks in well-tested codebases” – don’t assign it a complete redesign of your plugin in one go. But something like “Add caching to the get_events() function” is a contained task it can likely handle.
  • No Magic Bullet for Logic: Copilot won’t automatically know your business logic beyond what you describe. For WordPress, this means if your plugin has a very custom domain (say a unique way of calculating prices), Copilot can’t infer the correct logic without guidance. Use it for boilerplate, transformations, and known patterns, but when it comes to project-specific logic, be prepared to write or refine that part yourself. You can gradually teach Copilot by writing a couple of key functions manually – its suggestions will adapt to mimic your style and approach.
  • Maintain Your Own Knowledge: Finally, don’t let Copilot make you complacent. It’s a learning aid, not a replacement for understanding WordPress. If Copilot suggests using a certain hook or function you’re unfamiliar with, take the opportunity to read up on it (Copilot might even explain it if asked). Ensuring you understand the code will help you catch mistakes and also improve the prompts you give.

By following the steps and strategies in this guide, you can harness GitHub Copilot’s agentic capabilities as a force multiplier in WordPress plugin and theme development. You’ll spend less time on repetitive coding and configuration, and more time on creative problem solving – all while keeping code quality high. Copilot can write custom post types, meta boxes, hooks, filters, and more from prompts , turning natural language tasks into working WordPress code. Embrace this, but always stay in control: direct the AI with clear instructions, verify its output, and iteratively refine. With Copilot integrated across VS Code and GitHub, your WordPress development workflow can become both faster and more enjoyable – like having an expert co-pilot for every coding session. Happy coding, and may your “magical flow state” be ever sustained !

Sources: The information above references GitHub’s official announcements and documentation on Copilot (February–August 2025) and general best practices for AI-assisted WordPress development , ensuring that the guidance is up-to-date and specific to WordPress contexts.

Leave a Reply

Only people in my network can comment.