Supabase Inventory Tracker
Track stock levels, process restocks, and adjust quantities after orders without writing SQL. Read current inventory, upsert new products, and get low-stock alerts from your Supabase database.
The Challenge
Keeping inventory accurate in Supabase means someone has to update stock counts when shipments arrive, decrement when orders go out, and check for items running low before they go out of stock. Without a dedicated inventory system, this falls on whoever remembers to run the query. Quantities drift, reorder points get missed, and by the time someone notices an item is out of stock, customers are already seeing "unavailable" on the storefront.
What This Prompt Does
Check Stock
Reads current inventory levels and flags items that are low or out of stock against their reorder points
Upsert Products
Adds new products to inventory or updates existing ones when shipments arrive, using SKU as the conflict key
Adjust Quantities
Decrements stock for orders and increments for restocks with before-and-after verification
Generate Reports
Produces inventory summaries grouped by category with low-stock alerts and total value calculations
The Prompt
The Prompt
Task
Use @Supabase/Read RecordsName it "Supabase/Read Records" and call it with @Supabase/Read Records to check current inventory levels, @Supabase/Upsert RecordName it "Supabase/Upsert Record" and call it with @Supabase/Upsert Record to add new stock entries or update existing ones when shipments arrive, and @Supabase/Update RecordName it "Supabase/Update Record" and call it with @Supabase/Update Record to adjust quantities after orders are placed or stock is moved between locations.
Input
The user provides:
- The inventory table name in Supabase (defaults to "inventory")
- The action: check stock, add new products, restock, or adjust after orders
- Product identifiers: SKU, product_id, or name
- Quantity changes: units received, units sold, or new quantity to set
- Optional: warehouse or location for multi-location tracking
Example: "Check the current stock for SKU-1234 and SKU-5678. Then add 500 units of SKU-1234 from today's shipment and subtract 12 units of SKU-5678 for order #9901."
Context
Checking Inventory Levels
- Use @Supabase/Read RecordsName it "Supabase/Read Records" and call it with @Supabase/Read Records to pull current stock for specific SKUs or product IDs
- Filter by location or warehouse if multi-location tracking is in use
- Flag items that are below the reorder threshold
- Report items that are out of stock (quantity = 0)
- Include last_updated timestamps so the user knows how fresh the data is
Adding New Products
- Use @Supabase/Read RecordsName it "Supabase/Read Records" and call it with @Supabase/Read Records to check if the product already exists in the inventory table
- Use @Supabase/Upsert RecordName it "Supabase/Upsert Record" and call it with @Supabase/Upsert Record to insert new products with initial stock quantities
- Set the conflict resolution column (usually sku or product_id) so existing products get updated instead of duplicated
- Include all product metadata: name, SKU, category, reorder_point, unit_cost
Restocking
- Use @Supabase/Read RecordsName it "Supabase/Read Records" and call it with @Supabase/Read Records to get the current quantity for the product being restocked
- Calculate the new quantity: current_quantity + units_received
- Use @Supabase/Upsert RecordName it "Supabase/Upsert Record" and call it with @Supabase/Upsert Record to update the quantity and set last_restocked timestamp
- If the product does not exist, create a new record with the restocked quantity
Order Adjustments
- Use @Supabase/Read RecordsName it "Supabase/Read Records" and call it with @Supabase/Read Records to get the current quantity for ordered items
- Verify sufficient stock exists before decrementing
- Use @Supabase/Update RecordName it "Supabase/Update Record" and call it with @Supabase/Update Record to subtract the ordered quantity
- If the adjustment would bring quantity below zero, warn the user and do not apply
- If the new quantity falls below the reorder_point, flag the item for reorder
Inventory Reports
When the user asks for a report:
- Use @Supabase/Read RecordsName it "Supabase/Read Records" and call it with @Supabase/Read Records to pull all inventory records
- Group by category or location
- Highlight low-stock and out-of-stock items
- Calculate total inventory value (quantity * unit_cost) if cost data is available
Safety Guidelines
- Never set quantity to a negative number
- Always verify current stock before making adjustments
- Show before and after quantities for every change
- Warn if a restock would exceed a warehouse capacity limit (if defined)
Output
Inventory Status:
Current Stock Levels: | SKU | Product Name | Quantity | Reorder Point | Status | |-----|-------------|----------|---------------|--------| | [sku] | [name] | [qty] | [reorder_at] | In Stock / Low / Out of Stock |
Changes Applied: | SKU | Action | Previous Qty | Change | New Qty | |-----|--------|-------------|--------|---------| | [sku] | Restock | [old] | +[n] | [new] | | [sku] | Order adjustment | [old] | -[n] | [new] |
Alerts:
- Low stock: [list of items below reorder point]
- Out of stock: [list of items at zero]
- Reorder recommended: [items with suggested order quantities]
Summary:
- Products checked: [n]
- Restocked: [n]
- Adjusted for orders: [n]
- New products added: [n]
Example Usage
Try asking:
- →"Check inventory levels for all products in the electronics category. Flag anything below its reorder point."
- →"We just received a shipment: add 200 units of SKU-A100, 150 units of SKU-B200, and 75 units of SKU-C300 to the inventory table."
- →"Subtract inventory for order #4521: 3 units of SKU-A100 and 1 unit of SKU-B200. Warn me if either goes below the reorder point."