shopify-admin-collection-reorganization
Purpose
Reorders products in a manual Shopify collection by inventory level without navigating the Shopify admin UI. This skill queries all products in the collection, computes the desired sort order by totalInventory, and applies it in a single collectionReorderProducts mutation. Note: only works on manual (custom) collections — smart collections managed by Shopify rules are not supported.
Prerequisites
- Authenticated Shopify CLI session:
shopify auth login --store <domain> - API scopes:
read_products,write_products
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 |
| dry_run | bool | no | false | Preview operations without executing mutations |
| collection_id | string | yes | — | GID of the manual collection (e.g., gid://shopify/Collection/123) |
| sort_by | string | no | inventory_desc | inventory_desc (highest stock first) or inventory_asc (lowest stock first) |
Safety
⚠️ Step 2 executes
collectionReorderProductswhich changes the product display order immediately. The sort is reversible — run again with the oppositesort_byto restore previous order — but the original custom order cannot be recovered once overwritten. Themovesarray passed to the mutation must be complete; partial moves produce undefined ordering. Always run withdry_run: truefirst to review the computed sort order before committing.
collectionReorderProducts only works on manual (custom) collections. If the collection has sortOrder other than MANUAL, the skill must abort with a clear message: "Cannot reorder: collection sort order is not MANUAL. Switch the collection to manual sorting in the Shopify admin first."
Workflow Steps
-
OPERATION:
collection— query Inputs:id: <collection_id>,first: 250, pagination cursor Expected output: Collection metadata (title,sortOrder) and all product nodes withtotalInventory; verifysortOrder == "MANUAL"— abort if not; paginate until all products fetched -
OPERATION:
collectionReorderProducts— mutation Inputs:id: <collection_id>,movesarray sorted bytotalInventorypersort_byparameter — each move is{id: <product_id>, newPosition: "<index>"}(0-indexed string) Expected output:job.idandjob.done;userErrors
GraphQL Operations
# collection:query — validated against api_version 2025-01
query CollectionProducts($id: ID!, $first: Int!, $after: String) {
collection(id: $id) {
id
title
sortOrder
products(first: $first, after: $after) {
edges {
node {
id
title
totalInventory
variants(first: 100) {
edges {
node {
inventoryQuantity
}
}
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
# collectionReorderProducts:mutation — validated against api_version 2025-01
mutation CollectionReorderProducts($id: ID!, $moves: [MoveInput!]!) {
collectionReorderProducts(id: $id, moves: $moves) {
job {
id
done
}
userErrors {
field
message
}
}
}
Session Tracking
Claude MUST emit the following output at each stage. This is mandatory.
On start, emit:
╔══════════════════════════════════════════════╗
║ SKILL: collection-reorganization ║
║ 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>
If dry_run: true, prefix every mutation step with [DRY RUN] and do not execute it.
On completion, emit:
For format: human (default):
══════════════════════════════════════════════
OUTCOME SUMMARY
Collection: <title>
Products reordered: <n>
Sort order: <inventory_desc|inventory_asc>
Errors: 0
Output: none
══════════════════════════════════════════════
For format: json, emit:
{
"skill": "collection-reorganization",
"store": "<domain>",
"started_at": "<ISO8601>",
"completed_at": "<ISO8601>",
"dry_run": false,
"steps": [
{ "step": 1, "operation": "CollectionProducts", "type": "query", "params_summary": "collection_id: <gid>, first: 250", "result_summary": "<n> products fetched", "skipped": false },
{ "step": 2, "operation": "CollectionReorderProducts", "type": "mutation", "params_summary": "sort_by: inventory_desc, <n> moves", "result_summary": "job submitted", "skipped": false }
],
"outcome": {
"collection_title": "<title>",
"products_reordered": 0,
"sort_by": "inventory_desc",
"errors": 0,
"output_file": null
}
}
Output Format
No CSV output. The skill reports the new sort order in the session completion summary. Use dry_run: true to preview the computed position list without committing.
Error Handling
| Error | Cause | Recovery |
|---|---|---|
sortOrder is not MANUAL |
Collection is a smart/automated collection | Switch collection to manual ordering in Shopify admin |
userErrors in mutation |
Invalid product ID or position | Check all product IDs belong to the collection |
| Collection not found | Invalid collection GID | Verify the GID in Shopify admin |
| Rate limit (429) | Too many paginated requests | Reduce first to 100 and retry |
Best Practices
- Always run
dry_run: truefirst — the skill will print the proposed product order so you can verify before committing. collectionReorderProductsis asynchronous —job.donemay befalseimmediately. The sort completes within a few seconds; refresh the storefront to verify.- Use
sort_by: inventory_ascto push out-of-stock products to the bottom of the collection page, reducing customer frustration. - For large collections (250+ products), pagination is automatic but increases execution time. Consider running during off-peak hours.
- This skill only reads
totalInventoryfrom the products node — it does not aggregate per-location. If you need location-specific sorting, use thelow-inventory-restockskill to identify which products to prioritize.
More from 40rty-ai/shopify-admin-skills
shopify-admin-skills
Master skill collection for Shopify store operators. Provides access to all merchandising, marketing, support, and operations capabilities.
146shopify-admin-variant-option-normalizer
Detects inconsistent variant option naming (Sm vs Small vs S) and bulk-corrects to a standard set.
5shopify-admin-gift-card-issuance
Issue Shopify gift cards (store credit) to customers as a goodwill gesture, post-return incentive, or loyalty reward.
5shopify-admin-fulfillment-status-digest
Generate a daily fulfillment triage digest: all open orders segmented by fulfillment age and flagged for holds or exceptions.
5shopify-admin-product-lifecycle-manager
Bulk transition products through DRAFT → ACTIVE → ARCHIVED status for seasonal launches and sunsetting.
5shopify-admin-customer-note-bulk-annotator
Adds internal notes to customer records in bulk — useful for post-campaign flags, import annotations, or support context.
5