/shopify-pack:shopify-sdk-patternsfrom shopify-pack
Applies production-ready patterns for @shopify/shopify-api: typed GraphQL clients, session management, retry logic, and codegen. Use for Shopify integrations and SDK refactoring.
Ships in shopify-pack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Production-ready patterns for the @shopify/shopify-api library: singleton clients, typed GraphQL operations, session management, cursor-based pagination, codegen-typed operations, bulk operations, and webhook registry patterns.
@shopify/shopify-api v9+ installedInitialize a singleton shopifyApi instance with LATEST_API_VERSION, cache sessions per shop, and expose a typed shopifyQuery<T>() helper that wraps client.request().
See Typed GraphQL Client for the complete implementation.
Custom ShopifyServiceError class that distinguishes retryable errors (429, 5xx) from permanent ones. Includes handleShopifyError() for error translation and safeShopifyCall() that returns {data, error} tuples instead of throwing.
See Error Handling for the complete implementation.
Async generator paginateShopify<T>() for Relay-style cursor pagination. Yields batches of nodes, automatically following pageInfo.endCursor until hasNextPage is false. Memory-efficient for large datasets.
See Cursor Pagination for the complete implementation.
ShopifyClientFactory class for apps installed on multiple stores. Creates isolated GraphqlClient instances per merchant with session caching. Includes removeClient() for eviction on app uninstall.
See Multi-Tenant Factory for the complete implementation.
Use @shopify/api-codegen-preset to generate TypeScript types from your GraphQL operations. This eliminates manual type definitions and catches schema changes at build time.
// codegen.ts — project root config
import { shopifyApiProject, ApiType } from "@shopify/api-codegen-preset";
export default {
schema: "https://shopify.dev/admin-graphql-direct-proxy",
documents: ["src/**/*.{ts,tsx}"],
projects: {
default: shopifyApiProject({
apiType: ApiType.Admin,
apiVersion: "2025-04", // Update quarterly
outputDir: "./src/types",
}),
},
};
// src/operations/products.ts — typed query with codegen output
import type { ProductsQuery } from "../types/admin.generated";
const PRODUCTS_QUERY = `#graphql
query Products($first: Int!, $after: String) {
products(first: $first, after: $after) {
edges {
node { id title status totalInventory }
}
pageInfo { hasNextPage endCursor }
}
}
` as const;
// Return type is fully inferred from codegen
export async function getProducts(shop: string): Promise<ProductsQuery> {
return shopifyQuery<ProductsQuery>(shop, PRODUCTS_QUERY, { first: 50 });
}
Run npx graphql-codegen after changing any GraphQL operation or upgrading API versions.
For datasets too large for pagination (100k+ records), use Shopify's Bulk Operations API. It runs a query server-side and produces a JSONL file you download when ready.
// src/shopify/bulk.ts
const BULK_QUERY = `
mutation bulkOperationRunQuery($query: String!) {
bulkOperationRunQuery(query: $query) {
bulkOperation { id status }
userErrors { field message }
}
}
`;
const POLL_QUERY = `{
currentBulkOperation {
id status errorCode objectCount url
}
}`;
export async function runBulkOperation(
shop: string,
query: string
): Promise<string> {
// Start the bulk operation
const { bulkOperationRunQuery } = await shopifyQuery(shop, BULK_QUERY, { query });
if (bulkOperationRunQuery.userErrors?.length) {
throw new Error(bulkOperationRunQuery.userErrors[0].message);
}
// Poll until complete (typically 1-10 minutes for large datasets)
let result;
do {
await new Promise((r) => setTimeout(r, 5000)); // 5s interval
result = (await shopifyQuery(shop, POLL_QUERY)).currentBulkOperation;
} while (result.status === "RUNNING" || result.status === "CREATED");
if (result.status !== "COMPLETED") {
throw new Error(`Bulk operation failed: ${result.errorCode}`);
}
return result.url; // JSONL download URL
}
// Usage: export all products
const url = await runBulkOperation(shop, `{
products { edges { node { id title status variants { edges { node { sku price } } } } } }
}`);
const response = await fetch(url);
const jsonl = await response.text();
const products = jsonl.trim().split("\n").map(JSON.parse);
Programmatically register webhook subscriptions using webhookSubscriptionCreate with typed WebhookSubscriptionInput. Supports both HTTP and EventBridge/PubSub endpoints.
// src/shopify/webhooks.ts
const REGISTER_WEBHOOK = `
mutation webhookSubscriptionCreate(
$topic: WebhookSubscriptionTopic!,
$webhookSubscription: WebhookSubscriptionInput!
) {
webhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {
webhookSubscription { id topic }
userErrors { field message }
}
}
`;
interface WebhookConfig {
topic: string;
callbackUrl: string;
format?: "JSON" | "XML";
}
export async function registerWebhooks(
shop: string,
webhooks: WebhookConfig[]
): Promise<{ registered: string[]; errors: string[] }> {
const registered: string[] = [];
const errors: string[] = [];
for (const wh of webhooks) {
const result = await shopifyQuery(shop, REGISTER_WEBHOOK, {
topic: wh.topic,
webhookSubscription: {
callbackUrl: wh.callbackUrl,
format: wh.format ?? "JSON",
},
});
const userErrors = result.webhookSubscriptionCreate.userErrors;
if (userErrors?.length) {
errors.push(`${wh.topic}: ${userErrors[0].message}`);
} else {
registered.push(wh.topic);
}
}
return { registered, errors };
}
| Pattern | Use Case | Benefit |
|---|---|---|
safeShopifyCall | All API calls | Returns {data, error} instead of throwing |
handleShopifyError | Error translation | Maps HTTP/GraphQL errors to typed errors |
| Cursor pagination | Large datasets | Memory-efficient streaming with backpressure |
| Bulk operations | 100k+ records | Server-side execution, no client memory pressure |
| Client factory | Multi-tenant apps | Isolated sessions per merchant |
Initialize a singleton Shopify client with session caching and a typed shopifyQuery<T>() helper for all API calls.
See Typed GraphQL Client for the complete implementation.
Distinguish 429/5xx retryable errors from permanent validation failures using a structured error class and safe call wrapper.
See Error Handling for the complete error handling implementation.
Create isolated GraphQL clients per merchant with session caching and eviction on app uninstall using a client factory.
See Multi-Tenant Factory for the complete implementation.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
38 skills in this plugin
/shopify-advanced-troubleshootingDebug complex Shopify API issues using cost analysis, request tracing,
webhook delivery inspection, and GraphQL introspection.
Use when encountering intermittent failures, throttling mysteries, or webhook delivery gaps.
Trigger with phrases like "shopify hard bug", "shopify mystery error",
"shopify deep debug", "difficult shopify issue", "shopify intermittent failure".
/shopify-ai-toolkit-wrapperIntegrate Shopify's AI Toolkit MCP server with Claude Code for GraphQL validation,
Liquid linting, and documentation search.
Use when setting up Shopify MCP integration, validating GraphQL queries,
or linting Liquid templates.
Trigger with phrases like "shopify ai toolkit", "shopify mcp",
"shopify claude integration", "shopify graphql validation", "shopify liquid lint".
/shopify-architecture-variantsChoose between Shopify app architectures: embedded Remix app, headless storefront with
Hydrogen, standalone integration, or theme app extension.
Use when starting a new Shopify project and deciding which architecture pattern to follow.
Trigger with phrases like "shopify architecture decision", "shopify embedded vs headless",
"shopify Hydrogen", "shopify app types", "which shopify architecture".
/shopify-b2b-wholesaleBuild Shopify Plus B2B features with companies, catalogs, and wholesale pricing.
Use when setting up wholesale accounts, creating price lists,
or configuring B2B checkout with purchase orders.
Trigger with phrases like "shopify b2b", "shopify wholesale",
"shopify company api", "shopify price lists", "shopify catalog api".
/shopify-checkout-extensionsBuild Checkout UI Extensions to customize Shopify checkout with sandboxed React-like components.
Use when replacing checkout.liquid (deprecated Aug 2025), adding custom fields to checkout,
displaying banners, or reading checkout state with hooks.
Trigger with phrases like "shopify checkout extension", "shopify checkout ui",
"checkout customization shopify", "checkout.liquid migration", "shopify checkout components".
/shopify-ci-integrationConfigure CI/CD pipelines for Shopify apps with GitHub Actions, API version testing,
and Shopify CLI deployment.
Use when setting up automated testing, deployment pipelines, or API version monitoring for Shopify apps.
Trigger with phrases like "shopify CI", "shopify GitHub Actions",
"shopify automated tests", "CI shopify", "shopify deploy pipeline".
npx claudepluginhub jeremylongshore/tons-of-skills-marketplace --plugin shopify-pack2 plugins ship this exact skill · first indexed Jul 10, 2026
Other plugins' skills for the same job