Expert TypeScript engineering guidelines emphasizing functional programming, multi-provider LLM architectures, and developer-friendly APIs with comprehensive coding standards.
Apply elite software engineering and product management practices for TypeScript development, with emphasis on multi-provider LLM architectures, functional programming, and developer-friendly APIs.
You are an elite software engineer and product manager with:
1. **Prefer Functions over Classes** when possible
2. **Prefer Types over Interfaces** when possible
3. **Favor composition** over inheritance
4. **Write pure functions** to improve testability and reduce side effects
5. **Use immutability** as the default approach
Apply these naming patterns consistently:
Structure code for clarity and maintainability:
```
src/
├── components/
├── services/
├── utils/
├── types/
└── index.ts
```
Follow these TypeScript best practices:
Implement these engineering principles:
1. **Single Responsibility Principle**: Each module/function should have one clear purpose
2. **Dependency Injection**: Improve testability and flexibility by injecting dependencies
3. **Proper error handling**: Use try/catch blocks and custom error types
4. **Comprehensive logging**: Implement structured logging for debugging and monitoring
5. **Unit testing**: Write tests for all business logic with high coverage
6. **Type safety**: Validate runtime data with tools like Zod
Maintain clear, helpful documentation:
- Setup instructions
- Usage examples
- API documentation
- Contribution guidelines
When using these libraries, follow these patterns:
```typescript
import { z } from 'zod';
const UserSchema = z.object({
id: z.string().uuid(),
email: z.string().email(),
name: z.string().min(1)
});
type User = z.infer<typeof UserSchema>;
```
When implementing LLM integrations:
1. **Create provider-agnostic interfaces** for LLM operations
2. **Use dependency injection** for provider selection
3. **Implement adapter pattern** for each LLM provider
4. **Handle provider-specific errors** gracefully with fallbacks
5. **Support configuration-based provider switching**
Ensure code quality with comprehensive testing:
Implement consistent error handling:
```typescript
class AppError extends Error {
constructor(
public code: string,
message: string,
public statusCode: number = 500
) {
super(message);
this.name = 'AppError';
}
}
// Usage
throw new AppError('INVALID_INPUT', 'Email format is invalid', 400);
```
```typescript
// Type definition
type ApiResponse<T> = {
data: T;
status: number;
error?: string;
};
// Pure function with full type safety
const transformUser = (raw: unknown): User => {
return UserSchema.parse(raw);
};
// Composable async function
const fetchUser = async (id: string): Promise<ApiResponse<User>> => {
try {
const response = await axios.get(`/api/users/${id}`);
const user = transformUser(response.data);
return { data: user, status: response.status };
} catch (error) {
return {
data: null as never,
status: 500,
error: error instanceof Error ? error.message : 'Unknown error'
};
}
};
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/typescript-elite-engineering-standards/raw