Wocart
AGENTS.md420 starsChanged 5 days agoApache-2.0View on GitHub
Wocart (formerly CodFlow) is a cash-on-delivery e-commerce platform for Algeria: TypeScript, deployed on Cloudflare (Workers, D1, R2, KV). Package, folder, environment-variable and domain names still say CodFlow where renaming would break existing stores; keep them. - cod-server/ — the API (Hono on Workers, D1 through Drizzle): merchant /api/*, public /store/*, /webhooks, /media, /mcp. - cod-client-astro/ — the merchant dashboard (Astro 7): prerendered pages, plus a Worker for /api/auth/* and the MCP OAuth login. React islands call cod-server only through src/lib/api.ts.…
- Reads credentials
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,439 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository3 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- wocart-setupSkill
- wocart-updateSkill
The file
We split this AGENTS.md into the rules it gives an agent
11 rules. About 0 are common, 4 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 53
After changing TypeScript, run npm run typecheck in the affected package.
- Very specific: line 54
After changing behavior, run npm test in the affected package.
- Distinctive: line 61
Claims are verified against the code: Never write a feature into the README or the docs that the code does not do.
- Very specific: line 63
Never commit secrets: No live keys, carrier tokens or credentials in source, tests or fixtures.
- Distinctive: line 67
No explanatory code comments unless asked.
- Distinctive: line 79
A migration never loses a store's data: Add a new migration; never rewrite a released one.
- Distinctive: line 90
Ask before adding a production dependency or changing the D1 schema.
- Very specific: line 111
Never dispatch a side effect from a handler.
- Very specific: line 114
Carriers: Only Yalidine and ZR Express send webhooks.
- Very specific: line 200
Every endpoint is declared with defineRoute():
- Very specific: line 216
Always take scopes from SCOPES, and reuse the shared response schemas in cod-server/src/openapi/schemas.ts.
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Wocart — repository instructions for coding agents
Wocart (formerly CodFlow) is a cash-on-delivery e-commerce platform for Algeria: TypeScript, deployed on Cloudflare (Workers, D1, R2, KV). Package, folder, environment-variable and domain names still say CodFlow where renaming would break existing stores; keep them.
Layout
cod-server/— the API (Hono on Workers, D1 through Drizzle): merchant/api/*, public/store/*,/webhooks,/media,/mcp.cod-client-astro/— the merchant dashboard (Astro 7): prerendered pages, plus a Worker for/api/auth/*and the MCP OAuth login. React islands call cod-server only throughsrc/lib/api.ts.cod-shared/— the D1 schema, queries, permission scopes and error codes, imported by relative path (../../cod-shared/...). Not published.cod-astro/theme-00/— the reference storefront theme. It installs@wocart/storefrontand@wocart/themefrom npm like any outside theme and has its own lockfile. Readcod-astro/theme-00/AGENTS.mdbefore editing it.cod-docs/— the developer site (Zudoku), in English, French and Arabic, with its own lockfile. Readcod-docs/README.mdbefore editing it.
The root package.json has three npm workspaces (cod-shared, cod-server,
cod-client-astro) and the one root package-lock.json. Theme-00 and
cod-docs are deliberately outside them. Never add a lockfile to a workspace.
Commands
npm ci # repo root: every workspace
cd cod-server && npm run typecheck && npm test
cd cod-server && npm run dev # wrangler dev on :8787
cd cod-client-astro && npm run typecheck && npm test
cd cod-client-astro && npm run dev # astro dev on :4321
cd cod-astro/theme-00 && npm ci && npm test && npx astro check
cd cod-docs && npm ci && npm run typecheck && npm run check:i18nFirst local run: cd cod-server && npm run db:setup:local, then
cd cod-client-astro && npm run seed:admin (sign-up is disabled by design).
Signing in against an unmigrated local D1 is the usual cause of a dashboard
that "doesn't work" locally.
The dashboard and a storefront both default to port 4321; run one with
--port 4322 when developing both.
A docs build fetches /api/openapi.json from a local cod-server, or from
COD_OPENAPI_URL when set.
Verification
- After changing TypeScript, run
npm run typecheckin the affected package. - After changing behavior, run
npm testin the affected package. - CI (
.github/workflows/ci.yml) runs typecheck and tests for cod-server and the dashboard, and Theme-00's tests,astro checkand build against the published SDKs.
Conventions
- Claims are verified against the code. Never write a feature into the README or the docs that the code does not do.
- Never commit secrets. No live keys, carrier tokens or credentials in
source, tests or fixtures. Secrets go in
wrangler secretor.dev.vars(gitignored). The realwrangler.tomlfiles are gitignored; commit only the.exampletemplates. - No explanatory code comments unless asked.
- Private folders are never committed.
docs/,wocart-sdk/,.agents/internal-skills/and every theme incod-astro/other thantheme-00are maintainers' local folders, gitignored; never force-add them and never link to them from tracked files. A theme becomes public only by an explicit!/cod-astro/<name>/line in.gitignore. Anything developers or users need goes incod-docs.
Boundaries
cod-sharedis the single source of truth for the schema, queries, scopes and error codes. Never duplicate them in an app.- A migration never loses a store's data. Add a new migration; never
rewrite a released one. Migrations run on live stores before the new server
is deployed, so each keeps every row and keeps the running server working:
add first, stop reading in the next release, drop in a later one. A
statement that deletes or rewrites rows declares it with
-- data-safety: <table>[.<column>] — <reason>(or-- data-safety: rebuild <table> — <reason>), and the migration gets its ownsrc/db/migration-<NNNN>-*.e2e.test.tsproving it on data. Never rebuild (DROP + RENAME) a table other tables reference: on D1 the drop deletes their rows throughON DELETE CASCADE, whatever the pragmas.cod-server/src/db/migration-safety.e2e.test.tsenforces this. - Ask before adding a production dependency or changing the D1 schema.
- Theme-00 holds no engine logic: platform rules belong in
@wocart/storefront. It imports the SDKs only through their published entry points (sdk-boundary-contracts.test.ts), and no validator reaches shoppers' pages (no-validator-in-browser.test.ts). - The dashboard reads data only through
src/lib/api.ts; components never callfetch, and the dashboard never queries D1 for business data. - Theme editing (text edits, page documents, theme settings) is written by Wocart Cloud's editor, which is closed source. This repository only reads them; never add theme-writing endpoints or UI here.
Domain rules
- Delivery belongs to the shipment. An order's status is its processing
only (
cod-shared/orders/lifecycle.ts); carrier, driver, tracking and delivery milestones live inshipmentsandshipment_events, driver settlement indriver_payment_lines.orders.driver_id,orders.company_idandwebhook_events.order_idstill exist in D1 but not in the Drizzle schema; never read or write them. - Business events are written with the change. A
cod-sharedwriter of orders or shipments records its event withrecordEventin the same batch. Never dispatch a side effect from a handler. A deployed cod-server needs theEVENTS_QUEUEproducer and consumer, and both crons ("0 * * * *","*/5 * * * *"), aswrangler.toml.exampledeclares. - Carriers. Only Yalidine and ZR Express send webhooks; they land in the
webhook_eventsinbox and are processed after the answer (cod-server/src/inbound). NOEST, EcoTrack-platform companies and Guepex are synced by the five-minute cron and on demand. Tell carriers apart byproviderandcapabilities, never by company code. - The dashboard never re-implements delivery rules. It reads the lifecycle,
the stages and each shipment action's permission from cod-shared
(
shipments/actions.ts), and offers only the actions a shipment'sactionslist opens. - Removal is real deletion. A deleted product goes for good; order lines
keep what was sold. An order with a shipment can never be deleted (a trigger
raises
ORDER_HAS_SHIPMENT); a finished one is archived. There is no soft delete. A script that wipes orders deletesshipmentsfirst. - Orders and the basket. An order is a basket (
items[]) or a single product;normalizeOrderLines(cod-shared/queries/cart.ts) is the one place the shapes meet. The basket lives in the shopper's browser, never in D1, and every line is re-priced server-side: never trust a total from the wire. The cart is off by default per store (stores.cart_enabled). - Languages and translations.
stores.langis the primary language;store_localeslists the others, and only published ones reach/store/config. The supported list lives once, incod-shared/i18n/locales.ts. Merchant data is translated in thetranslationstable; the resource's own columns hold the primary language. A new translatable resource needs its own delete trigger. Order lines always take the catalog's primary-language names. - Theme text edits are keyed by theme (
store_content_overrides,defineTheme({ key })); renaming a theme's key orphans its merchants' edits. - Reviews. A shopper proves a purchase with the order number and its
phone, for a delivered order, one review per product. Photos are kept only
as WebP from the Images binding, which drops EXIF and GPS. Review files are
deleted after their rows (
cod-server/src/lib/reviews/removal.ts).processingreviews belong to the system. - Seed data has one source,
cod-shared/starter/.storeDefaultsSqlgives a store its default menus, collections, legal pages and, if it has never taken an order, a shipping profile;demoCatalogSqladds the starter catalog only to a store with no catalog of its own. Both are idempotent;cod-server/scripts/seed-store.ts(npm run db:setup:local/:remote) runs them. Never add seed data anywhere else.
Known traps
- Dashboard i18n. UI strings come from
locales/{ar,en,fr}throughuseT(namespace), and the i18n guard test enforces parity. Placeholders and counts go throught(key, values): a count is a plural message with one key per CLDR form its language has (Arabic has six); never.replace("{n}"). Relative times use@/lib/relative-time. PUBLIC_API_URLis baked in at build time. It does not go incod-client-astro/.env, which the build ignores (.dev.vars>wrangler.toml [vars]>process.env>.env). Set it in.dev.varslocally and inwrangler.toml [vars]for production;npm run deployrefuses a bundle that contains a loopback URL.MCP_LOGIN_TICKET_SECRETmust be identical on cod-server and the dashboard.BETTER_AUTH_SECRETis the dashboard's alone: cod-server checks the dashboard's tokens against its public keys atBETTER_AUTH_URL, so a 401 on every call meansBETTER_AUTH_URLorWORKER_SELF_URLis wrong.- The dashboard ships its own KV
secondaryStorage(src/lib/auth/server.ts) becausebetter-auth-cloudflare0.3.1 lacks theincrementits rate limiter needs; do not switch back to itskv:shortcut. - The OAuth provider tables predate Better Auth 1.7 and lack some of its columns and tables; MCP client token flows may need that alignment before heavy use.
- Cloud configuration comes from the root
.envthroughcod-server/scripts/cloud-env.mjs(process.env>.env> default). A new key goes in itsDEFAULTSand in.env.exampletogether.COD_SERVER_URLdefaults tohttp://localhost:8787; Theme-00's deploy refuses a loopback value unless--force-localis passed. - Local D1 state is shared through
.wrangler-shared/: cod-server writes it, and the dashboard's dev server reads it. - Vite pins. The root
overridespin Vite (^8.2.2) so astro and vitest share one major; removing it brings back theMissing field 'moduleType'crash. Theme-00 carries its own copy, plus@cloudflare/vite-plugin1.53.1 (newer ones break vitest there), and uses TypeScript 6 because@astrojs/check0.9 accepts no newer. - cod-server's unit-test mock db maps a full-table
select()by schema column order: a new column breaks that table's fixtures until it is added at the same position. Its tests need no network or credentials.
Skills
Two agent skills ship in .agents/skills/: wocart-setup (set up a
self-hosted store on Cloudflare, with an optional Vercel storefront) and
wocart-update (update one to the latest code). Nothing else belongs there.
Endpoints
Every endpoint is declared with defineRoute():
import { defineRoute } from "@/lib/route-builder";
import { SCOPES } from "../../../../cod-shared/rbac/scopes";
const listRoute = defineRoute({
method: "get",
path: "/",
auth: { scope: SCOPES.PRODUCTS_READ },
handler: handlers.list,
});
router.openapi(listRoute.route, listRoute.handler);Always take scopes from SCOPES, and reuse the shared response schemas in
cod-server/src/openapi/schemas.ts.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

