Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
40rty-ai avatar

Shopify Admin Discount Cost Trend

  • 2 installs
  • 173 repo stars
  • Updated June 26, 2026
  • 40rty-ai/shopify-admin-skills

shopify-admin-discount-cost-trend is a read-only Claude Code skill that tracks total Shopify discount dollars over week, month, or quarter buckets, broken down by discount type and code.

About

This Claude Code skill tracks how much a Shopify store gave away in discounts over time, bucketed by week, month, or quarter and broken down by discount code and type. A finance or store owner runs it to see whether discount spend is trending up or down and which campaigns drive it. It is read-only and exports a CSV of discount cost over time.

  • Tracks total discount dollars given over week/month/quarter buckets
  • Breaks discount spend down by code and discount type
  • Read-only, exporting a longitudinal discount-cost CSV

Shopify Admin Discount Cost Trend by the numbers

  • 2 all-time installs (skills.sh)
  • Ranked #1,759 of 2,064 Data Science & ML skills by installs in the Skillselion catalog
  • Data as of Aug 1, 2026 (Skillselion catalog sync)
At a glance

shopify-admin-discount-cost-trend capabilities & compatibility

Free skill; requires an authenticated Shopify store session with read_orders

Capabilities
discount cost tracking · promotion analytics · spend trend analysis
Use cases
data analysis
Runs
Runs locally
Pricing
Free
From the docs

What shopify-admin-discount-cost-trend says it does

Tracks how much money the store gave away in discounts over time, bucketed by week, month, or quarter, and broken down by discount code and discount type
SKILL.md
Answers: "is our discount spend trending up or down, and which campaigns are driving it?" Read-only — no mutations.
SKILL.md
npx skills add https://github.com/40rty-ai/shopify-admin-skills --skill shopify-admin-discount-cost-trend

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs2
repo stars173
Last updatedJune 26, 2026
Repository40rty-ai/shopify-admin-skills

What it does

Track Shopify discount spend over time by code and type to see cost trends.

Who is it for?

Finance owners tracking whether discount spend is rising or falling over time

Skip if: Per-discount ROI or cannibalization analysis, which a separate skill covers

When should I use this skill?

You want a time-series view of total discount cost by code and type

What you get

A bucketed discount-cost trend with per-code and per-type breakdowns.

  • discount_cost_trend_<date>.csv with per-bucket and per-code cost

By the numbers

  • periods_back defaults to 12
  • top_codes defaults to 10
  • 1 GraphQL operation (orders query)

Files

SKILL.mdMarkdownGitHub ↗

Purpose

Tracks how much money the store gave away in discounts over time, bucketed by week, month, or quarter, and broken down by discount code and discount type (percentage / fixed amount / free shipping / automatic). Answers: "is our discount spend trending up or down, and which campaigns are driving it?" Read-only — no mutations. Complements discount-roi-calculator (per-discount return) with a longitudinal view of total cost.

Prerequisites

  • Authenticated Shopify CLI session: shopify store auth --store <domain> --scopes read_orders
  • API scopes: read_orders

Parameters

ParameterTypeRequiredDefaultDescription
storestringyesStore domain (e.g., mystore.myshopify.com)
periodstringnomonthBucket size: week, month, or quarter
periods_backintegerno12Number of buckets to report
top_codesintegerno10Top discount codes to break out individually; remainder grouped as other
include_shipping_discountsboolnotrueWhether to count shipping discounts in the totals
formatstringnohumanOutput format: human or json

Safety

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

Workflow Steps

1. Compute window from period × periods_back (e.g., month × 12 → last 12 calendar months starting from the first day of the bucket 11 months ago)

2. OPERATION: orders — query Inputs: query: "created_at:>='<window_start>' financial_status:paid", first: 250, select createdAt, discountCodes, currentTotalDiscountsSet, totalDiscountsSet, cartDiscountAmountSet, discountApplications { allocationMethod, targetType, value, ... on DiscountCodeApplication { code }, ... on AutomaticDiscountApplication { title }, ... on ManualDiscountApplication { title } }, shippingLines { discountAllocations { allocatedAmountSet } }, pagination cursor Expected output: All paid orders in the window with discount data; paginate until hasNextPage: false

3. For each order, attribute discount cost:

  • cart_discount = currentTotalDiscountsSet.shopMoney.amount
  • shipping_discount = sum of shippingLines.discountAllocations.allocatedAmountSet (only if include_shipping_discounts: true)
  • total_discount = cart_discount + shipping_discount
  • Attribute by code: prefer first discountApplications.code for code discounts, title for automatic / manual

