Build a Magento module with AI: an honest walk-through
Yes, you can build a real custom Magento 2 module yourself with AI. Here is what Claude Code genuinely does well, a realistic example built step by step, and the modules you should still hand to a developer. I am Kishan Savaliya, an Adobe-Certified Magento developer, and this is the same workflow I set up for store owners.
What a Magento module actually is
A Magento 2 module is a folder of files that adds or changes behaviour without editing the core. Every module, from a one-line tweak to a full extension, is built from the same small set of parts. Once you know the parts, AI can assemble them for you, because the structure is predictable and well documented.
registration.php
One line that tells Magento the module exists and where it lives. Every module has exactly one.
module.xml
Declares the module name, version, and which other modules must load first. This is what bin/magento module:enable reads.
di.xml
Dependency injection wiring: where you register a plugin, a preference, or a virtual type. Most "change how core behaves" work lands here.
Plugins and observers
The safe way to hook into core logic. A plugin wraps a method; an observer reacts to an event. AI picks the right one when you describe the goal.
Controllers and routes
A controller answers a URL. Front-end for storefront pages, adminhtml for admin pages, each with its own routes.xml.
UI components and admin config
Admin grids, form fields, and the settings under Stores > Configuration. Verbose XML that AI is good at producing correctly.
If none of that means much yet, that is fine. The point of the setup is that you describe the outcome in plain words and the AI writes the parts. The pillar page, become your own Magento developer, explains the bigger picture, and set up Claude for Magento covers the one-time install this page assumes is already done.
What AI builds well
AI is strongest where the work is structured, repetitive, and has a clear right answer. That describes most of a Magento module. Here is what I trust Claude Code to produce, and it usually gets these right on the first or second pass.
Module scaffolding
The whole skeleton: registration.php, module.xml, folder layout, and a working di.xml. Boilerplate that is tedious by hand and easy to typo.
Plugins and observers
"Add free shipping when the cart has 3+ of category X" becomes a correctly-wired plugin on the right class, with the event or method chosen for you.
Admin system config
A new section under Stores > Configuration with fields, groups, and a config reader class. AI knows the system.xml and ACL patterns cold.
Admin grids
A UI-component listing backed by a database table, with columns, filters, and paging. Lots of XML, all predictable.
Database schema
A new table via db_schema.xml plus the model, resource model, and collection. AI generates the declarative schema and the classes together.
Small storefront features
A custom field, a block on a page, a simple controller returning a page. The kind of change a store owner actually asks for.
The common thread: these are all patterns Magento repeats thousands of times, so there is a large, consistent body of correct examples to draw from. When you ask for something novel or clever, the odds of a mistake go up, which is exactly what the staging step is there to catch.
A realistic example, step by step
Here is a real task a store owner asked me for, done the way you would do it yourself after the setup: add a delivery-date field to the checkout so customers can pick a preferred delivery day, and save it against the order so it shows up in the admin. This touches five of the module parts above, so it is a good honest test of what the workflow feels like.
Step 1: describe the outcome in plain English
You do not write XML. You type what you want:
# what you type to Claude Code
Create a module Panth_DeliveryDate. Add a "Preferred delivery
date" date field to the checkout shipping step. Save the value
on the order, show it read-only on the admin order view, and
put it in the order confirmation email. Do not let the customer
pick a date in the past.
Step 2: it scaffolds the module
Claude reads your project, then proposes the files. For this task the skeleton is:
app/code/Panth/DeliveryDate/ registration.php etc/module.xml etc/db_schema.xml # adds delivery_date column to sales_order etc/extension_attributes.xml # exposes it on the order API etc/frontend/di.xml # plugin to save the value Model/Checkout/LayoutProcessor.php # adds the field to the checkout UI view/frontend/web/js/view/delivery-date.js Plugin/SaveDeliveryDateToOrder.php view/adminhtml/... # read-only display on the order
The registration.php it writes is the standard one line, and the module.xml declares the dependency on Magento_Checkout and Magento_Sales so load order is correct. You do not have to remember any of that. You read the plan it shows and say go.
Step 3: it writes the code, you review each change
Claude Code does not silently rewrite your store. It shows each file it wants to create or edit and waits for you to approve. You will see, for example, the plugin that copies the field onto the order:
public function afterSaveAddressInformation(
ShippingInformationManagement $subject,
$result,
$cartId,
ShippingInformationInterface $addressInformation
) {
$extAttributes = $addressInformation->getExtensionAttributes();
$deliveryDate = $extAttributes->getDeliveryDate();
// validation + quote save happen here
return $result;
}
You do not need to be able to write that from scratch. You do need to read the summary Claude gives ("this saves the date to the quote, then a second plugin copies it to the order") and sanity-check that it matches what you asked for. That habit, reading the plan before approving, is the single most useful skill in this workflow.
Step 4: install and test on staging, never live
The setup points everything at a staging copy of your store. You run the standard commands there:
bin/magento module:enable Panth_DeliveryDate bin/magento setup:upgrade bin/magento setup:di:compile bin/magento cache:flush
Then you place a test order on staging and check three things: the field shows in checkout, it rejects a past date, and the value appears on the admin order and the email. If all three pass, you are done. If one fails, you tell Claude what you saw ("the field shows but the date is not on the admin order") and it fixes that specific gap. This is the loop: describe, review, test on staging, repeat.
Step 5: only then, deploy
Once staging is clean, the same module deploys to live through your normal release process. Nothing reaches the live store until you have watched it work on a copy. The build a Magento store without a developer page covers the wider "run the whole store this way" version of this loop.
Where AI needs a human
I would be selling you something false if I said AI can build every module safely on its own. It cannot, and the honest list of exceptions is short but firm. These are the cases where I tell store owners to bring in a developer, me or anyone qualified, rather than self-serve.
Hand these to a developer:
- Payment and checkout-total logic. A payment method, a custom tax rule, or anything that changes what a customer is charged. A subtle bug here costs real money and trust, and it needs a human who owns the outcome.
- Anything security-sensitive. Login, account data, admin permissions, API authentication, file uploads. AI can write these, but reviewing them safely takes security experience you should not fake.
- Complex data migrations. Bulk-editing millions of rows, migrating from Magento 1, or restructuring order or customer tables. One wrong query on production data is not recoverable, and "test on staging" is harder when the data itself is the risk.
- Heavy performance or third-party integration work. ERP sync, custom indexers, and anything touching how the whole store scales. AI helps, but the architecture calls should come from someone who has debugged these at 3am.
Notice the pattern: the exceptions are where a mistake is expensive, hard to reverse, or hard to even detect in testing. For the everyday "add a field, add a rule, add an admin setting" work that store owners actually need most weeks, AI plus staging is genuinely enough.
How the setup makes this safe
The reason a non-developer can do this without wrecking the store is not that AI never makes mistakes. It does. The safety comes from the one-time setup putting three guardrails in place before you write a single instruction.
| Guardrail | What it does | Why it matters |
|---|---|---|
| Coding standards pinned | Magento Coding Standard (phpcs) and static analysis run on generated code | The code that passes review is the code that would pass a real developer's review, not just "it runs" |
| Staging-only by default | Every install, compile, and test targets a copy of your store, not live | A broken module breaks a throwaway copy you can reset in minutes, never the store customers see |
| Command guardrails | Destructive and production commands are blocked or require explicit confirmation | The AI cannot flush a live cache, drop a table, or push to production on its own |
| Review before apply | Every file change is shown and waits for your approval | You are always the one who says yes, so nothing changes without a human in the loop |
| Version control | Every change is a git commit you can undo | If something is wrong, one command puts the code back exactly how it was |
That is the whole trick. The AI does the typing, the standards and staging and version control catch the mistakes, and you make the decisions. Set up once, it keeps working with no retainer. If you want me to put this in place on your project, set up Claude for Magento is the how, and the contact page is where you tell me about your store.
Frequently asked questions
Can AI really write a Magento module?
Yes, and I mean a genuine module that installs, enables, and does the job, not a toy. Claude Code writes the registration.php, module.xml, di.xml, plugins, observers, controllers, admin config, and UI components correctly because those follow well-documented patterns Magento repeats everywhere. What it needs from you is a clear description of the outcome and a review of the plan before you approve it.
Will the code pass Magento coding standards?
With the setup in place, yes. Part of the one-time setup is wiring the Magento Coding Standard (phpcs) and static analysis to run against generated code, so what you approve is code that would pass a real developer's review. Without that wiring, AI will still produce working code, but you lose the automatic check that it is clean, so the setup is worth doing properly.
Do I need to understand the code?
Not to write it, but you do need to read the summary and sanity-check it against what you asked for. You should be able to tell "this saves the field to the order" from "this saves it to the cart but forgets the order", because that plain-English gap is the kind of thing you catch, not the syntax. You are the product owner reviewing the work, not the person typing the syntax.
What kinds of modules should I not build with AI alone?
Payment methods and anything that changes what a customer is charged, anything security-sensitive (login, account data, admin permissions, API auth, uploads), complex data migrations, and heavy integration or scaling work. The common thread is that a mistake there is expensive, hard to reverse, or hard to spot in testing. For those, bring in a developer who owns the outcome.
How do I test it safely?
You test on a staging copy of your store, which the setup makes the default target. You enable the module, run setup:upgrade and di:compile, flush cache, then exercise the feature end to end: place a test order, trigger the rule, open the admin page. Only after staging is clean does the same module go to live through your normal release process. Nothing reaches customers until you have watched it work on a copy.
What if it breaks?
Two safety nets. First, breakage happens on staging, which you can reset in minutes, not on the live store. Second, every change is a git commit, so one command puts the code back exactly how it was. When something is wrong, you tell Claude what you saw and it fixes that specific gap, or you roll back and try a different instruction. Nothing is a dead end.
Is this the same as vibe coding a Magento module?
It is the disciplined version of it. "Vibe coding" usually means accepting whatever the AI produces without review. This workflow keeps the plain-English direction but adds the parts that make it safe on a real store: pinned coding standards, staging-only testing, command guardrails, and a human approving every change. The speed is similar, the risk is much lower.
What does the setup cost, and is there a retainer?
It is a one-time setup with no retainer. I install and configure Claude Code on your Magento project, wire the coding standards, point testing at staging, and put the command guardrails in place, then it keeps working on its own. Pricing depends on your project, so I quote it per store rather than posting a figure. Contact me with a bit about your setup and I will give you a number.
Want to build your own Magento modules? I set up Claude Code on your Magento project once, with the coding standards, staging workflow, and guardrails in place, so you can direct changes in plain English. One-time setup, no retainer. Contact me for pricing.
See how the setup worksOr tell me about your store