Use this skill whenever the user asks you to write, edit, review, refactor, debug, or design TypeScript or TSX code. It is especially relevant for application code, backend routes, React/UI work, schemas, runtime boundaries, persistence, async workflows, API contracts, tests, lint/typecheck fixes, and code review. Apply it even when the user does not explicitly mention "TypeScript" if the files or project are TypeScript-based.
89
85%
Does it follow best practices?
Impact
95%
1.26xAverage score across 5 eval scenarios
Passed
No known issues
A teammate opened a pull request for a new billing reminder endpoint. You have been asked for a concise review that helps the author fix correctness, safety, and maintainability problems before the change ships.
Review the changed files below. Do not rewrite the implementation; produce a review document the teammate can act on.
Create review.md in the current directory. It should include findings with file and line references, followed by any open questions or assumptions, and then any brief summary you think is useful.
The following files are provided as inputs. Extract them before beginning.
=============== FILE: src/routes/billingReminder.ts =============== 1 import { sendReminder } from "../services/billingService"; 2 import { db } from "../db"; 3 4 type ReminderRequest = { 5 tenantId: string; 6 invoiceIds: string[]; 7 messageHtml?: string; 8 redirectTo?: string; 9 }; 10 11 export async function billingReminderRoute(req: { body: ReminderRequest; user?: { id: string; tenantId: string } }) { 12 const body = req.body as ReminderRequest; 13 if (!req.user) { 14 return { status: 401, body: { error: "Not signed in" } }; 15 } 16 17 const invoices = await db.query( 18 "select * from invoices where id in (" + body.invoiceIds.map((id) => "'" + id + "'").join(",") + ")" 19 ); 20 21 await Promise.all( 22 invoices.rows.map(async (invoice: any) => { 23 sendReminder({ 24 to: invoice.email, 25 invoiceId: invoice.id, 26 tenantId: body.tenantId, 27 html: body.messageHtml, 28 redirectTo: body.redirectTo 29 }); 30 }) 31 ); 32 33 return { status: 200, body: { sent: invoices.rows.length, redirectTo: body.redirectTo } }; 34 }
=============== FILE: src/services/billingService.ts =============== 1 type Reminder = { 2 to: string; 3 invoiceId: string; 4 tenantId: string; 5 html?: string; 6 redirectTo?: string; 7 }; 8 9 export async function sendReminder(reminder: Reminder) { 10 try { 11 await fetch("https://email.example/send", { 12 method: "POST", 13 body: JSON.stringify({ 14 to: reminder.to, 15 subject: "Payment reminder", 16 html: reminder.html || "<p>Please pay your invoice.</p>", 17 cta: reminder.redirectTo 18 }) 19 }); 20 } catch (error) { 21 console.log("email failed", error); 22 } 23 }
=============== FILE: src/db.ts =============== 1 export const db = { 2 async query(sql: string) { 3 return { rows: [] as unknown[] }; 4 } 5 };