If you’ve ever tried using an AI tool to help debug or analyse a WordPress plugin, you may have run into a challenge: AI platforms often require a single file input, while your plugin is made up of multiple PHP, JavaScript, and other files.
Luckily, there’s a simple way to combine your plugin into a single file, making it easier to upload for AI-based debugging or code analysis.
Table of Contents
Why combine your plugin files?
AI tools like ChatGPT, Gemini, etc, can read and reason through code when you provide enough context – but context is hard to maintain when your plugin is spread across multiple files. By combining everything into one .txt
file, you can:
- Help the AI see the full structure of your plugin.
- Provide necessary dependencies and cross-file relationships.
- Avoid confusion caused by missing references.
How to combine a plugin into a .txt file
Follow these simple steps to consolidate your plugin into a single .txt
file.
Locate Your Plugin Directory
First, navigate to your plugin directory. It should be inside:
/wp-content/plugins/your-plugin-name/
Copy the plugin to a local folder
To avoid modifying your plugin, make a local copy of the plugin folder and put it on your desktop or in a similar location.

Combine the files
Use a simple command line script to combine all files. Here’s a bash command you can run in the plugin root directory:
find . -type f \( -name "*.php" -o -name "*.js" -o -name "*.css" \) | while read file; do
echo -e "\n\n==== FILE: $file ====\n" >> combined-plugin.txt
cat "$file" >> combined-plugin.txt
done
This command does the following:
- Finds all PHP, JS, and CSS files recursively.
- Adds a header for each file, so the AI can differentiate it.
- Appends the file content to
combined-plugin.txt
.
Note: You can adjust the file types as needed, for example, you may want to also include *.json
, *.txt
, etc.
Check the file
Open combined-plugin.txt
in a text editor and double-check the following:
- File headers and content are accurate and clear.
- No sensitive information, such as API keys, passwords, etc is included.
Upload to AI
Now you can upload the combined-plugin.txt
file to an AI assistant and ask specific questions, such as:
- “Can you help me with x error?”
- “Is there a security issue in how I’m using the x function?”
- “How can I refactor this plugin for better performance, specifically in x area?”
Tips
- Commit your code before any changes, so you can roll back easily.
- Exclude unnecessary files like images or language files.
- If your plugin is very large, split it into multiple
.txt
files grouped by function (e.g. admin, public, includes).
Project-aware IDEs
When working with WordPress plugins, consider using a project-aware IDE which can understand your plugin as a whole:
- Project-Wide Indexing: The IDE scans all files to create an index of your classes, functions, variables, and methods.
- Intelligent Code Completion: Autocomplete suggestions are based on the entire codebase, not just the current file.
- Advanced Code Navigation: You can instantly jump to the definition of a function or find every place it’s used across the whole project.
- Smart Refactoring: You can rename a function, class, or variable, and the IDE can intelligently update every instance of it throughout all your files.
- Dependency and Error Detection: The IDE understands your project’s dependencies and can flag potential errors, unused code, etc.
Check out Cursor, which is a fork of VS Code that has been specifically engineered to provide its integrated AI features with the deepest possible understanding of your entire project.