shopify-agentic-dev-workflow 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/.cursor/rules/shopify-agentic-dev.mdc +290 -0
  2. package/AGENTS.md +285 -0
  3. package/CHANGELOG.md +14 -0
  4. package/CLAUDE.md +285 -0
  5. package/GEMINI.md +285 -0
  6. package/HANDOFF.md +351 -0
  7. package/LICENSE +21 -0
  8. package/README.md +370 -0
  9. package/bin/shopify-agent.js +2786 -0
  10. package/docs/00-prerequisites.md +88 -0
  11. package/docs/01-onboarding.md +111 -0
  12. package/docs/02-theme-sdlc.md +106 -0
  13. package/docs/03-app-sdlc.md +66 -0
  14. package/docs/04-admin-api-ops.md +58 -0
  15. package/docs/05-codex-prompts.md +37 -0
  16. package/docs/06-security-guardrails.md +47 -0
  17. package/docs/07-github-rollout.md +30 -0
  18. package/docs/08-product-design.md +168 -0
  19. package/docs/09-shopify-cli-4-capabilities.md +48 -0
  20. package/docs/10-field-learnings.md +66 -0
  21. package/package.json +82 -0
  22. package/scripts/bootstrap.sh +35 -0
  23. package/scripts/validate-graphql.js +303 -0
  24. package/templates/.env.example +20 -0
  25. package/templates/codex-config.toml +3 -0
  26. package/templates/github-actions/deploy-theme.yml +32 -0
  27. package/templates/graphql/content/pages-list.graphql +12 -0
  28. package/templates/graphql/content/redirects-list.graphql +9 -0
  29. package/templates/graphql/customers/new-customers.graphql +15 -0
  30. package/templates/graphql/customers/top-spenders.graphql +16 -0
  31. package/templates/graphql/discounts/active-discounts.graphql +27 -0
  32. package/templates/graphql/discounts-list.graphql +40 -0
  33. package/templates/graphql/inventory-audit.graphql +38 -0
  34. package/templates/graphql/metafields/product-metafields.graphql +14 -0
  35. package/templates/graphql/orders/list-open.graphql +30 -0
  36. package/templates/graphql/orders/revenue-summary.graphql +15 -0
  37. package/templates/graphql/products/list.graphql +16 -0
  38. package/templates/graphql/products/low-inventory.graphql +18 -0
  39. package/templates/graphql/products-seo-audit.graphql +14 -0
  40. package/templates/graphql/shop-query.graphql +9 -0
  41. package/templates/graphql/store/full-info.graphql +23 -0
  42. package/templates/graphql/store/webhooks.graphql +16 -0
  43. package/templates/prompts/admin-operation.md +12 -0
  44. package/templates/prompts/theme-task.md +19 -0
