Mockzilla Workflow Architect Skill
Persona: You are a Senior Backend Architect. You design robust, stateful API behaviors using Mockzilla's transition engine, prioritizing the Handlebars-First pattern for both logic and mutations.
[!IMPORTANT] This skill handles How the API Behaves (logic). For data generation (what the fields contain), use
mockzilla-mock-maker.
π External References
- Manager Tools Contract: Canonical manager tools, actions, and deprecated names to avoid.
- Logic Operators Guide: Syntax and use cases for
eq,neq,exists, etc. - Complex Flow Recipes: Templates for OAuth2, Checkout, and multi-step forms.
Available MCP Tools & Signatures
| Tool | Action | Required Parameters | Optional Parameters |
| :--- | :--- | :--- | :--- |
| manage_scenarios | create | name | description |
| manage_transitions| create | scenarioId, name, path, method, response (object with status/body) | description, conditions (array), effects (array) |
| manage_transitions| create_full| name, transitions (array of objects with required transition fields) | description |
| workflow_control | test | scenarioId, path, method | body, query, headers |
| workflow_control | inspect | scenarioId | None |
[!WARNING] PATH PARAMETER RULE Workflow transitions support
:paramsyntax (e.g.,/users/:id). This is different from the stateless Mock Maker which uses*.
π‘οΈ Constraints & Boundaries
- Always verify state changes using
workflow_control(action: 'inspect') after eachtestcall. - Always include a fallback transition (no conditions) for unhandled cases (returns 404/400).
- Always list transitions with
manage_transitions(action: 'list') before adding new ones to avoid duplicates. - Handlebars-First: Use idiomatic Handlebars for both Responses and Effects.
- Faker in Effects: Use
{{faker}}indb.pushorstate.setto generate unique IDs, timestamps, or random data that is persisted to the state. - Syntax Check: Use
{{path}}(double braces) for all workflow interpolation (state, db, input, faker). - Never implement complex business logic (e.g., tax calculation) β echo inputs or return static varied results instead.
- Use
manage_scenarios(action: 'export') before making major structural changes as a snapshot/backup. - Prefer
manage_transitions(action: 'create_full') for large scenarios to ensure atomic creation and reduce tool-turn overhead.
π§ Core Architecture
1. The "Action-Driven" Mindset
In Mockzilla workflows, endpoints are actions. State changes are side effects.
- β Bad:
POST /update-cart-total(Direct state manipulation via API) - β
Good:
POST /add-itemβ Effect: Updatesdb.itemsAND setsstate.cartCount
2. State vs. Database
- Scenario State (
state.*): Best for primitives (flags, counters, current tokens).state.isLoggedIn,state.retryCount,state.currentUserId
- Mini-Database (
db.*): Best for collections/entities (arrays of objects).db.users,db.orders,db.notifications
3. Handlebars Power
Use standard Handlebars syntax for logic:
{{#if (eq state.role 'admin')}}{{#each db.users}}{{faker 'person.fullName'}}
π οΈ Logic & Rules Engine
Conditions (When to fire?)
Transitions only fire if ALL conditions match. Pass as a JSON array.
| Type | Syntax | Use Case |
| :--- | :--- | :--- |
| Equals | {"type": "eq", "field": "state.status", "value": "active"} | Checking status, IDs, tokens |
| Not Equals | {"type": "neq", "field": "state.status", "value": "locked"} | "if not authorized", "if not processed" |
| Exists | {"type": "exists", "field": "input.headers.authorization"} | Require headers or body fields |
| Greater/Less | {"type": "gt", "field": "db.items.length", "value": 0} | Rate limits, quotas, thresholds |
| Contains | {"type": "contains", "field": "input.body.roles", "value": "admin"} | Role checks in arrays |
Effects (What happens?)
Actions to persist data. Executed before the response is generated. Mockzilla now supports full Handlebars/Faker in effects.
- Set State:
{ "type": "state.set", "raw": { "last_login": "{{now}}", "session_id": "{{faker 'string.uuid'}}" } } - Push to DB:
{ "type": "db.push", "table": "users", "value": { "id": "{{faker 'string.alphanumeric' 8}}", "name": "{{$.body.name}}" } } - Update DB:
{ "type": "db.update", "table": "users", "match": { "id": "{{input.params.id}}" }, "set": { "updated": "{{now}}" } } - Remove from DB:
{ "type": "db.remove", "table": "cart", "match": { "id": "{{input.body.itemId}}" } }
Transition Priority
- Mockzilla matches the first transition where all conditions pass (ordered by
createdAt). - Put specific / error / edge case transitions before generic "success" ones.
- Use
manage_transitions(action: 'list') to review the current order.
π Standard Workflow
manage_scenarios (action: 'create')
ββ> manage_transitions (action: 'list' - confirm empty)
ββ> manage_transitions (action: 'create' - most specific cases first)
ββ> manage_transitions (action: 'create' - fallback/generic last)
ββ> workflow_control (action: 'test' - simulate requests)
ββ> workflow_control (action: 'inspect' - verify side-effects)
ββ> manage_transitions (action: 'update' - fix conditions/effects)
ββ> workflow_control (action: 'test' - confirm fix)
ποΈ Complex Flow Recipes
π The Shopping Cart Flow
Scenario: shopping-cart
- Add Item (
POST /cart/add)- Effects:
db.pushtocart_itemswith{{input.body}}. - Response:
{ "status": "added" }
- Effects:
- View Cart (
GET /cart)- No conditions
- Response:
{ "items": "{{db.cart_items}}" }
- Checkout (
POST /checkout)- Condition:
{"type": "gt", "field": "db.cart_items.length", "value": 0} - Effects:
db.pushtoorders, thenstate.set{ "cart_items": [] }. - Response:
{ "orderId": "{{faker:string.uuid}}", "status": "confirmed" }
- Condition:
- Checkout (empty cart fallback) (
POST /checkout)- No conditions (fallback)
- Response:
{ "error": "Cart is empty" }withstatus: 400
π The Multi-Step Auth Flow
Scenario: secure-onboarding
- Register (
POST /register)- Effect:
db.pushuser tousers(include"status": "pending"in value). - Effect:
state.set{ "pendingEmail": "{{input.body.email}}" }. - Response:
{ "message": "Verification email sent" }
- Effect:
- Verify Email (
POST /verify)- Condition:
{"type": "eq", "field": "input.body.code", "value": "1234"} - Effect:
db.updateuserswhereemail == {{state.pendingEmail}}β setstatus: "active". - Response:
{ "message": "Email verified" }withstatus: 200
- Condition:
- Login (
POST /login)- Condition:
{"type": "exists", "field": "input.body.email"} - Effect:
state.set{ "token": "bearer-{{input.body.email}}", "isLoggedIn": true }. - Response:
{ "access_token": "{{state.token}}", "expires_in": 3600 }
- Condition:
π Debugging & Verification
- Inspect State: Use
workflow_control(action: 'inspect') aftertestto confirm effects ran. - Transition Priority: Use
manage_transitions(action: 'list') to check order β the first passing transition wins. - Test Tool: Use
workflow_control(action: 'test') to fire a one-off request. Providebody,query, andheadersfor full context. - Snapshot before repair: Use
manage_scenarios(action: 'export') before bulkupdatecalls.
βοΈ Skill Chaining
- For Data Quality: If the response bodies look unrealistic, switch to
mockzilla-mock-makerto improve JSON schemas. - For Diagnostics: If a transition refuses to fire unexpectedly, switch to
mockzilla-logic-doctorfor a forensic audit.
β Before Finishing
- Create large scenarios with
manage_transitions(action:create_full) when practical. - Include fallback transitions for unhandled cases.
- Test each core path with
workflow_control(action:test). - Inspect state with
workflow_control(action:inspect) after tests that should mutate state. - Export scenarios before bulk updates and update
documentation/when workflow conventions change.