Agent Skills
› NeverSight/learn-skills.dev
› clean-typescript
clean-typescript
GitHub指导编写清晰、高效的TypeScript代码,强调类型用于提升正确性与可读性。涵盖类型哲学、接口使用、函数设计、空值安全、枚举替代方案及错误处理等最佳实践,倡导避免any和过度断言,注重可维护性。
Trigger Scenarios
编写或重构TypeScript代码
审查TypeScript类型定义
优化API函数签名
Install
npx skills add NeverSight/learn-skills.dev --skill clean-typescript -g -y
SKILL.md
Frontmatter
{
"name": "clean-typescript",
"description": "Write clean, efficient TypeScript code that follows common best practices"
}
Clean TypeScript
We use TypeScript as a correctness and clarity tool, not as ceremony. Types should reduce bugs and cognitive load.
Type Philosophy
- PREFER explicit, readable types over clever or overly generic ones
- AVOID
anyand unsafe type assertions - Use
unknowninstead ofanywhen necessary - Let TypeScript infer types when inference is clear and stable
Types & Interfaces
- PREFER
typealiases for most use cases - Use
interfaceprimarily for public, extendable object shapes - Keep types small, composable, and well-named
Functions & APIs
- PREFER explicit return types for public functions
- Avoid function overloads unless they meaningfully improve the API
- Keep function signatures simple and predictable
Nullability & Safety
- Handle
nullandundefinedexplicitly - DO NOT rely on non-null assertions (
!) except as a last resort - Prefer narrowing via control flow and guards
Enums & Constants
- AVOID
enum - PREFER union types or
as constobjects - Keep runtime output predictable and minimal
Error Handling
- Type errors and error states explicitly
- Prefer result objects or typed errors over throwing where appropriate
- Do not hide failure modes behind broad types
General Principles
- Types should explain intent
- If a type is hard to understand, it’s probably wrong
- Favor maintainability over theoretical completeness
Version History
- e0220ca Current 2026-07-05 22:49


