TypeScript Code Review
A comprehensive skill for conducting professional TypeScript code reviews, examining type safety, best practices, performance, security, and maintainability.
This skill is perfect for TypeScript developers who want to ensure their code follows best practices, maintains type safety, and avoids common security and performance pitfalls.
Skill Structure
The repository is organized to provide comprehensive code review guidance and resources:
Main Files:
- SKILL.md - Main skill instructions
- README.md - This documentation
Resource Directories:
- references/ - Detailed reference materials including:
type-safety-checklist.md- Type safety best practicescommon-antipatterns.md- TypeScript anti-patterns to avoidsecurity-checklist.md- Security considerationsperformance-tips.md- Performance optimization strategies
- examples/ - Example code:
before-review.ts- Code with common issuesafter-review.ts- Fixed version with best practicessample-review-output.md- Example of review format
What This Skill Does
This skill enables Claude to conduct thorough TypeScript code reviews across multiple dimensions. Whether you're looking for a general code review or focused assessment on specific concerns like security vulnerabilities or performance issues, this skill provides structured, actionable feedback.
Review Focus Areas
Core Review Categories
The skill evaluates code across five primary dimensions:
-
Type Safety
- Strict mode compliance
- Proper type annotations
- Null and undefined handling
- Effective use of generics
- Type narrowing and guards
-
Security
- Input validation and sanitization
- XSS prevention
- Secrets management
- Injection attack prevention
- Secure authentication patterns
-
Performance
- Algorithm efficiency
- Memory management
- Bundle size optimization
- Lazy loading strategies
- Runtime optimization
-
Code Quality
- Clear naming conventions
- Complexity reduction
- Error handling patterns
- Immutability practices
- Code organization
-
Best Practices
- Modern TypeScript features
- Proper async/await patterns
- Effective use of utility types
- Interface vs type usage
- Decorator patterns
How to Use
Simply ask Claude to review your TypeScript code. You can request:
- General Reviews: "Review this TypeScript code"
- Focused Assessments: "Check this code for security vulnerabilities"
- Specific Concerns: "Analyze the performance of this algorithm"
- Best Practice Checks: "Is this following TypeScript best practices?"
Getting the Best Results
For optimal review quality, provide:
- Project Context: Explain what the code does
- Specific Concerns: Mention areas you're worried about
- Configuration: Include your tsconfig.json settings
- Dependencies: Share related code that interacts with your code
Output Structure
Review Format
Reviews follow a prioritized framework for easy action:
š“ Critical Issues
- Security vulnerabilities
- Type safety violations
- Bugs that could cause runtime errors
š” Important Improvements
- Performance concerns
- Code quality issues
- Maintainability problems
šµ Suggestions
- Enhancement opportunities
- Modern feature adoption
- Refactoring ideas
ā Positive Observations
- Well-implemented patterns
- Good practices to maintain
- Strengths to build upon
Each finding includes:
- Clear explanation of the issue
- Code examples showing the problem
- Recommended fixes with code samples
- Impact assessment
Recommended TypeScript Configuration
For maximum type safety and best review results, enable these strict TypeScript compiler options:
{
"compilerOptions": {
"strict": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"exactOptionalPropertyTypes": true,
"noPropertyAccessFromIndexSignature": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"forceConsistentCasingInFileNames": true
}
}
Common Review Patterns
Type Safety
The skill checks for:
- Missing type annotations on function parameters
- Use of
anytype (recommends specific types) - Proper null/undefined handling
- Type assertions vs type guards
- Return type declarations
Security
Scans for:
- Unsanitized user input
- Direct DOM manipulation without escaping
- Hardcoded secrets or credentials
- SQL injection vulnerabilities
- Insecure random number generation
Performance
Analyzes:
- Inefficient algorithms (O(n²) where O(n) possible)
- Unnecessary re-renders or recalculations
- Memory leaks in event listeners
- Large bundle sizes
- Blocking operations
Code Quality
Evaluates:
- Function complexity (cyclomatic complexity)
- Naming clarity and consistency
- Error handling completeness
- Code duplication
- Single Responsibility Principle
Example Use Cases
- Pre-commit Review: "Review this TypeScript file before I commit"
- Security Audit: "Check this authentication code for security issues"
- Performance Analysis: "Analyze the performance of this data processing function"
- Refactoring Guidance: "How can I improve this TypeScript class?"
- Learning Tool: "Explain what's wrong with this code and how to fix it"
Repository Resources
The skill repository includes:
SKILL.md: Core skill instructions for Claudereferences/: Detailed guides on type safety, security, and performanceexamples/: Sample code demonstrating common patterns and anti-patterns
For the most comprehensive reviews, the skill draws from the latest TypeScript documentation, security best practices, and performance optimization techniques stored in the repository's reference materials.
Tips for Effective Reviews
Do:
- Provide complete code context
- Specify your TypeScript version
- Mention framework (React, Node, etc.)
- Share relevant dependencies
- Ask follow-up questions
Avoid:
- Sharing incomplete code snippets
- Omitting important configuration
- Ignoring critical issues
- Skipping recommended security fixes
Ready to improve your TypeScript code? Ask Claude to review your code using this skill!