{"success":true,"name":"brimind-client-db","description":"A client's details (price, invoice link and status, open promises, do-not rules, cadence step, the last messages both ways on every rail, facts) are one document in the team's local MongoDB. For any known client `client get <phone|email|slug|name>` comes FIRST — before any web search, file grep or old-session read — and what you learn or promise is saved with `client save <who> \"<fact in plain wor","category":"unitary","path":"unitary/brimind-client-db/SKILL.md","file":"SKILL.md","content":"---\nname: brimind-client-db\ndescription: A client's details (price, invoice link and status, open promises, do-not rules, cadence step, the last messages both ways on every rail, facts) are one document in the team's local MongoDB. For any known client `client get <phone|email|slug|name>` comes FIRST — before any web search, file grep or old-session read — and what you learn or promise is saved with `client save <who> \"<fact in plain words>\" --source <you>`. Use before any client-facing message, call, devis or price; when a client replies; the moment you promise something; and instead of opening dealflow/data/clients.json, clients/users/*/profile.json or the rails' logs by hand.\n---\n> Imported from [PRIVATE_HOST] `~/unitary/agents/skills/brimind-client-db`. Paths are relative to `[PRIVATE_HOST]:[PATH]`; run commands there via `ssh [PRIVATE_HOST] 'cd ~/unitary && ...'`. Owner send rules from skill i7-remote-ops still apply.\n\n\n# Client DB — one client, one document (owner, 2026-10-10)\n\n> « dont they use local mongo for the details ??? … create rail to get details from db and set details to db »\n> « do make it easy to save . and get pls and do perfect architecture , and rails »\n> « checking the DB beats checking the internet »\n\n## 1. The DB first, the internet second\n\n1. **A known client → `client get` FIRST**, before any web search, file grep or old-session read.\n   One `client get` is ~300–800 tokens; one web check is ~10–60k.\n2. **The internet is only for** a new prospect, or a fact that changes outside (website, address, hours).\n3. **Whatever you find is saved at once, with where it came from**, so nobody searches it twice:\n   `client save <who> \"horaires: 8h-17h\" --from https://maps.google.com/... --source omar`.\n\n## 2. Get — anything that names the client\n\n```bash\nclient get +[PHONE]            # phone in any format: +216…, 216…, [PHONE], [PHONE]\nclient get afrah-khalil               # folder slug · cl_0ab7eb435775 · an email · @user · Telegram id\nclient get \"La Perle du Lac\"          # a name; a shared name lists the candidates to pick from\nclient find \"perle\"                   # search by name, city, niche, note\nclient facts <who>                    # every current fact with its date, seat and source\nclient history <who> 30               # every change: from → to, when, who, from where\n```\n\nThe brief (≤40 lines): name · niche · city · stage · ids · offer + price · invoice number, STATUS and link ·\ncadence step · the SMS window (+216 only; unanswered → next ≥ 3 days; answered → no gap) · ⛔ do-not rules\n· open promises · facts · last notes · **the last 5 messages both ways, every rail** (WhatsApp ×2, SMS,\nTelegram, email, the agents' ledger, filed by the rails themselves every minute) · the last changes.\n\n## 3. Save — say it in plain words\n\n```bash\nclient save <who> \"prix 1200 DT\" --source solobro                 # → offer.price 1200, offer.currency TND\nclient save <who> \"rappeler lundi 10h\" --source farah             # → a callback promise, due Mon 10:00\nclient save <who> \"promis: envoyer la démo demain\" --source farah # → a promise, due tomorrow\nclient save <who> \"a dit STOP\" --source farah                     # → rule dnc\nclient save <who> \"decider: Mme Kefi, directrice\" --source omar   # → facts.decider\nclient save <who> \"la directrice préfère WhatsApp\" --source omar  # → kept as a note\nclient save <who> offer.price 390 --source sinda                  # one exact field (= client set)\nclient promise done <who> <p_id | a word of it> --source farah    # when a promise is kept (cancel: no longer holds)\nclient rule add <who> no-call-before-10h \"elle enseigne\" --source farah\nclient add --phone [PHONE] --name \"École X\" --source omar         # a new prospect\n```\n\n- The answer says what it understood (`saved as price 1200 TND`): a wrong guess is visible at once.\n- `--source <your seat>` on every write (solobro, farah, omar, sinda, nader, nadia, artisto, handoff…).\n  No source → refused, with the fix. Facts from the web: `--from <url>`.\n- **A promise you make is saved the moment you make it**, and closed when kept: it is on the brief of\n  every teammate who touches that client, and the client-memory guard refuses a send that ignores it.\n\n## 4. Rules\n\n- **Rails only.** Never write Mongo by hand, never edit `details.json` (a read-only mirror) or the\n  dealflow card to change a client detail: `client save`.\n- The owner's family (CLAUDE.md table, owner-profile.json) and our own lines, mailboxes and company are\n  never a client record. `client add` / `save phone` refuse them, and the sync purges them.\n- Nothing is overwritten silently: every change keeps `from → to`, when, who and from where.\n- **Before a send:** `client check --channel <ch> --to <who> --text \"…\"` (the client-memory guard:\n  exit 0 clear, exit 4 refused with the fix).\n\n## 5. JS (guard, worker, handoff, scripts)\n\n```js\nimport * as clients from '[PATH]';\nconst d = await clients.resolve('tel-[PHONE]');        // or a phone, email, slug, cl_…, name — null if unknown, never creates\nconst { text } = await clients.briefOf(d);                 // the brief\nawait clients.save(d, 'rappeler lundi 10h', { source: 'farah' });\nawait clients.set(d, 'facts.colour', '#0a7', { source: 'dali' });\nawait clients.addPromise(d, { what: '…', due: '2026-10-12' }, { source: 'farah' });\nawait clients.factsOf(d);                                  // [{ key, value, at, source, seat, ref }]\nclients.barredPhone(p);                                    // reason if p is the family or one of our lines\n```\n\n## 6. Health and the switch (Dali)\n\n`client doctor` (add `--verify` for the 1:1 check against the files): Mongo, schema, indexes, last sync,\nlast collect, family absent, journal, `client get` speed, tokens read. **Switch back to files at once:**\n`CLIENT_DB=off`, or `\"clientDb\": false` in agents/registry.json. Readers then fall back to their files;\nwrites wait in a journal that the next `client sync` replays.\n\n## Field notes (from session handoffs)\n- 2026-10-18: Si `node agents/tools/client.mjs get <identifiant>` répond `unknown command « get »`, utiliser `node agents/tools/client.mjs brief <phone|cl_id|users-id|email|@handle>` ; ajouter `--json` si nécessaire. Cette commande fournit l’offre actuelle, les promesses, les règles et les derniers messages. (when: Quand agents/tools/client.mjs get répond unknown command « get », ou avant de préparer une réponse client.) (links: S:vendor-onboarding (vérifier avant une réponse vendeur); S:brimind-owner-standing-rules (éviter les doublons))\n- 2026-10-19: 1. Si `node agents/tools/client.mjs get <who>` échoue avec `unknown command « get »`, utiliser `node agents/tools/client.mjs brief <phone|cl_id|users-id|email|@handle> --json`. 2. Ne pas traiter cette erreur de syntaxe comme une absence de client ou de données ; reprendre l’audit avec la sortie de `brief`. (when: Quand agents/tools/client.mjs get renvoie unknown command « get » pendant un audit client) (links: S:brimind-client-db (corrige la commande de lecture); S:brimind-director-claim-audit (permet de poursuivre la vérification client))\n- 2026-10-19: A client's details (price, invoice link and status, open promises, do-not rules, cadence step, the last messages both ways on every rail, facts) are one document managed with `client get` and saved with `client save` from agents/clients/index.mjs. (when: When a client's dossier or rail state needs to be loaded or persisted) (links: M:1o6zy17 «16/10 quatre lettres: b5 4 PASS documentaires pour17/10 08:00Z, cinquième retir…» (same client thread))\n","linked_files":[],"origin":"brimind","owner_id":null,"source":"router"}