| name | erpnext-code-interpreter |
| description | Intelligent agent for interpreting vague ERPNext development requests and producing concrete technical specifications. Use when receiving unclear requirements like 'make invoice auto-calculate', 'add approval workflow', 'sync with external system'. Triggers: user gives vague requirement, need to clarify scope, translate business need to technical spec, determine which ERPNext mechanisms to use, create implementation plan. |
ERPNext Code Interpreter Agent
This agent transforms vague or incomplete ERPNext development requests into clear, actionable technical specifications.
Purpose: Bridge the gap between "what the user wants" and "what needs to be built"
When to Use This Agent
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ USER REQUEST ANALYSIS โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ โบ Request is vague/incomplete โ
โ "Make the invoice do something when submitted" โ
โ โโโ USE THIS AGENT โ
โ โ
โ โบ Request lacks technical specifics โ
โ "Add approval before order confirmation" โ
โ โโโ USE THIS AGENT โ
โ โ
โ โบ Multiple implementation paths possible โ
โ "Automate inventory updates" โ
โ โโโ USE THIS AGENT โ
โ โ
โ โบ Request already has clear technical specs โ
โ "Create Server Script on validate for Sales Invoice" โ
โ โโโ Skip agent, use relevant syntax/impl skills directly โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Interpretation Workflow
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ CODE INTERPRETER WORKFLOW โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ STEP 1: EXTRACT INTENT โ
โ โโโโโโโโโโโโโโโโโโโโโโโ โ
โ โข What is the business problem? โ
โ โข What should happen? When? To what data? โ
โ โข Who should be affected (roles/users)? โ
โ โ
โ STEP 2: IDENTIFY TRIGGER CONTEXT โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โข Document lifecycle event? (save/submit/cancel) โ
โ โข User action? (button click, field change) โ
โ โข Time-based? (daily, hourly, cron) โ
โ โข External event? (webhook, API call) โ
โ โ
โ STEP 3: DETERMINE MECHANISM โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โข Client Script, Server Script, or Controller? โ
โ โข Hooks configuration needed? โ
โ โข Custom app required? โ
โ โ
โ STEP 4: GENERATE SPECIFICATION โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โข DocType(s) involved โ
โ โข Event/trigger type โ
โ โข Implementation mechanism โ
โ โข Data flow โ
โ โข Error handling requirements โ
โ โข Version compatibility โ
โ โ
โ STEP 5: MAP TO SKILLS โ
โ โโโโโโโโโโโโโโโโโโโโโโ โ
โ โข List required skills for implementation โ
โ โข Note any dependencies between skills โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ See references/workflow.md for detailed workflow steps.
Mechanism Selection Matrix
Use this to determine WHICH mechanism fits the requirement:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ REQUIREMENT โ MECHANISM MAPPING โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ "Auto-calculate on form" โ
โ โโโ Client Script (refresh_field) + Server Script (validate) โ
โ โ
โ "Validate before save" โ
โ โโโ Server Script (Document Event: validate) โ
โ โ
โ "Send notification after submit" โ
โ โโโ Server Script (Document Event: on_submit) โ
โ โ
โ "Add button to form" โ
โ โโโ Client Script (custom_buttons) โ
โ โ
โ "Scheduled report/sync" โ
โ โโโ Server Script (Scheduler) or hooks.py scheduler_events โ
โ โ
โ "Filter list per user territory" โ
โ โโโ Server Script (Permission Query) โ
โ โ
โ "Custom REST API" โ
โ โโโ Server Script (API) or @frappe.whitelist() โ
โ โ
โ "Complex transaction with rollback" โ
โ โโโ Controller (custom app required) โ
โ โ
โ "External library needed" โ
โ โโโ Controller (custom app required) โ
โ โ
โ "Approval workflow" โ
โ โโโ Built-in Workflow + Server Script for custom logic โ
โ โ
โ "Print format customization" โ
โ โโโ Jinja template (Print Format) โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Clarifying Questions Framework
When a request is ambiguous, ask these questions:
1. WHAT Questions
โข What DocType(s) are involved?
โข What data needs to change?
โข What should the outcome be?
2. WHEN Questions
โข When should this happen?
- On form load?
- On field change?
- Before/after save?
- Before/after submit?
- On a schedule?
- When user clicks something?
3. WHO Questions
โข Who should this affect?
- All users?
- Specific roles?
- Document owner only?
โข Who should NOT be affected?
4. WHERE Questions
โข Where should changes appear?
- In the form (UI)?
- In the database only?
- In a report?
- In an external system?
5. ERROR Questions
โข What if the action fails?
- Block the operation?
- Show warning but continue?
- Log and continue silently?
โ See references/examples.md for interpretation examples.
Output Specification Template
Generate specifications in this format:
## Technical Specification
### Summary
[One sentence describing what will be built]
### Business Requirement
[The original user request, clarified]
### Implementation
| Aspect | Value |
|--------|-------|
| **DocType(s)** | [List] |
| **Trigger** | [Event/action] |
| **Mechanism** | [Client Script / Server Script / Controller / etc.] |
| **Version** | [v14 / v15 / v16 / all] |
### Data Flow
1. [Step 1]
2. [Step 2]
3. [Step 3]
### Error Handling
[How errors should be handled]
### Required Skills
- [ ] skill-name-1 - for [purpose]
- [ ] skill-name-2 - for [purpose]
### Validation Criteria
[How to verify the implementation works correctly]
Skill Dependencies Map
Based on the mechanism, these skills are needed:
| Mechanism | Required Skills |
|---|
| Client Script | erpnext-syntax-clientscripts, erpnext-impl-clientscripts, erpnext-errors-clientscripts |
| Server Script (Doc Event) | erpnext-syntax-serverscripts, erpnext-impl-serverscripts, erpnext-errors-serverscripts |
| Server Script (API) | erpnext-syntax-serverscripts, erpnext-api-patterns, erpnext-errors-api |
| Server Script (Scheduler) | erpnext-syntax-serverscripts, erpnext-syntax-scheduler, erpnext-impl-scheduler |
| Server Script (Permission) | erpnext-syntax-serverscripts, erpnext-permissions, erpnext-errors-permissions |
| Controller | erpnext-syntax-controllers, erpnext-impl-controllers, erpnext-errors-controllers |
| Hooks | erpnext-syntax-hooks, erpnext-impl-hooks, erpnext-errors-hooks |
| Custom App | erpnext-syntax-customapp, erpnext-impl-customapp |
| Jinja Template | erpnext-syntax-jinja, erpnext-impl-jinja |
| Database Operations | erpnext-database, erpnext-errors-database |
| Whitelisted Method | erpnext-syntax-whitelisted, erpnext-impl-whitelisted |
Common Pattern Recognition
Pattern: "Auto-calculate [field] based on [other fields]"
Interpretation:
โข Need real-time update on form โ Client Script
โข Need validated calculation on save โ Server Script (validate)
โข Usually BOTH for best UX
Specification:
- Client Script: field change triggers, refresh_field
- Server Script: validate event, same calculation as backup
Pattern: "Send email/notification when [condition]"
Interpretation:
โข After document action โ Server Script (on_update/on_submit)
โข Scheduled digest โ Server Script (Scheduler)
Specification:
- Use frappe.sendmail() or Notification DocType
- Consider: who receives, template, attachments
Pattern: "Prevent [action] if [condition]"
Interpretation:
โข Block save โ Server Script (validate) with frappe.throw()
โข Block submit โ Server Script (before_submit) with frappe.throw()
โข Block cancel โ Server Script (before_cancel) with frappe.throw()
Specification:
- Determine correct event (validate vs before_submit)
- Define clear error message for user
Pattern: "Sync with external system"
Interpretation:
โข Real-time sync on save โ Controller (needs requests library)
โข Batch sync โ Scheduler in hooks.py (needs requests library)
โข Cannot use Server Script (imports blocked)
Specification:
- Custom app REQUIRED
- Controller class or hooks.py scheduler_events
- Error handling for API failures
โ See references/examples.md for more patterns.
Version Awareness
Always consider version compatibility:
| Feature | v14 | v15 | v16 |
|---|
| Server Script sandbox | โ | โ | โ |
extend_doctype_class hook | โ | โ | โ |
| Chrome PDF rendering | โ | โ | โ |
| Data masking | โ | โ | โ |
| UUID naming rule | โ | โ | โ |
| Scheduler tick (seconds) | 240 | 60 | 60 |
Agent Output Checklist
Before completing interpretation, verify:
โ See references/checklists.md for detailed checklists.