4. Bucket each order into its period (week-of-year, year-month, or year-quarter) and aggregate:

  • Total discount cost per bucket
  • Per discount code per bucket
  • Per discount type per bucket (percentage, fixed_amount, shipping, automatic)

5. Identify top codes by total cost across the window; aggregate the rest as other

GraphQL Operations

# orders:query — validated against api_version 2025-01
query DiscountCostTrend($query: String!, $after: String) {
  orders(first: 250, after: $after, query: $query) {
    edges {
      node {
        id
        name
        createdAt
        discountCodes
        currentTotalDiscountsSet { shopMoney { amount currencyCode } }
        totalDiscountsSet { shopMoney { amount currencyCode } }
        cartDiscountAmountSet { shopMoney { amount currencyCode } }
        discountApplications(first: 10) {
          edges {
            node {
              allocationMethod
              targetType
              targetSelection
              value {
                ... on PricingPercentageValue { percentage }
                ... on MoneyV2 { amount currencyCode }
              }
              ... on DiscountCodeApplication { code }
              ... on AutomaticDiscountApplication { title }
              ... on ManualDiscountApplication { title description }
            }
          }
        }
        shippingLines(first: 5) {
          edges {
            node {
              title
              discountAllocations {
                allocatedAmountSet { shopMoney { amount currencyCode } }
              }
            }
          }
        }
      }
    }
    pageInfo { hasNextPage endCursor }
  }
}

Session Tracking

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

On start, emit:

╔══════════════════════════════════════════════╗
║  SKILL: Discount Cost Trend                  ║
║  Store: <store domain>                       ║
║  Period: <period> × <periods_back>           ║
║  Started: <YYYY-MM-DD HH:MM UTC>             ║
╚══════════════════════════════════════════════╝

After each step, emit:

[N/TOTAL] <QUERY|MUTATION>  <OperationName>
          → Params: <brief summary of key inputs>
          → Result: <count or outcome>

On completion, emit:

For format: human (default):

══════════════════════════════════════════════
DISCOUNT COST TREND  (last <periods_back> <period>s)
  Total discount cost:    $<amount>
  Avg per <period>:        $<amount>
  Latest <period>:         $<amount>   (<delta_vs_prev_pct>% vs prior)

  By bucket:
    2025-Q1  $<n>   (cart $<n> / shipping $<n>)
    2025-Q2  $<n>   (cart $<n> / shipping $<n>)

  By discount type:
    code            $<n>   (<pct>%)
    automatic       $<n>   (<pct>%)
    manual          $<n>   (<pct>%)
    shipping        $<n>   (<pct>%)

  Top codes (by total cost):
    "<code>"        $<n>   (<pct>%)
    "<code>"        $<n>   (<pct>%)
    other           $<n>   (<pct>%)

  Output: discount_cost_trend_<date>.csv
══════════════════════════════════════════════

For format: json, emit:

{
  "skill": "discount-cost-trend",
  "store": "<domain>",
  "period": "month",
  "periods_back": 12,
  "total_discount_cost": 0,
  "by_bucket": [],
  "by_type": { "code": 0, "automatic": 0, "manual": 0, "shipping": 0 },
  "top_codes": [],
  "currency": "USD",
  "output_file": "discount_cost_trend_<date>.csv"
}

Output Format

CSV file discount_cost_trend_<YYYY-MM-DD>.csv with columns: bucket, discount_code_or_title, discount_type, orders_count, cart_discount, shipping_discount, total_discount, currency

Error Handling

ErrorCauseRecovery
THROTTLEDAPI rate limit exceededWait 2 seconds, retry up to 3 times
Stacked discount codesMultiple codes on one orderAttribute proportionally to each code by their value share, or label as multi-code if equal
Manual discount with no titleCashier-entered with empty titleGroup as manual:untitled
Multi-currency ordersPresentment currency != shop currencySum on shopMoney.amount (shop currency) for consistency

Best Practices

  • Use period: week for promotional businesses with frequent campaigns; period: month for stores with steady evergreen offers; period: quarter for board reporting.
  • A flat or rising trend with no campaign activity often points to automatic discount creep — review automatic discounts that have no end date.
  • Cross-reference the latest bucket against discount-roi-calculator to verify the cost increase is producing matching incremental revenue.
  • Set include_shipping_discounts: false if your accounting books shipping subsidy separately from product discounts.
  • Set up monthly automation: discount spend that drifts above budget should trigger a finance review before it shows up in margin reports.

Related skills

FAQ

What time buckets are supported?

Week, month, or quarter, set by the period parameter, with periods_back controlling how many buckets are reported (12 by default).

Can shipping discounts be excluded?

Yes, include_shipping_discounts defaults to true but can be turned off to exclude shipping discounts from the totals.

Data Science & MLecommercefinance

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.