openaec-foundation/frappe_claude_skill_package/frappe-impl-hooks
Claude Code and agent skill by openaec-foundation/frappe_claude_skill_package
- community
Checking that the SKILL.md file is still in the repository.
Use when implementing hooks.py configurations in a Frappe custom app. Covers step-by-step workflows for doc_events, scheduler_events, override/extend_doctype_class, permission hooks, extend_bootinfo, fixtures, asset injection, website hooks, and doctype_js. Prevents broken transactions, missed migrations, and multi-app conflicts. Keywords: hooks.py, doc_events, scheduler_events, override doctype,, how to add hook, when to use doc_events, scheduler setup, override existing behavior. extend doctype class, permission hook, scheduler job, fixtures, doctype_js, extend_bootinfo, website hooks.
Install
npx vskill@latest install openaec-foundation/frappe_claude_skill_package/frappe-impl-hooksSKILL.md
The same SKILL.md was published earlier as openaec-foundation/frappe_claude_skill_package/frappe-impl-hooks.
Frappe Hooks Implementation Workflow
Step-by-step workflows for implementing hooks.py configurations. For API syntax reference, see frappe-syntax-hooks.
Version: v14/v15/v16 (V16-specific features noted)
Master Decision: What Are You Implementing?
Workflow 1: Implementing doc_events
When to Use
Use doc_events when you need to react to document lifecycle events on DocTypes owned by OTHER apps (ERPNext, Frappe core). For YOUR OWN DocTypes, ALWAYS prefer controller methods.
Step-by-Step
Step 1: Choose the right event (see references/decision-tree.md)
Step 2: Add to hooks.py
Step 3: Create handler module
Step 4: Deploy
Step 5: Test
Critical Rules for doc_events
- NEVER call
frappe.db.commit()inside a doc_event handler — Frappe manages the transaction - NEVER modify
docfields inon_update— changes are lost; usefrappe.db.set_value()instead - ALWAYS accept
method=Noneas second parameter in handler signature - ALWAYS use rename signature:
def handler(doc, method, old, new, merge) - ALWAYS run
bench --site sitename migrateafter changing hooks.py
Workflow 2: Implementing scheduler_events
Step-by-Step
Step 1: Choose frequency
| Frequency | Short (< 5 min) | Long (5-25 min) | |
|---|---|---|---|
| Every tick | all | — | |
| Hourly | hourly | hourly_long | |
| Daily | daily | daily_long | |
| Weekly | weekly | weekly_long | |
| Monthly | monthly | monthly_long | |
| Custom | cron | cron (use long queue manually) |
Step 2: Add to hooks.py
Step 3: Implement task (NO arguments)
Step 4: Deploy and verify
Critical Rules for Scheduler
- NEVER add parameters to scheduler task functions — the scheduler passes none
- ALWAYS use
_longvariants for tasks exceeding 5 minutes (default queue timeout is 5 min) - ALWAYS commit periodically in long tasks to save progress
- Tasks > 25 minutes: split into chunks or use
frappe.enqueue()
Workflow 3: Implementing extend_doctype_class (V16+)
Step-by-Step
Step 1: Add to hooks.py
Step 2: Create mixin class
Step 3: Deploy — bench --site sitename migrate
When to Use extend vs override
- ALWAYS prefer
extend_doctype_classon V16+ — multiple apps can extend safely - ONLY use
override_doctype_classwhen you must completely replace controller logic - On V14/V15,
override_doctype_classis the only option — last installed app wins
Workflow 4: Implementing Permission Hooks
Step-by-Step
Step 1: Add to hooks.py
Step 2: Implement handlers
Critical Rules for Permission Hooks
permission_query_conditionsONLY works withget_list, NEVER withget_allhas_permissioncan ONLY deny access — returning True does NOT grant additional permissions- ALWAYS handle
user=Noneby defaulting tofrappe.session.user
Workflow 5: Asset Injection and doctype_js
Adding Global JS/CSS
Extending a Specific Form
ALWAYS run bench build --app myapp after changing JS/CSS files.
Workflow 6: Fixtures, Boot Info, and Website Hooks
Fixtures
NEVER export fixtures without filters — it captures ALL apps' customizations.
extend_bootinfo
Website Hooks
Migration: Moving Logic Between Hooks, Controllers, and Server Scripts
| From | To | Steps | |
|---|---|---|---|
| Server Script → hooks.py | 1. Create Python handler, 2. Add doc_events, 3. Disable Server Script, 4. Migrate | ||
| hooks.py → Controller | 1. Move logic to doctype .py, 2. Remove doc_events entry, 3. Migrate | ||
| Controller → hooks.py | 1. Create events module, 2. Add doc_events, 3. Remove from controller, 4. Migrate |
ALWAYS migrate after ANY hooks.py change: bench --site sitename migrate
Handler Signatures Quick Reference
| Hook | Signature | |
|---|---|---|
| doc_events | def handler(doc, method=None): | |
| rename events | def handler(doc, method, old, new, merge): | |
| scheduler_events | def handler(): (no args) | |
| extend_bootinfo | def handler(bootinfo): | |
| permission_query | def handler(user): returns SQL string | |
| has_permission | def handler(doc, user=None, permission_type=None): returns True/False/None | |
| on_login | def handler(login_manager): | |
| on_logout | def handler(): |
Version Differences
| Feature | V14 | V15 | V16 | |
|---|---|---|---|---|
| doc_events | Yes | Yes | Yes | |
| scheduler_events | Yes | Yes | Yes | |
| override_doctype_class | Yes | Yes | Yes | |
| extend_doctype_class | No | No | Yes | |
| permission hooks | Yes | Yes | Yes | |
| Scheduler tick interval | ~4 min | ~4 min | ~60 sec | |
| auth_hooks | No | Yes | Yes |
Reference Files
| File | Contents | |
|---|---|---|
| decision-tree.md | Complete hook selection flowcharts | |
| workflows.md | Step-by-step implementation patterns | |
| examples.md | Working code examples for all hook types |
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/source/impl/frappe-impl-hooks/SKILL.md
Popularity
- Repository stars
- 91
- Repository forks
- 26
- 7-day trend score
- 23
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 29 Apr 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/openaec-foundation/frappe_claude_skill_package/frappe-impl-hooks)