Skip to content

Commit 7aae5d3

Browse files
committed
Proto: shopify store execute
1 parent 60a9052 commit 7aae5d3

87 files changed

Lines changed: 9008 additions & 7023 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
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
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
shopify store auth [flags]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
shopify store execute [flags]
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
11
// This is an autogenerated file. Don't edit this file manually.
22
export interface appbuild {
3-
/**
4-
* The Client ID of your app.
5-
* @environment SHOPIFY_FLAG_CLIENT_ID
6-
*/
7-
'--client-id <value>'?: string
8-
9-
/**
10-
* The name of the app configuration.
11-
* @environment SHOPIFY_FLAG_APP_CONFIG
12-
*/
13-
'-c, --config <value>'?: string
14-
153
/**
164
* Disable color output.
175
* @environment SHOPIFY_FLAG_NO_COLOR
186
*/
197
'--no-color'?: ''
208

9+
/**
10+
* Increase the verbosity of the output.
11+
* @environment SHOPIFY_FLAG_VERBOSE
12+
*/
13+
'--verbose'?: ''
14+
2115
/**
2216
* The path to your app directory.
2317
* @environment SHOPIFY_FLAG_PATH
2418
*/
2519
'--path <value>'?: string
2620

21+
/**
22+
* The name of the app configuration.
23+
* @environment SHOPIFY_FLAG_APP_CONFIG
24+
*/
25+
'-c, --config <value>'?: string
26+
27+
/**
28+
* The Client ID of your app.
29+
* @environment SHOPIFY_FLAG_CLIENT_ID
30+
*/
31+
'--client-id <value>'?: string
32+
2733
/**
2834
* Reset all your settings.
2935
* @environment SHOPIFY_FLAG_RESET
@@ -35,10 +41,4 @@ export interface appbuild {
3541
* @environment SHOPIFY_FLAG_SKIP_DEPENDENCIES_INSTALLATION
3642
*/
3743
'--skip-dependencies-installation'?: ''
38-
39-
/**
40-
* Increase the verbosity of the output.
41-
* @environment SHOPIFY_FLAG_VERBOSE
42-
*/
43-
'--verbose'?: ''
4444
}
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
// This is an autogenerated file. Don't edit this file manually.
22
export interface appbulkcancel {
33
/**
4-
* The Client ID of your app.
5-
* @environment SHOPIFY_FLAG_CLIENT_ID
4+
* Disable color output.
5+
* @environment SHOPIFY_FLAG_NO_COLOR
66
*/
7-
'--client-id <value>'?: string
7+
'--no-color'?: ''
88

99
/**
10-
* The name of the app configuration.
11-
* @environment SHOPIFY_FLAG_APP_CONFIG
10+
* Increase the verbosity of the output.
11+
* @environment SHOPIFY_FLAG_VERBOSE
1212
*/
13-
'-c, --config <value>'?: string
13+
'--verbose'?: ''
1414

1515
/**
16-
* The bulk operation ID to cancel (numeric ID or full GID).
17-
* @environment SHOPIFY_FLAG_ID
16+
* The path to your app directory.
17+
* @environment SHOPIFY_FLAG_PATH
1818
*/
19-
'--id <value>': string
19+
'--path <value>'?: string
2020

2121
/**
22-
* Disable color output.
23-
* @environment SHOPIFY_FLAG_NO_COLOR
22+
* The name of the app configuration.
23+
* @environment SHOPIFY_FLAG_APP_CONFIG
2424
*/
25-
'--no-color'?: ''
25+
'-c, --config <value>'?: string
2626

2727
/**
28-
* The path to your app directory.
29-
* @environment SHOPIFY_FLAG_PATH
28+
* The Client ID of your app.
29+
* @environment SHOPIFY_FLAG_CLIENT_ID
3030
*/
31-
'--path <value>'?: string
31+
'--client-id <value>'?: string
3232

3333
/**
3434
* Reset all your settings.
@@ -37,14 +37,14 @@ export interface appbulkcancel {
3737
'--reset'?: ''
3838

3939
/**
40-
* The store domain. Must be an existing dev store.
41-
* @environment SHOPIFY_FLAG_STORE
40+
* The bulk operation ID to cancel (numeric ID or full GID).
41+
* @environment SHOPIFY_FLAG_ID
4242
*/
43-
'-s, --store <value>'?: string
43+
'--id <value>': string
4444

4545
/**
46-
* Increase the verbosity of the output.
47-
* @environment SHOPIFY_FLAG_VERBOSE
46+
* The store domain. Must be an existing dev store.
47+
* @environment SHOPIFY_FLAG_STORE
4848
*/
49-
'--verbose'?: ''
49+
'-s, --store <value>'?: string
5050
}

0 commit comments

Comments
 (0)