shopify-admin-agentic-…
Edit the theme's robots.txt.liquid to explicitly allow AI crawlers (GPTBot, ClaudeBot,…
Finds expired, zero-usage, or duplicate discount codes and optionally deactivates or deletes them.
$ npx -y skills add 40rty-ai/shopify-admin-skills --skill shopify-admin-discount-hygiene-cleanup --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/shopify-admin-discount-hygiene-cleanupContext preview
The summary Claude sees to decide when to auto-load this skill.
Finds expired, zero-usage, or duplicate discount codes and optionally deactivates or deletes them.
name: shopify-admin-discount-hygiene-cleanup role: store-management description: "Finds expired, zero-usage, or duplicate discount codes and optionally deactivates or deletes them." toolkit: shopify-admin, shopify-admin-execution api_version: "2025-01" graphql_operations: - discountNodes:query - discountCodeDelete:mutation status: stable compatibility: Claude Code, Cursor, Codex, Gemini CLI
Audits the discount catalog for expired codes, codes with zero redemptions, and duplicate code prefixes. Discount sprawl accumulates over months of campaigns and makes the admin difficult to navigate. Optionally deletes flagged codes. Replaces manual discount cleanup and builds on the `discount-ab-analysis` skill with a write step.
| Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | store | string | yes | — | Store domain (e.g., mystore.myshopify.com) | | flag_expired | bool | no | true | Flag/delete discounts past their end date | | flag_zero_usage | bool | no | true | Flag/delete discounts with 0 redemptions older than N days | | zero_usage_min_age_days | integer | no | 30 | Age threshold for zero-usage flags | | dry_run | bool | no | true | Preview without executing mutations | | format | string | no | human | Output format: `human` or `json` |
> ⚠️ `discountCodeDelete` permanently removes discount codes. Deleted codes cannot be recovered. Customers who received a deleted code will find it invalid. Run with `dry_run: true` to review the flagged list before committing. Always check that expired codes are not referenced in active email campaigns before deleting.
1. **OPERATION:** `discountNodes` — query **Inputs:** `first: 250`, select `discount { ... on DiscountCodeBasic { codes, usageLimit, asyncUsageCount, endsAt, status } }`, pagination cursor **Expected output:** All discount codes with usage and expiry data; paginate until `hasNextPage: false`
2. Flag discounts matching: `flag_expired` (status = EXPIRED) and/or `flag_zero_usage` (asyncUsageCount == 0 AND created > `zero_usage_min_age_days` ago)
3. **OPERATION:** `discountCodeDelete` — mutation **Inputs:** `id: <discount_node_id>` **Expected output:** `deletedCodeDiscountId`, `userErrors`
# discountNodes:query — validated against api_version 2025-01
query DiscountAudit($after: String) {
discountNodes(first: 250, after: $after) {
edges {
node {
id
discount {
... on DiscountCodeBasic {
title
status
createdAt
endsAt
asyncUsageCount
usageLimit
codes(first: 5) {
edges {
node {
id
code
}
}
}
}
... on DiscountCodeBxgy {
title
status
createdAt
endsAt
asyncUsageCount
usageLimit
}
... on DiscountCodeFreeShipping {
title
status
createdAt
endsAt
asyncUsageCount
usageLimit
}
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
}# discountCodeDelete:mutation — validated against api_version 2025-01
mutation DiscountCodeDelete($id: ID!) {
discountCodeDelete(id: $id) {
deletedCodeDiscountId
userErrors {
field
message
}
}
}**Claude MUST emit the following output at each stage. This is mandatory.**
**On start**, emit:
╔══════════════════════════════════════════════╗ ║ SKILL: Discount Hygiene Cleanup ║ ║ 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 Discounts scanned: <n> Expired: <n> Zero usage (> <n> days): <n> Total flagged: <n> Deleted: <n> Errors: <n> Output: discount_cleanup_<date>.csv ══════════════════════════════════════════════
For `format: json`, emit:
{
"skill": "discount-hygiene-cleanup",
"store": "<domain>",
"started_at": "<ISO8601>",
"dry_run": true,
"outcome": {
"scanned": 0,
"flagged_expired": 0,
"flagged_zero_usage": 0,
"deleted": 0,
"errors": 0,
"output_file": "discount_cleanup_<date>.csv"
}
}CSV file `discount_cleanup_<YYYY-MM-DD>.csv` with columns: `discount_id`, `title`, `status`, `created_at`, `ends_at`, `usage_count`, `usage_limit`, `flag_reason`, `action`
| Error | Cause | Recovery | |-------|-------|----------| | `THROTTLED` | API rate limit exceeded | Wait 2 seconds, retry up to 3 times | | `userErrors` on delete | Discount already deleted or active order using it | Log error, skip, continue | | No discounts flagged | Clean discount catalog | Exit with ✅ no cleanup needed |
Community-maintained AI agent skills for operating Shopify stores — workflows, optimization, reports and more
Edit the theme's robots.txt.liquid to explicitly allow AI crawlers (GPTBot, ClaudeBot,…
Rewrite thin product descriptions into structured, fact-rich copy (materials, fit, use-cases,…
Generate and set descriptive alt text on product images so AI agents (which can't 'see'…
Generate and publish an /llms.txt guide (brand summary, flagship products, key policies,…
Define and populate agentic-commerce metafields (material, attributes, key features, specs,…
Inject an Organization JSON-LD block (name, logo, sameAs social links, contactPoint) into the…