Frappe_Claude_Skill_Package frappe-core-utils
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/core/frappe-core-utils" ~/.claude/skills/openaec-foundation-frappe-claude-skill-package-frappe-core-utils && rm -rf "$T"
manifest:
skills/source/core/frappe-core-utils/SKILL.mdsource content
Frappe Utility Functions
Quick Reference: Python
| Need | Function | Returns |
|---|---|---|
| Current date | / | |
| Current datetime | | |
| Parse date string | | |
| Parse datetime string | | |
| Add days | | |
| Add months | | |
| Date difference | | (days) |
| Format for user | | (user locale) |
| Relative time | | ("2 hours ago") |
| Safe float | | |
| Safe int | | |
| Safe string | | |
| Safe bool | | |
| Safe division | | [v15+] |
| Money format | | |
| Money in words | | |
| Strip HTML | | |
| List to prose | | ("a, b, and c") |
| Validate email | | or |
| Validate URL | | |
| Parse JSON | | |
| Files path | | |
| Site path | | |
| Unique list | | |
| Hash | | |
ALL imports:
in controllers/whitelisted methods. In Server Scripts: Usefrom frappe.utils import nowdate, flt, ...directly — NO import statements allowed.frappe.utils.nowdate()
Decision Tree: "Which function do I use?"
Need a date/time value? ├─ Current date → nowdate() or today() ├─ Current datetime → now_datetime() ├─ Parse a string → getdate() or get_datetime() ├─ Add/subtract time → add_days(), add_months(), add_to_date() ├─ Difference → date_diff() (days), month_diff(), time_diff_in_seconds() ├─ Period boundary → get_first_day(), get_last_day(), get_quarter_start() └─ Display to user → format_date(), format_datetime(), pretty_date() Need a number? ├─ Convert safely → flt(), cint(), cstr(), sbool() ├─ Round → rounded() (banker's rounding) ├─ Safe divide → safe_div(a, b, default=0) [v15+] ├─ Format money → fmt_money(amount, currency) └─ Money to words → money_in_words(amount, currency) Need string processing? ├─ HTML → strip_html(), escape_html(), is_html() ├─ Join list → comma_and(), comma_or(), comma_sep() ├─ Markdown ↔ HTML → to_markdown(), md_to_html() └─ Mask sensitive → mask_string(input, show_first=4) [v16+] Need validation? ├─ Email → validate_email_address(email, throw=False) ├─ URL → validate_url(url, valid_schemes=["https"]) ├─ Phone → validate_phone_number(phone, throw=False) ├─ JSON → validate_json_string(s) └─ IBAN → validate_iban(iban) [v16+] Need file/path? ├─ Public files → get_files_path() ├─ Private files → get_files_path(is_private=True) ├─ Site directory → get_site_path("private", "backups") ├─ Bench root → get_bench_path() └─ File size → get_file_size(path, format=True)
Critical Anti-Patterns
NEVER use Python stdlib when frappe.utils exists
| NEVER (stdlib) | ALWAYS (frappe.utils) | Why |
|---|---|---|
| | Ignores system timezone |
| | Ignores system timezone |
| | Crashes on None/empty |
| | Crashes on None/empty |
| | Inconsistent rounding |
| | ZeroDivisionError [v15+] |
| | Crashes on None/empty |
| | Inconsistent serialization |
| | Ignores locale/currency |
| | Breaks multi-tenancy |
| | No localized "and" |
| | Ignores user preference |
| | Misses edge cases |
Server Script Sandbox
# ❌ NEVER in Server Scripts from frappe.utils import nowdate, flt import json # ✅ ALWAYS in Server Scripts (no imports allowed) today = frappe.utils.nowdate() amount = frappe.utils.flt(doc.amount, 2) data = frappe.parse_json(doc.json_field)
JavaScript Quick Reference
| Need | Function |
|---|---|
| Escape HTML | |
| HTML to text | |
| Check if HTML | |
| Parse JSON | |
| Validate URL | |
| Title case | |
| Join with "and" | |
| Unique array | |
| Copy clipboard | |
| Scroll to element | |
| Is mobile | |
| Throttle | |
| Debounce | |
| Format value | |
| Duration display | |
Version Differences
| Function | v14 | v15 | v16 |
|---|---|---|---|
| -- | Added | Yes |
| -- | Added | Yes |
| -- | Added | Yes |
| -- | Added | Yes |
| -- | -- | Added |
| -- | -- | Added |
| -- | -- | Added |
| -- | -- | Added |
| -- | -- | Added |
| Core functions | Yes | Yes | Yes |
Reference Files
- Date/Time Functions — Complete date/time API with signatures
- Number & Money Functions — flt, fmt_money, rounding
- String & Validation Functions — HTML, join, validate
- JavaScript Utilities — Client-side frappe.utils.*
- Anti-patterns — stdlib vs frappe.utils comparison