openaec-foundation/frappe_claude_skill_package/frappe-impl-serverscripts
Claude Code and agent skill by openaec-foundation/frappe_claude_skill_package
- community
Checking that the SKILL.md file is still in the repository.
Use when implementing server-side features via Setup > Server Script: document validation, auto-fill, API endpoints, scheduled tasks, permission queries. Covers sandbox-safe coding, script type selection, testing, migration to controllers. Keywords: how to implement server script, which script type, sandbox limitation, Document Event, API script, Scheduler Event, Permission Query, migrate to controller, no-code automation, run code on save, auto-fill field, server-side validation, scheduled script.
Install
npx vskill@latest install openaec-foundation/frappe_claude_skill_package/frappe-impl-serverscriptsSKILL.md
The same SKILL.md was published earlier as openaec-foundation/frappe_claude_skill_package/frappe-impl-serverscripts.
Server Scripts — Implementation Workflows
Step-by-step workflows for building server-side features without a custom app. For exact syntax, see frappe-syntax-serverscripts.
Version: v14/v15/v16 | v15+ Note: Server Scripts disabled by default — enable with bench set-config server_script_enabled true
CRITICAL: Sandbox Limitations
Rule: If you need import statements beyond json, ALWAYS use a Controller instead.
Workflow 1: Create a Server Script
- Enable server scripts:
bench set-config server_script_enabled true - Navigate to Setup > Server Script (or awesomebar: "New Server Script")
- Select Script Type (see decision tree below)
- Configure type-specific settings (DocType, event, API method, cron)
- Write script in the editor
- Save — script is active immediately
- Test by triggering the configured event
- Use "Compare Versions" button to diff changes
Workflow 2: Choose the Script Type
See references/decision-tree.md for complete decision tree.
Workflow 3: Document Event: Validation
Goal: Validate Sales Order before save.
Step 1: Choose event — "Before Save" maps to validate hook.
Step 2: Write sandbox-safe script:
Rules:
- ALWAYS collect errors and throw once (better UX than multiple throws)
- NEVER call
doc.save()in Before Save — framework handles it - ALWAYS use
frappe.throw()—msgprintdoes NOT stop save
Workflow 4: Document Event: Auto-Calculate
Goal: Auto-calculate totals and set derived fields.
Rule: ALWAYS modify doc fields directly in Before Save — they are automatically persisted.
Workflow 5: Document Event: Create Related Document
Goal: Create a ToDo when a new Lead is inserted.
Rules:
- ALWAYS use After Insert or After Save for creating related docs
- NEVER create documents in Before Save —
doc.namemay not exist yet - ALWAYS use
ignore_permissions=Truefor system-generated documents
Workflow 6: API Endpoint
Goal: Create authenticated REST API returning customer data.
Rules:
- ALWAYS validate input parameters
- ALWAYS check permissions (even with Allow Guest: No)
- ALWAYS cap query limits:
min(frappe.utils.cint(limit), 100) - NEVER expose full documents — return only needed fields
Workflow 7: Scheduler Event
Goal: Daily reminder for overdue invoices.
Rules:
- ALWAYS add
frappe.db.commit()at end of scheduler scripts - ALWAYS add
limitto queries — prevent memory exhaustion - ALWAYS use
try/except+frappe.log_error()in loops - NEVER run scheduler scripts that process unlimited records
Workflow 8: Permission Query
Goal: Users see only their territory's customers.
Rules:
- ALWAYS give System Manager full access (
conditions = "") - ALWAYS use
frappe.db.escape()for user input in SQL - ALWAYS set
conditionsvariable — it is the output - Permission Query only affects
frappe.db.get_list, NOTfrappe.db.get_all
Event Name Mapping
| UI Name | Internal Hook | Best For | |
|---|---|---|---|
| Before Validate | before_validate | Pre-validation defaults | |
| Before Save | `validate` | Validation + calculations (MOST COMMON) | |
| After Save | on_update | Notifications, audit logs | |
| After Insert | after_insert | Create related docs (new only) | |
| Before Submit | before_submit | Submit-time validation | |
| After Submit | on_submit | Post-submit automation | |
| Before Cancel | before_cancel | Cancel prevention | |
| After Cancel | on_cancel | Cleanup after cancel | |
| Before Delete | on_trash | Delete prevention |
Sandbox-Safe API Quick Reference
| Need | Use (NOT import) | |
|---|---|---|
| Parse JSON | frappe.parse_json() or json.loads() | |
| Serialize JSON | frappe.as_json() or json.dumps() | |
| Today's date | frappe.utils.today() | |
| Now (datetime) | frappe.utils.now() | |
| Add days | frappe.utils.add_days(date, n) | |
| Date diff | frappe.utils.date_diff(d1, d2) | |
| Float conversion | frappe.utils.flt(val) | |
| Int conversion | frappe.utils.cint(val) | |
| HTTP GET | frappe.make_get_request(url) | |
| HTTP POST | frappe.make_post_request(url, data) | |
| Render template | frappe.render_template(tmpl, ctx) | |
| Log error | frappe.log_error(msg, title) | |
| Send email | frappe.sendmail(recipients, subject, message) |
When to Migrate to Controller
ALWAYS migrate to a Document Controller when:
- You need
importstatements (beyondjson) - Script exceeds 100 lines
- You need try/except with rollback
- You need
frappe.enqueue()for background jobs - You need to extend an existing ERPNext DocType
- Multiple scripts on same DocType become hard to manage
Migration path: See frappe-impl-controllers for controller implementation.
Related Skills
frappe-syntax-serverscripts— Exact sandbox API referencefrappe-errors-serverscripts— Error handling and anti-patternsfrappe-core-database—frappe.db.*operationsfrappe-core-permissions— Permission system detailsfrappe-impl-controllers— When to migrate from Server Script
See references/decision-tree.md for complete decision trees.See references/workflows.md for extended patterns.See references/examples.md for 10+ complete examples.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/source/impl/frappe-impl-serverscripts/SKILL.md
Popularity
- Repository stars
- 88
- Repository forks
- 25
- 7-day trend score
- 22
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 29 Apr 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/openaec-foundation/frappe_claude_skill_package/frappe-impl-serverscripts)