snuset
v0.2.4
Published
CLI for the Snuset store — search, cart, and checkout from your terminal
Maintainers
Readme
snuset
Shop snus from your terminal — search the catalogue, manage a cart, and hand off to the browser for checkout.
npx snusetRuns interactively with no arguments, or accepts subcommands for scripting.
Install
npm install -g snuset
# or run ad-hoc
npx snusetRequires Node.js 18+.
Usage
snuset # interactive REPL
snuset search "general" # search products
snuset product <slug> # show a product with variants and pack sizes
snuset cart # view active order
snuset cart add <variantId> --quantity 2 --pack-size <id>
snuset cart adjust <lineId> --quantity 3
snuset cart remove <lineId>
snuset cart clear
snuset checkout url # print checkout URL (with session handoff)
snuset checkout open # open checkout in the default browser
snuset login [--email <e>] [--password <p>]
snuset register [--email <e>] [--password <p>]
snuset whoami
snuset logout
snuset help [--json] # `--json` prints the command manifest
snuset --versionAdd --json to any command for machine-readable output.
Using snuset from an AI agent (Claude Code, OpenAI, etc.)
The CLI is designed so an agent can drive it without any TUI affordances.
Machine-readable output. Pass --json or just pipe it — when stdout is not a TTY, --json is enabled automatically. All stdout is a single JSON document per command; colors and spinners are suppressed. snuset help --json prints the full command manifest.
No hidden prompts. In --json / non-TTY mode the CLI never asks for input. Missing required arguments return a structured error instead of blocking on stdin:
{ "error": "Missing required argument: --variant", "code": "MISSING_ARG" }Exit code is 1 on any error. Check code for branching: MISSING_ARG (agent forgot a flag), NO_TTY (agent invoked snuset with no subcommand). Unhandled errors from the API bubble up as { "error": "<message>" } without a code.
Session is file-based. snuset login --email … --password … writes a token to ~/.snuset-cli/session.json (or $XDG_STATE_HOME/snuset-cli/session.json). Subsequent calls in any process read it automatically, so an agent can log in once and then run many cart/search commands in separate invocations. Override the path with SNUSET_CLI_SESSION_PATH=/tmp/snuset.json to isolate sessions per run.
Typical agent flow:
snuset login --email $USER_EMAIL --password $USER_PASS --json
snuset search "general" --json | jq '.hits[0].productVariantId'
snuset cart add <variantId> --quantity 2 --pack-size <packSizeId> --json
snuset cart --json
snuset checkout url --json # hand the URL to the user for paymentDo not invoke snuset with no arguments from an agent — that opens the interactive REPL and will error out with code: "NO_TTY" under automation. Always pass a subcommand.
Discover commands programmatically with snuset help --json, which returns { name, version, commands: [...], globalFlags: [...] }.
Agent skill. A ready-made skill for Claude Code, OpenCode, Cursor, and others is published at snuset/skills. Install it with npx skills:
npx skills add snuset/skills # pick agents + skills interactively
npx skills add snuset/skills -s cli # just the CLI skillCheckout handoff
checkout open / checkout url appends the current session as a URL fragment (#cli_token=…) so the storefront can resume the cart in the browser without re-authentication. Agents should prefer checkout url and hand the URL back to the user — checkout open will launch a browser on the machine the CLI runs on, which is rarely where the user is.
License
MIT
