> Use when configuring Frappe hooks.py for app events, scheduler tasks, document events, fixtures, boot session, jenv customization, or website hooks.py, doc_events, scheduler_events, fixtures, app_include_js, override_whitelisted_methods, extend_doctype_class, hooks.py example, how to register hook, available hooks list, extend_doctype_class example.
npx skills add https://github.com/Impertio-Studio/Frappe_Claude_Skill_Package --skill frappe-syntax-hooks
Configuration hooks in hooks.py enable custom apps to extend Frappe/ERPNext
behavior. This skill covers ALL non-document-event hooks. For doc_events
(validate, on_submit, on_update, etc.), see frappe-syntax-hooks-events.
| Category | Key Hooks | Reference |
|----------|-----------|-----------|
| App metadata | app_name, app_title, required_apps | Below |
| Frontend assets | app_include_js/css, web_include_js/css | Below |
| Install/migrate | before_install, after_install, after_migrate | Below |
| Scheduler | hourly, daily, cron, *_long | scheduler-events.md |
| Session/auth | on_login, on_logout, auth_hooks | bootinfo.md |
| Request middleware | before_request, after_request | request-lifecycle.md |
| Permissions | permission_query_conditions, has_permission | permissions.md |
| DocType overrides | override_doctype_class, doctype_js | overrides.md |
| Website/portal | website_route_rules, portal_menu_items | request-lifecycle.md |
| File handling | before_write_file, write_file | Below |
| Email | override_email_send, default_mail_footer | Below |
| PDF | pdf_header_html, pdf_footer_html | Below |
| Jinja | jinja.methods, jinja.filters | Below |
| Boot/client data | extend_bootinfo, notification_config | bootinfo.md |
| Data/fixtures | fixtures, global_search_doctypes | Below |
| Method overrides | override_whitelisted_methods, standard_queries | overrides.md |
What do you want to achieve?
|
+-- ADD JS/CSS to desk or portal?
| +-- Desk --> app_include_js / app_include_css
| +-- Portal --> web_include_js / web_include_css
| +-- Specific form --> doctype_js
| +-- List view --> doctype_list_js
|
+-- RUN periodic background tasks?
| +-- < 5 min execution --> hourly / daily / weekly / monthly
| +-- 5-25 min execution --> hourly_long / daily_long / etc.
| +-- Exact time needed --> cron
| See: frappe-syntax-hooks > scheduler-events.md
|
+-- SEND data to client at page load?
| +-- extend_bootinfo
|
+-- MODIFY controller of existing DocType?
| +-- v16+ --> extend_doctype_class (RECOMMENDED)
| +-- v14/v15 --> override_doctype_class (last app wins)
|
+-- MODIFY API endpoint?
| +-- override_whitelisted_methods
|
+-- CUSTOMIZE permissions?
| +-- List filtering --> permission_query_conditions
| +-- Document-level --> has_permission
|
+-- REACT to document save/submit/delete?
| +-- See frappe-syntax-hooks-events skill
|
+-- EXPORT/IMPORT configuration?
| +-- fixtures
|
+-- SETUP on install or migrate?
| +-- after_install / after_migrate
|
+-- ADD custom Jinja functions?
| +-- jinja.methods / jinja.filters
|
+-- CUSTOMIZE website routing?
| +-- website_route_rules
| See: request-lifecycle.md for full routing pipeline
|
+-- INTERCEPT every request/response?
| +-- before_request / after_request
| See: request-lifecycle.md for lifecycle flow
|
+-- CUSTOM page rendering?
| +-- page_renderer hook
| See: request-lifecycle.md for renderer architecture
ALWAYS include these in every hooks.py:
app_name = "myapp"
app_title = "My App"
app_publisher = "My Company"
app_description = "Custom ERPNext extensions"
app_email = "[email protected]"
app_license = "MIT"
required_apps = ["erpnext"] # Declare dependencies
# Desk (backend UI) assets — loaded on EVERY desk page
app_include_js = "/assets/myapp/js/myapp.min.js" # string or list
app_include_css = "/assets/myapp/css/myapp.min.css"
# Website/portal assets — loaded on EVERY web page
web_include_js = "/assets/myapp/js/web.min.js"
web_include_css = "/assets/myapp/css/web.min.css"
# Web form specific assets
webform_include_js = {"My Web Form": "public/js/my_webform.js"}
webform_include_css = {"My Web Form": "public/css/my_webform.css"}
# Form script extensions (extend OTHER apps' forms)
doctype_js = {"Sales Invoice": "public/js/sales_invoice.js"}
# List view script extensions
doctype_list_js = {"Sales Invoice": "public/js/sales_invoice_list.js"}
# Custom sounds
sounds = [{"name": "alert", "src": "/assets/myapp/sounds/alert.mp3", "volume": 0.5}]
NEVER put heavy libraries in app_include_js — they load on every page.
before_install = "myapp.setup.before_install"
after_install = "myapp.setup.after_install"
after_sync = "myapp.setup.after_sync" # After fixture sync
before_migrate = "myapp.setup.before_migrate"
after_migrate = "myapp.setup.after_migrate"
before_uninstall = "myapp.setup.before_uninstall"
after_uninstall = "myapp.setup.after_uninstall"
before_tests = "myapp.setup.seed_test_data"
All accept a single dotted-path string. The function receives no arguments.
See scheduler-events.md for full reference.
scheduler_events = {
"all": ["myapp.tasks.every_minute"], # ~60s interval
"hourly": ["myapp.tasks.hourly_check"], # default queue, 5 min timeout
"daily": ["myapp.tasks.daily_report"],
"weekly": ["myapp.tasks.weekly_cleanup"],
"monthly": ["myapp.tasks.monthly_summary"],
"daily_long": ["myapp.tasks.heavy_sync"], # long queue, 25 min timeout
"cron": {
"0 9 * * 1-5": ["myapp.tasks.weekday_morning"] # cron expression
}
}
ALWAYS run bench --site sitename migrate after changing scheduler_events.
NEVER define task functions with arguments — they receive none.
on_login = "myapp.auth.on_login" # Receives login_manager
on_logout = "myapp.auth.on_logout" # No arguments
on_session_creation = "myapp.auth.on_session_creation" # No arguments
auth_hooks = ["myapp.auth.validate_request"] # List of validators
Execution order: on_login --> session created --> on_session_creation --> extend_bootinfo.
See request-lifecycle.md for the full request
lifecycle flow, page renderer architecture, and router API.
before_request = ["myapp.middleware.before_request"] # List of dotted paths
after_request = ["myapp.middleware.after_request"]
before_job = ["myapp.middleware.before_job"] # Before background job
after_job = ["myapp.middleware.after_job"] # After background job
See permissions.md for full reference.
permission_query_conditions = {
"Sales Invoice": "myapp.permissions.si_query_conditions"
}
has_permission = {
"Sales Invoice": "myapp.permissions.si_has_permission"
}
ALWAYS check if not user: user = frappe.session.user in handlers.
ALWAYS use frappe.db.escape(user) in SQL — NEVER string interpolation.
permission_query_conditions works ONLY with get_list, NOT get_all.
See overrides.md for full reference.
# v14+ — Full replacement (LAST installed app wins)
override_doctype_class = {
"Sales Invoice": "myapp.overrides.CustomSalesInvoice"
}
# v16+ — Mixin-based extension (ALL apps coexist) [RECOMMENDED]
extend_doctype_class = {
"Address": ["myapp.extensions.AddressMixin"]
}
ALWAYS call super().method() in overrides. Forgetting super() breaks core logic.
# URL routing
website_route_rules = [
{"from_route": "/custom-page/<name>", "to_route": "Custom Page"}
]
website_redirects = [
{"source": "/old-url", "target": "/new-url"}
]
website_catch_all = "myapp.www.custom_404"
# Homepage
homepage = "my-custom-home"
role_home_page = {"Sales User": "sales-dashboard"}
get_website_user_home_page = "myapp.utils.get_home_page"
# Portal sidebar
portal_menu_items = [{"title": "My Orders", "route": "/orders", "role": "Customer"}]
standard_portal_menu_items = [{"title": "My Items", "route": "/my-items"}]
# Template overrides
base_template = "myapp/templates/base.html"
website_context = {"brand_html": "<b>My Brand</b>"}
update_website_context = "myapp.context.update_context"
before_write_file = "myapp.files.before_write" # Pre-save hook
write_file = "myapp.files.custom_write" # Replace file storage (e.g., S3/CDN)
delete_file_data_content = "myapp.files.custom_delete" # Replace file deletion
Use write_file to redirect file storage to cloud providers (S3, GCS, Azure Blob).
override_email_send = "myapp.email.custom_send" # Replace email backend
get_sender_details = "myapp.email.get_sender" # Override From address
default_mail_footer = "myapp.email.get_footer" # HTML footer for all emails
pdf_header_html = "myapp.pdf.get_header" # Custom PDF header
pdf_body_html = "myapp.pdf.get_body" # Custom PDF body wrapper
pdf_footer_html = "myapp.pdf.get_footer" # Custom PDF footer
# pdf_generator = "myapp.pdf.generate" # [v16+] Replace PDF engine
# Add custom methods available in Jinja templates
jinja = {
"methods": ["myapp.jinja_utils.get_balance"],
"filters": ["myapp.jinja_utils.format_iban"]
}
# myapp/jinja_utils.py
def get_balance(customer):
"""Usage in template: {{ get_balance(doc.customer) }}"""
return frappe.db.get_value("Customer", customer, "outstanding_amount") or 0
def format_iban(value):
"""Usage in template: {{ bank_account|format_iban }}"""
if not value: return ""
return " ".join([value[i:i+4] for i in range(0, len(value), 4)])
See bootinfo.md for full reference.
extend_bootinfo = "myapp.boot.extend_boot"
notification_config = "myapp.notifications.get_config"
NEVER put secrets/API keys in bootinfo — it is sent to the browser.
NEVER run heavy queries in bootinfo — it runs on EVERY page load.
fixtures = [
{"dt": "Custom Field", "filters": [["module", "=", "My App"]]},
{"dt": "Property Setter", "filters": [["module", "=", "My App"]]},
{"dt": "Role", "filters": [["name", "like", "MyApp%"]]}
]
global_search_doctypes = {"My DocType": {"index": 10}}
ignore_links_on_delete = ["Communication", "Activity Log"]
calendars = ["My Event DocType"]
clear_cache = "myapp.cache.clear_custom_cache"
ALWAYS use filters in fixtures — NEVER export unfiltered (exports everything).
NEVER put transactional data (Sales Invoice, Stock Entry) in fixtures.
See overrides.md for full reference.
override_whitelisted_methods = {
"frappe.client.get_count": "myapp.overrides.custom_get_count"
}
standard_queries = {
"Customer": "myapp.queries.customer_query"
}
ALWAYS match the original method signature exactly when overriding.
| Hook | v14 | v15 | v16+ |
|------|-----|-----|------|
| extend_doctype_class | -- | -- | NEW |
| extend_bootinfo | Yes | Yes | Yes |
| auth_hooks | Yes | Yes | Yes |
| after_sync | Yes | Yes | Yes |
| before_uninstall | -- | Yes | Yes |
| after_uninstall | -- | Yes | Yes |
| website_path_resolver | -- | Yes | Yes |
| All other hooks | Yes | Yes | Yes |
bench --site sitename migrate after ANY hooks.py change"myapp.module.function") — NEVER lambdas| Wrong | Correct |
|-------|---------|
| No filters in fixtures | ALWAYS filter by module/app |
| Secrets in bootinfo | ONLY public config in bootinfo |
| Heavy queries in bootinfo | Cache or minimize data |
| get_all with permission hooks | Use get_list for permission filtering |
| Override without super() | ALWAYS call super().method() first |
| Scheduler tasks with args | Tasks receive NO arguments |
| Skip bench migrate | ALWAYS migrate after hook changes |
Full anti-patterns: anti-patterns.md
| File | Contents |
|------|----------|
| hooks.md | Complete hooks catalog by category |
| scheduler-events.md | Scheduler frequencies, cron syntax, timeouts |
| permissions.md | Permission hooks in detail |
| overrides.md | DocType class override patterns |
| bootinfo.md | extend_bootinfo, session hooks, notification_config |
| examples.md | Working hooks.py examples for each category |
| request-lifecycle.md | Request lifecycle, routing pipeline, page renderers, router API |
| anti-patterns.md | Common hook mistakes and corrections |
For document lifecycle events (doc_events), see: frappe-syntax-hooks-events
Comprehensive document creation, editing, and analysis with support for tracked changes, comments, formatting preservation, and text extraction. When Claude needs to work with professional documents (.docx files) for: (1) Creating new documents, (2) Modifying or editing content, (3) Working with tracked changes, (4) Adding comments, or any other document tasks
Comprehensive PDF manipulation toolkit for extracting text and tables, creating new PDFs, merging/splitting documents, and handling forms. When Claude needs to fill in a PDF form or programmatically process, generate, or analyze PDF documents at scale.
Presentation creation, editing, and analysis. When Claude needs to work with presentations (.pptx files) for: (1) Creating new presentations, (2) Modifying or editing content, (3) Working with layouts, (4) Adding comments or speaker notes, or any other presentation tasks
Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.
Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.
Use this skill any time a .pptx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates, layouts, speaker notes, or comments. Trigger whenever the user mentions \"deck,\" \"slides,\" \"presentation,\" or references a .pptx filename, regardless of what they plan to do with the content afterward. If a .pptx file needs to be opened, created, or touched, use this skill.
Create and edit Obsidian Flavored Markdown with wikilinks, embeds, callouts, properties, and other Obsidian-specific syntax. Use when working with .md files in Obsidian, or when the user mentions wikilinks, callouts, frontmatter, tags, embeds, or Obsidian notes.
Take impertio-studio/frappe-syntax-hooks from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.