Costco

From mvanhorn/printing-press-library · View interactive version

Costco is an AI agent skill from the GitHub repository mvanhorn/printing-press-library. Your complete Costco receipt history as data — past the website's 2-year wall, in a local database the site never gives you. Trigger phrases: `get my costco receipts`, `how far back do my costco receipts go`, `costco spend this year`, `costco receipt history past 2 years`, `export my costco purchase

How to use this skill

Skill file

Costco — Printing Press CLI

Prerequisites: Install the CLI

This skill drives the costco-pp-cli binary. You must verify the CLI is installed before invoking any command from this skill. If it is missing, install it first:

  1. Install via the Printing Press installer. It defaults binaries to $HOME/.local/bin on macOS/Linux and %LOCALAPPDATA%\Programs\PrintingPress\bin on Windows:

```bash

npx -y @mvanhorn/printing-press-library install costco --cli-only

```

  1. Verify: costco-pp-cli --version
  2. Ensure the reported install directory is on $PATH for the agent/runtime that will invoke this skill.

If the npx install fails (no Node, offline, etc.), fall back to a direct Go install (requires Go 1.26.6 or newer). This installs into $GOPATH/bin (default $HOME/go/bin), so add that directory to $PATH instead:

go install github.com/mvanhorn/printing-press-library/library/commerce/costco/cmd/costco-pp-cli@latest

If --version reports "command not found" after install, the runtime cannot see the binary directory on $PATH. Do not proceed with skill commands until verification succeeds.

Costco's site shows receipts in 6-month chunks up to 2 years, but the backend serves more. This CLI pulls in-warehouse, gas, and online purchase history over any date range, probes how far back your account actually goes with history-depth, computes spend and item-price-history analytics on the fly, and builds a local SQLite archive (sync) for offline SQL and search.

When to Use This CLI

Use this CLI when an agent or user needs Costco purchase history as structured data: pulling receipts past the 2-year UI cap, archiving line items locally, computing spend or savings totals, or tracking an item's price over time. It is read-only and member-scoped.

Anti-triggers

Do not use this CLI for:

Unique Capabilities

These capabilities aren't available in any other tool for this API.

Reach past the UI

_Reach for this to answer 'can I get receipts older than two years' — it probes the live API boundary instead of trusting the UI._

```bash

costco-pp-cli history-depth --json

```

Local state that compounds

_Use when an agent needs spend totals or trends the website never computes._

```bash

costco-pp-cli spend --by month --json

```

_Use to quantify how much Costco deals actually saved you._

```bash

costco-pp-cli savings --since 2024-01-01 --json

```

_Reach for this to find what you can still return before a deadline._

```bash

costco-pp-cli returns-window --days 90 --json

```

Spend insight

_Pick this to see whether a recurring buy has crept up in price._

```bash

costco-pp-cli item-history "rotisserie chicken" --json

```

HTTP Transport

This CLI uses Chrome-compatible HTTP transport for browser-facing endpoints. It does not require a resident browser process for normal API calls.

Command Reference

Receipt data

Analytics (novel)

Local archive

Utilities

Finding the right command

When you know what you want to do but not which command does it, ask the CLI directly:

costco-pp-cli which "<capability in your own words>"

which resolves a natural-language capability query to the best matching command from this CLI's curated feature index. Exit code 0 means at least one match; exit code 2 means no confident match — fall back to --help or use a narrower query.

Recipes

Find your true history floor

costco-pp-cli history-depth --json

Steps startDate backward and reports the earliest receipt the API will serve for your account.

Export receipts to a spreadsheet

costco-pp-cli receipts --since 2024-01-01 --csv

Flat line-item CSV ready for budgeting tools.

Narrow a verbose receipt payload for an agent

costco-pp-cli receipts --since 2025-01-01 --agent --select transactionDate,warehouseName,total

Receipts list output is a flat array; --select trims each row to just the fields an agent needs.

See spend by warehouse

costco-pp-cli spend --by warehouse --json

Aggregates local receipts into per-warehouse spend totals.

What can I still return?

costco-pp-cli returns-window --days 90 --json

Lists recently bought items still inside a 90-day window from their receipt date.

