shopify-admin-cli
AGENTS.md0 starsChanged 7 months agoMITView on GitHub
You are working with shopify-admin-cli, an agent-friendly CLI over the Shopify Admin GraphQL API. It wraps @shopify/shopify-api in custom-app mode — static admin token, no OAuth. docs/api/ is the citable reference. Shopify publishes the real markdown source of every doc page — append .md to any shopify.dev URL — so npm run docs:api mirrors rather than renders. Each file keeps Shopify's own frontmatter (source_url, api_version). Pinned to the version in lib/shopify.mjs (2026-01); pass --version to mirror another. Where a command…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,774 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository2 other files it gives its agents.
- shopify-admin-cliSkill
- shopify-adminSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
15 rules. About 0 are common, 2 are distinctive, and 13 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
13
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 17
Start with docs/api/usage-limits.md before scheduling anything — the Admin API is cost-based, not request-based, and a bulk sweep is the …
- Very specific: line 22
Read every file in
knowledge/: before issuing mutations. The Shopify-specific gotchas (cost throttling, GID format, idempotent refunds, … - Very specific: line 28
Every resource lives in commands/<resource>.mjs and default-exports { name, actions }.
- Very specific: line 48
Look up the GraphQL operation via shopify-admin-cli introspect type --name <ResourceName> or introspect mutations | jq '.[] | select(.name …
- Very specific: line 49
Write the action object. Test with --dry-run first.
- Very specific: line 50
Add the new action to coverage.json (endpoints[]).
- Very specific: line 51
Run npm test and clify validate ./.
- Very specific: line 63
When retryable: true and retryAfter: N, sleep N seconds and re-issue.
- Very specific: line 67
Don't bypass the SDK to hand-roll fetch calls — lib/shopify.mjs is the only init path.
- Very specific: line 68
Don't hardcode store URLs or tokens.
- Very specific: line 69
Don't skip --idempotency-key on refunds create.
- Very specific: line 70
Don't use productSet for partial edits.
- Very specific: line 71
Don't use raw orderUpdate for line-item changes.
- Distinctive: line 72
Don't reach for a knowledge file's prose when the CLI has the action — execute, don't recite.
- Distinctive: line 76
Before declaring a change "done":
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agent instructions for shopify-admin-cli
You are working with shopify-admin-cli, an agent-friendly CLI over the Shopify Admin GraphQL API. It wraps @shopify/shopify-api in custom-app mode — static admin token, no OAuth.
Source of truth
docs/api/ is the citable reference. Shopify publishes the real markdown source of
every doc page — append .md to any shopify.dev URL — so npm run docs:api mirrors
rather than renders. Each file keeps Shopify's own frontmatter (source_url,
api_version). Pinned to the version in lib/shopify.mjs (2026-01); pass
--version to mirror another.
Where a command disagrees with it, the command is wrong. Diagnose from the docs, not
from the error string. When you add a command module, add its object page to PAGES in
tools/fetch-api-docs.mjs.
Start with docs/api/usage-limits.md before scheduling anything — the Admin API is
cost-based, not request-based, and a bulk sweep is the usual way to discover that.
Before you act
- Read every file in
knowledge/before issuing mutations. The Shopify-specific gotchas (cost throttling, GID format, idempotent refunds, productSet vs productUpdate, three-phase order edits, staged uploads, bulk operations, B2B Plus-only) are non-obvious and the CLI does not enforce them. - Authenticate via
SHOPIFY_STORE_URL+SHOPIFY_ADMIN_TOKENenv vars (orshopify-admin-cli login --token shpat_...). - Validate auth with
shopify-admin-cli shop info --jsonbefore any mutation.
Shape
Every resource lives in commands/<resource>.mjs and default-exports { name, actions }. Each action declares:
{
kind: "graphql", // most actions
description: "...",
query: `query/mutation string`,
flags: { /* parseArgs options */ },
variables: (values) => ({ /* GraphQL variables */ }),
paginatePath: "products", // optional — for --all support
project: (data) => data.products, // optional — narrow the response
postProcess: async (data, values) => ... // optional — multi-step flows
}The dispatcher in bin/shopify-admin-cli.mjs handles the rest.
Adding a new action
- Decide if it fits an existing resource or needs a new file under
commands/. - Look up the GraphQL operation via
shopify-admin-cli introspect type --name <ResourceName>orintrospect mutations | jq '.[] | select(.name | contains("XYZ"))'. - Write the action object. Test with
--dry-runfirst. - Add the new action to
coverage.json(endpoints[]). - Run
npm testandclify validate ./.
Error handling
The CLI normalises every Shopify error into the structured-error shape:
{ "type": "error", "code": "...", "message": "...", "retryable": false }Codes: auth_missing, auth_invalid, forbidden, not_found, conflict, validation_error, rate_limited, server_error, network_error, timeout.
When retryable: true and retryAfter: N, sleep N seconds and re-issue. The CLI does not auto-retry.
Don't
- Don't bypass the SDK to hand-roll fetch calls —
lib/shopify.mjsis the only init path. - Don't hardcode store URLs or tokens. Always env-var or
shopify-admin-cli login. - Don't skip
--idempotency-keyonrefunds create. - Don't use
productSetfor partial edits; useproductUpdate. - Don't use raw
orderUpdatefor line-item changes; use the three-phase order-edit flow. - Don't reach for a knowledge file's prose when the CLI has the action — execute, don't recite.
Validation
Before declaring a change "done":
npm test # unit + integration
node bin/shopify-admin-cli.mjs --help # smoke
clify validate ./ # gate (8 categories)Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

