frappe-syntax-controllers

Generate Frappe document controllers with lifecycle hooks and validation logic.

Updated May 31, 2026
One-click install
npx skills add https://github.com/anonymousminati/Res-POS --skill frappe-syntax-controllers-anonymousminati
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: frappe-syntax-controllers
Source: https://github.com/anonymousminati/Res-POS/tree/main/.claude/skills/syntax/frappe-syntax-controllers
Command: npx skills add https://github.com/anonymousminati/Res-POS --skill frappe-syntax-controllers-anonymousminati

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you write reliable Python document controllers for Frappe and ERPNext DocTypes without breaking lifecycle behavior, naming rules, or post-save logic. It is designed to prevent common mistakes such as saving changes in the wrong hook, skipping parent logic, or using unsafe database updates.

Core Features & Use Cases

  • Lifecycle Hook Guidance: Choose the right hook for validation, save-time calculations, submit actions, cancel reversals, and delete cleanup.
  • Controller Extension Patterns: Apply override classes, mixins, or document events when customizing existing DocTypes.
  • Safety and Correctness Rules: Use flags, db_set, super calls, and version-aware patterns to avoid recursion, lost updates, and permission issues.
  • Use Case: Build a Sales Order controller that validates item rows, calculates totals, creates side effects on submit, and reverses them on cancel.

Quick Start

Use this skill to draft a Frappe document controller for a DocType with the correct hooks, naming logic, and validation flow.

Frequently Asked Questions about frappe-syntax-controllers

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

FAQPage Schema
How do I write a Frappe controller with correct lifecycle hook logic?

Frappe controller validation uses lifecycle hooks like before_validate or validate to check item rows and calculate totals. Proper hook-order awareness ensures calculations execute correctly before database commits without causing recursive saves.

What is the best way to override existing ERPNext DocType controllers safely?

The best way to override ERPNext DocType controllers is applying override classes, mixins, or document events. This extension pattern customizes existing logic while maintaining safe super calls and preserving base Frappe behavior.

When do I use db_set versus standard assignment in Frappe document events?

Use db_set in Frappe document events when you need to update fields after save or submit without triggering recursive lifecycle hooks. Standard assignment is safer during validation phases where normal save flows handle database commits.

Does this approach support Frappe v14 through v16 controller patterns?

Yes, this approach supports Frappe v14 through v16 by applying version-aware controller patterns. It handles differences in naming rules, flags, and post-save behavior across versions to ensure document events remain compatible.

How do I reverse side effects when a Frappe document is cancelled?

To reverse side effects on cancel, implement the on_cancel lifecycle hook in your Frappe document controller. This hook executes cleanup logic to undo submit actions, ensuring database consistency when documents are cancelled.

Why does my Frappe controller cause infinite recursion during save?

Frappe controller recursion happens when save or db_set calls are placed incorrectly inside validation or before_save hooks. Avoid this by using flags to control flow and ensuring post-save logic does not re-trigger the document event lifecycle.