workflow-patterns
БесплатноБез исполняемых скриптовНе проверенFrappe Workflow design — multi-state document lifecycles, role-based transitions, state-scoped field permissions, workflow handlers, and the team's pragmatic…
от UnityAppSuite★ 24 звезды на GitHubОб этом скилле
Frappe Workflow Patterns
Reference for designing Frappe workflows, aligned with the team's edu_quality conventions: workflow_state added via Custom Field in the customizations sub-app (not source DocType edits), pragmatic use of db_set over apply_workflow for programmatic transitions, and willingness to build a custom DocType + Page when stock Workflow doesn't fit.
Team conventions
These are the rules the existing codebase follows. New workflows should follow them; deviations need a reason.
- Add
workflow_statevia Custom Field insc_customizations(or equivalent customizations sub-app), not by editing the source DocType JSON. Keeps customizations isolated from upstream apps. Custom FieldJSON forworkflow_stateuses these settings:fieldtype: "Link",options: "Workflow State",default: "Approved"(or your default state),hidden: 1,no_copy: 1,allow_on_submit: 1. See the example insc_customizations/custom_field/Fees-workflow_state.json.- Use
db_set("workflow_state", "X")for programmatic transitions in most code paths. Pragmatic — bypasses transition validation, runs nocondition, fires no email — but matches what the codebase does today (e.g.refund_request.py:208,scan_receipts.py:17). Useapply_workflowonly when you specifically want the role check + condition + notification. - Always wrap
db_setcalls withhasattr(doc, "workflow_state")as a defensive check. The Custom Field may not be applied in every site; the code should still work. - When stock Workflow doesn't fit, build a custom workflow DocType plus a Frappe Page for the UI. We have precedent:
Funnel Workflowfor student application funnel,fee_workflowPage for fee operations. Don't try to bend Workflow to fit funnels or multi-doc orchestration.
When to use a stock Workflow
A stock Frappe Workflow is the right tool when all of these are true:
- The document moves through a fixed sequence of named states (Draft → Pending → Approved → ...).
- Different roles can move it between specific pairs of states.
- The "current state" is meaningful in the UI and reports.
Use a plain Select status field instead when:
- States are advisory rather than gating.
- Transitions don't need permission checks.
- You don't care who moved it from one state to another.
Build a custom workflow DocType + Page when:
- The workflow involves multiple linked documents (a funnel through Application → Enrollment → Fee Setup → Payment).
- The state transitions need a richer UI than the standard "Action" buttons (drag-and-drop, multi-select bulk actions, custom validation per stage).
- You need to track state changes as their own queryable records.
Don't use a Workflow alongside is_submittable: 1 unless you understand both will run — the workflow controls visible state, but Frappe still tracks docstatus (0 / 1 / 2) underneath.
Adding workflow_state via Custom Field
Create a Custom Field JSON in the customizations sub-app:
{
"doctype": "Custom Field",
"name": "Fees-workflow_state",
"dt": "Fees",
"fieldname": "workflow_state",
"label": "Workflow State",
"fieldtype": "Link",
"options": "Workflow State",
"default": "Approved",
"hidden": 1,
"no_copy": 1,
"allow_on_submit": 1,
"module": "Sc Customizations",
"creation": "2023-10-03 17:26:45.823538",
"modified": "2023-10-03 07:22:09.967376",
"modified_by": "Administrator"
}
File location: sc_customizations/custom_field/{DocType}-workflow_state.json. Register via fixtures in the customizations sub-app's hooks.py:
fixtures = [
{"dt": "Custom Field", "filters": "module", "=", "Sc Customizations"}
]
Why hidden by default: the workflow state is shown by the workflow timeline UI; the field itself doesn't need to be visible on the form.
Why no_copy: 1: a copied document should start at the default state, not inherit the source's state.
Why allow_on_submit: 1: the field can be updated on submitted docs (otherwise approval transitions on a submitted doc would fail).
Workflow anatomy
Workflows themselves are DocTypes — Workflow, Workflow State, Workflow Action Master, Workflow Transition. The Workflow doc lives in the database (created via the desk), exported with:
bench --site <site> export-fixtures
A workflow has these key fields:
| Field | What it does |
|---|---|
document_type |
The DocType this workflow applies to |
workflow_state_field |
Fieldname holding the current state — the team uses workflow_state consistently |
is_active |
1 to enable. Only one active workflow per DocType. |
send_email_alert |
1 sends notifications to the next actor on transition |
states |
Child table of Workflow Document State |
transitions |
Child table of Workflow Transition |
States — Workflow Document State
{
"state": "Pending Approval",
Установить workflow-patterns в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл workflow-patterns?
Frappe Workflow design — multi-state document lifecycles, role-based transitions, state-scoped field permissions, workflow handlers, and the team's pragmatic deviations (Custom Field for workflow_state, db_set over apply_workflow, custom workflow DocTypes). Use when designing or modifying an approval flow, a state machine on a DocType, or anything involving Workflow / Workflow State / Workflow Transition.
Как установить скилл workflow-patterns?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл workflow-patterns запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
docx
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
от AnthropicUse 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…
от Anthropicxlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
от Anthropicpptx
Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…
от Anthropic