code-review-typescript
Skill9 starsChanged 8 months agoMITView on GitHub
Performs structured code reviews on TypeScript codebases covering correctness, type safety, async patterns, security, testing, and style. Use when reviewing TypeScript code, pull requests, or when asked to do a code review on a TypeScript or Node.js project.
In this repository31 other files it gives its agents.
- git-workflow-releaseSkill
- skill-authoring-generalSkill
- git-workflow-releaseSkill
- skill-authoring-generalSkill
- accessibility-generalSkill
- accessibility-react-nativeSkill
- architecture-generalSkill
- architecture-pythonSkill
- assistant-rocky-lti-assistSkill
- assistant-ucd-mobileSkill
- ci-cd-github-actionsSkill
- code-review-generalSkill
- code-review-pythonSkill
- data-science-pythonSkill
- design-frontendSkill
- documentation-projectSkill
- documentation-readmeSkill
- git-workflow-generalSkill
- git-workflow-monorepoSkill
- git-workflow-pr-generatorSkill
- git-workflow-releaseSkill
- infrastructure-terraformSkill
- package-management-pythonSkill
- project-management-jiraSkill
- refactoring-typescriptSkill
- security-generalSkill
- skill-authoring-generalSkill
- testing-generalSkill
- testing-javaSkill
- testing-pythonSkill
- testing-typescriptSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. About 0 are common, 7 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
When asked to review code — a file, a function, a PR diff, or a module — follow this checklist systematically.
- Distinctive: line 14
Before writing any comment:
- Distinctive: line 16
Read the code top-to-bottom at least once without commenting.
- Distinctive: line 24
Check for bugs, edge cases, and incorrect assumptions.
- Very specific: line 51
strict: true: if the tsconfig lacks strict: true, flag it. - Very specific: line 53
interfacevstype: prefer interface for object shapes that may be extended. - Very specific: line 69
Unhandled promise rejections: every Promise must be either await-ed, .catch()-ed, or explicitly void-ed with a comment.
- Very specific: line 91
Never log secrets or PII: check console.log / logger calls for request bodies, auth headers, or user data.
- Very specific: line 92
Input validation: all external inputs (HTTP request bodies, query params, env vars) must be validated — flag raw req.body.x access without …
- Distinctive: line 94
SQL/NoSQL injection: never use template literals or string concatenation to build queries.
- Very specific: line 137
expect.assertions(n): use in async tests to catch cases where the assertion is never reached. - Very specific: line 144
constoverlet: prefer const for all values that are not reassigned. - Distinctive: line 148
TODO/FIXME comments: must include context and ideally a ticket reference.
- Distinctive: line 170
Call out what is done well.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Code Review — TypeScript
When asked to review code — a file, a function, a PR diff, or a module — follow this checklist systematically. Always provide specific, actionable feedback with line references and concrete improvement suggestions. Never give vague praise or criticism.
1. Understand the Intent First
Before writing any comment:
- Read the code top-to-bottom at least once without commenting.
- Understand what the code is supposed to do, not just what it does.
- Note the surrounding context (imports, types, callers).
2. Correctness & Logic
Check for bugs, edge cases, and incorrect assumptions.
- Null/undefined safety: are optional values guarded before use? Look for unchecked
?.chains that silently returnundefinedinstead of throwing. - Type narrowing gaps: is
typeof,instanceof, or a discriminated union guard used before accessing a narrowed type? - Return completeness: does every code path return a value? Does TypeScript's
noImplicitReturnsflag these? - Array/object mutation: is the caller's data mutated unintentionally? Flag in-place sorts or push/splice on received arrays.
- Equality:
==vs===— always use===in TypeScript. - Off-by-one errors, incorrect loop bounds, or fence-post mistakes.
Example:
// ❌ Bug: silently returns undefined if user is not found — caller likely expects to throw
const name = users.find(u => u.id === id)?.name;
// ✅ Fix: be explicit about the missing case
const user = users.find(u => u.id === id);
if (!user) throw new Error(`User ${id} not found`);
const name = user.name;3. Type Safety
anyusage: flag everyany. Suggestunknown+ type guard, or a proper interface.- Type assertions (
as): flag casts that bypass the type system without a guard.as unknown as Xis almost always wrong. - Non-null assertions (
!): flag every!postfix operator — it disables null checking. Require a comment explaining why it's safe, or replace with a guard. strict: true: if the tsconfig lacksstrict: true, flag it. At minimum,strictNullChecksandnoImplicitAnymust be enabled.- Overly wide types:
string | number | boolean | object— suggest a discriminated union or a named type. interfacevstype: preferinterfacefor object shapes that may be extended;typefor unions, intersections, and aliases.
Example:
// ❌ Unsafe: assertion without evidence
const result = response.data as UserProfile;
// ✅ Safe: validate at the boundary
if (!isUserProfile(response.data)) throw new TypeError('Unexpected API response shape');
const result: UserProfile = response.data;4. Async & Concurrency
- Unhandled promise rejections: every
Promisemust be eitherawait-ed,.catch()-ed, or explicitlyvoid-ed with a comment. - Floating
asyncfunctions:asyncfunctions called withoutawaitsilently drop errors. - Blocking in async context:
fs.readFileSync,execSync, or CPU-heavy loops in an async function block the event loop — flag them. - Sequential vs parallel: independent
awaitcalls that could run withPromise.allare a performance issue. Promise.allfailure modes:Promise.allfails fast on the first rejection; usePromise.allSettledwhen partial failure is acceptable.- Race conditions: shared mutable state mutated across
awaitpoints without a lock is a race condition.
Example:
// ❌ Sequential when independent
const user = await fetchUser(id);
const orders = await fetchOrders(id);
// ✅ Parallel
const [user, orders] = await Promise.all([fetchUser(id), fetchOrders(id)]);5. Security
- Hardcoded secrets: flag any hardcoded API keys, tokens, passwords, or connection strings as CRITICAL.
- Never log secrets or PII: check
console.log/ logger calls for request bodies, auth headers, or user data. - Input validation: all external inputs (HTTP request bodies, query params, env vars) must be validated — flag raw
req.body.xaccess without a schema (Zod, Valibot, or class-validator). - Prototype pollution:
Object.assign({}, userInput)or{...userInput}with untrusted input can pollute prototypes — prefer explicit field extraction. - SQL/NoSQL injection: never use template literals or string concatenation to build queries; always use parameterized queries or an ORM.
eval/Function(): flag any dynamic code execution.- Path traversal:
path.join(baseDir, userInput)without normalization and boundary-checking is a vulnerability.
6. Design & Architecture
- Single Responsibility: each function/class should do one thing. If a name needs "and", flag it.
- DRY: flag duplicated logic and suggest extraction.
- Dependency direction: high-level modules should not import implementation details from lower-level modules.
- Magic values: hardcoded strings and numbers should be named constants or config entries.
- Long parameter lists (4+): suggest an options object with a typed interface.
- Boolean parameters: a
doX(data, true)call is opaque — suggest two functions or a discriminated union. - God functions: functions over ~50 lines are a signal to decompose.
7. Error Handling
- Silent swallowing:
catch (e) {}orcatch (e) { return null; }hides failures — require logging and re-throwing or explicit handling. - Error types: throwing plain strings (
throw "something failed") loses stack traces — always throwErrorinstances or subclasses. - Error propagation: errors at async boundaries must be caught or they become unhandled rejections.
- Result types: in domain logic, consider
Result<T, E>patterns over throwing for expected failures.
// ❌ Loses the stack trace
throw "user not found";
// ✅
throw new UserNotFoundError(`User ${id} not found`);8. Testing
- Coverage: is the changed code covered? Call out specific untested paths explicitly.
- Test scope: unit tests must mock external I/O (HTTP clients, DB, filesystem). Integration tests may use real services.
- Edge cases: are error paths, empty inputs, and boundary values tested — not just the happy path?
- Assertions: tests must assert on the expected output or side effect — not just that the code ran without throwing.
- Isolation: tests must not share mutable state or depend on execution order. Use
beforeEach/afterEachto reset. - Naming:
it('should <do X> when <condition>')— notit('test 1'). expect.assertions(n): use in async tests to catch cases where the assertion is never reached.
9. Style & Consistency
- ESLint: flag obvious ESLint violations if a config is present.
constoverlet: preferconstfor all values that are not reassigned.- Imports: external packages before internal modules; no wildcard imports (
import * as foo). - Naming:
camelCasefor variables/functions,PascalCasefor types/classes/components,SCREAMING_SNAKE_CASEfor module-level constants. console.log: flag any left in production code — use a proper logger.- TODO/FIXME comments: must include context and ideally a ticket reference. Flag vague or stale ones.
- Unused variables: flag
_unusedthat are not intentional; TypeScript'snoUnusedLocalsshould catch these.
10. Output Format
Structure your response as follows:
Summary
A 2–4 sentence overview: what does the code do, is it generally well-written, what is the most important concern?
Critical Issues 🔴
Issues that must be fixed before merging: security vulnerabilities, data loss risks, correctness bugs, broken contracts. Number each item.
Improvements 🟡
Things that are not blocking but meaningfully improve quality: design issues, missing tests, performance problems, unclear naming. Number each item.
Minor / Nits 🟢
Style, convention, and cleanup items that improve consistency but have minimal functional impact. Can be bulleted for brevity.
Positive Highlights ✅
Call out what is done well. This is not optional — good feedback is balanced.
Quick Reference Checklist
- Logic is correct for all known edge cases
- No unchecked null/undefined access
- No
any— useunknown+ type guard or a proper type - No unsafe type assertions (
as X) without a guard - No non-null assertions (
!) without justification strict: true(or at minimumstrictNullChecks+noImplicitAny) in tsconfig- All promises are awaited, caught, or explicitly voided
- No blocking I/O in async context
- Independent async calls use
Promise.all - No hardcoded secrets or PII in logs
- All external inputs are validated with a schema
- No silent exception swallowing
- Errors thrown as
Errorinstances, not strings - Test coverage exists for the changed code
- No
console.logleft in production paths - No magic numbers or strings — use named constants
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