package/HANDOFF.md ADDED
@@ -0,0 +1,351 @@
1
+ # Agent Handoff: Shopify Agentic Development Workflow
2
+
3
+ ## Goal
4
+
5
+ A reusable npm/npx CLI package that enables the **entire Shopify team** — developers, catalogers, marketing teams, and business admins — to operate their Shopify stores entirely from the terminal through an AI-agent-centered workflow. Shopify CLI 4.x runs under the hood. Guardrail files injected into the project control how Codex, Claude, Cursor, or Gemini behave.
6
+
7
+ No one on the team should need to live inside Shopify Admin for day-to-day work. Admin is only needed for first-time approvals, OAuth, app installs, collaborator access, and UI-only checks (drag-and-drop theme editor).
8
+
9
+ ## Repository
10
+
11
+ - GitHub: `https://github.com/sagarchauhan005/shopify-agentic-dev-workflow`
12
+ - Local path: `/Users/sagar/Documents/Development/Shopify/Shopify Automation`
13
+ - Package name: `shopify-agentic-dev-workflow`
14
+ - Binary name: `shopify-agent`
15
+ - Runtime: Node.js 18+
16
+ - License: MIT
17
+
18
+ ## End-to-End Test Status
19
+
20
+ Fully tested on 2026-05-23 against `quickstart-3485ea1e.myshopify.com` (Dawn theme, unpublished):
21
+
22
+ ```
23
+ npm install -g github:sagarchauhan005/shopify-agentic-dev-workflow
24
+ shopify-agent init ✓ auth detected, org list probe, theme fetch, profile saved
25
+ shopify-agent doctor ✓ all tools OK, config shown
26
+ shopify-agent theme:list ✓ 3 themes returned with roles
27
+ shopify-agent theme:select ✓ live ⚠ warning shown, switched to Dawn (unpublished)
28
+ shopify-agent theme:pull ✓ Dawn files pulled to ./quick-start/
29
+ shopify-agent theme:dev ✓ dev server started, browser opened at 127.0.0.1:9292
30
+ shopify-agent theme:check ✓ no new errors
31
+ shopify-agent theme:push ✓ live-theme guard shown, staging option offered
32
+ ```
33
+
34
+ Theme changes deployed during test:
35
+ - Color scheme: blue buttons (`#2563EB`), rounded corners, card shadows, hover animations
36
+ - Homepage: hero copy, brand story section, feature-cards section
37
+ - New custom section: `agentic-features.liquid` (schema-driven feature cards grid)
38
+ - `assets/custom-overrides.css`: button transitions, card hover lift, header polish
39
+
40
+ ## Current File Layout
41
+
42
+ ```
43
+ bin/shopify-agent.js Core CLI — all 60+ commands, single file, stdlib only
44
+ docs/
45
+ 00-prerequisites.md Zero-to-working install guide (macOS, Windows, Linux)
46
+ 01-onboarding.md
47
+ 02-theme-sdlc.md
48
+ 03-app-sdlc.md
49
+ 04-admin-api-ops.md
50
+ 05-codex-prompts.md
51
+ 06-security-guardrails.md
52
+ 07-github-rollout.md
53
+ 08-product-design.md Product decisions and design notes
54
+ 09-shopify-cli-4-capabilities.md
55
+ scripts/bootstrap.sh Local repo bootstrap helper
56
+ templates/
57
+ .env.example
58
+ codex-config.toml
59
+ github-actions/deploy-theme.yml
60
+ graphql/
61
+ products/ list.graphql, low-inventory.graphql
62
+ orders/ list-open.graphql, revenue-summary.graphql
63
+ customers/ top-spenders.graphql, new-customers.graphql
64
+ discounts/ active-discounts.graphql
65
+ store/ full-info.graphql, webhooks.graphql
66
+ content/ pages-list.graphql, redirects-list.graphql
67
+ metafields/ product-metafields.graphql
68
+ shop-query.graphql
69
+ inventory-audit.graphql
70
+ discounts-list.graphql
71
+ products-seo-audit.graphql
72
+ prompts/admin-operation.md
73
+ prompts/theme-task.md
74
+ HANDOFF.md This file
75
+ README.md Team-facing quick start
76
+ package.json npm/npx package config
77
+ ```
78
+
79
+ ---
80
+
81
+ ## Full Command Surface
82
+
83
+ ### Setup & Diagnostics
84
+
85
+ | Command | What it does |
86
+ |---|---|
87
+ | `shopify-agent init` | Full wizard: auth check → org probe → store domain → theme token → theme select (live ⚠ warning) → app config → profile save → .env write → guardrail install |
88
+ | `shopify-agent auth` | `shopify auth login` |
89
+ | `shopify-agent doctor` | Check Node 18+, npm, git, Shopify CLI, gh. Show install hints + active config. |
90
+ | `shopify-agent capabilities` | Feature-detect Shopify CLI 4.x commands |
91
+ | `shopify-agent mcp:install` | Add Shopify Dev MCP to `~/.codex/config.toml` |
92
+ | `shopify-agent agents:install` | Write `AGENTS.md`, `CLAUDE.md`, `.cursor/rules/shopify-agentic-dev.mdc`, `GEMINI.md` |
93
+ | `shopify-agent profile:list` | List local profiles with active marker |
94
+ | `shopify-agent profile:use` | Switch active profile |
95
+ | `shopify-agent store:list` | `shopify organization list` — orgs + dev stores |
96
+ | `shopify-agent store:auth` | `shopify store auth` — create Admin API token with selected scopes |
97
+
98
+ ### Theme
99
+
100
+ | Command | What it does |
101
+ |---|---|
102
+ | `shopify-agent theme:list` | List themes with role |
103
+ | `shopify-agent theme:select` | Interactive picker — live ⚠ warning, offers to switch to unpublished |
104
+ | `shopify-agent theme:pull` | `shopify theme pull` with stored theme ID |
105
+ | `shopify-agent theme:dev` | Hot-reload dev server — `--open --allow-live --theme <id>` |
106
+ | `shopify-agent theme:check` | Liquid linter |
107
+ | `shopify-agent theme:push` | Live theme: 3-option guard (staging / live+type-domain / cancel). Unpublished: direct push. |
108
+ | `shopify-agent theme:publish` | Shows theme + store + consequences, prompts before going live |
109
+
110
+ ### App
111
+
112
+ | Command | What it does |
113
+ |---|---|
114
+ | `shopify-agent app:dev` | `shopify app dev` |
115
+ | `shopify-agent app:deploy` | `shopify app deploy` |
116
+
117
+ ### Raw GraphQL
118
+
119
+ | Command | What it does |
120
+ |---|---|
121
+ | `shopify-agent admin:query <file>` | Read-only GraphQL via `store execute` (CLI 4.x) or `app execute` |
122
+ | `shopify-agent admin:mutate <file>` | Mutation — shows filename + store, prompts before executing |
123
+
124
+ ### Products & Catalog
125
+
126
+ | Command | What it does |
127
+ |---|---|
128
+ | `shopify-agent products:list` | Table of products with status, inventory, price `[--status] [--limit]` |
129
+ | `shopify-agent products:get` | Interactive picker → full detail with all variants |
130
+ | `shopify-agent products:create` | Wizard: title, type, vendor, price, SKU, initial inventory, status |
131
+ | `shopify-agent products:publish` | Set selected product status to ACTIVE |
132
+ | `shopify-agent products:archive` | Set selected product status to ARCHIVED |
133
+ | `shopify-agent products:draft` | Set selected product status to DRAFT |
134
+ | `shopify-agent products:delete` | Delete product with confirmation |
135
+ | `shopify-agent variants:list` | Pick product → table of variants with SKU, price, inventory |
136
+ | `shopify-agent variants:update` | Pick product → variant → update price / SKU / barcode |
137
+ | `shopify-agent collections:list` | Table of collections with type (smart/manual) and product count |
138
+ | `shopify-agent collections:create` | Wizard: title, type, and smart rule builder (column / relation / condition) |
139
+
140
+ ### Inventory
141
+
142
+ | Command | What it does |
143
+ |---|---|
144
+ | `shopify-agent inventory:list` | All inventory items × all active locations with stock levels |
145
+ | `shopify-agent inventory:set <qty>` | Bulk-set ALL product variants to qty (with preview + confirm) |
146
+ | `shopify-agent inventory:adjust` | Pick variant → `+5`, `-3`, or `=10` (delta or absolute) |
147
+
148
+ ### Orders
149
+
150
+ | Command | What it does |
151
+ |---|---|
152
+ | `shopify-agent orders:list` | Table of orders `[--status open|closed|cancelled|any] [--limit]` |
153
+ | `shopify-agent orders:get` | Pick order → full detail: line items, tracking, subtotal/shipping/tax/total |
154
+ | `shopify-agent orders:cancel` | Pick order → choose reason → refund? → restock? → confirm |
155
+ | `shopify-agent orders:close` | Pick order → confirm → close |
156
+
157
+ ### Customers
158
+
159
+ | Command | What it does |
160
+ |---|---|
161
+ | `shopify-agent customers:list` | Table of customers with spend + location `[--limit]` |
162
+ | `shopify-agent customers:search` | Search by name, email, phone, or tag → table |
163
+ | `shopify-agent customers:get` | Search → pick → full profile with order history |
164
+ | `shopify-agent customers:create` | Wizard: name, email, phone, tags, marketing opt-in |
165
+ | `shopify-agent customers:tags` | Search → pick customer → add or remove tags |
166
+
167
+ ### Discounts & Gift Cards
168
+
169
+ | Command | What it does |
170
+ |---|---|
171
+ | `shopify-agent discounts:list` | Table: code, value, usage, limit, 1×/customer, status, expiry |
172
+ | `shopify-agent discounts:create` | Wizard: code, % or fixed, once-per-customer, start/end, usage limit |
173
+ | `shopify-agent discounts:delete` | Pick discount → confirm → delete |
174
+ | `shopify-agent discounts:enable` | Re-activate a disabled discount |
175
+ | `shopify-agent discounts:disable` | Deactivate without deleting |
176
+ | `shopify-agent gift-cards:list` | Table: masked code, initial value, balance, customer, expiry, status |
177
+ | `shopify-agent gift-cards:create` | Wizard: amount, note, expiry, optional customer assignment |
178
+
179
+ ### Store
180
+
181
+ | Command | What it does |
182
+ |---|---|
183
+ | `shopify-agent store:info` | Name, domain, plan, currency, timezone, multi-currency |
184
+ | `shopify-agent store:locations` | All locations with active/fulfills status |
185
+ | `shopify-agent store:dashboard` / `dashboard` | Snapshot: 5 open orders + active product inventory + active discounts |
186
+
187
+ ### Content
188
+
189
+ | Command | What it does |
190
+ |---|---|
191
+ | `shopify-agent pages:list` | Table of pages with handle, published status, last updated |
192
+ | `shopify-agent pages:create` | Wizard: title, body HTML, publish immediately? |
193
+ | `shopify-agent blogs:list` | List blogs with 5 recent articles each |
194
+ | `shopify-agent articles:list` | Pick blog → table of articles with author + published date |
195
+ | `shopify-agent redirects:list` | All URL redirects (from → to) |
196
+ | `shopify-agent redirects:create` | Create a URL redirect |
197
+
198
+ ### Metafields
199
+
200
+ | Command | What it does |
201
+ |---|---|
202
+ | `shopify-agent metafields:list` | Pick resource type → pick resource → list all metafields |
203
+ | `shopify-agent metafields:set` | Pick resource → namespace, key, type, value → create or update |
204
+ | Supported resource types | Product, Collection, Customer, Order, Shop |
205
+
206
+ ### Global Flags
207
+
208
+ | Flag | Effect |
209
+ |---|---|
210
+ | `--yes` / `-y` | Auto-confirm all prompts (scripting / CI) |
211
+ | `--status <s>` | Filter by status (products:list, orders:list) |
212
+ | `--limit <n>` | Limit result count (products:list, orders:list, customers:list) |
213
+
214
+ ---
215
+
216
+ ## Local State Model
217
+
218
+ All state is project-local and git-ignored:
219
+
220
+ ```
221
+ .env SHOPIFY_* env vars (7 managed keys, user keys preserved)
222
+ .shopify-agent/
223
+ profiles/<name>.json Store domain, theme ID/name/role, token, app config, API version
224
+ active-profile Active profile name pointer
225
+ config.json { profile: "<name>" }
226
+ ```
227
+
228
+ Profile fields: `name`, `store`, `themeId`, `themeName`, `themeRole`, `themeToken`, `appConfig`, `appClientId`, `storeScopes`, `apiVersion`.
229
+
230
+ `.env` merge-update: managed `SHOPIFY_*` keys are updated in-place; user-added keys are preserved.
231
+
232
+ ---
233
+
234
+ ## Key Design Decisions
235
+
236
+ 1. **Wrap Shopify CLI, don't replace it.**
237
+ Auth, theme ops, app dev, and Admin GraphQL all go through the `shopify` binary. This keeps the package aligned with Shopify-supported workflows and avoids extracting internal tokens.
238
+
239
+ 2. **All mutations prompt inline — no env var gates.**
240
+ Commands ask for confirmation at the moment of execution. The `--yes` / `-y` flag skips prompts for scripting. The single `confirm()` function checks `YES_FLAG` so every command benefits automatically.
241
+
242
+ 3. **Single-file, stdlib only.**
243
+ `bin/shopify-agent.js` uses only `fs`, `path`, `readline`, `child_process`, `os`. No `npm install` beyond the package itself. Keeps installs fast and avoids supply-chain risk.
244
+
245
+ 4. **Feature-detect CLI version at runtime.**
246
+ `hasShopifyCommand("store execute")` probes each command before use so the package works on CLI 3.x (degraded) and 4.x (full).
247
+
248
+ 5. **Auth probe via `organization list`.**
249
+ `shopify auth whoami` does not exist in CLI 4.x. Login state is detected by probing `shopify organization list --json` — success = logged in.
250
+
251
+ 6. **Live theme push is a 3-option explicit gate.**
252
+ Option 1: push to NEW unpublished staging theme (recommended). Option 2: push to live (requires typing store domain). Option 3: cancel. `themeRole` is stored in profile at select/init time so guards work without a network call.
253
+
254
+ 7. **ANSI stripped from all captured CLI output.**
255
+ `FORCE_COLOR=0` in env + `stripAnsi()` regex so `JSON.parse` never breaks on colored terminal output.
256
+
257
+ 8. **Dynamic mutations via temp files.**
258
+ Smart commands (inventory:set, discount:create, products:create, etc.) build GraphQL mutation strings from user input, write to a temp file in `os.tmpdir()`, pass to `store execute --allow-mutations`, then delete the temp file in a `finally` block.
259
+
260
+ 9. **Shared admin helpers.**
261
+ `captureAdminQuery(queryStr, cfg)` — run a query, parse JSON, return `data`.
262
+ `runAdminMutation(mutationStr, cfg)` — run a mutation, display output.
263
+ `printTable(rows)` — render ASCII table with borders.
264
+ `parseCliFlags()` — parse `--key value` flags from argv.
265
+ `extractId(gid)` — strip `gid://shopify/Type/` prefix.
266
+ `esc(str)` — escape for GraphQL string literals.
267
+
268
+ 10. **Agent guardrail files are project-local.**
269
+ `AGENTS.md`, `CLAUDE.md`, Cursor rules, `GEMINI.md` are written per project folder. They include the full command surface, hard rules, live theme consequences, and team-specific workflow examples.
270
+
271
+ ---
272
+
273
+ ## Shopify CLI 4.x Findings
274
+
275
+ - Installed at: `/Users/sagar/Library/Application Support/Herd/config/nvm/versions/node/v20.19.5/bin/shopify`
276
+ - Version: `4.0.0`
277
+ - Key new commands: `organization list`, `store auth`, `store execute`
278
+ - `auth whoami` does NOT exist — use `organization list` as auth probe
279
+ - `store execute` supports `--allow-mutations` flag for Admin writes
280
+ - `store execute` help text is probed for `--query-file` vs `--query` flag support
281
+ - Theme list JSON may have informational text before the JSON array — parser trims to first `[` or `{`
282
+ - `FORCE_COLOR=0` set in all captured calls defensively
283
+
284
+ ---
285
+
286
+ ## Agent Guardrail Content (summary)
287
+
288
+ Written to `AGENTS.md`, `CLAUDE.md`, Cursor rules, `GEMINI.md` by `agents:install`.
289
+
290
+ **Hard rules:**
291
+ 1. Never push to a live theme without explicit user confirmation — always offer staging first
292
+ 2. Never publish a theme without inline confirmation — show consequences first
293
+ 3. Never run Admin mutations without inline confirmation — show what will change first
294
+ 4. Never commit or print secrets (`.env`, tokens, client secrets)
295
+ 5. `--yes` flag only when user has already reviewed and explicitly approved
296
+
297
+ **Live theme consequences (agent must recite before any live push):**
298
+ - Storefront updates immediately for all visitors
299
+ - Broken Liquid/CSS is customer-visible instantly
300
+ - No auto-revert — must manually republish previous theme
301
+ - A single typo in a section template can blank pages for real customers
302
+
303
+ **Recommended workflow per team (as written in guardrail files):**
304
+ - Developers: `theme:dev` → edit → `theme:check` → `theme:push` → preview → `theme:publish`
305
+ - Catalogers: `products:list` → `products:create/update` → `inventory:adjust` → `collections:*`
306
+ - Marketing: `discounts:list` → `discounts:create` → `gift-cards:*` → `metafields:set`
307
+ - Business admins: `dashboard` → `orders:list` → `orders:get` → `customers:search`
308
+
309
+ ---
310
+
311
+ ## Verification Completed
312
+
313
+ ```bash
314
+ node --check bin/shopify-agent.js # syntax OK (2310 lines)
315
+ npm pack --dry-run # files listed, no secrets included
316
+ shopify version # 4.0.0
317
+ shopify-agent capabilities # all CLI 4.x commands available
318
+ shopify-agent init # full flow tested against quickstart store
319
+ shopify-agent theme:pull # Dawn theme pulled to ./quick-start/
320
+ shopify-agent theme:dev # hot-reload confirmed, browser opened
321
+ shopify-agent theme:push # live-push guard confirmed
322
+ ```
323
+
324
+ ---
325
+
326
+ ## Known Gaps / Recommended Next Steps
327
+
328
+ 1. **Publish to npm.** Package is ready — run `npm publish` with a scoped or unscoped name.
329
+ 2. **Automated tests.** No test suite yet. Priority: profile loading, `.env` merge, ANSI stripping, mutation confirmation gate, live-theme guard logic, `printTable` formatting.
330
+ 3. **`store list` via Shopify Partners API.** `organization list` returns orgs but not store domains. A Partners API OAuth call could enumerate stores properly.
331
+ 4. **Dry-run artifacts for mutations.** Before executing, write `.shopify-agent/runs/<timestamp>/plan.md` showing the operation and expected effect.
332
+ 5. **Order fulfillment commands.** `orders:fulfill`, `orders:refund` — not yet implemented.
333
+ 6. **Draft orders.** `draft-orders:list`, `draft-orders:create` — useful for wholesale flows.
334
+ 7. **`theme:push` target flag.** Currently pushes to profile-stored theme ID. Add `--to <theme-id>` for one-off pushes.
335
+ 8. **Scope picker for `store:auth`.** Currently free-text comma-separated. Could be an interactive multiselect.
336
+ 9. **Windows smoke test.** CLI uses `path.join` correctly but `bootstrap.sh` is bash-only.
337
+ 10. **metafields:delete.** Deletion not yet implemented (`metafieldDelete` mutation).
338
+ 11. **articles:create.** Content creation wizard not yet implemented.
339
+ 12. **Bulk operations.** `inventoryBulkAdjust`, `productBulkCreate` for large catalogues.
340
+
341
+ ---
342
+
343
+ ## External Sources
344
+
345
+ - https://shopify.dev/docs/api/shopify-cli/store/store-auth
346
+ - https://shopify.dev/docs/api/shopify-cli/store/store-execute
347
+ - https://shopify.dev/docs/api/shopify-cli/app/app-execute
348
+ - https://shopify.dev/docs/api/shopify-cli/theme
349
+ - https://shopify.dev/docs/storefronts/themes/tools/cli
350
+ - https://shopify.dev/docs/apps/build/ai-toolkit
351
+ - https://shopify.dev/docs/api/admin-graphql
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.