Build a Magento module with AI: an honest walk-through
Yes, you can build a real custom Magento 2 module yourself with AI. I am Kishan Savaliya, an Adobe Certified Magento developer, and this is the workflow I set up for store owners. Below: what Claude Code does well, one real module built step by step, and the modules I would still hand to a developer. One limit up front: Claude writes clean boilerplate, but it can still hook the wrong method or miss an edge case, so every module gets tested on staging before it goes near live.
What a Magento module actually is
A Magento 2 module is a folder of files that adds or changes behaviour without touching core code. A one-line tweak and a full extension are built from the same small set of parts. That predictable structure is why you can build a Magento module with AI at all: the parts are well documented, so Claude assembles them reliably once you know what to ask for.
registration.php
One line that tells Magento the module exists and where its files live. Each module has exactly one.
module.xml
Declares the module name and the modules that must load before it. Run bin/magento module:status to see whether Magento has picked it up.
di.xml
The dependency injection wiring. Plugins, preferences and virtual types are registered here, so most "change how core behaves" work ends up in this file.
Plugins and observers
The safe way to hook into core logic. A plugin wraps a method, an observer reacts to an event. Describe the goal and Claude picks one, but check its choice: it sometimes reaches for an observer where a plugin is cleaner.
Controllers and routes
A controller answers a URL. Storefront pages use a frontend route, admin pages use adminhtml, and each has its own routes.xml.
UI components and admin config
Admin grids, form fields and the settings under Stores > Configuration. Long, verbose XML: the kind Claude writes correctly and people mistype.
If none of that means much yet, fine. You describe the outcome in plain words and Claude writes the parts. The bigger picture is on the pillar page, become your own Magento developer, and set up Claude for Magento covers the one-time install this page assumes you already have.
What AI builds well
Claude is strongest where the work is structured, repetitive and has a clear right answer. Most of a Magento module looks like that. These are the pieces I trust Claude Code to write, and it usually gets them right on the first or second pass.
Module scaffolding
The full skeleton: registration.php, module.xml, folder layout and a working di.xml. Tedious by hand and easy to typo.
Plugins and observers
"Add free shipping when the cart has 3+ of category X" becomes a plugin wired to the right class. Read which method it hooks before you approve, because that is where it most often guesses wrong.
Admin system config
A new section under Stores > Configuration with groups, fields and a class that reads the values. Claude knows the system.xml and ACL patterns well.
Admin grids
A UI component listing backed by a database table, with columns, filters and paging. A lot of XML, all of it predictable.
Database schema
A new table in db_schema.xml plus the model, resource model and collection, written together. You still run bin/magento setup:upgrade on staging and check the table before you trust it.
Small storefront features
A custom field, a block on a page, a simple controller that returns a page. The kind of change store owners actually ask me for.
All of these are patterns Magento repeats everywhere, so there are plenty of correct examples behind them. Ask for something novel or clever and the chance of a mistake goes up. That is what the staging step is for.
A realistic example, step by step
Here is a real task a store owner asked me for, done the way you would do it after the setup: add a delivery-date field to checkout so customers can pick a preferred day, and save it on the order so it shows in the admin. It touches five of the module parts above, so it is a fair test of how the workflow feels.
Step 1: describe the outcome in plain English
You do not write any XML. You type the outcome 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 first, then lists the files it plans to create. For this task:
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 is the standard one line, and module.xml declares Magento_Checkout and Magento_Sales as dependencies so the load order is right. You do not need to remember any of that. You read the plan and say go.
Step 3: it writes the code, you review each change
Claude Code does not quietly rewrite your store. It shows each file it wants to create or edit and waits for your approval. For example, here is 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 yourself. 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 check it matches what you asked for. Reading the plan before you approve is the most useful habit in this workflow. Claude can also be wrong in ways that look fine, such as skipping the past-date check, which is why the next step exists.
Step 4: install and test on staging, never live
Everything points at a staging copy of your store. Check git status to see which files changed, then run the usual commands there:
bin/magento module:enable Panth_DeliveryDate bin/magento setup:upgrade bin/magento setup:di:compile bin/magento cache:flush
Then place a test order on staging and check three things: the field shows in checkout, a past date is rejected, and the value appears on the admin order and in the email. If all three pass, you are done. If one fails, tell Claude what you saw ("the field shows but the date is not on the admin order") and it fixes that gap. That is the loop: describe, review, test on staging, repeat.
Step 5: only then, deploy
Once staging is clean, the same module goes live through your normal release process. Nothing reaches the live store until you have watched it work on a copy, and if something slips through, git revert <commit> takes it back out. The build a Magento store without a developer page covers running the whole store this way.
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