Pantry Tracker
Track grocery items from purchase to plate (or trash). Parses grocery order emails, stores items in Supabase with estimated expiry dates, and sends daily summaries of what needs eating.
Setup
1. Supabase
Create a Supabase project and run the schema in
references/supabase-schema.sql in the SQL editor.
Store credentials as env vars:
CODEBLOCK0
Use the anon key (not the service role key). The anon key is safe for client-side use and sufficient for all pantry operations. Never use the service role key — it bypasses Row Level Security.
2. Cron Jobs
Set up two cron jobs in OpenClaw:
Email scanner (every 2-4 hours):
Use the agent's existing email tool (e.g. gog for Gmail, or whatever email skill is installed) to search for grocery order confirmations. This skill does NOT access email directly — the agent reads email through its own authenticated tools, then passes parsed items to the pantry CLI.
CODEBLOCK1
Morning summary (daily, e.g. 7am):
CODEBLOCK2
CLI Reference
All commands: python3 scripts/pantry.py <command>
| Command | Description |
|---|
| INLINECODE3 | Add single item |
| INLINECODE4 |
Add items from JSON (email parse output) |
|
expiring [--days N] | Show items expiring within N days (default 3) |
|
status | Full pantry overview by category |
|
use <name> | Mark item as used |
|
toss <name> | Mark item as tossed/wasted |
|
refresh | Auto-update statuses (fresh → use-soon → expired) |
|
summary | Morning summary for cron (outputs PANTRY_OK if nothing urgent) |
Bulk-add JSON format
CODEBLOCK3
Email Parsing Guide
When scanning grocery emails, extract:
- 1. Item name — normalize to common name (e.g., "Org Strawberries 1lb" → "Strawberries")
- Quantity — preserve as-is from email ("2 lbs", "1 bunch", "6 ct")
- Category — assign: produce, dairy, meat, bakery, pantry, frozen, other
- Shelf life — look up in
references/shelf-life.md. If not listed, estimate conservatively. - Source — which store (whole-foods, instacart, costco, etc.)
Supported email patterns
- - Whole Foods / Amazon Fresh: Subject contains "Your delivery" or "order delivered"
- Instacart: Subject contains "delivery complete" or "order receipt"
- Costco: Subject contains "order confirmation"
- Walmart: Subject contains "delivery confirmed"
Search email for these patterns. Parse the item list from the email body. When in doubt about an item's category or shelf life, use conservative estimates.
Manual Usage
Users can also say things like:
- - "Add chicken breast to the pantry, expires in 2 days"
- "What's expiring soon?"
- "Mark the strawberries as used"
- "I tossed the leftover salmon"
- "What's in my pantry right now?"
Map these to the appropriate CLI commands.
食品储藏室追踪器
追踪食品杂货从购买到上桌(或丢弃)的全过程。解析食品杂货订单邮件,将物品存储在Supabase中并附上预估保质期,每天发送需要食用的物品摘要。
设置
1. Supabase
创建一个Supabase项目,在SQL编辑器中运行references/supabase-schema.sql中的数据库模式。
将凭证存储为环境变量:
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=your-anon-key
使用匿名密钥(而非服务角色密钥)。匿名密钥在客户端使用是安全的,足以满足所有食品储藏室操作。切勿使用服务角色密钥——它会绕过行级安全策略。
2. 定时任务
在OpenClaw中设置两个定时任务:
邮件扫描器(每2-4小时):
使用代理现有的邮件工具(例如Gmail的gog,或任何已安装的邮件技能)搜索食品杂货订单确认邮件。此技能不直接访问邮件——代理通过自身认证工具读取邮件,然后将解析后的物品传递给食品储藏室CLI。
搜索近期食品杂货订单邮件(Whole Foods、Instacart、Amazon Fresh、Costco、Walmart)。解析物品名称和数量。对于每个物品,在references/shelf-life.md中查找保质期,并从今天起计算过期时间。将物品写入JSON数组并运行:python3 scripts/pantry.py bulk-add /tmp/pantry-items.json
早晨摘要(每日,例如早上7点):
运行:python3 scripts/pantry.py summary
如果输出不是PANTRY_OK,则将摘要发送给用户。
CLI参考
所有命令:python3 scripts/pantry.py <命令>
| 命令 | 描述 |
|---|
| add <名称> -c <类别> -q <数量> -e <天数> | 添加单个物品 |
| bulk-add <文件.json> |
从JSON添加物品(邮件解析输出) |
| expiring [--days N] | 显示N天内过期的物品(默认3天) |
| status | 按类别查看完整食品储藏室概览 |
| use <名称> | 标记物品为已使用 |
| toss <名称> | 标记物品为已丢弃/浪费 |
| refresh | 自动更新状态(新鲜→即将食用→已过期) |
| summary | 定时任务的早晨摘要(无紧急事项时输出PANTRY_OK) |
批量添加JSON格式
json
[
{
name: 草莓,
category: 生鲜,
quantity: 1磅,
expires_days: 5,
source: whole-foods,
order_id: 111-1234567
}
]
邮件解析指南
扫描食品杂货邮件时,提取:
- 1. 物品名称 — 标准化为通用名称(例如有机草莓1磅→草莓)
- 数量 — 保持邮件原文(2磅、1把、6个)
- 类别 — 分配:生鲜、乳制品、肉类、烘焙、干货、冷冻、其他
- 保质期 — 在references/shelf-life.md中查找。如未列出,保守估计。
- 来源 — 哪个商店(whole-foods、instacart、costco等)
支持的邮件模式
- - Whole Foods / Amazon Fresh:主题包含您的配送或订单已送达
- Instacart:主题包含配送完成或订单收据
- Costco:主题包含订单确认
- Walmart:主题包含配送已确认
搜索这些模式的邮件。从邮件正文中解析物品列表。如对物品类别或保质期不确定,使用保守估计。
手动使用
用户也可以这样说:
- - 将鸡胸肉添加到食品储藏室,2天后过期
- 什么快过期了?
- 将草莓标记为已使用
- 我把剩下的三文鱼扔了
- 我的食品储藏室里现在有什么?
将这些映射到相应的CLI命令。