Use when the user wants a local second-opinion code review via OpenAI Codex CLI — on the current branch, staged changes, a single file, or a piped diff. Triggers include "codex review", "review with codex", "run codex on this diff", "second opinion from codex", or pre-commit / pre-PR review requests that ask for codex specifically.
90
97%
Does it follow best practices?
Impact
97%
2.25xAverage score across 2 eval scenarios
Passed
No known issues
You are reviewing a diff from a multi-tenant ecommerce analytics monorepo:
Multi-tenant isolation. Company data lives in metrics_<company_id>_v1 (Postgres) and redshift_<company_id>_v1 (Redshift). The ONLY tables allowed in public.* are: companies, users, user_sessions, user_company_roles, api_keys, metrics_catalog, shopify_shops, shopify_app_sessions, shopify_oauth_credentials, magic_links. Flag any company-scoped query against public.*.
Parameterized queries. Every user-derived value must use $1/$2/... — flag string-interpolated SQL. Schema names interpolated via format('%I', ...) are OK in migrations.
Auth middleware. Routes must use authenticate + a role guard: requireViewer (GET), requireExecutor (POST/PUT), requireEditor (DELETE/config), requireFinsiUser (platform admin). Flag any route missing a guard or using the wrong tier.
Error responses. Never leak error.message to clients — generic strings only. Flag any res.json({ error: err.message }) or equivalent.
req.body handling. Never spread req.body. Whitelist fields explicitly.
Migrations. Any new company-scoped table in backend/src/db/migrations/NNN_*.sql must also be added to backend/src/db/templates/company_schema_template.sql. If the diff adds one without the other, flag it.
ESM runtime safety. No require() in .ts / .mts / .mjs files — it compiles but throws at runtime.
Redshift SUPER type. Use dot notation (attributes.email::varchar), NOT PostgreSQL JSON operators (->>, ->).
AI services. BedrockClient calls must strip markdown fences before JSON.parse. Flag prompt-injection risk if untrusted user input is concatenated into prompts without escaping.
Middleware order in server.ts. Must be: express-async-errors → cors → helmet → auth → companyContext → rate limiting → error tracking. Flag any change that breaks this chain.
Frontend. API calls go through authenticatedFetch from frontend/src/lib/apiClient.ts. Interactive elements need data-testid. Routes are registered in frontend/src/routes/{appRoutes,adminRoutes,publicRoutes}.tsx and lazy-imported via frontend/src/routes/lazyPages.ts. Flag dangling imports, removed routes still in nav, or missing testids on new interactive elements.
Scheduler. New pg-boss jobs registered in backend/src/services/scheduler/schedulerRegistrations.ts must have a corresponding handler. Cron strings must be valid 5- or 6-field syntax.
Group findings by severity. Within each, list as file:line — problem — fix.
Rules for the report:
_*.mjs, _tmp_*, or files under backend/scripts/ unless they expose a real bug.