Auth Setup

Costco's receipts API uses a short-lived bearer token (idToken) that your browser stores in localStorage after login. Capture it once from DevTools (localStorage.idToken and localStorage.clientID) and set it with auth set-token; the token expires in minutes, so doctor decodes its expiry and tells you when to refresh. No cookies or password are stored.

Run costco-pp-cli doctor to verify setup.

Agent Mode

Add --agent to any command. Expands to: --json --compact --no-input --no-color --yes.

```bash

costco-pp-cli raw --query example-value --agent --select id,name,status

```

Paths and state

Agents should treat the CLI's path resolver as part of the runtime contract:

```json

{

"mcpServers": {

"costco": {

"command": "costco-pp-mcp",

"env": {

"COSTCO_HOME": "/srv/costco"

}

}

}

}

```

Fleet precedence: an inherited per-kind env var overrides an explicit --home for that kind. Use COSTCO_HOME or per-kind vars as durable fleet levers, and use --home only for a single invocation. Relocation is not reversible by unsetting env vars; move files manually before clearing COSTCO_HOME, or doctor will not find credentials left under the former root.

Agent Feedback

When you (or the agent) notice something off about this CLI, record it:

costco-pp-cli feedback "the --since flag is inclusive but docs say exclusive"
costco-pp-cli feedback --stdin < notes.txt
costco-pp-cli feedback list --json --limit 10

Entries are stored locally as feedback.jsonl under the resolved data dir. They are never POSTed unless COSTCO_FEEDBACK_ENDPOINT is set AND either --send is passed or COSTCO_FEEDBACK_AUTO_SEND=true. Default behavior is local-only.

Write what surprised you, not a bug report. Short, specific, one line: that is the part that compounds.

Output Delivery

Every command accepts --deliver <sink>. The output goes to the named sink in addition to (or instead of) stdout, so agents can route command results without hand-piping. Three sinks are supported:

| Sink | Effect |

|------|--------|

| stdout | Default; write to stdout only |

| file:<path> | Atomically write output to <path> (tmp + rename) |

| webhook:<url> | POST the output body to the URL (application/json or application/x-ndjson when --compact) |

Unknown schemes are refused with a structured error naming the supported set. Webhook failures return non-zero and log the URL + HTTP status on stderr.

Named Profiles

A profile is a saved set of flag values, reused across invocations. Use it when a scheduled agent calls the same command every run with the same configuration - HeyGen's "Beacon" pattern.

costco-pp-cli profile save briefing --json
costco-pp-cli --profile briefing raw --query example-value
costco-pp-cli profile list --json
costco-pp-cli profile show briefing
costco-pp-cli profile delete briefing --yes

Explicit flags always win over profile values; profile values win over defaults. agent-context lists all available profiles under available_profiles so introspecting agents discover them at runtime.

Exit Codes

| Code | Meaning |

|------|---------|

| 0 | Success |

| 2 | Usage error (wrong arguments) |

| 3 | Resource not found |

| 4 | Authentication required |

| 5 | API error (upstream issue) |

| 7 | Rate limited (wait and retry) |

| 10 | Config error |

Argument Parsing

Parse $ARGUMENTS:

  1. Empty, help, or --help → show costco-pp-cli --help output
  2. Starts with install → ends with mcp → MCP installation; otherwise → see Prerequisites above
  3. Anything else → Direct Use (execute as CLI command with --agent)

MCP Server Installation

  1. Install the MCP server:

```bash

go install github.com/mvanhorn/printing-press-library/library/commerce/costco/cmd/costco-pp-mcp@latest

```

  1. Register with Claude Code:

```bash

claude mcp add costco-pp-mcp -- costco-pp-mcp

```

  1. Verify: claude mcp list

Direct Use

  1. Check if installed: which costco-pp-cli

If not found, offer to install (see Prerequisites at the top of this skill).

  1. Match the user query to the best command from the Unique Capabilities and Command Reference above.
  2. Execute with the --agent flag:

```bash

costco-pp-cli <command> [subcommand] [args] --agent

```

  1. If ambiguous, drill into subcommand help: costco-pp-cli <command> --help.
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.