Loading...
Loading...
Compare original and translation side by side
.tsxasasasas| Signal | Mode | Behavior |
|---|---|---|
| "Write", "implement", "create", "add", "refactor", "tighten typing", "improve typing", "make TS stricter", "harden types" | Authoring | Write code, apply fixes, output files |
| "Review", "audit", "check", "look at" | Review | Report findings, never auto-fix, block on P0 |
| Ambiguous | Ask | Clarify with the user before proceeding |
| 信号词 | 模式 | 行为 |
|---|---|---|
| "Write", "implement", "create", "add", "refactor", "tighten typing", "improve typing", "make TS stricter", "harden types" | 创作模式 | 编写代码、应用修复、输出文件 |
| "Review", "audit", "check", "look at" | 审查模式 | 报告发现的问题,绝不自动修复,对P0级问题实施阻止 |
| 模糊不清 | 询问模式 | 先与用户澄清需求再继续 |
| Category | Reference to load |
|---|---|
| Type system (generics, narrowing, inference) | type-system.md |
| Patterns (result types, branded types, builders) | patterns.md |
| Anti-patterns (any, ts-ignore, unsafe casts) | anti-patterns.md |
| Error handling (Result, retry, aggregation) | error-handling.md |
| Strict config (tsconfig, strict flags) | strict-config.md |
| Tooling (ESLint, Biome, Prettier, CI) | tooling.md |
| Migration (JS-to-TS, version upgrades) | migration.md |
| Performance (compilation speed, traces) | performance.md |
| Testing (type tests, expect-type, tsd) | testing.md |
| Modern features (decorators, using, satisfies) | modern-features.md |
Steering note: Most tasks span two categories. Load the primary reference plus one adjacent. If uncertain which category fits, scan the table above for keywords that match the user request.
| 类别 | 需加载的参考文档 |
|---|---|
| 类型系统(泛型、类型收窄、类型推断) | type-system.md |
| 代码模式(结果类型、品牌类型、构建器) | patterns.md |
| 反模式(any、ts-ignore、不安全类型转换) | anti-patterns.md |
| 错误处理(Result、重试、聚合) | error-handling.md |
| 严格配置(tsconfig、严格模式标志) | strict-config.md |
| 工具链(ESLint、Biome、Prettier、CI) | tooling.md |
| 迁移(JS转TS、版本升级) | migration.md |
| 性能(编译速度、追踪) | performance.md |
| 测试(类型测试、expect-type、tsd) | testing.md |
| 现代特性(装饰器、using、satisfies) | modern-features.md |
指导说明: 大多数任务会涉及两个类别。加载主要参考文档及一个相邻文档。 若不确定适用类别,扫描上表寻找与用户请求匹配的关键词。
Steering note: When reviewing tsconfig.json, only flagas legacy.moduleResolution: "node","node16", and"nodenext"are all modern and correct for their contexts. Choose the baseline that matches the repo's runtime first; strictness flags are orthogonal to module mode. Do not "upgrade""bundler"/node16projects tonodenextunless the user explicitly wants that runtime change. If the repo has multiple tsconfig files, start with the config that governs the files you are touching, then follow itsbundlerchain to shared base configs. If there is no ESLint/Biome config, record that absence and skip Step 5 conflict handling rather than inventing lint policy.extends
指导说明: 审查tsconfig.json时,仅将标记为旧版配置。moduleResolution: "node","node16", and"nodenext"均为现代配置,适用于各自的场景。 首先选择与仓库运行时匹配的基准配置;严格性标志与模块模式相互独立。除非用户明确要求更改运行时,否则不要将"bundler"/node16项目"升级"为nodenext模式。 若仓库包含多个tsconfig文件,先从你要修改的文件对应的配置开始,再跟随其bundler链查看共享基础配置。若没有ESLint/Biome配置,记录该情况并跳过步骤5的冲突处理,不要自行制定代码检查规则。extends
satisfiesany@ts-ignoreasunknownanyany@ts-ignore@ts-expect-errorasSteering note: Distinguish lint warnings from type errors. Lint warnings are project-specific (respect the project's config). Type errors fromare universal and always blocking.tsc
satisfiesany@ts-ignoreasunknownanyany@ts-ignore@ts-expect-erroras指导说明: 区分代码检查警告与类型错误。代码检查警告是项目特定的(需遵循项目配置)。抛出的类型错误是通用的,始终会阻止审批。tsc
undefinedundefined
> **Steering note:** The `satisfies` audit catches config objects that use type annotations
> where `satisfies` would preserve literal types. This is a common missed opportunity.
> Run these audits from the repository root, or replace `.` with the target package path in a monorepo.
> If the repo contains TSX and `jsx` is `react-jsx`, verify the React runtime/types are actually installed before treating the typecheck result as meaningful.
> **指导说明:** `satisfies`审核会捕获那些使用类型注解的配置对象,而使用`satisfies`可以保留字面量类型。这是一个常见的遗漏点。
> 从仓库根目录运行这些审核,或者在单体仓库中将`.`替换为目标包路径。
> 若仓库包含TSX文件且`jsx`设置为`react-jsx`,在将类型检查结果视为有效之前,需先验证React运行时/类型是否已实际安装。Steering note: Do not unilaterally re-enable lint rules. The project may have valid reasons for disabling them (e.g., gradual migration from JavaScript, third-party type issues).
指导说明: Do not unilaterally re-enable lint rules. The project may have valid reasons for disabling them (e.g., gradual migration from JavaScript, third-party type issues).
ReactElementimport type { ReactElement } from 'react'JSX.ElementSteering note: Always produce a deliverable — code or findings list. Never end with only commentary or advice. The user expects actionable output.
import type { ReactElement } from 'react'ReactElementJSX.Element指导说明: Always produce a deliverable — code or findings list. Never end with only commentary or advice. The user expects actionable output.
| Mistake | Why it's wrong | What to do instead |
|---|---|---|
Flagging | Only bare | Check strict-config.md flag table |
Using | | Use |
| Ignoring cross-realm instanceof issues | Objects from iframes/workers fail instanceof | Use brand checks or Symbol.hasInstance |
| Auto-fixing code in review mode | Review should report, not modify | Block and describe; let the author fix |
| Skipping the deliverable step | User gets advice but no output | Always output code or structured findings |
Treating | | Always prefer |
| 错误 | 错误原因 | 正确做法 |
|---|---|---|
将 | 只有裸 | 查看strict-config.md中的标志表 |
使用 | | 使用 |
| 忽略跨领域instanceof问题 | 来自iframe/worker的对象会导致instanceof检查失败 | 使用品牌检查或Symbol.hasInstance |
| 在审查模式下自动修复代码 | 审查应仅报告问题,不修改代码 | 阻止审批并描述问题;让作者自行修复 |
| 跳过交付成果步骤 | 用户仅得到建议而无实际输出 | 始终输出代码或结构化问题清单 |
将 | | 始终优先使用 |
| File | Load when |
|---|---|
| type-system.md | Working with generics, conditional types, type guards, narrowing, variance |
| patterns.md | Implementing Result types, branded types, builders, middleware, retry logic |
| anti-patterns.md | Reviewing code for unsafe patterns or scanning for anti-pattern violations |
| error-handling.md | Implementing error handling, retry logic, error aggregation, or Result types |
| strict-config.md | Configuring or auditing tsconfig.json and strict mode flags |
| tooling.md | Setting up or choosing between ESLint, Biome, Prettier, CI pipelines |
| migration.md | Migrating JS to TS, upgrading TS versions, handling circular dependencies |
| performance.md | Diagnosing slow compilation, reading traces, optimizing type-check speed |
| testing.md | Writing type-level tests, choosing test strategies, testing generics |
| modern-features.md | Using decorators, |
| 文件 | 加载场景 |
|---|---|
| type-system.md | 处理泛型、条件类型、类型守卫、类型收窄、方差相关内容 |
| patterns.md | 实现结果类型、品牌类型、构建器、中间件、重试逻辑 |
| anti-patterns.md | 审查代码中的不安全模式或扫描反模式违规情况 |
| error-handling.md | 实现错误处理、重试逻辑、错误聚合或结果类型 |
| strict-config.md | 配置或审核tsconfig.json与严格模式标志 |
| tooling.md | 设置或选择ESLint、Biome、Prettier、CI流水线 |
| migration.md | JS转TS迁移、TS版本升级、处理循环依赖 |
| performance.md | 诊断缓慢编译问题、读取追踪信息、优化类型检查速度 |
| testing.md | 编写类型级测试、选择测试策略、测试泛型 |
| modern-features.md | 使用装饰器、 |
anyunknown@ts-ignore@ts-expect-errorasanyunknown@ts-ignore@ts-expect-erroras