agentleFS
codeyogi911codeyogi911/shopify-admin-cli/AGENTS.md

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.

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
  1. Very specific:

    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 …

    line 17
  2. Very specific:

    Read every file in knowledge/: before issuing mutations. The Shopify-specific gotchas (cost throttling, GID format, idempotent refunds, …

    line 22
  3. Very specific:

    Every resource lives in commands/<resource>.mjs and default-exports { name, actions }.

    line 28
  4. Very specific:

    Look up the GraphQL operation via shopify-admin-cli introspect type --name <ResourceName> or introspect mutations | jq '.[] | select(.name …

    line 48
  5. Very specific:

    Write the action object. Test with --dry-run first.

    line 49
  6. Very specific:

    Add the new action to coverage.json (endpoints[]).

    line 50
  7. Very specific:

    Run npm test and clify validate ./.

    line 51
  8. Very specific:

    When retryable: true and retryAfter: N, sleep N seconds and re-issue.

    line 63
  9. Very specific:

    Don't bypass the SDK to hand-roll fetch calls — lib/shopify.mjs is the only init path.

    line 67
  10. Very specific:

    Don't hardcode store URLs or tokens.

    line 68
  11. Very specific:

    Don't skip --idempotency-key on refunds create.

    line 69
  12. Very specific:

    Don't use productSet for partial edits.

    line 70
  13. Very specific:

    Don't use raw orderUpdate for line-item changes.

    line 71
  14. Distinctive:

    Don't reach for a knowledge file's prose when the CLI has the action — execute, don't recite.

    line 72
  15. Distinctive:

    Before declaring a change "done":

    line 76

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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

  1. 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.
  2. Authenticate via SHOPIFY_STORE_URL + SHOPIFY_ADMIN_TOKEN env vars (or shopify-admin-cli login --token shpat_...).
  3. Validate auth with shopify-admin-cli shop info --json before 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

  1. Decide if it fits an existing resource or needs a new file under commands/.
  2. Look up the GraphQL operation via shopify-admin-cli introspect type --name <ResourceName> or introspect mutations | jq '.[] | select(.name | contains("XYZ"))'.
  3. Write the action object. Test with --dry-run first.
  4. Add the new action to coverage.json (endpoints[]).
  5. Run npm test and clify 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.mjs is the only init path.
  • Don't hardcode store URLs or tokens. Always env-var or shopify-admin-cli login.
  • Don't skip --idempotency-key on refunds create.
  • Don't use productSet for partial edits; use productUpdate.
  • Don't use raw orderUpdate for 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)

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.