/shopify-admin-profit-margin-calculator
Read-only: calculates true net profit per order and per product by factoring in COGS, shipping costs, transaction fees, discounts, refunds, and taxes.
$ npx -y skills add 40rty-ai/shopify-admin-skills --skill shopify-admin-profit-margin-calculator --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/shopify-admin-profit-margin-calculator
Context preview
The summary Claude sees to decide when to auto-load this skill.
Read-only: calculates true net profit per order and per product by factoring in COGS, shipping costs, transaction fees, discounts, refunds, and taxes.
SKILL.md
shopify-admin-profit-margin-calculator.SKILL.mdname: shopify-admin-profit-margin-calculator
role: finance
description: "Read-only: calculates true net profit per order and per product by factoring in COGS, shipping costs, transaction fees, discounts, refunds, and taxes."
toolkit: shopify-admin, shopify-admin-execution
api_version: "2025-01"
graphql_operations:
- orders:query
- inventoryItems:query
- productVariants:query
status: stable
compatibility: Claude Code, Cursor, Codex, Gemini CLI
Purpose
Calculates true net profit and margin at both order-level and product-level granularity. Unlike basic revenue reports, this skill deducts all cost components — COGS (from inventoryItem.unitCost), shipping costs, transaction/payment processing fees, applied discounts, refund amounts, and duties/taxes — to surface actual margin percentages. Read-only — no mutations.
Prerequisites
- Authenticated Shopify CLI session: `shopify store auth --store <domain> --scopes read_orders,read_products,read_inventory`
- API scopes: `read_orders`, `read_products`, `read_inventory`
- For accurate results, products should have `inventoryItem.unitCost` populated
Parameters
| Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | store | string | yes | — | Store domain (e.g., mystore.myshopify.com) | | days_back | integer | no | 30 | Lookback window for orders | | group_by | string | no | order | Grouping: `order`, `product`, or `variant` | | min_orders | integer | no | 1 | Minimum orders for a product to appear (product/variant mode) | | include_refunded | boolean | no | true | Include fully refunded orders in calculation | | 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:>='<NOW - days_back days>'"`, `first: 250`, select `id`, `name`, `createdAt`, `totalPriceSet`, `subtotalPriceSet`, `totalShippingPriceSet`, `totalTaxSet`, `totalDiscountsSet`, `currentTotalPriceSet`, `displayFinancialStatus`, `refunds { totalRefundedSet }`, `lineItems { variant { id, inventoryItem { id, unitCost { amount, currencyCode } } }, quantity, originalTotalSet, discountedTotalSet }`, pagination cursor **Expected output:** All orders in window with full cost breakdown
2. **OPERATION:** `inventoryItems` — query **Inputs:** Batch of `inventoryItemIds` from line item variants for any missing unitCost data **Expected output:** Unit cost for each inventory item
3. For each order, calculate:
- **Revenue** = `currentTotalPriceSet.shopMoney.amount`
- **COGS** = Σ(lineItem.quantity × variant.inventoryItem.unitCost)
- **Shipping Cost** = `totalShippingPriceSet.shopMoney.amount` (merchant-paid portion estimate)
- **Discounts** = `totalDiscountsSet.shopMoney.amount`
- **Transaction Fee** = estimated at 2.9% + $0.30 of total (configurable)
- **Refunds** = Σ(refunds.totalRefundedSet.shopMoney.amount)
- **Net Profit** = Revenue - COGS - Shipping - Transaction Fee - Refunds
- **Margin %** = (Net Profit / Revenue) × 100
4. If `group_by: product` or `variant`, aggregate profits by product/variant across all orders
5. **OPERATION:** `productVariants` — query (enrichment) **Inputs:** Variant IDs from profitable/unprofitable items for product title context **Expected output:** Product titles, SKUs for display
GraphQL Operations
# orders:query — validated against api_version 2025-01
query OrdersWithCosts($query: String!, $after: String) {
orders(first: 250, after: $after, query: $query) {
edges {
node {
id
name
createdAt
displayFinancialStatus
totalPriceSet { shopMoney { amount currencyCode } }
subtotalPriceSet { shopMoney { amount currencyCode } }
totalShippingPriceSet { shopMoney { amount currencyCode } }
totalTaxSet { shopMoney { amount currencyCode } }
totalDiscountsSet { shopMoney { amount currencyCode } }
currentTotalPriceSet { shopMoney { amount currencyCode } }
refunds {
totalRefundedSet { shopMoney { amount currencyCode } }
}
lineItems(first: 50) {
edges {
node {
quantity
originalTotalSet { shopMoney { amount currencyCode } }
discountedTotalSet { shopMoney { amount currencyCode } }
variant {
id
sku
inventoryItem {
id
unitCost { amount currencyCode }
}
product {
id
title
}
}
}
}
}
}
}
pageInfo { hasNextPage endCursor }
}
}# inventoryItems:query — validated against api_version 2025-01
query InventoryItemCosts($ids: [ID!]!) {
nodes(ids: $ids) {
... on InventoryItem {
id
unitCost { amount currencyCode }
}
}
}# productVariants:query — validated against api_version 2025-01
query VariantDetails($ids: [ID!]!) {
nodes(ids: $ids) {
... on ProductVariant {
id
sku
title
product { id title vendor }
}
}
}Session Tracking
**Claude MUST emit the following output at each stage. This is mandatory.**
**On start**, emit:
╔══════════════════════════════════════════════╗
║ SKILL: Profit & Margin Calculator ║
║ Store: <store domain> ║
║ 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):
══════════════════════════════════════════════
PROFIT & MARGIN REPO
Read more
name: shopify-admin-profit-margin-calculator role: finance description: "Read-only: calculates true net profit per order and per product by factoring in COGS, shipping costs, transaction fees, discounts, refunds, and taxes." toolkit: shopify-admin, shopify-admin-execution api_version: "2025-01" graphql_operations: - orders:query - inventoryItems:query - productVariants:query status: stable compatibility: Claude Code, Cursor, Codex, Gemini CLI
Purpose
Calculates true net profit and margin at both order-level and product-level granularity. Unlike basic revenue reports, this skill deducts all cost components — COGS (from inventoryItem.unitCost), shipping costs, transaction/payment processing fees, applied discounts, refund amounts, and duties/taxes — to surface actual margin percentages. Read-only — no mutations.
Prerequisites
- Authenticated Shopify CLI session: `shopify store auth --store <domain> --scopes read_orders,read_products,read_inventory`
- API scopes: `read_orders`, `read_products`, `read_inventory`
- For accurate results, products should have `inventoryItem.unitCost` populated
Parameters
| Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | store | string | yes | — | Store domain (e.g., mystore.myshopify.com) | | days_back | integer | no | 30 | Lookback window for orders | | group_by | string | no | order | Grouping: `order`, `product`, or `variant` | | min_orders | integer | no | 1 | Minimum orders for a product to appear (product/variant mode) | | include_refunded | boolean | no | true | Include fully refunded orders in calculation | | 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:>='<NOW - days_back days>'"`, `first: 250`, select `id`, `name`, `createdAt`, `totalPriceSet`, `subtotalPriceSet`, `totalShippingPriceSet`, `totalTaxSet`, `totalDiscountsSet`, `currentTotalPriceSet`, `displayFinancialStatus`, `refunds { totalRefundedSet }`, `lineItems { variant { id, inventoryItem { id, unitCost { amount, currencyCode } } }, quantity, originalTotalSet, discountedTotalSet }`, pagination cursor **Expected output:** All orders in window with full cost breakdown
2. **OPERATION:** `inventoryItems` — query **Inputs:** Batch of `inventoryItemIds` from line item variants for any missing unitCost data **Expected output:** Unit cost for each inventory item
3. For each order, calculate:
- **Revenue** = `currentTotalPriceSet.shopMoney.amount`
- **COGS** = Σ(lineItem.quantity × variant.inventoryItem.unitCost)
- **Shipping Cost** = `totalShippingPriceSet.shopMoney.amount` (merchant-paid portion estimate)
- **Discounts** = `totalDiscountsSet.shopMoney.amount`
- **Transaction Fee** = estimated at 2.9% + $0.30 of total (configurable)
- **Refunds** = Σ(refunds.totalRefundedSet.shopMoney.amount)
- **Net Profit** = Revenue - COGS - Shipping - Transaction Fee - Refunds
- **Margin %** = (Net Profit / Revenue) × 100
4. If `group_by: product` or `variant`, aggregate profits by product/variant across all orders
5. **OPERATION:** `productVariants` — query (enrichment) **Inputs:** Variant IDs from profitable/unprofitable items for product title context **Expected output:** Product titles, SKUs for display
GraphQL Operations
# orders:query — validated against api_version 2025-01
query OrdersWithCosts($query: String!, $after: String) {
orders(first: 250, after: $after, query: $query) {
edges {
node {
id
name
createdAt
displayFinancialStatus
totalPriceSet { shopMoney { amount currencyCode } }
subtotalPriceSet { shopMoney { amount currencyCode } }
totalShippingPriceSet { shopMoney { amount currencyCode } }
totalTaxSet { shopMoney { amount currencyCode } }
totalDiscountsSet { shopMoney { amount currencyCode } }
currentTotalPriceSet { shopMoney { amount currencyCode } }
refunds {
totalRefundedSet { shopMoney { amount currencyCode } }
}
lineItems(first: 50) {
edges {
node {
quantity
originalTotalSet { shopMoney { amount currencyCode } }
discountedTotalSet { shopMoney { amount currencyCode } }
variant {
id
sku
inventoryItem {
id
unitCost { amount currencyCode }
}
product {
id
title
}
}
}
}
}
}
}
pageInfo { hasNextPage endCursor }
}
}# inventoryItems:query — validated against api_version 2025-01
query InventoryItemCosts($ids: [ID!]!) {
nodes(ids: $ids) {
... on InventoryItem {
id
unitCost { amount currencyCode }
}
}
}# productVariants:query — validated against api_version 2025-01
query VariantDetails($ids: [ID!]!) {
nodes(ids: $ids) {
... on ProductVariant {
id
sku
title
product { id title vendor }
}
}
}Session Tracking
**Claude MUST emit the following output at each stage. This is mandatory.**
**On start**, emit:
╔══════════════════════════════════════════════╗ ║ SKILL: Profit & Margin Calculator ║ ║ Store: <store domain> ║ ║ 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):
══════════════════════════════════════════════ PROFIT & MARGIN REPO
Community-maintained AI agent skills for operating Shopify stores — workflows, optimization, reports and more
Other skills on shopify-admin-skills.
- /shopify-admin-agentic-crawler-access
Edit the theme's robots.txt.liquid to explicitly allow AI crawlers (GPTBot, ClaudeBot, PerplexityBot, Google-Extended, OAI-SearchBot, Amazonbot) so AI assistants are permitted to read the catalog.
Open skill - /shopify-admin-agentic-description-enrichment
Rewrite thin product descriptions into structured, fact-rich copy (materials, fit, use-cases, the words shoppers actually type) so AI agents have something concrete to quote and match.
Open skill - /shopify-admin-agentic-image-alt-text
Generate and set descriptive alt text on product images so AI agents (which can't 'see' pixels) can understand and recommend what each product looks like.
Open skill - /shopify-admin-agentic-llms-txt
Generate and publish an /llms.txt guide (brand summary, flagship products, key policies, contact) via a theme template so AI assistants get a curated, machine-readable map of the store.
Open skill - /shopify-admin-agentic-metafields-setup
Define and populate agentic-commerce metafields (material, attributes, key features, specs, sizing) so AI agents can filter and match products to specific shopper requirements.
Open skill - /shopify-admin-agentic-organization-schema
Inject an Organization JSON-LD block (name, logo, sameAs social links, contactPoint) into the theme so AI agents can verify the store is a real, trusted brand and link it to its public identity.
Open skill

