Frappe_Claude_Skill_Package frappe-agent-debugger
install
source · Clone the upstream repo
git clone https://github.com/OpenAEC-Foundation/Frappe_Claude_Skill_Package
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/OpenAEC-Foundation/Frappe_Claude_Skill_Package "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/source/agents/frappe-agent-debugger" ~/.claude/skills/openaec-foundation-frappe-claude-skill-package-frappe-agent-debugger && rm -rf "$T"
manifest:
skills/source/agents/frappe-agent-debugger/SKILL.mdsource content
Frappe Debugging Agent
Systematically diagnoses Frappe/ERPNext issues by classifying errors, locating relevant code, and applying targeted diagnosis checklists.
Purpose: Eliminate trial-and-error debugging — follow a deterministic diagnostic workflow.
When to Use This Agent
ERROR ANALYSIS TRIGGER | +-- Python traceback or error message | "ImportError: cannot import name X from frappe" | --> USE THIS AGENT | +-- JavaScript console error | "Uncaught TypeError: frm.set_value is not a function" | --> USE THIS AGENT | +-- Silent failure (no error, wrong behavior) | "Server Script runs but nothing happens" | --> USE THIS AGENT | +-- Scheduler/background job failure | "Job X failed" in scheduler logs | --> USE THIS AGENT | +-- Build/asset errors | "Module not found" or blank page after build | --> USE THIS AGENT
Debugging Workflow
STEP 1: CLASSIFY ERROR TYPE Python | JavaScript | Database | Permission | Hook | Scheduler | Build STEP 2: IDENTIFY THE MECHANISM Controller | Server Script | Client Script | Hook | Scheduler | API STEP 3: LOCATE RELEVANT CODE Use Frappe file path conventions to find source STEP 4: APPLY DIAGNOSIS CHECKLIST Run type-specific checklist for the error class STEP 5: SUGGEST FIX Provide corrected code + reference relevant frappe-* skills
See references/workflow.md for detailed steps.
Step 1: Error Classification
| Error Type | Indicators | Primary Tool |
|---|---|---|
| Python | Traceback with files | , logs |
| JavaScript | Browser console error, issues | Browser DevTools |
| Database | , | |
| Permission | , 403 responses | Permission Inspector |
| Hook | Errors after , wrong events | |
| Scheduler | warnings, RQ failures | Scheduler logs |
| Build | Missing assets, blank page, module errors | |
Step 2: Mechanism Identification
| Symptom | Likely Mechanism |
|---|---|
| Error during form save/submit | Controller or Server Script (validate/on_submit) |
| Error on page load | Client Script or Web Template |
| Error message from API call | Whitelisted method or REST API handler |
| Error in background | Scheduler event or job |
Error after | Hook configuration or patch |
Error after | Frontend asset pipeline |
Step 3: File Path Conventions
ALWAYS check these locations based on the mechanism:
| Mechanism | File Path Pattern |
|---|---|
| Controller | |
| Server Script | Desk > Server Script list (stored in DB) |
| Client Script | Desk > Client Script list (stored in DB) |
| hooks.py | |
| Scheduler | or hooks.py |
| Whitelisted | (search for ) |
| Jinja | |
| Patches | |
Step 4: Diagnosis Checklists (Quick Reference)
Python Errors
| Error Pattern | Likely Cause | Fix |
|---|---|---|
| returned None | Check document exists first |
| in validate | Read the message — it IS the diagnosis |
| Wrong import path or Server Script using imports | Server Scripts CANNOT import |
| Referenced document does not exist | Verify Link field target exists |
| Concurrent edit conflict | Reload document before save |
| Unique constraint violation | Check naming series or unique fields |
| Required field is empty | Set field before save/submit |
| Wrong docstatus transition | Follow 0→1→2 sequence |
| Self-referencing parent-child | Fix document hierarchy |
JavaScript Errors
| Error Pattern | Likely Cause | Fix |
|---|---|---|
| Wrong API or stale code | Clear cache, check API name |
| Code runs outside form context | Use from handler parameter |
| Missing async/await on | Add callback or await |
in | Field does not exist on DocType | Check fieldname spelling |
| Form not refreshing | Missing | Add refresh after |
Database Errors
| Error Pattern | Likely Cause | Fix |
|---|---|---|
| Column does not exist | Run |
| Table does not exist | Run |
| Duplicate primary key | Check naming/autoname |
| Foreign key violation | Linked document missing |
| Deadlock | Reduce transaction scope |
| Invalid character for charset | Check input encoding |
Permission Errors
| Error Pattern | Likely Cause | Fix |
|---|---|---|
| User lacks role permission | Check Role Permission Manager |
| 403 on API call | Missing or wrong | Add permission check or guest flag |
| Empty list view | User Permissions filtering | Check User Permission for that user |
| Cannot submit | No Submit permission for role | Add Submit perm in DocType |
Debug Tools
bench console (Python REPL)
bench --site {site} console # Then: frappe.get_doc("Sales Invoice", "SINV-00001") # Inspect document frappe.db.sql("SELECT name FROM `tabSales Invoice` LIMIT 5") # Raw SQL frappe.get_hooks("doc_events") # Inspect active hooks frappe.get_all("Server Script", filters={"disabled": 0}, fields=["name", "script_type"])
bench mariadb (SQL shell)
bench --site {site} mariadb -- Then: SHOW CREATE TABLE `tabSales Invoice`; SELECT * FROM `tabError Log` ORDER BY creation DESC LIMIT 10;
bench doctor
bench doctor # Check scheduler, workers, background jobs
frappe.logger()
logger = frappe.logger("my_debug", allow_site=True) logger.info(f"Variable value: {my_var}") # Logs to: sites/{site}/logs/my_debug.log
Browser DevTools
Console tab → JavaScript errors Network tab → Failed API calls (check response body for traceback) Application tab → Session/cookie issues
Log File Locations
| Log | Path | Contains |
|---|---|---|
| Frappe web | | Web request errors |
| Worker | | Background job errors |
| Scheduler | | Scheduled task output |
| Custom logger | | output |
| Bench | | Bench command output |
| Error Log DocType | Desk > Error Log | UI-accessible error records |
| Supervisor | | Process manager logs |
| nginx | | HTTP request/proxy errors |
Common Error Patterns Table
| Error Message | Likely Cause | Fix | Relevant Skill |
|---|---|---|---|
| Using in Server Script | Use or move to Controller | |
| JS accessing field before form load | Add null check | |
| Missing app install or migration | or | |
| Workers stopped | , restart workers | |
| gunicorn timeout on long operation | Use for long tasks | |
| Python package not installed | | |
| Name collision in naming series | Check autoname or naming_series | |
| Missing role for operation | Check Role Permissions | |
| Modifying docstatus=1 doc | Use or cancel first | |
| Schema out of sync | | |
Agent Output Format
ALWAYS produce debugging output in this format:
## Debug Report ### Error Classification **Type**: [Python/JS/Database/Permission/Hook/Scheduler/Build] **Mechanism**: [Controller/Server Script/Client Script/Hook/etc.] ### Root Cause [One-sentence diagnosis] ### Evidence - [What log/traceback line confirms this] - [What code path is involved] ### Fix [Corrected code or configuration change] ### Verification Steps 1. [How to confirm the fix works] 2. [What to check in logs/UI] ### Referenced Skills - `frappe-*`: [what was consulted]
Debugging Decision Tree
ERROR RECEIVED | +-- Has traceback? | +-- YES: Read LAST line first (actual error) | | +-- Contains ".py" --> Python error (Step 4: Python checklist) | | +-- Contains "SQL" --> Database error (Step 4: Database checklist) | +-- NO: Check browser console | +-- Has JS error --> JavaScript error (Step 4: JS checklist) | +-- No error visible --> Silent failure | +-- Check Error Log DocType | +-- Check frappe.log | +-- Add frappe.logger() statements | +-- Error after bench command? | +-- After migrate --> Hook/schema issue | +-- After build --> Frontend asset issue | +-- After update --> Version compatibility issue | +-- Intermittent error? +-- Check scheduler logs +-- Check worker logs +-- Check for race conditions (TimestampMismatchError)
See references/checklists.md for complete diagnosis checklists. See references/examples.md for debugging walkthrough examples. See references/advanced-debugging.md for VS Code DAP setup, bench console patterns, mariadb diagnostics, and profiling tools.