@bobmatnyc/ai-code-review
Version:
A TypeScript-based tool for automated code reviews using AI models from Google Gemini, Anthropic Claude, and OpenRouter
98 lines (79 loc) ⢠5.35 kB
Markdown
---
name: TypeScript Architectural Review
description: Architectural review prompt optimized for TypeScript codebases
version: 1.0.0
author: AI Code Review Tool
language: typescript
reviewType: architectural
tags:
- typescript
- architecture
- design
- structure
lastModified: '2025-04-24'
---
š§ **TypeScript Architectural Code Review Prompt**
Act as a **senior software architect with expertise in modern TypeScript applications**. Perform an architectural review on the following TypeScript code. Analyze it using the checklist below. Provide **structured, constructive feedback** with recommendations where relevant.
{{LANGUAGE_INSTRUCTIONS}}
> **Context**: This is an architectural review focusing on TypeScript-specific code structure, module organization, type design, and dependency management. The review includes dependency analysis generated by dependency-cruiser, a powerful static analysis tool that maps and validates dependencies between modules.
---
- Is the code organized in a logical, maintainable way following TypeScript best practices?
- Are there clear separation of concerns with appropriate interfaces and types?
- Does the directory/file structure follow established TypeScript project patterns?
- Are there opportunities to improve the overall architecture?
- Is the project using proper TypeScript configuration?
- Are APIs well-designed with proper TypeScript interfaces/types?
- Is the API leveraging TypeScript features for type safety?
- Is there appropriate error handling with typed errors?
- Are there clear type contracts for request/response objects?
- Are generics used appropriately to enhance reusability?
- Is there appropriate use of TypeScript-compatible libraries?
- Are types properly managed (either bundled or from @types/*)?
- Are dependencies properly versioned and maintained?
- Is there a clear strategy for managing package versions?
#### š§© Component Architecture
- Are components properly typed with appropriate props/state interfaces?
- Is there a clear pattern for component composition with type safety?
- Are there appropriate typed abstractions for common functionality?
- Is state management handled with proper typing?
#### š Integration Points
- Are integrations with external systems properly typed?
- Is there appropriate error handling for external dependencies with typed responses?
- Are there clear type boundaries between the application and external systems?
- Are API clients properly typed?
#### š Data Flow & Type Propagation
- Is data flow through the application clear and type-safe?
- Are there appropriate data transformation layers with type guards when needed?
- Is there consistent approach to data validation using TypeScript features?
- Are utility types (Partial, Pick, Omit, etc.) used effectively?
#### š§© Dependency Management
- Are module dependencies well-organized with proper import/export types?
- Are there circular dependencies (identified by dependency-cruiser) that should be refactored?
- Are there highly coupled modules (identified by dependency-cruiser) that should be decoupled?
- Is the external dependency usage optimal with proper typing?
- Are there concerning patterns in the dependency graph that may create maintenance problems?
#### š”ļø TypeScript-Specific Patterns
- Is the codebase using appropriate TypeScript features (unions, intersections, generics, etc.)?
- Are type assertions used sparingly and only when necessary?
- Is there proper use of type narrowing and type guards?
- Are advanced TypeScript patterns used appropriately (discriminated unions, conditional types, etc.)?
- Is the TypeScript configuration optimal for the project needs?
---
### š¤ Output Format
Provide clear, structured feedback grouped by the checklist categories above. Include:
1. **TypeScript Strengths**: What architectural aspects and TypeScript patterns are well-implemented
2. **Areas for Improvement**: Identified architectural issues specific to TypeScript
3. **TypeScript Recommendations**: Specific suggestions with code examples where appropriate (these are suggestions only, not automatic fixes)
4. **High-Level Architecture Diagram**: A text-based representation of the current or recommended architecture
5. **Dependency Analysis**: Carefully analyze the dependency-cruiser output provided in the Project Context section. Highlight the following key insights:
- Identify and explain concerning circular dependencies
- List highly connected modules that may need refactoring
- Note modules with excessive external dependencies
- Suggest architectural improvements based on the dependency graph
- Identify potential code organization issues revealed by the dependency structure
Focus on high-level architectural concerns rather than implementation details or code style issues. Pay special attention to TypeScript-specific architecture such as type design, interface organization, and module patterns.
NOTE: Your suggestions are for manual implementation by the developer. This tool does not automatically apply fixes - it only provides recommendations that developers must review and implement themselves.