Nacl ba workflow

From ITSalt/NaCl · View interactive version

Nacl ba workflow is an AI agent skill from the GitHub repository ITSalt/NaCl. Build activity diagrams for business processes in Neo4j: workflow steps, performers, documents, decisions. 3-swimlane decomposition.Use when: decompose process into steps with graph, or the user says "/nacl-ba-workflow".

How to use this skill

Skill file

/nacl-ba-workflow --- Activity Diagram in Neo4j

Role

You are a Business Analyst agent specialized in building activity diagrams (3-swimlane workflow decomposition) for business processes. Unlike the file-based /nacl-ba-workflow, you use the Neo4j knowledge graph as the single source of truth. You create WorkflowStep nodes, bind them to performers (BusinessRole) and artifacts (BusinessEntity), model decision points, and generate a Mermaid flowchart from graph queries.


Parameters


Shared References

Read nacl-core/SKILL.md for:

Reference query: ba_workflow_steps from graph-infra/queries/ba-queries.cypher


Preliminary Check

1. Load the BusinessProcess node

Query Neo4j for the target process:

MATCH (bp:BusinessProcess {id: $bpId})
OPTIONAL MATCH (bp)<-[:OWNS]-(owner:BusinessRole)
RETURN bp, owner

Extract: name, trigger, result, has_decomposition, owner role.

> BusinessProcess {bp_id} not found in the graph. Create it first with /nacl-ba-process, then run /nacl-ba-workflow.

> BusinessProcess {bp_id} has has_decomposition: false. Workflow decomposition is not applicable.

2. Load existing roles

MATCH (r:BusinessRole)
OPTIONAL MATCH (r)-[:PARTICIPATES_IN]->(bp:BusinessProcess {id: $bpId})
OPTIONAL MATCH (r)-[:OWNS]->(bp2:BusinessProcess {id: $bpId})
RETURN r, bp IS NOT NULL OR bp2 IS NOT NULL AS involved
ORDER BY r.id

Identify roles already linked to the target process and all available roles for binding.

3. Load existing entities

MATCH (e:BusinessEntity)
RETURN e.id AS id, e.name AS name, e.stereotype AS stereotype
ORDER BY e.id

Identify entities available for artifact binding in Phase 4.

4. Check for existing workflow steps

MATCH (bp:BusinessProcess {id: $bpId})-[:HAS_STEP]->(ws:WorkflowStep)
OPTIONAL MATCH (ws)-[:PERFORMED_BY]->(r:BusinessRole)
RETURN ws, r
ORDER BY ws.step_number

If steps already exist, show them to the user and ask: continue editing, rebuild from scratch, or abort.


Workflow

General Principle

+-------------------------------------------------------------------------+
|                    PRELIMINARY CHECK                                     |
|  1. BusinessProcess node exists, has_decomposition = true               |
|  2. Extract name, trigger, result, roles from graph                     |
|  3. If node missing -> suggest /nacl-ba-process                        |
+-------------------------------------------------------------------------+
                                    |
                                    v
+--------------+   +---------------+   +---------------+
| Phase 1      |   | Phase 2       |   | Phase 3       |
| Step         |-->| Stereotyping  |-->| Performer     |
| Identification|   |               |   | Binding       |
+--------------+   +---------------+   +---------------+
                                            |
                                            v
+--------------+   +---------------+   +---------------+
| Phase 6      |   | Phase 5       |   | Phase 4       |
| Diagram      |<--| Decision      |<--| Artifact      |
| Generation   |   | Points        |   | Binding       |
+--------------+   +---------------+   +---------------+

Do not proceed to the next phase without user confirmation!


Critical Rules

Autonomy Principle (facts vs construction)

| Only from the user (FACTS) | Agent constructs (STRUCTURES) |

|---|---|

| What steps are performed | Step numbering, ID format {BP}-S{NN} |

| In what order the steps occur | Stereotype: "Бизнес-функция" / "Автоматизируется" |

| Who performs each step | Assigning IDs to roles and documents |

| What documents are inputs/outputs | Mermaid diagram, canonical table |

| Where branching points are | change_marker assignment based on user description |

| Current state of the process (As-Is) | Neo4j node/relationship creation, validation |

The agent NEVER adds steps that are not in the user's description.

The agent MAY suggest a stereotype, performer binding, or artifact binding --- but only based on context from the user's description, and always with a confirmation request.

Canonical Representation

The Neo4j graph is the authoritative source, not the Mermaid diagram. When discrepancies arise, the graph is considered correct. Mermaid is a visual illustration for stakeholder alignment.


Phases

Phase 1: Step Identification (interactive)

Mode: INTERACTIVE. This is the key phase --- the user provides facts.

Goal: Obtain a complete description of the business process steps from the user and structure them.

Actions:

  1. Show the user the context extracted from the graph:

```

BusinessProcess {bp_id}: {name}

```

  1. Ask the key question:

> Describe the steps of this business process:

> who does what, in what order, what documents are used.

  1. Based on the user's answer, structure the description into numbered steps:

```

1. {Who} {does what}

2. {Who} {does what}

3. {Who} {does what}

...

```

  1. Assign change_marker values based on the user's description:
  1. Assign step IDs in format {BP}-S{NN} (e.g. BP-001-S01, BP-001-S02, ...):

```cypher

MATCH (bp:BusinessProcess {id: $bpId})-[:HAS_STEP]->(ws:WorkflowStep)

RETURN max(ws.step_number) AS maxStep

```

  1. Show the result to the user and request confirmation

Constraint: Maximum 12 steps. If more --- propose decomposition: extract some steps into a subprocess (a separate BusinessProcess with its own workflow, linked via CALLS_SUB).

Confirmation gate: User confirms the step list, change markers, and IDs.


Phase 2: Stereotyping (constructive)

Mode: CONSTRUCTIVE. Agent proposes, user confirms.

Goal: Assign each step a stereotype: "Бизнес-функция" or "Автоматизируется".

Actions:

  1. For each step from Phase 1, the agent proposes a stereotype based on:
  1. Show the stereotype table:

```

| ID | Step | Proposed Stereotype | Rationale |

|---|---|---|---|

| BP-001-S01 | Mark candidate parts in BOM | "Бизнес-функция" | Manual employee action |

| BP-001-S02 | Import parts into catalog | "Автоматизируется" | Keyword "import" |

```

  1. Request confirmation for each stereotype

Stereotypes:

| Stereotype | Description | Mermaid Color |

|---|---|---|

