|
| 1 | +--- |
| 2 | +name: manage-store-with-cli |
| 3 | +description: 'Help a merchant use Shopify CLI to manage an existing Shopify store through the Admin API. Use when users say things like "I want to add products", "update inventory", "change prices", "tag products", "clean up sample products", "bulk edit my store", or ask how to use Shopify CLI with their store. Use `shopify store auth` first, then `shopify store execute`; do not use `shopify app execute`.' |
| 4 | +--- |
| 5 | + |
| 6 | +# Manage Store With CLI |
| 7 | + |
| 8 | +## Principle |
| 9 | + |
| 10 | +Start from the merchant task, not from GraphQL. |
| 11 | + |
| 12 | +Treat auth as setup, not the main event. Keep it brief unless the user asks for auth details. |
| 13 | + |
| 14 | +Use `shopify ...` commands. |
| 15 | + |
| 16 | +Internal demo assumption: use `/tmp/shopify-store-client-secret.txt` as the standard client secret file path, but do not call attention to it unless the user asks or troubleshooting requires it. |
| 17 | + |
| 18 | +Translate the merchant request into a small Admin API operation, then follow this exact CLI flow: |
| 19 | + |
| 20 | +1. `shopify store auth` |
| 21 | +2. `shopify store execute` with a safe shop query |
| 22 | +3. `shopify store execute --allow-mutations` for the task-specific write |
| 23 | + |
| 24 | +For this merchant-store workflow, do not switch to `shopify app execute`. |
| 25 | + |
| 26 | +Use this flow when the user already has a Shopify store and wants Admin API access through Shopify CLI without needing a local app project. |
| 27 | + |
| 28 | +## Typical asks |
| 29 | + |
| 30 | +- "I want to add products to my store" |
| 31 | +- "Can I update inventory with CLI?" |
| 32 | +- "I need to change prices" |
| 33 | +- "How do I tag products?" |
| 34 | +- "I want to clean up sample products" |
| 35 | +- "How do I use Shopify CLI with my store?" |
| 36 | + |
| 37 | +## Failures this skill prevents |
| 38 | + |
| 39 | +Without this skill, agents tend to: |
| 40 | + |
| 41 | +- skip app authentication and jump straight to `shopify store execute` |
| 42 | +- start with GraphQL details instead of the merchant goal |
| 43 | +- give a mutation before verifying store access |
| 44 | +- forget `--allow-mutations` for write operations |
| 45 | + |
| 46 | +## Required flow |
| 47 | + |
| 48 | +For merchant store-management requests, give commands in this order: |
| 49 | + |
| 50 | +1. Confirm the merchant goal. |
| 51 | +2. Collect the two user-specific inputs before giving commands: |
| 52 | + - store domain |
| 53 | + - minimum required scopes |
| 54 | + |
| 55 | +3. Run this exact auth step: |
| 56 | + |
| 57 | + ```bash |
| 58 | + shopify store auth \ |
| 59 | + --store example.myshopify.com \ |
| 60 | + --scopes read_products,write_products \ |
| 61 | + --client-secret-file /tmp/shopify-store-client-secret.txt |
| 62 | + ``` |
| 63 | + |
| 64 | +4. Verify access with a safe read-only `shopify store execute` query. |
| 65 | +5. Only then give the task-specific `shopify store execute` command. |
| 66 | +6. Add `--allow-mutations` if the task writes data. |
| 67 | +7. If auth is missing, expired, or underscoped, send the user back to step 3. |
| 68 | + |
| 69 | +## Pattern |
| 70 | + |
| 71 | +1. Restate the merchant task in plain language, then map it to an Admin API action. |
| 72 | +2. Confirm they already have a store and staff access. |
| 73 | +3. Ensure Shopify CLI is available. |
| 74 | +4. Before giving commands, collect: |
| 75 | + - the store domain |
| 76 | + - the minimum scopes needed for the task |
| 77 | +5. Treat `shopify store auth` as the normal first command unless you already know the store has valid app auth for the needed scopes. |
| 78 | +6. Run `shopify store auth` using the standard demo secret path `/tmp/shopify-store-client-secret.txt`, without separately explaining that path unless needed. |
| 79 | +7. Verify access with `query { shop { name id } }` using `shopify store execute`. |
| 80 | +8. Mention auth in at most one short sentence, and only if it helps the user follow the steps. |
| 81 | +9. Give the smallest task-specific command. |
| 82 | + |
| 83 | +If the merchant task is ambiguous, ask one clarifying question before giving commands. |
| 84 | + |
| 85 | +## Decision table |
| 86 | + |
| 87 | +| Merchant request | Likely Admin API action | |
| 88 | +|---|---| |
| 89 | +| Add products | `productCreate` | |
| 90 | +| Change product details | `productUpdate` | |
| 91 | +| Delete or archive products | `productDelete` or `productUpdate(status: ARCHIVED)` | |
| 92 | +| Update inventory | inventory-related Admin API mutation; clarify location and item | |
| 93 | +| Change prices | pricing mutation; clarify scope | |
| 94 | +| Add tags | `tagsAdd` or object update | |
| 95 | +| List products or orders | read-only query | |
| 96 | + |
| 97 | +## Default commands |
| 98 | + |
| 99 | +### Verify the local CLI repo command works |
| 100 | + |
| 101 | +```bash |
| 102 | +shopify version |
| 103 | +``` |
| 104 | + |
| 105 | +### Authenticate the app against the store |
| 106 | + |
| 107 | +```bash |
| 108 | +shopify store auth \ |
| 109 | + --store example.myshopify.com \ |
| 110 | + --scopes read_products,write_products \ |
| 111 | + --client-secret-file /tmp/shopify-store-client-secret.txt |
| 112 | +``` |
| 113 | + |
| 114 | +### Safe verification query |
| 115 | + |
| 116 | +```bash |
| 117 | +shopify store execute \ |
| 118 | + --store example.myshopify.com \ |
| 119 | + --query 'query { shop { name id } }' |
| 120 | +``` |
| 121 | + |
| 122 | +### Small write example |
| 123 | + |
| 124 | +```bash |
| 125 | +shopify store execute \ |
| 126 | + --store example.myshopify.com \ |
| 127 | + --query 'mutation { productCreate(product: { title: "Sample product", status: DRAFT }) { product { id title status } userErrors { field message } } }' \ |
| 128 | + --allow-mutations |
| 129 | +``` |
| 130 | + |
| 131 | +### File and variables example |
| 132 | + |
| 133 | +```bash |
| 134 | +cat >/tmp/products.graphql <<'GRAPHQL' |
| 135 | +query Products($first: Int!) { |
| 136 | + products(first: $first) { |
| 137 | + nodes { |
| 138 | + id |
| 139 | + title |
| 140 | + status |
| 141 | + } |
| 142 | + } |
| 143 | +} |
| 144 | +GRAPHQL |
| 145 | + |
| 146 | +shopify store execute \ |
| 147 | + --store example.myshopify.com \ |
| 148 | + --query-file /tmp/products.graphql \ |
| 149 | + --variables '{"first": 5}' |
| 150 | +``` |
| 151 | + |
| 152 | +## Auth explanation |
| 153 | + |
| 154 | +Default behavior: do not volunteer auth details unless the user asks or the auth step is the only thing blocking progress. |
| 155 | + |
| 156 | +If you need one sentence, use this: |
| 157 | + |
| 158 | +> First run `shopify store auth`, then use `shopify store execute` for the actual store command. |
| 159 | +
|
| 160 | +Only add more if needed: |
| 161 | + |
| 162 | +- if auth is missing or expired, re-run `shopify store auth` |
| 163 | + |
| 164 | +## Guardrails |
| 165 | + |
| 166 | +- Mirror the user's language first, then translate it into an API operation. |
| 167 | +- Do not start with GraphQL jargon unless the user is already speaking in GraphQL terms. |
| 168 | +- Before giving commands, collect the store domain and required scopes. |
| 169 | +- Default to `shopify store auth` before `shopify store execute` unless valid store auth is already established for the needed scopes. |
| 170 | +- If `shopify store execute` would fail because auth is missing, expired, or underscoped, tell the user to re-run `shopify store auth` with the right scopes. |
| 171 | +- Keep auth commentary minimal. Do not explain OAuth, tokens, client IDs, client secrets, or callback URLs unless the user asks or troubleshooting requires it. |
| 172 | +- Use `/tmp/shopify-store-client-secret.txt` as the standard demo secret path. |
| 173 | +- Do not call attention to the client secret file path outside the command itself unless troubleshooting requires it. |
| 174 | +- For this workflow, do not use `shopify app execute`. |
| 175 | +- Always present the commands as an explicit sequence: auth, verify, then task command. |
| 176 | +- Start with the safe shop query before giving a mutation. |
| 177 | +- Add `--allow-mutations` for any write operation. |
| 178 | +- Use `--mock` only for demos, not as a real store operation. |
| 179 | + |
| 180 | +## Success |
| 181 | + |
| 182 | +The user leaves with: |
| 183 | + |
| 184 | +1. Shopify CLI available in their terminal |
| 185 | +2. one successful read-only Admin API call against their store |
| 186 | +3. one task-specific command they can run next |
| 187 | +4. a clear sense that Shopify CLI can help with their store task without requiring an app project |
0 commit comments