Clawshier
Process a receipt or invoice image through a four-step pipeline, then reply with a short summary of what was added.
Input handling
- - If the user provides a local file path to the image, use that path directly.
- If the user sends an image in chat and a local attachment path is available, use that path.
- If no local file path is available for the image, ask the user to resend it as a file or provide a path you can execute against.
- If the user explicitly gives the receipt date, preserve it and pass it to step 3 with
--date YYYY-MM-DD.
Workflow
Run the safe pipeline runner. If it fails, retry it up to 2 times before surfacing the error.
Primary path — Safe pipeline runner
Run:
CODEBLOCK0
If the user explicitly provided a date, always pass it in ISO format:
CODEBLOCK1
This runner performs OCR → structure → validate/deduplicate → store internally using JSON files, not shell-interpolated pipeline strings.
It writes to:
- - the monthly expense tab (
MM-YY) - INLINECODE2
- INLINECODE3
It also removes the default Sheet1 tab if present.
Handler compatibility note
The individual handlers still support stdin/stdout for testing, but when automating the skill, prefer scripts/run_pipeline.js or the handlers' --input-file/--output-file options instead of embedding untrusted receipt/LLM output into shell commands.
If OCR reports that the image is not a receipt or invoice, tell the user:
I couldn't detect a receipt or invoice in that image. Could you try again with a clearer photo?
If the validator reports a duplicate, stop and tell the user:
This receipt appears to already be logged (vendor, date, total match an existing entry). Skipping.
Success reply
After a successful run, reply in this format:
Added expense: {vendor} — {total} {currency} on {date} ({category}). Row #{row} in your spreadsheet (tab {MM-YY}).
If the user explicitly asks for tracing/debugging/cost tracing, append a compact per-step trace summary using the last recorded trace file. Otherwise keep the normal success reply short.
Failure reply
If a step still fails after retries, say which step failed and include the error message.
Notes
- - Use
{baseDir} exactly so the commands do not depend on the current working directory. - For old invoices, prefer
--date YYYY-MM-DD instead of relying on same-day date inference. - OCR backend selection is machine-level:
CLAWSHIER_VISION_PROVIDER=openai|ollama|auto (default: openai). - INLINECODE11 tries local Ollama first and falls back to OpenAI. Set to
ollama to force local-only OCR. - Use
CLAWSHIER_OLLAMA_MODEL, CLAWSHIER_OLLAMA_HOST, and CLAWSHIER_OLLAMA_MAX_DIMENSION to control the Ollama OCR backend. - When
CLAWSHIER_TEST_MODE=1 is present in the environment, the handlers use local test fixtures and a local mock sheet store. Use that for safe smoke tests before touching real APIs. - Optional tracing: set
CLAWSHIER_TRACE=1 to record per-step timing/usage metadata to .clawshier-last-trace.json. Show that trace in chat only when the user explicitly asks for tracing/debugging/cost tracing.
Clawshier
通过四步流程处理收据或发票图像,然后回复所添加内容的简短摘要。
输入处理
- - 如果用户提供图像的本地文件路径,则直接使用该路径。
- 如果用户在聊天中发送图像且存在本地附件路径,则使用该路径。
- 如果图像没有可用的本地文件路径,则要求用户重新以文件形式发送或提供可执行的路径。
- 如果用户明确提供了收据日期,则保留该日期,并在步骤3中使用--date YYYY-MM-DD参数传递。
工作流程
运行安全管道运行器。如果失败,最多重试2次,然后显示错误。
主要路径 — 安全管道运行器
运行:
bash
node {baseDir}/scripts/run_pipeline.js --image <图像路径>
如果用户明确提供了日期,始终以ISO格式传递:
bash
node {baseDir}/scripts/run_pipeline.js --image <图像路径> --date 2026-03-25
该运行器执行OCR → 结构化 → 验证/去重 → 使用JSON文件存储,而非shell插值的管道字符串。
它会写入:
如果存在默认的Sheet1标签页,也会将其移除。
处理器兼容性说明
各个处理器仍支持stdin/stdout用于测试,但在自动化该技能时,优先使用scripts/run_pipeline.js或处理器的--input-file/--output-file选项,而不是将不可信的收据/LLM输出嵌入到shell命令中。
如果OCR报告图像不是收据或发票,则告知用户:
我无法在该图像中检测到收据或发票。能否尝试使用更清晰的照片?
如果验证器报告重复,则停止并告知用户:
此收据似乎已记录(商家、日期、总金额与现有条目匹配)。跳过。
成功回复
成功运行后,按以下格式回复:
已添加支出:{商家} — {总金额} {货币} 于 {日期}({类别})。电子表格中的第#{行号}行(标签页 {MM-YY})。
如果用户明确要求追踪/调试/成本追踪,则使用最后记录的追踪文件附加紧凑的逐步骤追踪摘要。否则保持简短的标准成功回复。
失败回复
如果某个步骤在重试后仍然失败,则说明哪个步骤失败并包含错误信息。
备注
- - 精确使用{baseDir},使命令不依赖于当前工作目录。
- 对于旧发票,优先使用--date YYYY-MM-DD,而不是依赖同一天日期推断。
- OCR后端选择为机器级别:CLAWSHIERVISIONPROVIDER=openai|ollama|auto(默认:openai)。
- auto首先尝试本地Ollama,失败时回退到OpenAI。设置为ollama以强制仅使用本地OCR。
- 使用CLAWSHIEROLLAMAMODEL、CLAWSHIEROLLAMAHOST和CLAWSHIEROLLAMAMAXDIMENSION来控制Ollama OCR后端。
- 当环境中存在CLAWSHIERTESTMODE=1时,处理器使用本地测试夹具和本地模拟表格存储。在接触真实API之前,使用该模式进行安全冒烟测试。
- 可选追踪:设置CLAWSHIERTRACE=1以记录每步骤的时间/使用情况元数据到.clawshier-last-trace.json。仅在用户明确要求追踪/调试/成本追踪时在聊天中显示该追踪信息。