# Shopify Admin Frequently Bought Together

> Read-only: mines order history to find product pairs and triplets frequently purchased together, generating cross-sell and bundle recommendations.

- **Type:** Skill
- **Install:** `agentstack add skill-40rty-ai-shopify-admin-skills-shopify-admin-frequently-bought-together`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [40RTY-ai](https://agentstack.voostack.com/s/40rty-ai)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [40RTY-ai](https://github.com/40RTY-ai)
- **Source:** https://github.com/40RTY-ai/shopify-admin-skills/tree/main/skills/conversion-optimization/shopify-admin-frequently-bought-together
- **Website:** http://skills.40rty.ai

## Install

```sh
agentstack add skill-40rty-ai-shopify-admin-skills-shopify-admin-frequently-bought-together
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

## Purpose
Analyzes order history to discover which products are frequently purchased together. Calculates co-occurrence frequency, lift scores, and confidence metrics to generate data-driven cross-sell recommendations and bundle candidates. Read-only — no mutations.

## Prerequisites
- Authenticated Shopify CLI session: `shopify store auth --store  --scopes read_orders,read_products`
- API scopes: `read_orders`, `read_products`

## Parameters

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| store | string | yes | — | Store domain |
| days_back | integer | no | 180 | Order lookback window |
| min_support | integer | no | 3 | Minimum co-occurrence count to report a pair |
| max_results | integer | no | 25 | Maximum product pairs to return |
| group_size | integer | no | 2 | Pair size: `2` for pairs, `3` for triplets |
| collection_filter | string | no | — | Limit to products in a specific collection |
| format | string | no | human | Output format: `human` or `json` |

## Safety

> ℹ️ Read-only skill — no mutations are executed. Safe to run at any time.

## Workflow Steps

1. **OPERATION:** `orders` — query
   **Inputs:** `query: "created_at:>=''"`, `first: 250`, select `lineItems { product { id, title } }`, pagination cursor
   **Expected output:** All orders with product-level line items

2. For each order with 2+ distinct products, generate all product pair combinations

3. Build co-occurrence matrix:
   - **Support** = number of orders containing both products
   - **Confidence(A→B)** = P(B|A) = support(A,B) / support(A)
   - **Lift** = confidence(A→B) / P(B) — lift > 1.0 means positive association

4. **OPERATION:** `products` — query (enrichment)
   **Inputs:** Product IDs from top pairs for titles, images, prices
   **Expected output:** Product details for display

5. Rank pairs by lift score (descending), filter by min_support

## GraphQL Operations

```graphql
# orders:query — validated against api_version 2025-01
query OrderLineItems($query: String!, $after: String) {
  orders(first: 250, after: $after, query: $query) {
    edges {
      node {
        id
        lineItems(first: 50) {
          edges {
            node {
              product { id title }
              quantity
            }
          }
        }
      }
    }
    pageInfo { hasNextPage endCursor }
  }
}
```

```graphql
# products:query — validated against api_version 2025-01
query ProductDetails($ids: [ID!]!) {
  nodes(ids: $ids) {
    ... on Product {
      id
      title
      vendor
      productType
      priceRangeV2 {
        minVariantPrice { amount currencyCode }
        maxVariantPrice { amount currencyCode }
      }
      totalInventory
      status
    }
  }
}
```

## Session Tracking

**Claude MUST emit the following output at each stage. This is mandatory.**

**On start**, emit:
```
╔══════════════════════════════════════════════╗
║  SKILL: Frequently Bought Together           ║
║  Store:                        ║
║  Started:              ║
╚══════════════════════════════════════════════╝
```

**After each step**, emit:
```
[N/TOTAL]   
          → Params: 
          → Result: 
```

**On completion**, emit:

For `format: human` (default):
```
══════════════════════════════════════════════
FREQUENTLY BOUGHT TOGETHER  ( days,  orders analyzed)
  Unique product pairs found: 
  Pairs meeting min_support:  

  TOP PAIRS BY LIFT:
  #1  "" + ""
      Support:  orders  Lift: x  Confidence: %

  #2  "" + ""
      Support:  orders  Lift: x  Confidence: %

  BUNDLE CANDIDATES (high support + high lift):
    "" + ""  →  Suggested bundle price: $

  Output: fbt_pairs_.csv
══════════════════════════════════════════════
```

## Output Format
CSV file `fbt_pairs_.csv` with columns:
`product_a_id`, `product_a_title`, `product_b_id`, `product_b_title`, `support`, `confidence_a_to_b`, `confidence_b_to_a`, `lift`, `combined_avg_price`

## Error Handling
| Error | Cause | Recovery |
|-------|-------|----------|
| `THROTTLED` | API rate limit exceeded | Wait 2 seconds, retry up to 3 times |
| Single-item orders only | Store with no multi-item orders | Report empty — suggest longer lookback window |
| Too many products | Combinatorial explosion | Limit to top 500 products by order count |

## Best Practices
- Use `days_back: 180` or `365` for sufficient sample size.
- Pairs with lift > 2.0 are strong bundle candidates.
- Use results to create manual product bundles or configure upsell apps.
- Cross-reference with `top-product-performance` to ensure paired items are high-performing.
- Products with high confidence A→B but low confidence B→A suggest directional upsells (show B when A is in cart).

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [40RTY-ai](https://github.com/40RTY-ai)
- **Source:** [40RTY-ai/shopify-admin-skills](https://github.com/40RTY-ai/shopify-admin-skills)
- **License:** MIT
- **Homepage:** http://skills.40rty.ai

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-40rty-ai-shopify-admin-skills-shopify-admin-frequently-bought-together
- Seller: https://agentstack.voostack.com/s/40rty-ai
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
