frappe-syntax-hooks-events

Map Frappe doc_events lifecycle behaviors to correct event names and execution order.

163|53|Updated Jan 14, 2026
One-click install
npx skills add https://github.com/Impertio-Studio/Frappe_Claude_Skill_Package --skill frappe-syntax-hooks-events-impertio-studio
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: frappe-syntax-hooks-events
Source: https://github.com/Impertio-Studio/Frappe_Claude_Skill_Package/tree/main/skills/source/syntax/frappe-syntax-hooks-events
Command: npx skills add https://github.com/Impertio-Studio/Frappe_Claude_Skill_Package --skill frappe-syntax-hooks-events-impertio-studio

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill prevents fragile, production-breaking mistakes when implementing Frappe document lifecycle hooks via hooks.py doc_events, especially around incorrect event names and misunderstandings of execution order.

Core Features & Use Cases

  • Accurate lifecycle event execution order: Guides you through the correct sequence for insert, save, submit, cancel, delete, rename, and update-after-submit flows.
  • Correct doc_events registration patterns: Covers doc_events structure, wildcard handlers, multiple handlers per event, and the required handler function signature including method.
  • Safer multi-app behavior: Clarifies extend vs override behavior across apps, including v16+ extend_doctype_class stacking and v14+ override_doctype_class pitfalls.
  • Transaction-aware implementation rules: Highlights when handlers run relative to DB writes and when it’s safe to create linked documents or raise errors.

Quick Start

When wiring up hooks.py for Sales Invoice lifecycle logic, ask an AI to map your required behavior to the exact Frappe event (e.g., validate vs before_validate vs on_submit) and generate correct doc_events code that follows the documented ordering and handler signature.

Frequently Asked Questions about frappe-syntax-hooks-events

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement Frappe doc_events lifecycle hooks correctly?

Implement Frappe doc_events by mapping intended behavior to precise event names in hooks.py, ensuring correct execution order and the required handler function signature (doc, method=None) to prevent production-breaking mistakes.

What is the execution order for Frappe document lifecycle events?

Frappe document lifecycle events follow a specific execution sequence for insert, save, submit, cancel, delete, rename, and update-after-submit flows, dictating exactly when handlers run relative to database writes.

Does Frappe v16 support multi-app override patterns for doc_events?

Frappe v16 supports multi-app behavior using extend_doctype_class stacking, while v14+ override_doctype_class carries specific pitfalls to avoid, ensuring safer extend versus override execution across multiple apps.

How do I abort a transaction safely inside a Frappe hook?

Abort a transaction safely inside a Frappe hook by using frappe.throw to raise errors, avoiding incorrect commit assumptions and recursion while ensuring the document operation halts properly.

When do I need wildcard handling in Frappe hooks.py?

Wildcard handling in Frappe hooks.py is needed when applying doc_events across all document types, requiring specific syntax to ensure the handler function catches the intended events globally.