CtrlK
BlogDocsLog inGet started
Tessl Logo

finsi/codex-review

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

2.25x
Quality

97%

Does it follow best practices?

Impact

97%

2.25x

Average score across 2 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

PROMPT.mdresources/

You are reviewing a diff from a multi-tenant ecommerce analytics monorepo:

  • Backend: Express + TypeScript + PostgreSQL + Amazon Redshift
  • Frontend: React 18 + TypeScript + Vite + TailwindCSS + shadcn/ui
  • Jobs: pg-boss
  • AI: AWS Bedrock via BedrockClient

Repo invariants — flag any violation

  1. 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.*.

  2. Parameterized queries. Every user-derived value must use $1/$2/... — flag string-interpolated SQL. Schema names interpolated via format('%I', ...) are OK in migrations.

  3. 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.

  4. Error responses. Never leak error.message to clients — generic strings only. Flag any res.json({ error: err.message }) or equivalent.

  5. req.body handling. Never spread req.body. Whitelist fields explicitly.

  6. 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.

  7. ESM runtime safety. No require() in .ts / .mts / .mjs files — it compiles but throws at runtime.

  8. Redshift SUPER type. Use dot notation (attributes.email::varchar), NOT PostgreSQL JSON operators (->>, ->).

  9. 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.

  10. 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.

  11. 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.

  12. 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.

What to look for beyond invariants

  • Security: SQL injection, XSS, SSRF, auth bypass, timing leaks, secrets in logs, IDOR (missing company_id check).
  • Correctness: Off-by-one, null/undefined access, unhandled promise rejection, race conditions, swallowed errors.
  • Data integrity: Missing transactions around multi-statement writes, dropped FK checks, partial updates.
  • Performance: N+1 queries, missing indexes implied by new WHERE clauses, unbounded result sets.
  • Tests: New service logic without tests; test changes that delete assertions rather than update them.
  • Dead code: Deleted pages/components with surviving imports, routes, nav entries, or tour references.

Output format

Group findings by severity. Within each, list as file:line — problem — fix.

  • CRITICAL — security holes, tenant leaks, data loss, broken auth, runtime crashes on hot paths
  • HIGH — correctness bugs, missing guards, ESM runtime breakage, missing migration template update
  • MEDIUM — missing tests, missing data-testid on new UI, error-leak strings, perf concerns
  • LOW — style, naming, minor dead code

Rules for the report:

  • One sentence per problem, one sentence per fix. No filler.
  • Skip "good job overall" or general summaries.
  • If a section has no findings, write "(none)".
  • If the diff is clean on a given invariant, do not mention it.
  • Do NOT flag scratch files matching _*.mjs, _tmp_*, or files under backend/scripts/ unless they expose a real bug.

resources

SKILL.md

tile.json