mcpField
T
typescript-skills

typescript-skills

github.com/llama-farm开发83681 次安装21 周前更新
代码仓库

关于 typescript-skills

为 LlamaFarm 的 React Designer 和 Electron 应用提供通用 TypeScript 指引,重点包括严格类型、常用模式、测试和安全实践。

主要功能

  1. 01严格类型与空值安全
  2. 02接口定义与显式返回类型
  3. 03React 和 TanStack Query 模式
  4. 04测试与安全指引

适用场景

  1. 01在不同子系统采用一致的 TypeScript 实践
  2. 02检查应用代码中的类型与空值处理
  3. 03编写 React 组件和查询钩子

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/llama-farm/llamafarm --skill typescript-skills

安装后在 Claude Code 中输入/typescript-skills确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

patterns.md
security.md
testing.md
typing.md

详细介绍

LlamaFarm 的 TypeScript 技能

适用于 Designer(React)和 Electron App 子系统的通用 TypeScript 最佳实践。

概述

此技能介绍了适用于 LlamaFarm 前端应用的惯用 TypeScript 模式:

  • designer/:React 18 + TanStack Query + TailwindCSS + Radix UI
  • electron-app/:Electron 28 + Electron Vite

技术栈

子系统框架构建工具主要库
designerReact 18ViteTanStack Query、Radix UI、axios、react-router-dom
electron-appElectron 28electron-viteelectron-updater、axios

配置

两个项目都使用严格的 TypeScript:

{
  "strict": true,
  "noUnusedLocals": true,
  "noUnusedParameters": true,
  "noFallthroughCasesInSwitch": true
}

核心原则

  1. 始终启用严格模式 - 没有明确理由时,切勿使用 any
  2. 优先使用接口 - 对象结构使用 interface,联合类型和交叉类型使用 type
  3. 明确指定返回类型 - 始终为公共函数的返回值指定类型
  4. 不可变性 - 在适用时使用 readonly 和 as const
  5. 空值安全 - 显式处理 null/undefined,避免使用非空断言

相关文档

快速参考

React 组件模式
interface Props {
  readonly title: string
  readonly onAction?: () => void
}

function MyComponent({ title, onAction }: Props): JSX.Element {
  return <button onClick={onAction}>{title}</button>
}
TanStack Query Hook 模式
export const projectKeys = {
  all: ['projects'] as const,
  lists: () => [...projectKeys.all, 'list'] as const,
  detail: (id: string) => [...projectKeys.all, 'detail', id] as const,
}

export function useProject(id: string) {
  return useQuery({
    queryKey: projectKeys.detail(id),
    queryFn: () => fetchProject(id),
    enabled: !!id,
  })
}
错误类模式
export class ApiError extends Error {
  constructor(
    message: string,
    public readonly status: number,
    public readonly response?: unknown
  ) {
    super(message)
    this.name = 'ApiError'
  }
}

检查清单摘要

类别严重高中低
类型3421
模式2332
测试2321
安全4210

评论

支持 Markdown