跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
部署与云服务

frappe-agent-validator

Use when reviewing or validating Frappe/ERPNext code against best practices and common pitfalls. Checks generated code before deployment, validates against all 61 frappe-* skills, catches v16 patterns (extend_doctype_class, type annotations), validates ops patterns (bench commands, deployment), and generates correction reports. Keywords: review code, check script, validate deployment, find bugs, code quality, check my code, is this correct, code review, before deploying, best practices check.

OpenAEC-Foundation · 已有静态检查记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add Impertio-Studio/Frappe_Claude_Skill_Package --skill frappe-agent-validator

技能说明


name: frappe-agent-validator description: > Use when reviewing or validating Frappe/ERPNext code against best practices and common pitfalls. Checks generated code before deployment, validates against all 61 frappe-* skills, catches v16 patterns (extend_doctype_class, type annotations), validates ops patterns (bench commands, deployment), and generates correction reports. Keywords: review code, check script, validate deployment, find bugs, code quality, check my code, is this correct, code review, before deploying, best practices check. license: MIT compatibility: "Claude Code, Claude.ai Projects, Claude API. Frappe v14-v16." metadata: author: OpenAEC-Foundation version: "2.0"

Frappe Code Validator Agent

Validates Frappe/ERPNext code against the complete 61-skill knowledge base, catching errors BEFORE deployment.

Purpose: Catch errors before deployment, not after

When to Use This Agent

CODE VALIDATION TRIGGERS
|
+-- Code has been generated and needs review
|   "Check this Server Script before I save it"
|   --> USE THIS AGENT
|
+-- Code is causing errors
|   "Why isn't this working?"
|   --> USE THIS AGENT
|
+-- Pre-deployment validation
|   "Is this production-ready?"
|   --> USE THIS AGENT
|
+-- Code review for best practices
|   "Can this be improved?"
|   --> USE THIS AGENT
|
+-- Ops/deployment validation
|   "Is my bench setup correct?"
|   --> USE THIS AGENT

Validation Workflow

STEP 1: IDENTIFY CODE TYPE
  Client Script | Server Script | Controller | hooks.py |
  Jinja | Whitelisted | Bench/Ops | DocType JSON

STEP 2: RUN TYPE-SPECIFIC CHECKS
  Apply checklist for identified code type

STEP 3: CHECK UNIVERSAL RULES
  Error handling | Security | Performance | User feedback

STEP 4: VERIFY VERSION COMPATIBILITY
  v14/v15/v16 features | Deprecated patterns

STEP 5: VALIDATE AGAINST SKILL CATALOG
  Cross-reference with relevant frappe-* skills

STEP 6: GENERATE VALIDATION REPORT
  Critical errors | Warnings | Suggestions | Corrected code

See references/workflow.md for detailed steps.

Critical Checks by Code Type

Server Script Checks

CheckSeverityPatternFix
Import statementsFATALimport X or from X import YUse frappe.utils.X() directly
Wrong doc variableFATALself.field or document.fieldUse doc.field
Wrong event for purposeERRORValidation code in on_updateMove to validate event
try/except blocksWARNINGtry: ... except:Use frappe.throw() for validation
No null checksWARNINGdoc.field.lower()Add if doc.field: guard

Client Script Checks

CheckSeverityPatternFix
Server-side API callsFATALfrappe.db.get_value()Use frappe.call()
Missing async handlingFATALlet x = frappe.call()Use callback or async/await
No refresh after set_valueERRORfrm.set_value() aloneAdd frm.refresh_field()
Using cur_frmWARNINGcur_frm.doc.fieldUse frm parameter
No form state checkWARNINGMissing __islocal/docstatusAdd state guards

Controller Checks

CheckSeverityPatternFix
self.* in on_updateFATALself.field = X in on_updateUse self.db_set()
Circular saveFATALself.save() in lifecycle hookRemove self.save()
Missing super()ERROROverride without super()Add super().method()
v16 extend_doctype_classERRORMissing super() in mixinALWAYS call super() first
No type annotationsSUGGESTIONMissing type hints (v16)Add type annotations

hooks.py Checks

CheckSeverityPatternFix
Invalid Python syntaxFATALSyntax errorsFix dict/list structure
Wrong event namesFATALTypo in event nameUse correct event names
Invalid function pathsFATALWrong dotted pathVerify path exists
v16-only hooks on v14/v15ERRORextend_doctype_classUse doc_events instead
Missing required_appsWARNINGNo dependency declarationAdd all dependencies

Ops/Bench Checks

CheckSeverityPatternFix
No migrate after hooksFATALhooks.py changed, no migrateRun bench migrate
Wrong bench command syntaxERRORIncorrect CLI argsCheck frappe-ops-bench
Missing backup before upgradeERRORUpgrade without backupALWAYS backup first
Production without supervisorWARNINGNo process managerUse supervisor/systemd
No SSL in productionWARNINGHTTP-only deploymentConfigure SSL/TLS

DocType JSON Checks

CheckSeverityPatternFix
Missing mandatory fieldsERRORNo primary identifierAdd name or autoname
Duplicate fieldnamesFATALSame fieldname twiceUse unique fieldnames
Wrong fieldtype for dataWARNINGText for short valuesUse Data/Small Text
No permissions definedWARNINGEmpty permission listAdd role permissions

v16 Specific Validations

extend_doctype_class Pattern

# VALIDATE: Mixin class MUST call super()
class CustomSalesInvoice(SalesInvoice):
    def validate(self):
        super().validate()       # REQUIRED - never skip
        self.custom_validation()

    def on_submit(self):
        super().on_submit()      # REQUIRED - never skip
        self.custom_on_submit()

Type Annotations (v16 best practice)

# v16 recommended pattern
def get_customer_balance(customer: str) -> float:
    ...

# Validate: type hints on public API methods
@frappe.whitelist()
def process_order(order_name: str, action: str = "approve") -> dict:
    ...

Data Masking (v16)

# Validate: sensitive fields should use data masking
# Check if PII fields have mask_with confi
阅读完整来源 ↗