StatLens — Agent Rules
Mission
Build a free, reliable, beautiful, BROWSER-ONLY web replacement for GraphPad Prism.
Statistical correctness is the top priority; UX polish is second. No backend server and no
database — statistics run in the browser via Pyodide, files live in the user’s Google Drive.
When in doubt, prefer correctness and clarity over cleverness, and prefer fewer moving parts.
Golden rules
- STATISTICAL CORRECTNESS IS NON-NEGOTIABLE. Every statistic/test has a unit test against
known reference values (SciPy/statsmodels/pingouin/lifelines docs, R, or published worked
examples) with sensible tolerance. Never change an algorithm without updating tests + comments.
- DO NOT INVENT statistical methods. Use numpy/scipy/statsmodels/pingouin/scikit-posthocs/
lifelines/scikit-learn (in Pyodide). If multiple conventions exist, pick one, cite it in a
comment, be consistent.
- NO BACKEND, NO DATABASE. All computation runs in the browser via Pyodide (in a Web Worker so
the UI never freezes). All persistence is Google Drive. Do NOT add a server, API service, or
DB. If a specific library truly cannot run in Pyodide, STOP and ask the human before adding any
server-side component; never silently introduce one.
- LEAST PRIVILEGE for Google Drive: scope
https://www.googleapis.com/auth/drive.file only.
Operate only on files/folders StatLens created. Never log tokens or raw user data.
- SECRETS: none in the repo. The only user-supplied config is a PUBLIC OAuth client ID (not a
secret). Provide
.env.example; add .env* to .gitignore.
- TYPE SAFETY: TypeScript strict; no
any unless documented. Strongly type the JS↔Pyodide
boundary (validate shapes crossing into/out of Python) and the project file format.
- CHARTS: render as vector SVG; default background transparent; PNG export preserves transparency
and matches the on-screen graph exactly.
- THEMING: global light + dark via design tokens (CSS variables / Tailwind). No hardcoded hex in
components; theme all UI and chart colors through tokens/palettes.
- ACCESSIBILITY: semantic HTML, keyboard access, visible focus, ARIA where appropriate, WCAG-AA
contrast in both themes, colorblind-friendly palettes.
- PRIVACY: user data goes only to (a) the user’s own Google Drive and (b) their own browser’s
computation. No external analytics on data; nothing leaves the browser but Drive API calls.
- LEGAL DISTINCTNESS: do NOT copy any GraphPad Prism text/tooltips/menu strings/icons/branding
or its exact UI. All in-app copy (tooltips, table-type descriptions, test explanations,
figure-legend notes, errors) is original, written from scratch.
- ENGINEERING CONVENTIONS: single app
apps/web (Vite + React + TS) with a clear module layout:
data/ (workbook model + Drive I/O), stats/ (Pyodide worker + typed wrappers + tests),
charts/ (SVG chart engine + significance layer + PNG export), ui/ (shell, editor, panels).
Co-locate tests (*.test.ts). Keep the app runnable at the end of every phase.
- VERIFICATION: a phase is done only when TS type checks pass, all tests pass, and the phase’s
acceptance criteria are demonstrably met with browser screenshots saved as artifacts and a
note appended to /docs/PROGRESS.md.
Verification discipline (added Phase 4.5)