Dev

Using with AI Agents

The CloudCart CLI is designed to be operated by AI assistants — structured output, self-describing commands, and built-in LLM context.

The CLI was built so that an AI assistant (Claude Code, Cursor, Codex CLI, Gemini CLI, or your own agent) can operate a CloudCart store autonomously and safely. Three design decisions make that work:

  1. Structured output everywhere — --json and --compact-output on every data command
  2. Self-description — cloudcart describe --json lists every command and flag
  3. Built-in context — cloudcart llms-context teaches the assistant the correct workflow

Set up an agent in 60 seconds

# 1. Give the agent non-interactive credentials
export CLOUDCART_CLI_TOKEN=cc_pat_your_token
export CLOUDCART_CLI_STORE=mystore.cloudcart.com

# 2. Drop the CLI context into your project
cloudcart llms-context > CLOUDCART.md

Then tell your assistant to read CLOUDCART.md — or add it to CLAUDE.md / AGENTS.md / .cursorrules so it loads automatically.

Start with a Read Only token

Give agents a Read Only PAT until you trust the workflow, then switch to Custom Permissions scoped to exactly what the automation needs. Creating a token takes seconds — see the PAT guide.

The workflow agents should follow

The context from llms-context teaches this three-step loop:

# 1. Discover — search the schema instead of guessing field names
cloudcart app schema --search product --compact

# 2. Validate — catch errors before touching the store
cloudcart app validate --query '{ products(first:5) { edges { node { id name } } } }' --json

# 3. Execute — with token-efficient output
cloudcart app execute --query '{ products(first:5) { edges { node { id name } } } }' --compact-output

This loop eliminates the classic failure mode of AI-generated GraphQL: hallucinated fields. A query that passes validate will not fail on schema errors in execute.

Token-efficient output

--compact-output strips all whitespace from JSON responses. On large result sets this saves a significant share of the tokens your agent burns reading results:

cloudcart app execute --query '{ orders(first: 50) { edges { node { id amounts { total } } } } }' --compact-output

CLI or MCP server?

Both are first-class — pick based on where the work happens:

CloudCart CLIDev MCP server
Best forExecuting real operations on a storeWriting correct GraphQL code in your editor
AuthPAT (store credentials)None needed — schema only
Can modify dataYes (with a Full Access PAT)No — validation and introspection only
Works inAny terminal, CI, cron, scriptsClaude Code, Cursor, Claude Desktop, VS Code, Codex CLI, Gemini CLI

They combine well: the MCP server helps the assistant write the query, the CLI runs it.

Example: a scheduled inventory agent

#!/bin/bash
# Runs nightly: report products that are low on stock
export CLOUDCART_CLI_TOKEN=$CC_READONLY_PAT
export CLOUDCART_CLI_STORE=mystore.cloudcart.com

cloudcart app execute --compact-output --query '
{ products(first: 100, stock: { operator: lte, value: 5 }) {
    edges { node { id name inventory { threshold variantsCount } } }
    pageInfo { total }
} }' | your-notifier

On this page