shopify-admin-return-cost-attribution
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "shopify-admin-return-cost-attribution" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-f7f59dca2a29ada4bc039193a27c67578df554a52668919f93bce20a61af798d. Verify the upstream source and version against https://github.com/40RTY-ai/shopify-admin-skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Read-only: Compute true cost of returns by reason and product — including refund amounts, restocking impact, lost shipping costs, and cost-of-goods impact for discarded items.
Introduction source: third_party · 40RTY-ai · 0.0.1 Reference
SkillPi interpretation
- Tasks
- Read-only: calculates the true cost of returns by reason and product — refund dollars, restocking impact, shipping cost lost, and COGS impact for items written off.
- Inputs and outputs
- CSV file `return_cost_<YYYY-MM-DD>.csv` with columns: `group_key`, `return_count`, `units`, `refund_amount`, `shipping_loss`, `cogs_writeoff`, `restocking_labor`, `total_cost`, `avg_cost_per_return`, `top_return_reason`, `currency`
- Software, accounts and paid services
- `shopify store auth --store <domain> --scopes read_orders,read_returns,read_inventory` API scopes: `read_orders`, `read_returns`, `read_inventory`
- Testing
- Not tested
Browse files
Frontmatter
name: shopify-admin-return-cost-attribution
role: returns
description: "Read-only: calculates the true cost of returns by reason and product — refund dollars, restocking impact, shipping cost lost, and COGS impact for items written off."
toolkit: shopify-admin, shopify-admin-execution
api_version: "2025-01"
graphql_operations:
- returns:query
- orders:query
- inventoryItems:query
status: stable
compatibility: Claude Code, Cursor, Codex, Gemini CLIPurpose
Quantifies the full cost of returns over a window — not just the refunded amount. Combines refund totals, lost shipping revenue, COGS for non-restockable items (e.g., DEFECTIVE), and restocking labor into a per-reason and per-product return P&L. Read-only. Use to prioritize which reasons or product lines deserve operational fixes — better packaging, size guides, listing accuracy.
Prerequisites
shopify store auth --store <domain> --scopes read_orders,read_returns,read_inventory- API scopes:
read_orders,read_returns,read_inventory
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| store | string | yes | — | Store domain (e.g., mystore.myshopify.com) |
| format | string | no | human | Output format: human or json |
| days_back | integer | no | 90 | Lookback window for returns |
| group_by | string | no | reason | Aggregation level: reason, product, sku, or reason_x_product |
| min_returns | integer | no | 3 | Minimum returns per group to include in summary |
| writeoff_reasons | array | no | ["DEFECTIVE"] |
Return reasons whose items are treated as non-restockable (full COGS write-off) |
| flat_restocking_cost | float | no | 5.00 | Average labor cost per return line item to model restocking workload |
Safety
ℹ️ Read-only skill — no mutations are executed. Cost figures are estimates derived from
unitCost, refund totals, andflat_restocking_cost— calibrate the flat-cost figure to your operation before treating outputs as accounting truth.
Workflow Steps
-
OPERATION:
returns— query Inputs:query: "created_at:>='<NOW - days_back days>'",first: 250, select returns with line item pricing, product/variant,inventoryItem.idExpected output: All returns in window with per-line-item pricing -
OPERATION:
orders— query Inputs: For each return'sorder.id, fetchrefunds { totalRefundedSet refundLineItems { quantity subtotalSet totalTaxSet lineItem { id } } }Expected output: Refund amounts mappable to line items -
OPERATION:
inventoryItems— query — batch uniqueinventoryItem.idfrom step 1; returnsunitCostper item -
Per line item compute:
refund_amount(matched refundLineItem proportional to returned qty),shipping_loss(order shipping × line-item value share for full-order returns; else 0),cogs_writeoff(unitCost × qtyonly ifreturnReason in writeoff_reasons),restocking_labor(flat_restocking_cost × qty). Sum and aggregate bygroup_by.
GraphQL Operations
# returns:query — validated against api_version 2025-01
query ReturnsForCostAttribution($query: String!, $after: String) {
returns(first: 250, after: $after, query: $query) {
edges {
node {
id
status
createdAt
totalQuantity
order {
id
name
totalShippingPriceSet { shopMoney { amount currencyCode } }
totalPriceSet { shopMoney { amount currencyCode } }
}
returnLineItems(first: 50) {
edges { node {
id
quantity
returnReason
fulfillmentLineItem { lineItem {
id
title
quantity
discountedTotalSet { shopMoney { amount currencyCode } }
originalUnitPriceSet { shopMoney { amount currencyCode } }
variant { id sku inventoryItem { id } }
product { id title vendor }
} }
} }
}
}
}
pageInfo { hasNextPage endCursor }
}
}
# orders:query — validated against api_version 2025-01
query OrderRefundsForReturns($query: String!, $after: String) {
orders(first: 250, after: $after, query: $query) {
edges {
node {
id
name
refunds {
id
createdAt
totalRefundedSet { shopMoney { amount currencyCode } }
refundLineItems(first: 50) {
edges { node {
quantity
subtotalSet { shopMoney { amount currencyCode } }
totalTaxSet { shopMoney { amount currencyCode } }
lineItem { id }
} }
}
}
}
}
pageInfo { hasNextPage endCursor }
}
}
# inventoryItems:query — validated against api_version 2025-01
query InventoryUnitCosts($ids: [ID!]!) {
nodes(ids: $ids) {
... on InventoryItem {
id
unitCost { amount currencyCode }
tracked
}
}
}
Session Tracking
Claude MUST emit the following output at each stage. This is mandatory.
On start, emit:
╔══════════════════════════════════════════════╗
║ SKILL: Return Cost Attribution ║
║ 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):
══════════════════════════════════════════════
RETURN COST ATTRIBUTION (<days_back> days, group: <group_by>)
Returns analyzed: <n>
Total return cost: $<amount> (refund <pct>%, shipping <pct>%, COGS <pct>%, labor <pct>%)
Top cost drivers:
<group> Returns: <n> Total: $<n> Avg: $<n> Top reason: <reason>
Output: return_cost_<date>.csv
══════════════════════════════════════════════
For format: json, emit:
{
"skill": "return-cost-attribution",
"store": "<domain>",
"period_days": 90,
"group_by": "reason",
"returns_analyzed": 0,
"totals": {
"total_cost": 0, "refund": 0, "shipping_loss": 0,
"cogs_writeoff": 0, "restocking_labor": 0, "currency": "USD"
},
"groups": [],
"output_file": "return_cost_<date>.csv"
}
Output Format
CSV file return_cost_<YYYY-MM-DD>.csv with columns:
group_key, return_count, units, refund_amount, shipping_loss, cogs_writeoff, restocking_labor, total_cost, avg_cost_per_return, top_return_reason, currency
Error Handling
| Error | Cause | Recovery |
|---|---|---|
THROTTLED |
API rate limit exceeded | Wait 2 seconds, retry up to 3 times |
Missing unitCost |
Cost not recorded | Treat COGS as 0 and flag the row |
| Refund not yet processed | Customer not yet refunded | Use line item discounted total as estimate |
| Multiple refunds per return | Partial refund history | Sum refunds tied to the return's line items |
| No shipping cost | Free shipping | Shipping loss = 0 |
Best Practices
- Use
group_by: reason_x_productto surface lethal combos likeDEFECTIVE × <hero SKU>— supplier-quality issues addressable at the source. - Re-run after
unitCostupdates; stale cost most often skews COGS write-off. - Pair with
return-reason-analysisto compare "what returns most" with "what costs most" — they often diverge.
Version history
-
v1.1.0
GitHub ↗
Original release notes
## 🤖 New category: Agentic Commerce Readiness The fix-it side of the [**agentiq.report**](https://agentiq.report) audit. The audit tells operators *where* AI shopping agents (ChatGPT, Gemini, Perplexity, agentic checkout) can't find, read, or recommend their store. This release adds **10 skills that remediate those findings** via the native Shopify Admin GraphQL toolkit — closing the loop: **audit finds the gap → run the matching skill → re-audit confirms.** Every skill declares the audit **signals** it fixes (`audit_signals` frontmatter), so a finding in the report maps directly to the skill that resolves it. ### Skills - **`agentic-readiness-audit`** — flagship, read-only store-side scorecard that routes each gap to its fix skill - **`agentic-product-jsonld-backfill`** — barcode/GTIN, vendor, product type for complete Product JSON-LD - **`agentic-image-alt-text`** — descriptive alt text on product media - **`agentic-description-enrichment`** — fact-rich descriptions for AI quoting - **`agentic-metafields-setup`** — define + populate agentic metafields for filtering - **`agentic-product-taxonomy`** — Shopify Standard Product Taxonomy categories - **`agentic-crawler-access`** — allow GPTBot/ClaudeBot/PerplexityBot… in `robots.txt.liquid` - **`agentic-llms-txt`** — publish a curated `/llms.txt` for AI assistants - **`agentic-organization-schema`** — Organization JSON-LD (sameAs, contactPoint) into the theme - **`agentic-policy-readability`** — machine-readable shipping/returns policies Plus a weekly **`agentic-readiness-monitor`** routine that re-audits and alerts on regressions. ### Stats **116 skills across 11 categories** (was 106/10), **21 routines** (was 20). All GraphQL validated against the live Admin 2025-01 schema; `pnpm validate:index` passes (116 skills, 64 operations). ### Notes Theme-editing and policy skills default to `dry_run`/`audit` mode, write inside managed `# BEGIN/END` blocks, and recommend duplicating the theme first.
Current listing version
0.0.1
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 直接解决电商运营中退货成本核算的核心痛点
- 提供多维度的成本归因分析(退款、运费损失、COGS、人工成本)
- 帮助商家识别高成本退货原因和产品,优化运营决策
Highlights
- description明确描述了技能的功能和使用场景
- 触发词精准完整,覆盖多种变体,边界清晰
Highlights
- 文档结构良好,包含详细的参数说明、工作流程、GraphQL操作和错误处理
- Phase/步骤清晰,有出口条件,含端到端示例
- frontmatter完整,单文件≤500行
Highlights
- 工具来源明确,参数正确
- 覆盖主要异常,提供了详细的错误处理机制
- 不可逆操作有确认机制(只读操作)
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
`shopify store auth --store <domain> --scopes read_orders,read_returns,read_inventory` API scopes: `read_orders`, `read_returns`, `read_inventory`
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.