Purpose
Given a list of grocery items, find the best-matching Costco Same-Day (Instacart-powered) product for each item and add it to the cart, biasing toward previously purchased products when a logged-in "Buy It Again" history is available. Returns, per item, the product chosen (name + price) and whether it came from purchase history, plus the running cart count. This skill is write-to-cart but read-only past that — it stops at the cart and never proceeds to checkout, payment, or order placement.
When to Use
- "Add organic milk, large eggs, and bananas to my Costco Same-Day cart."
- Reorder/restock flows where a user wants their usual groceries queued for delivery.
- Converting a meal-plan or shopping-list into a ready-to-review Costco cart.
- Any flow that needs products selected and added — but not purchased.
Workflow
The recommended method is browser driving the public storefront. Costco Same-Day is an Instacart white-label storefront; its internal product/cart APIs are session-token-gated and not usable cookieless, so the rendered storefront is the reliable surface. A bare remote session is sufficient — no residential proxy or stealth/verified browser was needed (homepage anti-bot probe: none detected; a plain `` run completed the full add-to-cart flow cleanly).
Two distinct capability tiers — know which one you're in:
- Guest (no credentials): search + add-to-cart fully work. The previously-purchased bias is NOT available — the "Buy It Again" page is empty for guests. Fall back to relevance search for every item.
- Logged in (Costco.com SSO): the "Buy It Again" page is populated with order history, enabling the previously-purchased bias. Sign-in is delegated to Costco.com and requires real member credentials; an automated agent without them cannot complete it — treat it as an auth wall and proceed as a guest.
Steps
Keep steps 1–7 inside ONE browserless_agent call's commands array — the guest/session context must be set in the same session or the storefront 302s back to the landing page (see gotcha). The session persists across calls (keyed by the call's proxy/profile config), so batching is a convenience that saves round-trips and avoids accidentally dropping that config on a follow-up call and landing in a different, blank session; there is no session-release step.
Open the entry page.
{ "method": "goto", "params": { "url": "https://sameday.costco.com/", "waitUntil": "load", "timeout": 45000 } }, then{ "method": "snapshot" }. The page offers two buttons:Sign in via Costco.comandBrowse as a guest.- If you have valid Costco member credentials and need the purchase-history bias, load the
autonomous-loginskill (viabrowserless_skill) and follow its gates through the Costco.com SSO. Otherwise{ "method": "click", "params": { "selector": "..." } }onBrowse as a guest(resolve its selector from thesnapshot). { "method": "waitForTimeout", "params": { "time": 10000 } }(the transition takes ~10s).
- If you have valid Costco member credentials and need the purchase-history bias, load the
Land on the storefront. You arrive at
https://sameday.costco.com/store/costco/storefront. The delivery ZIP is auto-set from the session's IP (e.g.97818) and the cart starts at 0. The header shows aView Cart. Items in cart: Nbutton — this N is your source of truth for confirming adds.Check previously-purchased (the bias step). Add a
gototohttps://sameday.costco.com/store/costco/buy_it_again.- Logged in: this lists products from the member's order history. For any grocery-list item that matches an item here, prefer that product (set
from_previously_purchased: true). - Guest: the page shows "Reordering is a breeze / Items you order from this store will show up here" — i.e. empty. Record
previously_purchased_available: falseand fall back to search for every item.
- Logged in: this lists products from the member's order history. For any grocery-list item that matches an item here, prefer that product (set
Search each item. For each list entry,
gotothe search URL directly (no need to type in the box):https://sameday.costco.com/store/costco/s?k=<URL-encoded query>Then
{ "method": "waitForTimeout", "params": { "time": 3000 } }(results render 1–3s after load), then{ "method": "snapshot" }.Pick the best match. Each result is a
group: Productnode containing:- a
headingwith the full product name, - a
StaticText: Current price: $X.XX, - a sibling
button: Add 1 ct <product name>.
Choose the first result that genuinely matches the requested item. Prefer Kirkland Signature and the size/variant closest to the request (e.g. "organic milk" → an organic whole/2% milk multi-pack, not almond/soy unless asked). Costco sells in bulk multi-packs — there is rarely a single-unit option.
- a
Add to cart.
clickthe item'sAdd 1 ct ...button. It morphs into Decrement/Increment controls, and the headerView Cart. Items in cart: Nincrements by 1.{ "method": "waitForTimeout", "params": { "time": 2000 } },snapshot, and verify N increased before moving to the next item.Confirm and emit. After all items, read the final cart count and confirm it equals the number of items successfully added. Emit the JSON in Expected Output. Stop here — do not open the cart's checkout flow.
Site-Specific Gotchas
- WRITE-TO-CART, NOT CHECKOUT. Add items and stop. Never click through to checkout, payment, scheduling, or "Place order."
- Previously-purchased bias requires login. The "Buy It Again" page (
/store/costco/buy_it_again) is the only previously-purchased surface, and it is empty for guests. Without Costco.com credentials the bias is impossible — be honest in the output (previously_purchased_available: false) rather than pretending. This is the core limitation of the task for an unauthenticated agent. - Sign-in is delegated to Costco.com. The "Sign in via Costco.com" button leaves the Instacart storefront for Costco's own SSO. There is no in-storefront login form; an agent without real member credentials cannot pass it — treat as an auth wall, not a bug.
- Storefront/Buy-It-Again URLs 302-redirect to
/?next=...until context is set. Hitting/store/costco/storefrontor/store/costco/buy_it_againcold (fresh session, no guest/login choice made) bounces you to the landing page. Always make the guest/login choice first and keep the subsequent navigations in the samebrowserless_agentcall (so they stay in one session — or, across separate calls, repeat the sameproxy/profileconfig to reconnect to it), then navigate. - Delivery ZIP is IP-geolocated. The storefront picks a delivery ZIP from the session's outbound IP (
97818on a bare US session). Product availability and prices are ZIP-specific. If you need a specific delivery area, set it via theDelivery <ZIP>button in the header before searching; otherwise document the ZIP you actually got (it's in the header and in the output). - No proxy/stealth needed. A plain
browserless_agentcall completed the entire flow; no Akamai block, captcha, or login wall on the storefront/search/add surfaces. Residential proxy / stealth are unnecessary (and a proxy only changes which ZIP you geolocate to). - Search is URL-driven — skip the typeahead.
https://sameday.costco.com/store/costco/s?k=<q>renders results directly; you don't need to interact with the search textbox. Wait ~3s after navigation before thesnapshot(results render progressively). - Snapshots are large (500–700 refs). Filter for
Add 1 ct,Current price, andItems in cartrather than reading the whole tree — or use anevaluateto project just the product/price/cart nodes. Addbutton vs. product button. Each product card has TWO buttons: the product tile itself (opens the detail page) and the separateAdd 1 ct <name>button. Click theAddbutton to add to cart without leaving the results page.- Internal APIs are session-gated. The Instacart backend that powers search/cart is not usable cookieless (requires session bundle tokens). Don't waste time trying to hit a JSON endpoint directly — drive the rendered storefront.
- Bulk-only sizing. Costco results are warehouse multi-packs (e.g. "Kirkland Signature Eggs, Large, 5 dozen-count"). Match on product identity, not pack size, when the list item is generic ("eggs").
Expected Output
{
"success": true,
"store": "costco-same-day",
"delivery_zip": "97818",
"logged_in": false,
"previously_purchased_available": false,
"previously_purchased_note": "Buy It Again is empty for guests; requires Costco.com login",
"items_added": [
{
"query": "organic milk",
"product_name": "Kirkland Signature Organic A2 Whole Milk, Half Gallon, 3-count",
"price": "$16.33",
"from_previously_purchased": false
},
{
"query": "large eggs",
"product_name": "Kirkland Signature Eggs, Large, 5 dozen-count",
"price": "$13.61",
"from_previously_purchased": false
},
{
"query": "bananas",
"product_name": "Bananas, 3 lbs",
"price": "$2.26",
"from_previously_purchased": false
}
],
"cart_count": 3,
"error_reasoning": null
}Variant outcomes:
// An item had no usable match — product fields null, continue with the rest
{
"query": "saffron threads",
"product_name": null,
"price": null,
"from_previously_purchased": false,
"note": "no relevant Costco result"
}// Logged in: previously-purchased bias applied for matching items
{
"logged_in": true,
"previously_purchased_available": true,
"items_added": [
{
"query": "milk",
"product_name": "Kirkland Signature Organic Whole Milk, 8 fl oz, 18-count",
"price": "$17.58",
"from_previously_purchased": true
}
]
}// Auth wall hit (sign-in required but no credentials) — proceed as guest, not a hard failure
{
"success": true,
"logged_in": false,
"previously_purchased_available": false,
"previously_purchased_note": "Sign in via Costco.com requires member credentials; ran as guest",
"cart_count": 3
}