{
  "format": "siebly-agent-recipe/v1",
  "id": "ai-pattern-library",
  "title": "AI Pattern Library",
  "lastReviewed": "2026-05-12",
  "scope": {
    "runtime": "Node.js LTS",
    "language": "TypeScript preferred for exchange integrations",
    "purpose": "Index reusable implementation lifecycles first, then exchange-specific guides that specialize them."
  },
  "patterns": [
    {
      "id": "historical-live-data-pipeline-core",
      "title": "Historical Backfill with Live WebSocket Streams",
      "guide": "https://siebly.io/ai/historical-live-data-pipeline",
      "recipe": "https://siebly.io/.well-known/recipes/historical-live-data-pipeline-core.json",
      "implementations": [
        "https://siebly.io/ai/candle-pipeline/binance",
        "https://siebly.io/ai/candle-pipeline/bybit"
      ]
    },
    {
      "id": "exchange-state-management",
      "title": "Exchange State Management",
      "guide": "https://siebly.io/ai/exchange-state",
      "recipe": "https://siebly.io/.well-known/recipes/exchange-state-management.json",
      "manifest": "https://siebly.io/.well-known/agent-manifests/exchange-state-management/latest.json",
      "runtimeKit": "https://siebly.io/.well-known/runtime-kits/exchange-state-management/v1/index.json",
      "integrationKit": "https://siebly.io/.well-known/integration-kits/exchange-state-management/latest.json",
      "conformancePack": "https://siebly.io/.well-known/conformance/exchange-state-management/latest.json",
      "implementations": [
        "https://siebly.io/ai/exchange-state/binance",
        "https://siebly.io/ai/exchange-state/bybit"
      ]
    },
    {
      "id": "order-intent-chaser",
      "title": "Order Intent Chasing with Exchange APIs & WebSockets",
      "guide": "https://siebly.io/ai/order-intent-chaser",
      "recipe": "https://siebly.io/.well-known/recipes/order-intent-chaser.json",
      "implementations": []
    }
  ],
  "categories": [
    {
      "id": "core-patterns",
      "title": "Core patterns",
      "items": [
        {
          "id": "historical-live-data-pipeline-core",
          "title": "Historical Backfill with Live WebSocket Streams",
          "guide": "https://siebly.io/ai/historical-live-data-pipeline"
        },
        {
          "id": "exchange-state-management",
          "title": "Exchange State Management",
          "guide": "https://siebly.io/ai/exchange-state"
        }
      ]
    },
    {
      "id": "execution-adapters",
      "title": "Execution adapters",
      "items": [
        {
          "id": "order-intent-chaser",
          "title": "Order Intent Chasing with Exchange APIs & WebSockets",
          "guide": "https://siebly.io/ai/order-intent-chaser"
        }
      ]
    },
    {
      "id": "exchange-implementations",
      "title": "Exchange implementations",
      "items": [
        {
          "id": "binance-spot-candle-close-pipeline",
          "title": "Candle-Close Pipeline with Binance APIs & WebSockets",
          "guide": "https://siebly.io/ai/candle-pipeline/binance"
        },
        {
          "id": "binance-position-manager",
          "title": "Position Management with Binance APIs & WebSockets",
          "guide": "https://siebly.io/ai/exchange-state/binance"
        },
        {
          "id": "bybit-candle-close-pipeline",
          "title": "Candle-Close Pipeline with Bybit APIs & WebSockets",
          "guide": "https://siebly.io/ai/candle-pipeline/bybit"
        },
        {
          "id": "bybit-position-manager",
          "title": "Position Management with Bybit APIs & WebSockets",
          "guide": "https://siebly.io/ai/exchange-state/bybit"
        }
      ]
    },
    {
      "id": "exchange-request-shapes",
      "title": "Exchange request shapes",
      "items": [
        {
          "id": "binance-usdm-algo-orders",
          "title": "Stop Loss using Conditional Algo Orders with Binance USD-M APIs & WebSockets",
          "guide": "https://siebly.io/ai/algo-orders/binance"
        }
      ]
    }
  ],
  "usage": [
    "Read the core pattern before an exchange implementation page when the workflow matches a reusable lifecycle.",
    "Use core pages for exchange-neutral lifecycle behavior.",
    "Use exchange pages for SDK client names, request fields, private topics, error codes, product terminology, and conformance artifacts.",
    "Keep reusable lifecycle behavior consistent when combining prompts, guides, recipes, skills, and local code.",
    "Trace the full lifecycle chain across runtime boundaries before implementation is considered complete.",
    "Every behavior claim should map to a fixture, replay case, or documented non-claim."
  ],
  "safety": [
    "Pattern pages do not override exchange docs, installed SDK declarations, or current package examples.",
    "DEMO, TESTNET, and LIVE remain disabled by default until the selected [EXECUTION_MODE](https://siebly.io/reference/glossary#execution-mode) value is explicitly configured and all required gates pass.",
    "Public-data, private-state, and execution-adapter workflows use different trust boundaries; do not copy order/position rules into market-data-only code."
  ],
  "promptFrameworkCompletionWorkflow": {
    "instruction": "Recursive completion workflow:\n1. Before implementation, save this exact prompt in docs/AI_PROMPT.md (or docs/SPEC.md when that is the project standard) and write docs/PLAN.md with phases, invariants, tests or fixtures, docs to update, and acceptance gates.\n2. Review docs/PLAN.md for missing workflows, unsafe assumptions, product/exchange-specific leakage, unclear state ownership, confirmation or recovery gaps, missing tests, and incomplete docs. Update docs/PLAN.md and repeat until one full review pass finds no actionable changes.\n3. Implement one plan phase at a time. After each phase, review changed code, tests, fixtures, docs, generated artifacts, and runtime workflows against docs/PLAN.md and this prompt. Fix gaps and repeat until that phase has no actionable changes before starting the next phase.\n4. After all phases, run a full-depth project review across every workflow, lifecycle, state transition, error path, and artifact. This is not a shallow summary pass. Fix every actionable gap and repeat until a full pass finds no further changes, then record the final review outcome in docs/PLAN.md.",
    "acceptanceRequirement": "docs/PLAN.md records the initial plan, plan-review iterations, phase review outcomes, final full-project review, validation commands, and any documented non-claims. No plan phase or project completion is accepted until the recursive review loop finds no actionable gaps, flaws, or incomplete workflows left to correct."
  }
}
