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
Customer success uses a nightly partner import to update customer profiles shown in the admin console. A recent partner change caused old import entries to be overwritten, and support can no longer tell which source file created a displayed value. The current code also makes it hard to know which fields are partner data, stored data, or admin-facing display data.
Rework the import module so historical imports remain explainable and the admin view can still be produced from the stored data. Keep the task focused on the import feature.
Produce a TypeScript project in the current directory. Include updated source files and focused tests covering the repaired import behavior.
The following files are provided as inputs. Extract them before beginning.
=============== FILE: AGENTS.md ===============
src/features/<feature>/.=============== FILE: package.json =============== { "type": "module", "scripts": { "test": "vitest run", "typecheck": "tsc --noEmit" }, "dependencies": { "zod": "^3.23.8" }, "devDependencies": { "typescript": "^5.5.3", "vitest": "^2.0.4" } }
=============== FILE: tsconfig.json =============== { "compilerOptions": { "target": "ES2022", "module": "NodeNext", "moduleResolution": "NodeNext", "strict": true, "exactOptionalPropertyTypes": true, "noUncheckedIndexedAccess": true, "skipLibCheck": true }, "include": ["src/**/*.ts"] }
=============== FILE: src/features/customers/importCustomers.ts =============== export type Customer = { id: string | null; email: string | null; fullName: string | null; plan: string | null; source: string | null; importedAt: string | null; displayName: string | null; rowNumber: number | null; };
const customers: Customer[] = [];
export function importCustomers(sourceName: string, rows: unknown[]): Customer[] { rows.forEach((row, index) => { const data = row as any; const existing = customers.find((customer) => customer.email === data.email); const next: Customer = { id: existing?.id ?? String(index), email: data.email ?? null, fullName: data.name ?? data.full_name ?? null, plan: data.plan ?? null, source: sourceName, importedAt: new Date().toISOString(), displayName: data.name ?? data.email ?? null, rowNumber: index };
if (existing) {
Object.assign(existing, next);
} else {
customers.push(next);
}});
return customers.map((customer) => ({ ...customer, displayName: customer.displayName || customer.email })); }
export function listCustomers(): Customer[] { return customers; }