shopify-sdk-patterns
Apply production-ready patterns for @shopify/shopify-api including typed GraphQL clients, session management, and retry logic. Use when implementing Shopify integrations, refactoring SDK usage, or establishing team coding standards for Shopify. Trigger with phrases like "shopify SDK patterns", "shopify best practices", "shopify code patterns", "idiomatic shopify", "shopify client wrapper".
What this skill does
# Shopify SDK Patterns
## Overview
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.
## Prerequisites
- `@shopify/shopify-api` v9+ installed
- Familiarity with Shopify's GraphQL Admin API
- Understanding of async/await and TypeScript generics
## Instructions
### Step 1: Typed GraphQL Client Wrapper
Initialize 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](references/typed-graphql-client.md) for the complete implementation.
### Step 2: Error Handling with Shopify Error Types
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](references/error-handling.md) for the complete implementation.
### Step 3: Cursor-Based Pagination
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](references/cursor-pagination.md) for the complete implementation.
### Step 4: Multi-Tenant Client Factory
`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](references/multi-tenant-factory.md) for the complete implementation.
### Step 5: Codegen-Typed Operations
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.
```typescript
// 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",
}),
},
};
```
```typescript
// 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.
### Step 6: Bulk Operation Helpers
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.
```typescript
// 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);
```
### Step 7: Webhook Registry Patterns
Programmatically register webhook subscriptions using `webhookSubscriptionCreate` with typed `WebhookSubscriptionInput`. Supports both HTTP and EventBridge/PubSub endpoints.
```typescript
// 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 };
}
```
## Output
- Type-safe GraphQL client with singleton session management
- Structured error handling that distinguishes retryable from permanent errors
- Cursor-based pagination generator for large datasets
- Multi-tenant client factory for apps serving multiple stores
- Codegen-typed operations eliminating manual type definitions
- Bulk operation helpers for large dataset exports
- Webhook registry patterns for programmatic subscription management
## Error Handling
| 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 |
## Examples
### Setting Up a Type-Safe GraphQL Client
Initialize a singleton Shopify client with session caching and a typed `shopifyQuery<T>()` helper for all API calls.
See [Typed GraphQL Client](references/typed-graphql-client.md) for the complete implementation.
### Handling Retryable vs Permanent Errors
Distinguish 429/5xx retryable errors from permanent validation failures using a structured error class and safe call wrapper.
See [Error Handling](references/error-handling.md) for the complete error handling implementation.
### Building a Multi-Tenant App
Create isolated GraphQL clients per merchant with session caching and eviction on app uninstall using a client factory.
See [Multi-Tenant Factory](references/multi-tenant-factory.md) for the complete implementation.
## Resources
- [@shopify/shopify-api Reference](https://github.com/Shopify/shoRelated in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.