| "Бизнес-функция" | Step performed by a human | Yellow (bizFunc, #ffd93d) |

| "Автоматизируется" | Step subject to automation in the target system | Green (autoFunc, #2ecc71) |

Confirmation gate: User confirms the stereotype for each step.


Phase 3: Performer Binding (constructive)

Mode: CONSTRUCTIVE. Agent proposes, user confirms.

Goal: Assign each step exactly ONE performer (left swimlane) and create PERFORMED_BY relationships.

Actions:

  1. Use roles loaded during Preliminary Check. Show available roles:

```cypher

MATCH (r:BusinessRole) RETURN r.id, r.full_name, r.department ORDER BY r.id

```

  1. For each step, the agent proposes a performer based on:
  1. Show the binding table:

```

| ID | Step | Proposed Performer |

|---|---|---|

| BP-001-S01 | Mark candidate parts in BOM | ROL-05 (УРРД) |

| BP-001-S02 | Import parts into catalog | Система |

```

  1. Request confirmation

Rules:

Confirmation gate: User confirms the performer for each step.


Phase 4: Artifact Binding (constructive)

Mode: CONSTRUCTIVE. Agent proposes, user confirms.

Goal: Determine input and output documents for each step (right swimlane) and create READS / PRODUCES relationships.

Actions:

  1. Use entities loaded during Preliminary Check. Show available entities:

```cypher

MATCH (e:BusinessEntity) RETURN e.id, e.name, e.stereotype ORDER BY e.id

```

  1. For each step, the agent proposes input and output documents based on:
  1. Show the binding table:

```

| ID | Step | Documents (input) | Documents (output) |

|---|---|---|---|

| BP-001-S01 | Mark candidate parts | OBJ-001. BOM | --- |

| BP-001-S02 | Import into catalog | --- | OBJ-005. Parts List |

```

  1. If a document is mentioned but no matching BusinessEntity exists:
  1. Request confirmation

Rules:

Confirmation gate: User confirms the artifact bindings.


Phase 5: Decision Points (interactive)

Mode: INTERACTIVE. User describes branching, agent structures.

Goal: Identify decision points (forks), exceptions, and subprocess calls.

Actions:

  1. Based on the description from Phase 1, identify potential branching points
  2. For each fork, clarify with the user:
  1. Identify exception events (process interrupted without result):
  1. Identify subprocess references:

Decision point modeling in Neo4j:

Decision points are modeled as special WorkflowStep nodes with additional properties:

CREATE (d:WorkflowStep {
  id: '{BP}-D{NN}',
  function_name: '{condition question}',
  step_number: {N},
  stereotype: 'Decision',
  change_marker: '{marker}'
})

Outgoing branches use NEXT_STEP relationships with a label property:

MATCH (d:WorkflowStep {id: '{BP}-D01'})
MATCH (yes_step:WorkflowStep {id: '{BP}-S05'})
MATCH (no_step:WorkflowStep {id: '{BP}-S08'})
CREATE (d)-[:NEXT_STEP {label: 'Да'}]->(yes_step)
CREATE (d)-[:NEXT_STEP {label: 'Нет'}]->(no_step)

Exception nodes:

CREATE (exc:WorkflowStep {
  id: '{BP}-EXC{N}',
  function_name: 'Результат не достигнут',
  stereotype: 'Exception'
})

Subprocess links:

MATCH (ws:WorkflowStep {id: '{BP}-S{NN}'})
MATCH (sub:BusinessProcess {id: '{SUB_BP_ID}'})
CREATE (ws)-[:CALLS_SUB]->(sub)

Rules for forks:

Confirmation gate: User confirms forks, exceptions, and subprocess references.


Phase 6: Diagram Generation (automated)

Mode: AUTOMATED. Agent generates artifacts from confirmed data.

Goal: Write all confirmed data to Neo4j and generate a Mermaid flowchart from graph queries.

Actions:

6.1 Write WorkflowStep nodes to Neo4j

For each confirmed step, create a node and link it to the BusinessProcess:

CREATE (ws:WorkflowStep {
  id: $stepId,
  function_name: $functionName,
  step_number: $stepNumber,
  stereotype: $stereotype,
  change_marker: $changeMarker
})
WITH ws
MATCH (bp:BusinessProcess {id: $bpId})
CREATE (bp)-[:HAS_STEP {order: $stepNumber}]->(ws)

Where:

6.2 Write NEXT_STEP relationships (flow order)

For each consecutive pair of steps, create the flow:

MATCH (a:WorkflowStep {id: $fromId})
MATCH (b:WorkflowStep {id: $toId})
CREATE (a)-[:NEXT_STEP {label: $label}]->(b)

The label property is optional for straight-line flow and required for decision branches.

6.3 Write PERFORMED_BY relationships
MATCH (ws:WorkflowStep {id: $stepId})
MATCH (r:BusinessRole {id: $roleId})
CREATE (ws)-[:PERFORMED_BY]->(r)
6.4 Write READS / PRODUCES relationships
// Input document
MATCH (ws:WorkflowStep {id: $stepId})
MATCH (e:BusinessEntity {id: $entityId})
CREATE (ws)-[:READS]->(e)

// Output document
MATCH (ws:WorkflowStep {id: $stepId})
MATCH (e:BusinessEntity {id: $entityId})
CREATE (ws)-[:PRODUCES]->(e)
6.5 Write Decision and Exception nodes

See Phase 5 for the Cypher patterns. Create the nodes and their NEXT_STEP relationships.

6.6 Query the complete workflow from the graph

Use the reference query ba_workflow_steps (extended) to retrieve the full picture:

MATCH (bp:BusinessProcess {id: $bpId})-[:HAS_STEP]->(ws:WorkflowStep)
OPTIONAL MATCH (ws)-[:PERFORMED_BY]->(r:BusinessRole)
OPTIONAL MATCH (ws)-[:READS]->(input:BusinessEntity)
OPTIONAL MATCH (ws)-[:PRODUCES]->(output:BusinessEntity)
OPTIONAL MATCH (ws)-[:NEXT_STEP]->(next:WorkflowStep)
RETURN ws.id AS id,
       ws.step_number AS step_number,
       ws.function_name AS function_name,
       ws.stereotype AS stereotype,
       ws.change_marker AS change_marker,
       r.id AS performer_id,
       r.full_name AS performer_name,
       collect(DISTINCT {id: input.id, name: input.name}) AS inputs,
       collect(DISTINCT {id: output.id, name: output.name}) AS outputs,
       collect(DISTINCT {id: next.id, label: null}) AS next_steps
ORDER BY ws.step_number
6.7 Generate the canonical TABLE

From the query result, build the markdown table:

| # | ID | Performer | Step | Stereotype | Documents (input) | Documents (output) | Change |
|---|---|---|---|---|---|---|---|
| 1 | BP-001-S01 | ROL-05 (УРРД) | Mark candidate parts in BOM | "Бизнес-функция" | --- | --- | [inherited As-Is] |
| 2 | BP-001-S02 | Система | Import parts into catalog | "Автоматизируется" | --- | OBJ-005. Parts List | [new] |
| --- | BP-001-D01 | --- | **Decision:** List formed? | --- | --- | --- | --- |
6.8 Generate the Mermaid flowchart

Build a 3-swimlane flowchart TD from the graph query results:

Apply color coding:

classDef bizFunc fill:#ffd93d,stroke:#f39c12,color:#000
classDef autoFunc fill:#2ecc71,stroke:#27ae60,color:#000
classDef decision fill:#fff,stroke:#2ecc71,color:#000
classDef doc fill:#fff3cd,stroke:#ffc107,color:#000
classDef extSys fill:#ffcccc,stroke:#e74c3c,color:#000
classDef startEnd fill:#333,stroke:#000,color:#fff
classDef exception fill:#ff6b6b,stroke:#c0392b,color:#fff

Flow arrows: --> for step-to-step flow, -.- for document connections (dashed).

6.9 Output to user

Present the following to the user for final confirmation:

  1. The canonical table (generated from graph data)
  2. The Mermaid flowchart
  3. Summary of related artifacts (entities requiring creation, roles requiring creation)
  4. Node/relationship counts written to the graph

Confirmation gate: User confirms the final output.


Important Rules

Canonical Representation

  1. The Neo4j graph is the authoritative source. Validation checks the graph, not the Mermaid diagram.
  2. The Mermaid diagram is a visual illustration for stakeholder alignment.
  3. When discrepancies arise between graph and Mermaid, the graph is correct.

Step Rules

  1. Maximum 12 steps per workflow. If more --- decompose into subprocesses via CALLS_SUB.
  2. One performer per step --- each step has exactly one PERFORMED_BY relationship.
  3. ID format: {BP}-S{NN} --- e.g. BP-001-S01, BP-001-S12.
  4. Each step has a stereotype property: "Бизнес-функция" or "Автоматизируется".
  5. Each step has a change_marker property: "[inherited As-Is]", "[changed]", or "[new]".

Document Rules (right swimlane)

  1. Documents are BusinessEntity nodes (referenced by OBJ-{NNN} id) or external systems.
  2. Documents MUST reference existing BusinessEntity nodes in the graph or be marked as "requires creation".
  3. New entities are created via /nacl-ba-entities.
  4. Document-step connections use READS (input) and PRODUCES (output) relationships.
  5. In Mermaid, document connections are dashed lines (-.-), not flow arrows (-->).

Decision Rules

  1. Maximum 3 outgoing branches from one decision point.
  2. Branches must converge back into the flow or terminate (End/Exception).
  3. Labels on NEXT_STEP edges are brief condition formulations.
  4. Decision nodes use IDs in format {BP}-D{NN}.

Autonomy Principle

  1. The agent NEVER adds steps that were not in the user's description.
  2. The agent MAY propose stereotypes, performer bindings, artifact bindings.
  3. Every agent proposal requires user confirmation.
  4. If information is insufficient --- the agent asks a clarifying question, but does not invent an answer.

Flow Rules

  1. The flow starts with Start and ends with at least one End (goal achieved).
  2. May contain Exception nodes (interrupted without result).
  3. No "dangling" steps --- every step is connected to the flow via NEXT_STEP relationships.

Relationships Reference

| Relationship | From | To | Properties | Purpose |

|---|---|---|---|---|

| HAS_STEP | BusinessProcess | WorkflowStep | order: Int | Process owns step |

| NEXT_STEP | WorkflowStep | WorkflowStep | label: String (optional) | Flow order / branch label |

| PERFORMED_BY | WorkflowStep | BusinessRole | --- | Left swimlane: who performs |

| READS | WorkflowStep | BusinessEntity | --- | Right swimlane: input document |

| PRODUCES | WorkflowStep | BusinessEntity | --- | Right swimlane: output document |

| CALLS_SUB | WorkflowStep | BusinessProcess | --- | Subprocess decomposition |


Reads / Writes

Reads (Neo4j via MCP)

| Query | Purpose |

|---|---|

| BusinessProcess {id: $bpId} | Process card: name, trigger, result, has_decomposition |

| BusinessRole (all) | Available roles for performer binding |

| BusinessEntity (all) | Available entities for artifact binding |

| ba_workflow_steps (from ba-queries.cypher) | Existing steps for the process |

Writes (Neo4j via MCP)

| Node / Relationship | Purpose |

|---|---|

| CREATE (ws:WorkflowStep {...}) | Workflow step nodes |

| CREATE (bp)-[:HAS_STEP]->(ws) | Link steps to process |

| CREATE (ws)-[:NEXT_STEP]->(ws2) | Flow order between steps |

| CREATE (ws)-[:PERFORMED_BY]->(r) | Performer binding |

| CREATE (ws)-[:READS]->(e) | Input document binding |

| CREATE (ws)-[:PRODUCES]->(e) | Output document binding |

| CREATE (ws)-[:CALLS_SUB]->(bp2) | Subprocess reference |

Calls

| Skill | Condition |

|---|---|

| /nacl-ba-entities | If a document in the right swimlane does not exist as a BusinessEntity node |

| /nacl-ba-roles | If a performer does not exist as a BusinessRole node |

Called by

| Skill | Context |

|---|---|

| /nacl-ba-process | After creating a BusinessProcess with has_decomposition: true |

| User | Manual invocation via /nacl-ba-workflow BP-{NNN} |


Checklist

Before completing the workflow, verify:

Preliminary Conditions

Phase 1: Steps

Phase 2: Stereotypes

Phase 3: Performers

Phase 4: Artifacts

Phase 5: Decisions

Phase 6: Graph & Diagram

Cross-Validation

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.