frappe-core-utils

For scenarios using frappe.utils.* helper functions in Frappe v14–v16, covering date/time (e.g. nowdate, getdate, add_days, date_diff, pretty_date), numeric and money handling (e.g. flt, cint, fmt_money), string and validation (e.g. validate_email), and file path operations (e.g. get_files_path). Aims to avoid reinventing the wheel while preserving timezone-aware, localized formatting and multi-tenant behavior.

Last repository push
GitHub Stars
211
Forks
61
Issues / PRs
4

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "frappe-core-utils" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-3c84e52541ec684832e7e5ed1c9f3bde6bbc743759c8e442869eecb15f5ef2b8. Verify the upstream source and version against https://github.com/Impertio-Studio/Frappe_Claude_Skill_Package before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

For scenarios using frappe.utils.* helper functions in Frappe v14–v16, covering date/time (e.g. nowdate, getdate, add_days, date_diff, pretty_date), numeric and money handling (e.g. flt, cint, fmt_money), string and validation (e.g. validate_email), and file path operations (e.g. get_files_path). Aims to avoid reinventing the wheel while preserving timezone-aware, localized formatting and multi-tenant behavior.

0 Downloads

Introduction source: third_party · Impertio-Studio · 3.0 Reference

SkillPi interpretation

Tasks
ALL imports**: `from frappe.utils import nowdate, flt, ...` in controllers/whitelisted methods. In **Server Scripts**: Use `frappe.utils.nowdate()` directly — NO import statements allowed.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: frappe-core-utils
description: >
  Use when working with utility functions in Frappe v14-v16. Covers
  frappe.utils.* for date/time, number/money, string, validation, and
  file path operations. Prevents reinventing stdlib alternatives that
  break timezone awareness, locale formatting, or multi-tenancy.
  Keywords: frappe.utils, nowdate, flt, cint, fmt_money, getdate,, date calculation, format number, money format, validate email, how to calculate days between.
  add_days, date_diff, validate_email, pretty_date, get_files_path.
license: MIT
compatibility: "Claude Code, Claude.ai Projects, Claude API. Frappe v14-v16."
metadata:
  author: OpenAEC-Foundation
  version: "3.0"

Frappe Utility Functions

Quick Reference: Python

Need Function Returns
Current date nowdate() / today() datetime.date
Current datetime now_datetime() datetime.datetime
Parse date string getdate(str) datetime.date
Parse datetime string get_datetime(str) datetime.datetime
Add days add_days(date, n) datetime.date
Add months add_months(date, n) datetime.date
Date difference date_diff(end, start) int (days)
Format for user format_date(dt) str (user locale)
Relative time pretty_date(dt) str ("2 hours ago")
Safe float flt(val, precision) float
Safe int cint(val) int
Safe string cstr(val) str
Safe bool sbool(val) bool
Safe division safe_div(a, b) float [v15+]
Money format fmt_money(amt, currency) str
Money in words money_in_words(amt, cur) str
Strip HTML strip_html(text) str
List to prose comma_and(items) str ("a, b, and c")
Validate email validate_email_address(e) str or ""
Validate URL validate_url(url) bool
Parse JSON parse_json(s) Any
Files path get_files_path(is_private) str
Site path get_site_path(*parts) str
Unique list unique(seq) list
Hash generate_hash(s, length) str

ALL imports: from frappe.utils import nowdate, flt, ... in controllers/whitelisted methods. In Server Scripts: Use frappe.utils.nowdate() directly — NO import statements allowed.


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
datetime.datetime.now() now_datetime() Ignores system timezone
datetime.date.today() nowdate() Ignores system timezone
float(val) flt(val, precision) Crashes on None/empty
int(val) cint(val) Crashes on None/empty
round(val, 2) rounded(val, 2) Inconsistent rounding
val1 / val2 safe_div(val1, val2) ZeroDivisionError [v15+]
json.loads(s) parse_json(s) Crashes on None/empty
json.dumps(obj) frappe.as_json(obj) Inconsistent serialization
"{:,.2f}".format(a) fmt_money(a, currency) Ignores locale/currency
os.path.join(...) get_site_path(...) Breaks multi-tenancy
", ".join(items) comma_and(items) No localized "and"
dt.strftime(fmt) format_date(dt) Ignores user preference
re.sub(r'<.*?>', '', h) strip_html(h) 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 frappe.utils.escape_html(txt)
HTML to text frappe.utils.html2text(html)
Check if HTML frappe.utils.is_html(txt)
Parse JSON frappe.utils.parse_json(str)
Validate URL frappe.utils.is_url(txt)
Title case frappe.utils.to_title_case(str)
Join with "and" frappe.utils.comma_and(list)
Unique array frappe.utils.unique(list)
Copy clipboard frappe.utils.copy_to_clipboard(txt)
Scroll to element frappe.utils.scroll_to(el)
Is mobile frappe.utils.is_mobile()
Throttle frappe.utils.throttle(fn, delay)
Debounce frappe.utils.debounce(fn, delay)
Format value frappe.format(value, df, options, doc)
Duration display frappe.utils.get_formatted_duration(secs)

Version Differences

Function v14 v15 v16
safe_div() -- Added Yes
duration_to_seconds() -- Added Yes
guess_date_format() -- Added Yes
validate_duration_format() -- Added Yes
mask_string() -- -- Added
validate_iban() -- -- Added
validate_name() -- -- Added
safe_json_loads() -- -- Added
groupby_metric() -- -- Added
Core functions Yes Yes Yes

Reference Files

