typescript
Typescript rules for the project Applies to files matching: *.tsx,*.ts.
When & Why to Use This Skill
This Claude skill enforces strict TypeScript development standards to ensure maximum type safety and maintainable project architecture. It focuses on eliminating unsafe type casts, optimizing module imports by avoiding barrel files, and promoting clean, inline interface definitions for better code readability and performance.
Use Cases
- Automated Code Auditing: Automatically scan and refactor TypeScript files to remove 'any' types and unsafe type assertions, ensuring a robust and error-free codebase.
- Project Architecture Optimization: Enforce direct import patterns and eliminate index barrel files to improve build times and enable more efficient tree-shaking in modern bundlers.
- Standardizing Development Workflows: Provide consistent coding guidelines for teams, ensuring that all function parameters use inline interfaces for better local context and reduced boilerplate.
| name | typescript |
|---|---|
| description | Typescript rules for the project Applies to files matching: *.tsx,*.ts. |
Typing Guidelines
- Avoid
anyat all cost. The types should work or they indicate a problem. - Never use
as "any"oras unknown asto solve/avoid type errors. The types should work or they indicate a problem. - Avoid using
asto cast to a specific type. The types should work or they indicate a problem.
Exports / Imports
- Never create index barrel files (index.ts, index.js)
- Always use direct imports with named exports
- Always use inline interfaces with function parameters
Examples
Good - Inline interface with function:
export function processData({
id,
name,
options,
}: {
id: string;
name: string;
options: ProcessingOptions;
}): ProcessedResult {
// implementation
}
Bad - Separated interface:
interface ProcessDataProps {
id: string;
name: string;
options: ProcessingOptions;
}
export function processDAta({
id,
name,
options,
}: ProcessDataProps): ProcessResult {
// Implementation
}