AI · 2026
Shopify Automation
- Year
- 2026
- Scope
- AI · Client
- Role
- AI Automation Engineer
- Team
- Team of 2
- Stack
- Python, Claude Code, MCP, Scrapling
- Status
- Completed
One supplier link becomes a review-ready Shopify draft product.
An agent pipeline that turns a single Alibaba or 1688 product link into a complete Shopify draft product (brand name, locked-format description, linked variants, cost, size chart, metafields, and supplier photos) with every rule enforced after creation.
Paste one Alibaba or 1688 product link and a review-ready draft appears in the client's Shopify store, carrying a distilled brand name, a description in a locked format, Color × Size variants linked to Shopify metaobjects, supplier cost in USD, weight, a size chart in centimetres, category metafields, tags, collections, SKUs, and the supplier's own photography. Nothing is ever published automatically: every product stays a draft until a human releases it.
Read moreShow less
The governing decision is a split: the model is allowed to judge, and code does the mechanics. The model decides only four things per product: the product type, a distilled brand name with supplier codes and keyword stuffing stripped out, the plain text of the description, and two vision calls that pick which description tiles actually show the garment and transcribe the size chart out of an image. Everything else is deterministic Python: colour matching, attribute-to-metaobject mapping, tags, collections, category, SKUs, variants, weight, size chart to HTML, description assembly, metafields, the text of every GraphQL mutation, and a final rule-by-rule verification.
The payoff is that output stays consistent even when the model reasons at a low setting, and bugs move out of "the model misremembered the API" and into scripts that carry unit tests. A derived rule follows from it: the model never writes GraphQL. Generator scripts emit each mutation, the model pastes the output verbatim, and the MCP response is dumped to a fixed filename for the next generator to read.
A batch mode exists for multiple links at once. Since a session is a single agent thread, only extraction genuinely parallelises, so extraction fans out as background subprocesses while draft and Shopify work stays serial. One blocked product does not bring down its batch, and re-running the same links preserves what already succeeded; a refreshed cookie resumes a half-finished run.

Impact
2
MCP calls per product
Plus two more only when a new colour swatch has to be created
~1x
Batch extraction cost
Extraction fans out as background subprocesses instead of running once per product in sequence
Brief
Problem
Listing a supplier garment on Shopify by hand means retyping the title into a brand name, rewriting the description into house format, matching every colour to a swatch metaobject, mapping attributes, transcribing a size chart out of an image into centimetres, building variants and SKUs, and attaching photos; repeated for every product, with a mistake anywhere producing a listing that looks wrong or breaks a smart collection.
Solution
Give the model only the judgment calls and let deterministic scripts handle every mechanical step, then verify the finished product against every business rule on Shopify itself before reporting success.
My role
- 01
Built the extraction, build, and verification pipeline as one of two people on the project
Features
- 01
Pasting a supplier link auto-triggers the upload flow; several links at once switch to batch mode
- 02
Two sources, Alibaba and 1688, normalised into one shared extraction schema
- 03
Preflight hard gate covering virtualenv, stealth browser, cookie locale, config, and a live CNY to USD rate with cache and config fallback
- 04
Vision pass over a labelled contact sheet to pick product-showing tiles and transcribe the size chart
- 05
Deterministic build of description HTML, colour matching, attribute mapping, tags, collections, category, SKUs, variants, and weight
- 06
Automatic creation of swatch metaobjects for colours the store has never seen
- 07
Two MCP calls per product by folding collections, option links, and verification into one aliased mutation
- 08
Post-create verification of ten rule groups against the real product in Shopify
- 09
Batch mode with parallel extraction, per-product failure isolation, and resume from a manifest
- 10
Behaviour driven by config files rather than code: rules, GIDs, and thresholds are all data
Architecture
A command-driven agent pipeline: preflight gate, extraction per source into a shared schema, a vision pass, four model decisions, a deterministic build step that emits the payload and the mutation text, creation over the Shopify Admin GraphQL API through MCP, an aliased finalize mutation, and a verification gate. Behaviour lives in two config files holding rules and Shopify GIDs, so changing what the system does rarely means changing code.
- Back end
- Python
- Tools
- Claude Code, MCP, Scrapling, Chromium, GraphQL
- Integrations
- Shopify Admin GraphQL API, Alibaba, 1688, Frankfurter FX API
Challenges
- 01
Problem
The model wrote Shopify GraphQL mutations from memory and drifted repeatedly, confusing optionValues with optionValuesToUpdate, misplacing name fields into "cannot have both metafield linked and nonlinked option values", and getting reorder positions wrong. Inline documentation contracts were not enough to stop it.
Solution
Moved every hot-path mutation into generator scripts. The model runs the script and pastes stdout verbatim, then dumps the MCP response to a fixed filename for the next generator. The model never authors GraphQL.
- 02
Problem
1688 exposes raw data only in Chinese; the English text comes from 1688's own client-side translator, which only runs in Global / EN / USD mode. Translating with an LLM would have added cost, latency, and new failure modes.
Solution
Read English strings from the rendered DOM after waiting for the translator, while keeping structural fields (image URLs, SKU ids, weight, MOQ, gallery, video) from the SSR blob, since translation does not change those. LLM translation was rejected outright.
- 03
Problem
Running five extractions at once tripped 1688's anti-bot, which answers with a Captcha Interception page returning HTTP 200 and no SSR blob, so the failure looked like a successful fetch of an empty product.
Solution
Capped concurrent extraction at two with a 15 to 20 second cooldown between fan-outs, measured from the end of the previous extraction batch so agent work counts toward it and a slow batch sleeps for zero seconds.
- 04
Problem
Size chart numbers printed at 8 to 12 points turn to mush in the 420-pixel contact sheet used for vision, so a conclusion of "this product has no size chart" drawn from the montage alone could not be trusted.
Solution
Made the absent-chart claim earn its place: the agent must fetch full-resolution tiles and read each one, and the verifiedAbsent marker is only accepted when the reason names every tile label and the full-resolution directory exists as proof. Both build and verify hard-fail a 1688 draft without one of the three chart sources.
- 05
Problem
Cookies from either site localise the response, and a non-English cookie silently corrupts colour names and attributes rather than failing loudly.
Solution
Made cookie locale a hard preflight gate. The run stops and asks the operator to switch the site language, and cookies are never translated or hand-edited.
- 06
Problem
Every MCP round trip to Shopify dominated wall-clock time, and a naive implementation would spend one call each on collections, colour linking, size linking, and verification.
Solution
Folded collections, both option links, and the verification fetch into a single aliased mutation, bringing the cost to two MCP calls per product, plus two more only when a new colour needs a swatch.
Lessons
- 01
Splitting the work so the model only judges and code does the mechanics kept output consistent even at low reasoning effort, and moved bugs into scripts that can be unit tested.
- 02
Documentation contracts alone did not stop the model from drifting on API shape. Removing its ability to author the mutation did.
- 03
Anti-bot systems fail in ways that look like success; a captcha page returning HTTP 200 reads as a fetched product until you check for the data blob.