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:
- Structured output everywhere —
--jsonand--compact-outputon every data command - Self-description —
cloudcart describe --jsonlists every command and flag - Built-in context —
cloudcart llms-contextteaches 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.mdThen 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-outputThis 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-outputCLI or MCP server?
Both are first-class — pick based on where the work happens:
| CloudCart CLI | Dev MCP server | |
|---|---|---|
| Best for | Executing real operations on a store | Writing correct GraphQL code in your editor |
| Auth | PAT (store credentials) | None needed — schema only |
| Can modify data | Yes (with a Full Access PAT) | No — validation and introspection only |
| Works in | Any terminal, CI, cron, scripts | Claude 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