Version history

  1. v3.1.1 GitHub ↗
    Original release notes

    ## What's new Expanded Keywords in all skill descriptions with user-friendly, non-technical discovery terms. Skills are now easier to find when users describe problems in plain language instead of technical terminology. Examples of added terms: - Symptom-based: "app is slow", "nothing shows", "container won't start" - Beginner-friendly: "how do I start", "what is", "getting started" - Error messages: literal error text users would paste - Alternative names: common synonyms and abbreviations No skill content was changed. Only the Keywords line in SKILL.md frontmatter was expanded.

  2. v3.1.0 GitHub ↗
    Original release notes

    ## What's new - package.json with agents.skills[] manifest for external discovery (60 skills) - agents/openai.yaml for OpenAI Codex - GitHub topic agentskills added - SKILLS_LOG.md added to .gitignore - Em-dashes replaced with colons in 31 SKILL.md section headings Enables discovery via npx skills add, skills.sh, LobeHub, and other platforms.

  3. v3.0.0 GitHub ↗
    Original release notes

    ## Summary - **60 deterministic skills** for Frappe Framework v14-v16 (up from 53 in v2.0) - **~95% surface area coverage** (up from ~85%) - 7 new skills + 12 existing skills extended with new reference files ## New Skills (7) | Skill | Category | Coverage | |-------|----------|----------| | `frappe-core-translation` | core | i18n, _(), __(), CSV/PO files, string extraction | | `frappe-core-utils` | core | 140+ date, number, string, validation functions | | `frappe-syntax-print` | syntax | Print formats, PDF generation, Letter Head | | `frappe-syntax-query-builder` | syntax | frappe.qb, joins, aggregation, cross-DB | | `frappe-impl-workspace` | impl | Workspace builder, number cards, charts | | `frappe-core-logging` | core | frappe.logger(), Error Log, Sentry integration | | `frappe-core-search` | core | Link search, global search, SQLiteSearch FTS5 | ## Extended Skills (12) 13 new reference files added to existing skills covering: Controls API, Tree View, Portal Generators, Print Format decision tree, Email system, Module/Workspace shipping, complete Document API, custom bench commands, request lifecycle, advanced debugging (VS Code DAP), Frappe Packages, data masking (v16+), and Python type stubs. ## Stats | Category | Count | |----------|:-----:| | syntax/ | 13 | | core/ | 11 | | impl/ | 14 | | errors/ | 7 | | ops/ | 8 | | agents/ | 5 | | testing/ | 2 | | **Total** | **60** | ## Install ```bash git clone https://github.com/OpenAEC-Foundation/Frappe_Claude_Skill_Package.git cp -r Frappe_Claude_Skill_Package/skills/source/* ~/.claude/skills/ ```

  4. v2.0.0 GitHub ↗
    Original release notes

    ## Frappe Claude Skill Package v2.0.0 Massive upgrade from 28 ERPNext-specific skills to **53 Frappe Framework skills** covering ~85% of the Frappe surface area. ### What's New - **25 new skills** across 3 new categories (ops, testing, agents) - **28 existing skills** fully rewritten with fresh research - **Renamed** from `erpnext-*` to `frappe-*` (all skills are Frappe Framework, not ERPNext-specific) - **7 categories**: syntax (11), core (7), impl (13), errors (7), ops (8), agents (5), testing (2) ### New Categories - **ops/** — Bench CLI, deployment, backup, performance, upgrades, frontend build, cloud - **testing/** — Unit/integration tests, CI/CD with GitHub Actions - **3 new agents** — debugger, migrator, architect ### Key Improvements - All skills verified against official Frappe docs (March 2026) - v16 features documented: `extend_doctype_class`, data masking, type annotations - MIT license (was LGPL-3.0) - Deterministic language throughout (ALWAYS/NEVER) 🤖 Generated with [Claude Code](https://claude.com/claude-code)

  5. v1.1.0 GitHub ↗
    Original release notes

    V16 compatibility update and documentation improvements. ## Added - USAGE.md with platform-specific guides (Claude.ai, Claude Code, API) - Complete README overhaul with quick start guide ## Changed - All 28 skills updated for ERPNext/Frappe V16 compatibility - Agent Skills now follow standard skill structure - Improved validation: 28/28 skills pass all checks ## Fixed - V16-specific syntax changes in 9 skills - Agent SKILL.md files now under 500 lines

Only the five most recent versions are shown. View full version history at the source ↗

Current listing version

3.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 提供 Frappe v14-v16 核心工具函数的全面指南
  • 涵盖日期时间、数字金额、字符串处理、验证和文件路径等高频场景
  • 有效帮助开发者避免常见反模式和错误
Trigger Precision95/100

Highlights

  • 触发词精准完整,覆盖具体函数名和使用场景
  • 关键词列表详尽,边界清晰,便于准确触发
Structure and Standards88/100

Areas to improve

  • 缺少显式 When to Use 章节 Reported severity: Minor

    文档结构完整但缺少显式的 When to Use 章节标题

    Recommendation: 建议添加显式的 When to Use 章节以提升规范性

Highlights

  • 文档结构清晰,包含快速参考、决策树、反模式对比等完整章节
  • frontmatter 完整,兼容性说明清晰
Execution Reliability82/100

Areas to improve

  • 缺少端到端代码示例 Reported severity: Minor

    提供了函数参考但未包含完整的端到端使用示例

    Recommendation: 建议添加完整的端到端代码示例以提升执行可靠性

Highlights

  • 提供了具体的导入方式和使用注意事项
  • 详细说明了 Server Script 中的特殊用法
  • stdlib 与 frappe.utils 对比清晰,指导性强
Evidence Verifiability (mean of the first four)88/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.