Api

From abracadabra50/uk-grocery-cli · View interactive version

Api is an AI agent skill from the GitHub repository abracadabra50/uk-grocery-cli. Use the local groc HTTP API to search Sainsbury's groceries, search favourites, add/update/remove basket items, and view basket.

How to use this skill

Skill file

Grocery API Skill

Use this skill when the user asks about Sainsbury's groceries, favourites, searching products, adding/updating/removing basket items, or viewing the basket.

The local API must already be running on port 7876:

GROC_API_PORT=7876 npm run api

Commands

Run from the repo root:

node skills/api/wrapper.js fav-search "milk"
node skills/api/wrapper.js search "milk"
node skills/api/wrapper.js favourites
node skills/api/wrapper.js basket
node skills/api/wrapper.js add <product-id> [qty]
node skills/api/wrapper.js remove <item-id>
node skills/api/wrapper.js update <item-id> <qty>

All commands return JSON from the local API.

Add-to-basket workflow

When the user asks to add an item to the basket:

  1. First search favourites:

```bash

node skills/api/wrapper.js fav-search "USER ITEM"

```

  1. If there is a clear favourite result that matches the user's intent, add it directly:

```bash

node skills/api/wrapper.js add <product-id> [qty]

```

  1. If there are multiple plausible favourite results, ask the user which one to add. Include names, prices, and product IDs.
  1. If there are no good favourite matches, or if the user explicitly asks to look outside favourites, use regular search:

```bash

node skills/api/wrapper.js search "USER ITEM"

```

  1. For regular search results, always confirm with the user before adding anything to the basket.
  1. After adding, show or summarize the basket:

```bash

node skills/api/wrapper.js basket

```

Remove/update workflow

When the user asks to remove or update an item:

  1. First inspect the basket to get basket item IDs:

```bash

node skills/api/wrapper.js basket

```

  1. Use the basket item_id, not the product ID:

```bash

node skills/api/wrapper.js remove <item-id>

node skills/api/wrapper.js update <item-id> <qty>

```

  1. If the item to change is ambiguous, ask the user which basket item they mean.
  1. After removing or updating, show or summarize the basket.

Notes

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.