home / skills / venkateshvenki404224 / frappe-apps-manager / frappe-workflow-generator

frappe-workflow-generator skill

/frappe-apps-manager/skills/frappe-workflow-generator

This skill generates production-ready Frappe Workflows for document state management, approvals, and multi-step processes to accelerate business automation.

npx playbooks add skill venkateshvenki404224/frappe-apps-manager --skill frappe-workflow-generator

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
3.1 KB
---
name: frappe-workflow-generator
description: Generate Frappe Workflows for document state management and approvals. Use when creating approval workflows, state transitions, or multi-step document processes.
---

# Frappe Workflow Generator

Generate production-ready Frappe Workflows for document state management, approvals, and business process automation.

## When to Use This Skill

Claude should invoke this skill when:
- User wants to create approval workflows
- User needs document state transitions
- User requests multi-step approval processes
- User mentions workflows, approvals, or document states
- User wants role-based approval routing
- User needs to implement document lifecycle management

## Capabilities

### 1. Workflow JSON Generation

**Basic Approval Workflow:**
```json
{
  "name": "Sales Invoice Approval",
  "document_type": "Sales Invoice",
  "is_active": 1,
  "workflow_state_field": "workflow_state",
  "states": [
    {
      "state": "Draft",
      "doc_status": "0",
      "allow_edit": "Sales User",
      "update_field": "status",
      "update_value": "Draft"
    },
    {
      "state": "Pending Approval",
      "doc_status": "0",
      "allow_edit": "Sales Manager",
      "update_field": "status",
      "update_value": "Pending"
    },
    {
      "state": "Approved",
      "doc_status": "1",
      "update_field": "status",
      "update_value": "Approved"
    },
    {
      "state": "Rejected",
      "doc_status": "2",
      "update_field": "status",
      "update_value": "Rejected"
    }
  ],
  "transitions": [
    {
      "state": "Draft",
      "action": "Submit for Approval",
      "next_state": "Pending Approval",
      "allowed": "Sales User",
      "allow_self_approval": 0
    },
    {
      "state": "Pending Approval",
      "action": "Approve",
      "next_state": "Approved",
      "allowed": "Sales Manager"
    },
    {
      "state": "Pending Approval",
      "action": "Reject",
      "next_state": "Rejected",
      "allowed": "Sales Manager"
    },
    {
      "state": "Rejected",
      "action": "Revise",
      "next_state": "Draft",
      "allowed": "Sales User"
    }
  ]
}
```

### 2. Conditional Transitions

**Workflow with Amount-Based Routing:**
```json
{
  "transitions": [
    {
      "state": "Draft",
      "action": "Submit",
      "next_state": "Pending L1 Approval",
      "allowed": "Sales User",
      "condition": "doc.grand_total <= 10000"
    },
    {
      "state": "Draft",
      "action": "Submit",
      "next_state": "Pending L2 Approval",
      "allowed": "Sales User",
      "condition": "doc.grand_total > 10000 && doc.grand_total <= 50000"
    },
    {
      "state": "Draft",
      "action": "Submit",
      "next_state": "Pending Director Approval",
      "allowed": "Sales User",
      "condition": "doc.grand_total > 50000"
    }
  ]
}
```

## References

**Frappe Workflow Core:**
- Workflow: https://github.com/frappe/frappe/blob/develop/frappe/workflow/doctype/workflow/workflow.py
- Workflow State: https://github.com/frappe/frappe/blob/develop/frappe/workflow/doctype/workflow_state/workflow_state.py

**Official Documentation:**
- Workflows: https://frappeframework.com/docs/user/en/desk/workflows

Overview

This skill generates production-ready Frappe Workflows to manage document states, approvals, and multi-step processes. It produces workflow JSON tailored for the Frappe Framework, including states, transitions, role-based permissions, and conditional routing. Use it to accelerate implementation of approval paths, lifecycle management, and automated state updates.

How this skill works

Provide the document type, desired states, role permissions, and transition rules. The skill returns a Frappe-compatible workflow JSON that defines workflow_state field mapping, states with doc_status and update actions, and transitions with allowed roles, self-approval flags, and optional conditions. It can generate conditional transitions (e.g., amount-based routing), multi-level approvals, and example payloads ready to import or apply via Frappe APIs.

When to use it

  • Creating approval workflows for invoices, purchase orders, or custom doctypes
  • Defining multi-step document lifecycles with role-based edit permissions
  • Implementing conditional routing based on document fields (amount, customer type, etc.)
  • Enforcing separation of duties and preventing self-approval
  • Standardizing state updates and automatic status fields across documents

Best practices

  • Define a single workflow_state field on the doctype to store the active state
  • Keep states minimal and meaningful (Draft, Pending Approval, Approved, Rejected)
  • Use roles for permission checks rather than individual users when possible
  • Leverage conditional transitions for amount or attribute-based routing to avoid duplicated states
  • Test workflows in a staging environment and include revert transitions for common corrections

Example use cases

  • Sales Invoice approval with Draft → Pending Approval → Approved/Rejected and role-based actions
  • Purchase Order routing: values trigger L1/L2/Director approvals based on total amount
  • Expense claim process with finance and HR approvals and a Revise transition back to draft
  • Contract lifecycle: Draft → Legal Review → Commercial Approval → Signed with conditional fast-track for low-risk deals
  • Custom doctype lifecycle where state changes update a status field and trigger follow-up workflows

FAQ

Can this generate conditional transitions based on numeric fields?

Yes. You can specify conditions like doc.grand_total <= 10000 and the skill will produce transitions that evaluate those expressions in Frappe workflow rules.

How do I prevent self-approval?

Include allow_self_approval: 0 on transitions where the acting role must be different from the document owner; the generated JSON will set that flag for the appropriate transition.