重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
typescript-refactor by pproenca/dot-skills
npx skills add https://github.com/pproenca/dot-skills --skill typescript-refactor专为 AI 代理和 LLM 设计的综合性 TypeScript 重构与现代化指南。包含 8 个类别共 43 条规则,按影响优先级排序,以指导自动化重构、代码审查和代码生成。
在以下情况下参考这些指南:
as 类型断言时satisfies、using、常量类型参数)时| 优先级 | 类别 | 影响 | 前缀 |
|---|---|---|---|
| 1 | 类型架构 | 关键 | arch- |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 2 | 类型收窄与守卫 | 关键 | narrow- |
| 3 | 现代 TypeScript | 高 | modern- |
| 4 | 泛型模式 | 高 | generic- |
| 5 | 编译器性能 | 中高 | compile- |
| 6 | 错误安全 | 中 | error- |
| 7 | 运行时模式 | 中 | perf- |
| 8 | 怪异行为与陷阱 | 低中 | quirk- |
arch-discriminated-unions — 使用可辨识联合替代字符串枚举,以实现详尽的模式匹配arch-branded-types — 对领域标识符使用品牌类型,以防止值混淆arch-satisfies-over-annotation — 对配置对象使用 satisfies 以保留字面量类型arch-interfaces-over-intersections — 扩展接口而非交叉类型,以获得更好的错误信息arch-const-assertion — 使用 as const 进行不可变字面量推断arch-readonly-by-default — 函数参数和返回值默认使用只读类型arch-avoid-partial-abuse — 避免在构建器模式中滥用 Partial<T>narrow-custom-type-guards — 编写自定义类型守卫而非类型断言narrow-assertion-functions — 使用断言函数进行前置条件检查narrow-exhaustive-switch — 使用 never 强制实现详尽的 switch 语句narrow-in-operator — 使用 in 运算符收窄接口联合类型narrow-eliminate-as-casts — 通过适当的收窄链消除 as 类型断言narrow-typeof-chains — 在属性访问前使用 typeof 进行类型收窄modern-using-keyword — 使用 using 关键字进行资源清理modern-const-type-parameters — 使用常量类型参数进行字面量推断modern-template-literal-types — 使用模板字面量类型处理字符串模式modern-noinfer-utility — 使用 NoInfer 控制类型参数推断modern-accessor-keyword — 使用 accessor 关键字实现自动生成的 getter 和 settermodern-verbatim-module-syntax — 启用 verbatimModuleSyntax 以获得显式的导入类型generic-infer-over-annotate — 让 TypeScript 推断而非显式注解generic-constrain-dont-overconstrain — 最小化地约束泛型generic-avoid-distributive-surprises — 控制分配条件类型generic-mapped-type-utilities — 为重复的转换构建自定义映射类型generic-return-type-inference — 在泛型函数中保留返回类型推断compile-explicit-return-types — 为导出的函数添加显式返回类型compile-avoid-deep-recursion — 避免深度递归的类型定义compile-project-references — 在 monorepo 构建中使用项目引用compile-base-types-over-unions — 使用基类型替代大型联合类型error-result-type — 使用 Result 类型替代抛出异常error-exhaustive-error-handling — 对类型化的错误变体使用详尽检查error-typed-catch — 将 catch 子句变量类型化为 unknownerror-never-for-unreachable — 使用 never 标记不可达的代码路径error-discriminated-error-unions — 将领域错误建模为可辨识联合perf-union-literals-over-enums — 使用联合字面量替代枚举perf-avoid-delete-operator — 避免在对象上使用 delete 运算符perf-object-freeze-const — 结合使用 Object.freeze 和 as const 实现真正的不可变性perf-object-keys-narrowing — 避免 Object.keys 的类型拓宽perf-map-set-over-object — 对动态集合使用 Map 和 Set 替代普通对象quirk-excess-property-checks — 理解对象字面量的多余属性检查quirk-empty-object-type — 避免使用 {} 类型——它表示非空值quirk-type-widening-let — 防止 let 声明导致的类型拓宽quirk-variance-annotations — 对泛型接口使用变体注解quirk-structural-typing-escapes — 防范结构类型系统的“后门”阅读各个参考文件以获取详细解释和代码示例:
| 文件 | 描述 |
|---|---|
| references/_sections.md | 类别定义和排序 |
| assets/templates/_template.md | 新规则模板 |
| metadata.json | 版本和参考信息 |
每周安装次数
67
代码仓库
GitHub 星标数
85
首次出现
2026年2月11日
安全审计
安装于
codex63
gemini-cli62
github-copilot62
kimi-cli61
opencode61
amp60
Comprehensive TypeScript refactoring and modernization guide designed for AI agents and LLMs. Contains 43 rules across 8 categories, prioritized by impact to guide automated refactoring, code review, and code generation.
Reference these guidelines when:
as castssatisfies, using, const type parameters)| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Type Architecture | CRITICAL | arch- |
| 2 | Type Narrowing & Guards | CRITICAL | narrow- |
| 3 | Modern TypeScript | HIGH | modern- |
| 4 | Generic Patterns | HIGH | generic- |
| 5 | Compiler Performance | MEDIUM-HIGH | compile- |
| 6 | Error Safety | MEDIUM | error- |
| 7 | Runtime Patterns | MEDIUM | perf- |
| 8 | Quirks & Pitfalls | LOW-MEDIUM | quirk- |
arch-discriminated-unions — Use discriminated unions over string enums for exhaustive pattern matchingarch-branded-types — Use branded types for domain identifiers to prevent value mix-upsarch-satisfies-over-annotation — Use satisfies for config objects to preserve literal typesarch-interfaces-over-intersections — Extend interfaces instead of intersecting types for better error messagesarch-const-assertion — Use for immutable literal inferencenarrow-custom-type-guards — Write custom type guards instead of type assertionsnarrow-assertion-functions — Use assertion functions for precondition checksnarrow-exhaustive-switch — Enforce exhaustive switch with nevernarrow-in-operator — Narrow with the in operator for interface unionsmodern-using-keyword — Use the using keyword for resource cleanupmodern-const-type-parameters — Use const type parameters for literal inferencemodern-template-literal-types — Use template literal types for string patternsmodern-noinfer-utility — Use NoInfer to control type parameter inferencegeneric-infer-over-annotate — Let TypeScript infer instead of explicit annotationgeneric-constrain-dont-overconstrain — Constrain generics minimallygeneric-avoid-distributive-surprises — Control distributive conditional typesgeneric-mapped-type-utilities — Build custom mapped types for repeated transformationsgeneric-return-type-inference — Preserve return type inference in generic functionscompile-explicit-return-types — Add explicit return types to exported functionscompile-avoid-deep-recursion — Avoid deeply recursive type definitionscompile-project-references — Use project references for monorepo buildscompile-base-types-over-unions — Use base types instead of large union typeserror-result-type — Use Result types instead of thrown exceptionserror-exhaustive-error-handling — Use exhaustive checks for typed error variantserror-typed-catch — Type catch clause variables as unknownerror-never-for-unreachable — Use never to mark unreachable code pathsperf-union-literals-over-enums — Use union literals instead of enumsperf-avoid-delete-operator — Avoid the delete operator on objectsperf-object-freeze-const — Use Object.freeze with as const for true immutabilityperf-object-keys-narrowing — Avoid type wideningquirk-excess-property-checks — Understand excess property checks on object literalsquirk-empty-object-type — Avoid the {} type — it means non-nullishquirk-type-widening-let — Prevent type widening with let declarationsquirk-variance-annotations — Use variance annotations for generic interfacesRead individual reference files for detailed explanations and code examples:
| File | Description |
|---|---|
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |
Weekly Installs
67
Repository
GitHub Stars
85
First Seen
Feb 11, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex63
gemini-cli62
github-copilot62
kimi-cli61
opencode61
amp60
Node.js 环境配置指南:多环境管理、类型安全与最佳实践
10,500 周安装
as constarch-readonly-by-default — Default to readonly types for function parameters and return valuesarch-avoid-partial-abuse — Avoid Partial<T> abuse for builder patternsnarrow-eliminate-as-castsasnarrow-typeof-chains — Use typeof narrowing before property accessmodern-accessor-keywordaccessormodern-verbatim-module-syntax — Enable verbatimModuleSyntax for explicit import typeserror-discriminated-error-unionsObject.keysperf-map-set-over-object — Use Map and Set over plain objects for dynamic collectionsquirk-structural-typing-escapes