freight-quote-invariants
Verify that the freight-quote implementation and every UI that renders quotes still honours the invariants declared in CONTEXT.md. Use when adding a Service tier, changing pricing, introducing a new currency, or before merging any change under packages/business-logic or uis/backoffice.
- License 许可
- MIT
- 最近更新
- 2026-10-29
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- freight-quote-invariants
- license
- MIT
- metadata
- { "author": "armonon", "project": "trackflow-monorepo", "version": "1.0.0" }
- description
- Verify that the freight-quote implementation and every UI that renders quotes still honours the invariants declared in CONTEXT.md. Use when adding a Service tier, changing pricing, introducing a new currency, or before merging any change under packages/business-logic or uis/backoffice.
02 资源文件 1
- 脚本scripts/verify.mjs3.9 KB
03 SKILL.md 正文
Freight-quote invariants — verification skill
Objective
Confirm that packages/business-logic/src/freight-quote.ts and every
caller in uis/** obeys the freight-quote invariants declared in
CONTEXT.md. One objective, one artifact
(the exit code of scripts/verify.mjs).
Inputs
The skill needs nothing from the requester beyond a working repository at HEAD. It reads:
CONTEXT.md— the source of truth for the invariants.packages/business-logic/src/freight-quote.ts— implementation under test.packages/business-logic/dist/*— must exist. If it doesn't, the script fails fast withnpm run bootstrapas the remedy.
Expected output
- Exit code
0and a single line to stdout:freight-quote-invariants: OK (N assertions). - Any failure prints the offending assertion, expected vs. actual,
and the line in
CONTEXT.mdthat the assertion enforces. Exit code1.
Invariants asserted (locked to CONTEXT.md)
The script currently asserts these — extend it, don't work around it.
- Currency by country.
country: "MX"→currency: "MXN";country: "ES"→currency: "EUR". Never"USD", never"$". - Priority service tier eligibility.
serviceTier: "priority"accepted only whencountry === "MX"and bothoriginZoneanddestinationZoneare"metro". Any other combination throws with a message that names the failing precondition. - Weight and distance floors.
weightKg > 0anddistanceKm > 0. Zero or negative → thrown error, not a silent zero-quote. - Deterministic pricing. For a frozen input,
quoteShipmentreturns the same object shape and same numeric total across two consecutive calls (totalPrice,currency,serviceTier,breakdown.base,breakdown.distance,breakdown.weight). - Rounding.
totalPriceis rounded to 2 decimals. No floating-point drift like123.4500000001.
How to run
node .agents/skills/freight-quote-invariants/scripts/verify.mjs
or via the workspace alias:
npm run verify:freight-quote
Acceptance criteria (checklist)
- [ ]
node ...scripts/verify.mjsexits0. - [ ] Output line matches
freight-quote-invariants: OK (\d+ assertions). - [ ] Adding a new invariant to CONTEXT.md is followed, in the
same PR, by a matching assertion in
scripts/verify.mjs. If the invariant is added without an assertion, the reviewer blocks the PR — a rule without a check is decorative. - [ ] The script has zero runtime dependencies outside Node's stdlib
(
node:assert,node:test, dynamicimport). It must run on a bare Codespace with nonpm installbeyond the workspace bootstrap. - [ ] When the script fails, its message names both the CONTEXT.md section and the code path that diverged — the point is to make the fix obvious, not to signal that "something's off".
Anti-patterns to reject
- Duplicating any invariant check in
uis/backoffice. The UI consumesquoteShipment; the invariant lives here. - Bypassing the skill with a hand-run test when adding a new
invariant. If the invariant is real, it belongs in
scripts/verify.mjsso future agents pick it up automatically. - Adding new currency codes without also extending assertion (1).
04 同仓库更多 Skills
webapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
vercel-react-best-practices
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.
dashboard-metric-card
Add or modify a KPI card on this financial dashboard with the required type, aggregation, formatting, accessibility, and tests. Use for requests to add a KPI, show a new metric, or change a header card; do not use for unrelated charts or backend-only metrics.
accessibility
Audit and improve web accessibility following WCAG 2.2 guidelines. Use when asked to "improve accessibility", "a11y audit", "WCAG compliance", "screen reader support", "keyboard navigation", or "make accessible".
dashboard-metric-card
Add or modify a KPI card on the financial dashboard so it fits the project's conventions end-to-end — type, aggregation, formatting, colour badge, and accessibility wiring. Use when asked to "add a KPI", "show a new metric on the dashboard", or "change how X displays on the header cards".
webapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.