Automated summary
Domain-expert skill for an ERP's order lifecycle across POS and backoffice: statuses, list and edit-item RPCs, void/refund, and realtime consistency.
Strengths
- Gives verified real names for enums, columns, RPCs and filters, preventing false assumptions about the schema
- Draws explicit boundaries with pos-specialist and backoffice-specialist so it does not overlap the UI skills
- Ships preventive checklists for status guards, idempotency, totals recalculation and realtime consistency
- Calls out concrete traps, such as the non-existent 'open' status fixed by a corrective migration
Limitations
- Tightly bound to one specific codebase (apps/backoffice, apps/pos, supabase/migrations paths) and not portable
- Deliberately defers project patterns to CLAUDE.md, which it does not itself contain
- Covers business logic only; UI surfaces are left to the sibling skills
Use it before editing any order lifecycle RPC, status transition, edit-items flow, or the orders realtime hook.
For POS or backoffice UI component work (ProductGrid, OrdersListPage, filter rendering), which belongs to pos-specialist and backoffice-specialist.
Security analysis
SafeThis is a documentation/guidance skill: it maps order-lifecycle RPC names, enum values, and schema column names, plus checklists and an anti-overlap boundary against other skills. It declares no allowed tools and contains no executable instructions, no shell/network/docker usage, no credential or secret handling beyond legitimately noting that void/refund operations are gated by a manager PIN passed via an HTTP header in the existing application design (documented, not instructed to be extracted or exfiltrated). No obfuscation, no destructive commands, no safety-disabling content.
No concerns found
How this analysis is madeExamples
Add a new server-side filter on pending_payment to get_orders_list_v2 and wire it into the backoffice orders list, following the existing JSONB filter pattern.I want to allow voiding an order that is still in pending_payment — update void_order_rpc and double-check the status guards, the manager PIN header and idempotency.After remove_order_item_v1 the order totals are stale in the UI; check _recalc_order_totals and the useOrdersRealtime updates for this flow.name: orders description: >- Orders domain expert — order lifecycle, list v2 server-filters, edit-items RPCs, void/refund, realtime. Cross-app business logic (POS writes + BO management); distinct from pos-specialist (POS UI surface) and backoffice-specialist (BO UI surface). Use this skill whenever the task mentions order(s) / commande(s), statut de commande, void / annulation, refund / remboursement, pending_payment, held order / commande en attente, ardoise, complete_order_with_payment, pay_existing_order, fire_counter_order, create_tablet_order, order items / lignes de commande, totaux de commande, orders realtime — or touches apps/backoffice features/orders, POS order-history, or any supabase migration/test with order in the name. Invoke it BEFORE editing any order lifecycle RPC or status transition, even a small one. pathPatterns:
- 'apps/backoffice/src/features/orders/**'
- 'apps/backoffice/src/pages/**/Order*'
- 'apps/pos/src/features/order-history/**'
- 'supabase/migrations/order.sql'
- 'supabase/tests/order.test.sql'
- 'supabase/tests/complete_order_v10_display.test.sql'
promptSignals:
phrases:
- 'order list'
- 'order status'
- 'edit order item'
- 'void order'
- 'order refund'
- 'pending_payment'
- 'get_orders_list'
- 'order totals'
- 'orders realtime'
- 'complete_order'
- 'add_order_item'
- 'remove_order_item'
Orders — The Breakery ERP
Expert on order business logic across POS (writes) and Backoffice (management). Two use-cases:
- Guide changes to the order lifecycle — new status transitions, edit-items flows, new filters.
- Audit order integrity — status guards, idempotency, realtime consistency, totals recalc.
CLAUDE.md est la source de vérité pour les patterns projet (RPC versioning, REVOKE pairs, PIN header, idempotency). Ce skill ajoute uniquement la surface map ordres, les noms réels vérifiés, et les checklists préventives spécifiques.
Anti-overlap boundary : ce skill couvre la logique métier ordres (RPCs, tables, enums, guards). pos-specialist couvre l'UI POS (ProductGrid, CartSidebar, …). backoffice-specialist couvre l'UI BO (OrdersListPage, filtres, ExportButtons). Les trois coexistent sans collision.
Mental model — Order lifecycle
POS create BO management
────────── ─────────────
complete_order_with_payment get_orders_list_v2
↓ status: paid ↓ cursor-paginé, 11 filtres JSONB
pay_existing_order
↓ draft → pending_payment → paid add/update/remove_order_item_v1
create_tablet_order ↓ draft | pending_payment uniquement
↓ status: draft ↓ _recalc_order_totals atomique
create_b2b_order
↓ status: b2b_pending void_order_rpc
↓ status: voided (manager PIN)
refund_order_rpc
↓ INSERT refunds row useOrdersRealtime
↓ PIN header x-manager-pin ↓ postgres_changes INSERT+UPDATE
↓ idempotency header ↓ StrictMode-safe via useId
Les numéros de version RPC sont volontairement omis dans ce skill (versions omises — vérifier
CLAUDE.md/supabase/migrations/) — ils bumpent presque chaque session ; les mentions d'historique (« Drop v9 », noms de migration) sont conservées.
order_status enum — valeurs réelles (vérifiées migrations S5/S24 + corrective S33 _023)
draft | paid | voided | pending_payment | completed | b2b_pending
PAS de valeur
open— le corrective20260618000023a corrigé exactement ce bug dans les 3 RPCs edit-items (étaitIN ('draft', 'open'), doit êtreIN ('draft', 'pending_payment')). Ne jamais introduire'open'.
order_type enum (vérifié migration S24)
dine_in | take_out | delivery | b2b | tablet
Schema reality (noms de colonnes réels — diffèrent de l'intuition)
| Table | Colonne réelle | Pas |
|-------|---------------|-----|
| orders | total | total_amount |
| orders | served_by | created_by |
| order_items | name_snapshot | product_name |
| order_items | modifiers (JSONB array) | modifiers_json |
| refunds | total | amount |
| customers | name | full_name |
orders.session_id est NULL autorisé pour order_type = 'b2b' et created_via = 'tablet' (CHECK relaxed S24 _007 + S25 _014).
RPCs — noms vérifiés dans supabase/migrations/
Write RPCs (JAMAIS d'INSERT direct — passe toujours par RPC)
| RPC | Fichier migration | Notes |
|-----|------------------|-------|
| complete_order_with_payment | 20260530190828 | Double déduction display_stock + current_stock pour is_display_item. Drop v9 in same migration. |
| pay_existing_order | 20260507000005 + bumps | draft → pending_payment → paid |
| create_tablet_order(p_client_uuid UUID) | 20260602000011 | p_client_uuid REQUIRED, idempotency via tablet_order_idempotency_keys. |
| refund_order_rpc | 20260517000014 | PIN via header x-manager-pin. p_idempotency_key propagé par EF refund-order v7. |
| void_order_rpc | 20260512000009 | Manager PIN gated (pos.sale.void). Émet JE-VOID + stock sale_void + reverse loyalty. |
| create_b2b_order | 20260601000022 | Gate validate_b2b_credit_limit_v1. Status b2b_pending. |
| mark_item_served | (S5) | KDS/tablet — marque l'item servi. |
List & edit RPCs (S32/S33)
get_orders_list_v2(p_start TEXT, p_end TEXT, p_filters JSONB, p_limit INT, p_cursor TIMESTAMPTZ)
(migration 20260618000011, drops v1 in same file)
- Gate:
orders.read - 11 filtres JSONB :
status,order_type,customer_id,served_by,total_min,total_max,customer_type,payment_method,terminal_id,hour(0-23 Asia/Makassar),refund_status(none|partial|full) terminal_idvia JOINpos_sessions→ requiert que l'ordre ait unsession_id- Computed output :
refund_status,has_modifiers,payment_method_primary(ou'mixed'),items_count,customer_name,served_by_name,terminal_id
Edit-items (seulement sur draft | pending_payment) :
| RPC | Signature | Action clé |
|-----|-----------|-----------|
| add_order_item_v1 | (p_order_id, p_product_id, p_qty, p_modifiers, p_idempotency_key) | name_snapshot + retail_price (pas .price) |
| update_order_item_qty_v1 | (p_order_item_id, p_qty, p_idempotency_key) | qty > 0 (sinon utiliser remove) |
| remove_order_item_v1 | (p_order_item_id, p_idempotency_key) | DELETE + recalc |
Les 3 appellent _recalc_order_totals(order_id) (helper interne, non callable directement). Idempotency via table dédiée order_edit_idempotency_keys (colonnes: key UUID PK, action TEXT, order_id UUID, result JSONB). Chaque RPC a sa propre action string : 'add', 'update_qty', 'remove'.
Orchestrateur BO useEditOrderItems : séquence removes → updates → adds pour éviter les conflits de totaux.
Permissions (vérifiées migration 20260618000021)
orders.read — MANAGER / ADMIN / SUPER_ADMIN (S31 _010)
orders.edit_open — MANAGER / ADMIN / SUPER_ADMIN (S33 _021)
orders.void — MANAGER / ADMIN / SUPER_ADMIN (S33 _021)
Critical patterns (ordres-spécifiques)
- Jamais d'INSERT direct dans
orders— toujours via RPC. Les RPCs gèrent atomiquement : JE triggers, loyalty, promotions,display_stockdouble-déduction,table_state. - Status guard sur edit-items —
('draft', 'pending_payment')uniquement. Lever P0002 sinon. Ne pas ajouter'open'(valeur inexistante dans l'enum). products.retail_price(pas.price) — vérifié dans le corrective_023. Utiliserretail_pricepourunit_pricedans les edit-items RPCs.- Idempotency keys propres par RPC — ne pas partager une même
p_idempotency_keyentre deux appels RPC distincts dansuseEditOrderItems. Générer un UUID par call. - PIN en header —
refund_order_rpcetvoid_order_rpclisent le PIN via headerx-manager-pin, jamais dans le body JSON (loggé par PostgREST/pgaudit). - Realtime StrictMode-safe —
useOrdersRealtimeutiliseuseId()pour nommer le channel ; pas de channel name statique (collisions StrictMode double-mount). orders.session_idnullable — NULL autorisé pourb2bETtabletvia 2 CHECK distincts. Ne jamais resserrer à NOT NULL global.- display_stock double-déduction —
complete_order_with_payment(comportement introduit en v10) décrémente à la foisdisplay_stock.quantityETproducts.current_stockpour lesis_display_item=true. Non-display :current_stockseulement (comportement v9 inchangé).
Audit checklist
- [ ] Status transition valide — seuls les états de l'enum réel sont utilisés. Grep
'open'dans les nouvelles migrations ordres. - [ ] Edit-items guard — les 3 RPCs vérifient
status IN ('draft', 'pending_payment')(pas'open'). - [ ] Totals cohérents — après chaque edit-item,
orders.total = SUM(order_items.line_total) + tax_amount - discount_amount. Vérifiable via_recalc_order_totals. - [ ] Idempotency replay — même
p_idempotency_key+ mêmeactionretourne leresultJSONB stocké sans mutation. - [ ]
order_edit_idempotency_keysisolé — pas de GRANT EXECUTE exposant cette table àanonouauthenticatedhors des RPCs SECURITY DEFINER. - [ ] Refund integrity —
SUM(refunds.total) <= orders.totalpour un même order_id.refund_statuscomputed parget_orders_list_v2en découle. - [ ] REVOKE pair complet — chaque nouveau RPC ordres a les 3 lignes (PUBLIC + anon + ALTER DEFAULT PRIVILEGES). Vérifier
20260618000012/016/018/020. - [ ] Types regen — toute migration ordres touchant la signature d'un RPC doit déclencher
generate_typescript_types→packages/supabase/src/types.generated.ts.
Sources de vérité (pointeurs)
Migrations (historique chronologique)
supabase/migrations/20260503000008_init_complete_order_rpc.sql — v1 initial
supabase/migrations/20260530190828_bump_complete_order_v10.sql — v10 display-stock
supabase/migrations/20260617000013_create_get_orders_list_v1_rpc.sql — list v1 (dropped by v2)
supabase/migrations/20260618000011_bump_get_orders_list_v2_server_filters.sql
supabase/migrations/20260618000013..020_*.sql — edit-items RPCs + REVOKE
supabase/migrations/20260618000021_seed_orders_edit_open_perm.sql
supabase/migrations/20260618000023_fix_edit_items_rpc_status_enum.sql — corrective 'open'→'pending_payment'
Tests (vérité comportementale)
supabase/tests/orders_read_perm.test.sql — S31 perm gate
supabase/tests/orders_list_v1.test.sql — S32 (remplacé par v2)
supabase/tests/orders_list_v2.test.sql — S33, 10/10 PASS
supabase/tests/order_edit_items.test.sql — S33, 12/12 PASS
supabase/tests/complete_order_v10_display.test.sql — display-stock double-déduction
Docs / workplan
CLAUDE.md — §S32 (get_orders_list_v1, schema discoveries) + §S33 (v2 server-filters, edit-items, realtime, void)
docs/workplan/specs/2026-05-29-session-33-spec.md
docs/workplan/plans/2026-05-29-session-33-plan.md
Verification before claiming complete
# Type & lint (cheap, run first)
pnpm typecheck
# pgTAP via MCP execute_sql (BEGIN/ROLLBACK envelope)
# Fichiers : orders_list_v2.test.sql, order_edit_items.test.sql, complete_order_v10_display.test.sql
# BO smoke
pnpm --filter @breakery/app-backoffice test orders
# POS smoke
pnpm --filter @breakery/app-pos test order
Baseline : ~24 BO échecs env-gated (VITE_SUPABASE_URL Required) ≠ régression (DEV-S25-2.A-02).
When to escalate
- Ajouter une valeur à
order_statusouorder_type→ confirm business intent, enum ADD VALUE doit vivre dans sa propre TX, puis vérifier tous les guards existants (status IN (…)). - Modifier la signature de
complete_order_with_payment→ bump obligatoire (RPC versioning monotone),DROPde l'ancienne version dans la même migration. Vérifier tous les callers POS/BO. - Relax ou tighten la contrainte
orders.session_id→ peut casser les flows tablet ou B2B (cf. S25 corrective_014). - Nouveau filtre
get_orders_list_v2impliquant un JOIN sur une table sans index → profiler d'abord. - Changement du mécanisme PIN (ex.
void-orderEF sweep POST-S30 déféré) → coordonner avecsecurity-authskill.
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/orders-domain-expert-ms1aw3pi/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/orders-domain-expert-ms1aw3pi' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/orders-domain-expert-ms1aw3pi/download' --output '.skill-downloads/orders-domain-expert-ms1aw3pi/SKILL.md.part' && mv '.skill-downloads/orders-domain-expert-ms1aw3pi/SKILL.md.part' '.skill-downloads/orders-domain-expert-ms1aw3pi/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/orders-domain-expert-ms1aw3pi/SKILL.md' && test -s '.skill-downloads/orders-domain-expert-ms1aw3pi/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/orders' && cp -R '.skill-downloads/orders-domain-expert-ms1aw3pi' '.claude/skills/orders'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/orders-domain-expert-ms1aw3pi'openskills read 'orders-domain-expert-ms1aw3pi'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/orders-domain-expert-ms1aw3pi/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
React Hook Form Best Practices
Development
Master React Hook Form: avoid anti-patterns, manage subscriptions, and handle reset, dirty state, and controlled inputs correctly.
Emotion to Mantine Migration
Development
Migrate Emotion styled-components to Mantine components with style props and CSS modules. Use when converting .styled.tsx files or removing @emotion imports.
Scope Creep Detector
Development
Analyzes git diffs against a stated intent to detect scope creep, unrelated files, broad PRs, and oversized changes, then suggests keep, split, or justify actions.