More screenshots

    Works with the AI tools you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseOpenClawOpenClaw+21 more

    Workflow State Contract Repair

    1

    Workflow State Contract Repair is a bounded ToolForge Labs workflow.

    $8.99

    Secure checkout via Stripe

    30-day refund guarantee

    Converts to your local currency at checkout

    Security scanned
    Workflow State Contract Repair

    Workflow State Contract Repair

    Example session with this skill installed

    I have a Next.js/TypeScript B2B SaaS with PostgreSQL, Prisma, BullMQ, and React. Customer onboarding, purchase approvals, and support escalations each use status fields, but the UI, API, and workers disagree on allowed transitions. Admin endpoints can jump directly to terminal states, retries can send duplicate side effects, completed records can be reopened by stale jobs, and some flows persist both status and boolean flags that contradict each other. Approval timestamps sometimes precede review timestamps, and a canceled workflow can still receive a late completion callback. Files include models, services, route handlers, workers, permission helpers, event code, tests, fixtures, docs, and runbooks. Repair the workflow-state contract locally. Do not access live data, choose business approval policy, run migrations, or deploy.

    • Read your context and instructions
    • Compiled the workflow state contract

    1. Repair decision

    Decision: CROSS-LAYER WORKFLOW STATE DRIFT FOUND — SAFE LOCAL PATCH AVAILABLE; production records and workers remain unverified.

    2. Scope and boundary

    Reviewed: Prisma models, services, routes, BullMQ workers, permission helpers, React state mapping, tests, fixtures, docs, and runbook.

    Not accessed: production databases, Redis, queues, customer records, external systems, or deployment configuration.

    The repository contains onboarding, purchase-approval, and support-escalation workflows. The repair can unify mechanics without inventing who may approve, cancel, reopen, or complete them.

    3. Workflow-state contract source register

    SourceCurrent behaviorStatus
    modelsstatus plus booleansContradiction risk
    APItransitions differ from servicesDrift
    admindirect terminal writesGuard bypass
    workersstale jobs advance recordsVersion gap
    retriesside effects repeatIdempotency gap
    Reactseparate action mapParity drift
    timestampslifecycle order conflictsChronology gap
    callbackscan complete canceled workTerminal gap

    4. Canonical repository contract

    Exact transition graphs are OWNER DECISION REQUIRED where sources disagree.

    Safe shared structure

    • one typed state set per workflow;
    • named transition commands instead of raw status writes;
    • current-state, authority, required-data, and version guards;
    • explicit terminal-state behavior;
    • stable operation identity per transition;
    • derived flags from canonical state where practical;
    • side effects from the committed result;
    • shared transition metadata for UI, API, workers, and bulk tools.

    5. Drift findings

    F1 — Competing state representations

    Records persist status beside flags such as is_closed, approved, or completed.

    Repair: make status the candidate source of truth and expose derived predicates. Keep legacy fields behind compatibility code until migration is separately approved.

    F2 — Raw terminal-state writes

    Admin routes assign terminal values without service guards.

    Repair: route writes through commands such as approve, cancel, complete, or reopen. Reject unsupported source/target combinations.

    F3 — UI/API disagreement

    React and API code maintain independent action lists.

    Repair: generate actions from shared transition metadata. Server authorization remains authoritative.

    F4 — Stale worker transitions

    Queued jobs can advance records after cancellation.

    Repair: require expected state or workflow version. A delayed job against newer state returns stale_transition.

    F5 — Duplicate side effects

    Retries repeat notifications or downstream work.

    Repair: use stable operation IDs and record the committed result. Replays return it without repeating the same logical effect.

    F6 — Terminal-state regression

    Bulk actions and callbacks can move terminal records backward.

    Repair: define terminal behavior per workflow. If reopen policy is unclear, return policy_required.

    F7 — Timestamp drift

    Different layers set lifecycle timestamps independently.

    Repair: derive or validate timestamps from committed transitions.

    F8 — False completion

    A worker result can be treated as completion after state changed.

    Repair: apply completion only if current state and version still permit it.

    6. Safe patch plan

    AreaChange
    Statetyped states
    Transitionsnamed commands/table
    Guardsstate, authority, data, version
    Legacy flagsderived helpers
    Workersstate/version checks
    Retriesoperation IDs
    Side effectscommitted-result boundary
    UI/APIshared transition metadata
    Tests/docsparity, replay, stale-job, terminal tests

    No production rewrite, migration, policy invention, or deployment.

    7. Deterministic test matrix

    1. Supported transitions succeed only from approved source states.
    2. Invalid jumps fail consistently across API and services.
    3. Patched paths avoid raw terminal writes.
    4. Derived flags match canonical state.
    5. A stale BullMQ job cannot advance a canceled record.
    6. Replaying one transition produces one logical side effect.
    7. Concurrent approvals converge on one committed transition.
    8. Terminal records cannot regress without an explicit transition.
    9. Late completion cannot override a newer canceled state.
    10. UI actions do not invent server transitions.
    11. Lifecycle timestamps remain consistent.
    12. Dashboard groups use canonical state classification.

    8. Verification steps

    Run repository-supported workflow tests, then typecheck, lint, and build.

    Target transition-table, API/service parity, stale-worker, replay, concurrency, terminal-state, legacy-flag, and dashboard tests.

    Search for raw status assignments, duplicated transition maps, stale booleans, jobs mutating without expected state/version, and side effects before commit.

    9. Production boundary

    Unknown issues may include contradictory legacy flags, impossible historical states, stale jobs, duplicate effects already sent, old app versions, and bulk-action histories.

    These require separate reconciliation, migration, rollout, monitoring, and rollback.

    10. Human approval request

    Safe now: state types, transition commands, guards, replay protection, worker version checks, derived predicates, shared metadata, tests, and docs.

    Decisions required: workflow-specific graphs, reopen policy, actor authority, prerequisites, legacy migration, historical cleanup, rollout, and rollback.

    Status: PATCH READY FOR LOCAL REVIEW — PRODUCTION RECORDS, HISTORICAL INVALID STATES, QUEUED JOBS, AND DEPLOYED POLICY NOT VERIFIED

    11. Suggested commit message

    fix(workflows): centralize state transitions and replay guards

    Connects securely to your tools. The creator never sees your data.

    What you get

    Synchronize status enums between UI components and backend models.Add version guards to prevent stale background jobs from overriding new state.Protect terminal states from being regressed by bulk admin actions.Ensure retries do not trigger duplicate notifications or API calls.

    About this skill

    Workflow State Contract Repair is a bounded ToolForge Labs workflow. Repair workflow-state drift in applications using Cursor. Compare statuses, transitions, guards, ownership, retries, concurrency, terminal states, side effects, UI/API/jobs, tests, and docs across orders, onboarding, approvals, tickets, subscriptions, and business flows. Detect invalid jumps, stuck records, duplicate effects, stale transitions, contradictory states, replay bugs, and false completion; prepare bounded patches and tests without data, policy choices, migrations, or deployment. The skill works from supplied repository files or partial evidence, separates verified facts from assumptions, avoids invented execution claims, and provides concrete next steps plus deterministic validation where possible.

    How to install

    Works the same in every agent - Claude, Cursor, Codex, Copilot and 20+ more.

    ~30 seconds
    1. 1

      Download the ZIP

      Free skills download straight away. Paid skills unlock right after purchase.

    2. 2

      Unzip into your skills folder

      Every agent reads skills from one folder on your machine. Drop the unzipped folder in there.

    3. 3

      Ask your agent to use it

      Restart the agent if it was already running. It picks the skill up automatically - no config needed.

    Skills folder by agent

    Click the path to copy it. Create the folder if it does not exist yet.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill passes our trust checks below.

    Security scanned

    Passed our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    30-day refund

    Not a fit? Get your money back

    Trust & safety

    Security scanned

    Verified clean 20 days ago

    • Passed all security checks, Safe to install

    Listed20 days ago

    What's inside

    Frequently Asked Questions