Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    What-If: Universal Dynamic Stress-Testing Engine

    1

    Autonomously uncover hidden failure modes, race conditions, and business logic exploits across any code, database schema, or architecture using the 5-Layer Reality Stack and 3-Tier Remediation Blueprint.

    $9.99

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    What-If: Universal Dynamic Stress-Testing Engine

    What-If: Universal Dynamic Stress-Testing Engine

    Example session with this skill installed

    /what-if --deep
    We are launching flash-sale VIP table reservations and coupon discounts for a high-traffic event platform. Here is our reservation SQL and checkout logic:

    -- Reserve VIP table and deduct stock
    UPDATE venue_tables 
    SET reserved_count = reserved_count + 1 
    WHERE id = $1 AND reserved_count < max_capacity
    RETURNING id, price;
    
    async function checkoutTable(userId: string, tableId: string, coupon?: { code: string; discountAmount: number; minSpend: number }) {
      const table = await db.query(RESERVE_SQL, [tableId]);
      if (!table) throw new Error("Sold out");
    
      let finalPrice = table.price;
      if (coupon && finalPrice >= coupon.minSpend) {
        finalPrice = finalPrice - coupon.discountAmount;
      }
    
      await paymentGateway.charge(userId, finalPrice);
      return { status: "confirmed", tableId, finalPrice };
    }
    
    • Read your context and instructions
    • Compiled the what-if

    Summary

    Decompiled 5 hidden optimistic assumptions across your SQL reservation query and TypeScript checkout flow, uncovering

    3 critical High-Blast-Radius vulnerabilities (inventory lockouts on payment failure, negative charge exploits, and single-use coupon race conditions) along with drop-in atomic fixes.


    🪙 Detected Failure Currencies: Money | Data Consistency | Availability

    🧬 Auto-Spawned Dimensions: Inventory Lockout, Race Condition, Promo Arbitrage, Partial Commit


    🎯 1. Assumption Decompilation (Hidden Optimism)

    Coupled State Mutation: Assumes paymentGateway.charge() will always succeed after venue_tables.reserved_count is incremented outside a single transaction boundary.
    2.

    Unbounded Coupon Arithmetic: Assumes coupon.discountAmount is strictly positive and never exceeds finalPrice.
    3.

    Single-Tab Execution: Assumes a user cannot trigger two concurrent checkoutTable calls with the same single-use coupon in parallel tabs.
    4.

    Idempotent Retries: Assumes network timeouts from paymentGateway.charge() won't cause the client to retry and reserve a second table.


    ⚡ 2. Top 3 Silent Killers (Prioritized by Blast Radius)

    [W-01] Ghost Sold-Out Lockout (Partial Commit): UPDATE venue_tables commits immediately, then paymentGateway.charge() fails or times out. The VIP table remains permanently locked (reserved_count + 1) with zero revenue collected. →

    Blast Radius: HIGH
    2.

    [W-02] Dual-Tab Coupon Double-Spend: User opens 2 browser tabs and submits checkout at the same millisecond using a single-use coupon. Both threads pass validation before redemption is recorded. →

    Blast Radius: HIGH
    3.

    [W-03] Negative Settlement / Arbitrage: If coupon.discountAmount ($150) > table.price ($100), finalPrice becomes -$50, either crashing the gateway or issuing an unintended credit. →

    Blast Radius: HIGH


    📊 3. Full Edge-Case Matrix

    IDLayerScenarioLikelihood × ImpactBlast RadiusDefault Failure
    W-01L2: ConcurrencyPayment fails after UPDATE venue_tables executesHigh × HighHIGHGhost inventory depletion; VIP tables locked without payment
    W-02L2: ConcurrencyConcurrent requests redeem the same coupon codeMed × HighHIGHSingle-use promo applied multiple times across orders
    W-03L1: InvariantdiscountAmount > table.price or negative valueMed × HighHIGHNegative finalPrice passed to payment gateway
    W-04L3: Human UXUser panic-clicks "Pay Now" 4 times during 3s gateway lagHigh × MedMED4 tables reserved and 4 duplicate charges initiated
    W-05L5: ChaosGateway charge succeeds + return webhook drops + user retriesMed × HighHIGHCustomer double-charged while reserving 2 separate VIP tables

    🛡️ 4. The 3-Tier Remediation Blueprint

    Tier 1: Invariants & Hard Guards (Database & Code Drop-In Fix)

    Use a two-phase

    TTL Hold Pattern (PENDING → CONFIRMED) with explicit row locking (FOR UPDATE) and clamped arithmetic:

    async function checkoutTableSafe(
      userId: string,
      tableId: string,
      idempotencyKey: string,
      couponCode?: string
    ) {
      // 1. Atomic DB transaction creates a 10-minute expiring hold + locks coupon
      const hold = await db.transaction(async (tx) => {
        const [table] = await tx.query(
          `SELECT id, price, reserved_count, max_capacity 
           FROM venue_tables WHERE id = $1 FOR UPDATE`,
          [tableId]
        );
        if (!table || table.reserved_count >= table.max_capacity) {
          throw new Error("Sold out");
        }
    
        let discount = 0;
        if (couponCode) {
          const [coupon] = await tx.query(
            `UPDATE coupons SET used_count = used_count + 1
             WHERE code = $1 AND is_active = true AND used_count < max_uses
              AND $2 >= min_spend
             RETURNING discount_amount`,
            [couponCode, table.price]
          );
          if (!coupon) throw new Error("Invalid or exhausted coupon");
          discount = Math.max(0, Number(coupon.discount_amount) || 0);
        }
    
        const finalPrice = Math.round(Math.max(0, table.price - discount));
    
        await tx.query(
          `UPDATE venue_tables SET reserved_count = reserved_count + 1 WHERE id = $1`,
          [tableId]
        );
    
        const [reservation] = await tx.query(
          `INSERT INTO reservations (user_id, table_id, amount, status, idempotency_key, expires_at)
           VALUES ($1, $2, $3, 'PENDING', $4, NOW() + INTERVAL '10 minutes')
           ON CONFLICT (idempotency_key) DO NOTHING
           RETURNING id, amount`,
          [userId, tableId, finalPrice, idempotencyKey]
        );
        return reservation;
      });
    
      // 2. Charge outside DB lock using deterministic idempotency key
      try {
        await paymentGateway.charge(userId, hold.amount, { idempotencyKey });
        await db.query(`UPDATE reservations SET status = 'CONFIRMED' WHERE id = $1`, [hold.id]);
        return { status: "confirmed", reservationId: hold.id, finalPrice: hold.amount };
      } catch (err) {
        // Immediate rollback of held seat on deterministic payment decline
        await db.query(`SELECT release_expired_or_failed_hold($1)`, [hold.id]);
        throw err;
      }
    }
    

    Tier 2: Resilient Interfaces (Ergonomic UX)

    • Generate a client-side UUIDv4

    Idempotency Key when the checkout modal mounts so panic-clicking "Pay Now" never creates duplicate reservations.

    Tier 3: Governance & Operational SOP

    • Run a lightweight cron reaper every 60 seconds to release PENDING reservations where expires_at < NOW() and restore reserved_count.

    Next steps

    • Replace the raw UPDATE query with the transactional FOR UPDATE hold pattern above.
    • Pass idempotencyKey from the frontend checkout session to prevent double-charging on network retries.

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

    About this skill

    Stop Relying on Static Checklists. Break Your System Before Production Does.

    Most software architectures, database schemas, and pricing models don't fail because engineers forgot a basic checklist—they fail because real-world failures are combinatorial, emergent, and multi-layered. A system that passes unit tests can still collapse when Webhook B arrives before Webhook A during a 2-second network lag while a user panic-clicks the submit button.

    What-If is an open-ended, domain-agnostic failure-mode and scenario stress-testing engine adapted from high-reliability systems engineering, Fault-Tree Analysis (FTA), game theory, and pre-mortem deliberation.


    Why Engineers, Architects & Strategists Use What-If

    • Zero-Scenario Input Mode: You don't need to brainstorm "what could go wrong." Paste raw code, a SQL migration, an API spec, a pricing rule, or a PRD—the engine decompiles your hidden optimism and discovers non-obvious edge cases autonomously.
    • The "Currency of Failure" Heuristic: Automatically detects what is irreversibly at stake (Money, Data Consistency, Identity/Trust, Health/Safety, Availability/SLA, Attention, Compliance) and spawns domain-specific attack vectors on the fly.
    • The 5-Layer Reality Stack: Systematically stress-tests your artifact from micro to macro:
      1. Layer 1 — Computational & Invariants: Null coercion, float drift, negative boundaries, non-idempotent state mutations.
      2. Layer 2 — Architectural & Concurrency: Race conditions, out-of-order webhooks, split-brain states, thundering herds.
      3. Layer 3 — Human, Cognitive & Social: Panic resubmits, non-reading users, bystander dilemmas, clipboard corruption.
      4. Layer 4 — Business, Game Theory & Legal: Promo arbitrage, Goodhart's Law exploitation, referral loops, GDPR vs. audit immutability clashes.
      5. Layer 5 — Combinatorial Chaos (Swiss Cheese Model): Pairwise compound failures where 2–3 individually benign conditions collide simultaneously.
    • Strict Actionability Gate (Zero Doom-Mongering): Every discovered flaw is paired with a concrete 3-Tier Remediation Blueprint (Hard Code/DB Guards, Resilient UX Interfaces, and Operational Telemetry SOPs).

    Three Execution Modes

    • /what-if --quick — Fast Layer 1–2 scan for PR reviews and single functions (~500 tokens).
    • /what-if --deep (Default) — Full 5-Layer architectural & concurrency audit for schemas, APIs, and PRDs.
    • /what-if --adversarial — Red-Team & Game Theory focus to expose loopholes in pricing, referral engines, and auth flows.

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Testing & Debugging.

    What-If performs static, architectural, and game-theoretic stress-testing on source code, SQL schemas, and system specs; it does not run live load-testing traffic or active network exploits against production servers. For large monorepos, best results are achieved by scoping audits to specific modules, transaction flows, or PRDs using frontier reasoning models (such as Claude Sonnet/Opus, GPT-4o, or Gemini Pro).

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 9 days ago

    Software
    Git

    Permissions

    Terminal / Shell
    Write Files
    Browser
    Network Access
    Read Files
    Listed9 days ago
    Updated7 days ago

    What's inside

    Frequently Asked Questions

    No. What-If operates on Zero-Scenario Input Mode. You simply paste your raw code, SQL schema, API endpoint, or pricing rule, and the engine automatically decompiles your hidden assumptions, detects what risk currency is at stake, and discovers the non-obvious failure modes for you.

    What-If follows the open SKILL.md standard. It works seamlessly with Claude Code, Cursor, Codex CLI, VS Code GitHub Copilot, Windsurf, Cline, Google Antigravity, and any other agent environment that supports custom skills.

    No. What-If runs 100% locally within your existing AI agent's execution context. It requires only read-only file access to inspect code, makes zero external network requests, and collects no telemetry. Your proprietary codebase and business logic never leave your environment.

    Linters check syntax, and unit tests only verify scenarios you already anticipated. What-If is a combinatorial chaos and pre-mortem engine designed to catch emergent failures: race conditions where webhooks arrive out-of-order, floating-point rounding drift, negative price arbitrage, panic-click resubmissions, and multi-variable Swiss-Cheese catastrophes.

    New in Testing & Debugging