Umutcan As someone who has experimented with this, honestly, I don’t think AI alone can create an entire extension. As GreXXL suggested, you should first introduce the documentation page to the AI, but this won’t be enough because, personally, I find Flarum’s documentation page insufficient.
Introducing Flarum’s source files to AI would be unnecessary for modern AI models. They already scan popular GitHub repositories regularly.
Instead, I provide the AI with files from MIT-licensed extensions that have similar functionality to the extension I want to write. I ask it to analyze them. Then, I upload the files of the extension I’m working on and ask it to analyze those as well.
If you tell it, “Write me this extension,” it will fail again. Instead, first ask it to create a roadmap for you. Then, step by step, start creating the files based on this roadmap with the help of AI.
Rather than letting AI manage the project, think of yourself as the project manager and AI as a team member. Instead of making big requests all at once, break them down into smaller tasks. This way, if it makes a mistake, you can ask it to correct it.
At some point, it will get confused. You’ll need to go back to the beginning, reintroduce the similar extensions and documentation, and then reintroduce the latest version of your extension. You can continue where you left off based on the roadmap.
While AI can be helpful, it cannot write an entire extension from start to finish on its own. I use ChatGPT 4o and o1 (plus version), yet it still hallucinates frequently, breaking old code while adding new features.
Lastly, AI generally lacks the concept of optimization. It tends to rely on libraries immediately in the code it writes. This is why you need to review and optimize the code it generates.
These are my personal experiences. I hope they are helpful for you.