Here my suggestions âenhancedâ with AI of course :
Mastering Moqui ERP with AI: A Developerâs Guide
Developing in Moqui often feels like âassemblingâ a system rather than just coding it. By using the right AI workflows, you can turn that assembly process into a high-speed pipeline.
1. Establish the âBrainâ of Your Project: CLAUDE.md and GEMINI.md
Standard LLMs often hallucinate Moqui syntax because they mix it up with older frameworks like OFBiz or generic Java patterns. To prevent this, you must anchor your AI with Project Guidelines.
Create CLAUDE.md and GEMINI.md files in your project root. These serve as the âSystem Promptâ that the AI reads before every session.
- Coding Standards: Specify that services should use Groovy and entities must follow the
moqui-framework XSDs.
- Folder Structure: Tell the AI where your components live (e.g.,
runtime/component/my-app).
- No-Go Zones: Instruct the AI never to use deprecated patterns like
<entity extends="..."> (use <extend-entity> instead).
Pro Tip: Include a list of frequently used shell commands (like ./gradlew load or java -jar moqui.war) in these files so the AI can help you run and test your changes immediately.
2. The âPattern Referenceâ Prompting Strategy
Moqui is built on the Data Model Resource Book patterns. The most efficient way to build new features is to point the AI to a âGold Standardâ already in the system.
Instead of saying âCreate a service to track equipment,â use a Pattern Reference Prompt:
âCreate a new entity Equipment in my component. Follow the same pattern and use the same standard fields (like description, lastUpdatedStamp) as the Product entity in mantle-udm.â
Why this works:
- It ensures naming consistency (e.g., using
description vs name).
- It automatically includes Mantle integration logic that the AI might otherwise overlook.
- It forces the AI to âlookâ at your existing codebase to maintain architectural harmony.
3. Cloning Services with High Fidelity
Moqui services are the engine of your ERP. When creating a new service, refer to an existing service that has the same âflavorâ (e.g., a CRUD service, a process service, or an integration service).
Prompt Example:
âCreate a service called updateEquipmentStatus. Use the same pattern as update#Product from the Mantle Product services. Specifically, ensure it includes an ec.message check and follows the same transaction attributes.â
This approach prevents the AI from writing generic Groovy scripts and ensures it uses the Moqui Execution Context (ec) correctly.
4. Post-Change Documentation: The âClosing Loopâ
Large changes in an ERPâlike adding a new multi-tenant billing logicâcan quickly become âblack boxes.â Once the AI has finished a significant task, task it with documenting its own work.
The Workflow:
- Complete the code changes.
- Prompt: âReview the changes made in the last 3 files. Create a technical summary and save it as
docs/features/billing-v2.md.â
- Ensure the document covers:
- Data Model Changes: New entities or fields.
- Service API: Input/output parameters.
- Side Effects: Any EECAs (Entity-Event-Condition-Actions) or SECAs triggered.
Having a documents/ directory filled with AI-generated explainers makes it significantly easier to onboard other developers (or even a different AI agent) later.
5. Automated Testing Integration
Donât let the AI stop at the code. Moquiâs XML-based testing is perfect for AI generation.
The Next Step:
âNow that youâve created the Equipment entity and services, generate a MoquiTest XML file that creates a test record, updates it, and verifies the status change. Refer to ExampleTests.xml for the structure.â