Install any skill in seconds. Free to start, no credit card required.
Get Started Free →shinpr/frontend-typescript-rules
Applies React/TypeScript type safety, component design, and state management rules.
Passed 20 of 22 test cases with the skill, and 14 of 22 without it.
and 5 more in the full report
6 fixed14 passed either way2 still failing0 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 6 test cases the skill fixed. Same model, same prompt, with and without the skill.
We are building a backend Node.js Express route handler for database transaction processing in PostgreSQL. Here is a snippet handling order creation with SQL queries. Please review and refactor the backend transaction logic.
| Checked | Without skill | With skill |
|---|---|---|
| Focuses the refactoring on Express route handling. | Missed | Passed |
| Manages database transactions without introducing frontend React constructs. | Missed | Passed |
The instructions your model reads when the skill loads.
前端专属的 React/TypeScript 实现规则:阈值、边界类型安全、组件/状态设计、错误处理与项目约定。
在应用某项项目约定之前,先检查 TypeScript、打包器/框架、lint/format、路径别名以及具有代表性的组件配置。当配置或既有仓库模式支持某项约定时,将其视为已观察到;仅凭少量示例得出的结论应标注为推断。当存在相互冲突的模式,且会影响公共行为、兼容性或组件边界时,应停下来指出所需的权威来源或决策点。
触发设计调整的信号:
将不可信或类型未知的数据接收为 unknown,并通过类型守卫进行收窄。仅当运行时/框架不变量能够证明所断言的类型时才使用 as,并在附近注释中记录该不变量。既有的生成代码或第三方声明中包含 any 属于需要包装的边界输入,而不是在应用契约中扩散 any 的理由。
在应用内部,React Props/State 已由类型保证——无需 unknown。在每一个外部边界处,先接收为 unknown,再通过类型守卫收窄后使用:API 响应、localStorage/sessionStorage、URL 参数、解析后的 JSON。受控组件的表单输入通过 React 合成事件保持类型安全。
const raw: unknown = await (await fetch(url)).json()
if (!isUser(raw)) throw new ValidationError('invalid user')
const user = raw // 已收窄为 User
function UserCard({ user, onSelect }: UserCardProps)。直接在函数上标注 props 类型,使 props 契约保持显式useReducer,而不是大量 useState 调用"use client" 边界之后;仅浏览器可用的 API(window、localStorage、事件处理函数)应保留在客户端组件内,因为在服务端组件中调用它们会破坏渲染。纯客户端 SPA(例如 Vite)没有服务端组件运行时,因此可跳过此项Result 类型将预期内的失败表示为值;将 throw 保留给非预期/不可恢复的情况test cases passed, vs 14 / 22 without
Published skills whose descriptions closely match this one, with their headline benchmark lift.
More skills from the same source and nearby in the registry, with their headline benchmark lift.