Token导航 LogoToken导航

Agent Skill · 开发规范

typescript-best-practices(TypeScript 最佳实践)

typescript-best-practices 用于补充开发规范相关能力,适合在 Codex、Claude、Cursor、Gemini CLI 中需要让 Agent 承接开发规范相关任务时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

typescript-best-practices 是开发规范类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证为 MIT,暂无第三方扫描结果,按安装量在开发规范类的 1,265 个 Skill 里排第 1,180。

总安装 210周安装 9GitHub Stars 公开资料未说明下载 73核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
MIT

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:typescript-best-practices(TypeScript 最佳实践)
来源仓库:https://github.com/zatkniz/sporty-group
仓库路径:skills/typescript-best-practices
安装命令:
npx skills add zatkniz/sporty-group --skill "typescript-best-practices"
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

AgentSkills.tonpx skills
npx skills add zatkniz/sporty-group --skill "typescript-best-practices"

这个 Skill 是做什么的

开发规范类 Skill 用来统一代码风格、目录结构和评审口径,产出多为检查清单或改写建议。

typescript-best-practices 用于辅助 TypeScript 项目开发与维护,提供最佳实践指导。适合在 Codex、Claude、Cursor、Gemini CLI 中处理类型定义、代码规范和构建配置。通过 npx skills add 命令安装,需指定仓库和技能名称。

安装前建议确认项目技术栈,避免引入不兼容的规范或工具链。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

来源仓库内路径:skills/typescript-best-practices

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add zatkniz/sporty-group --skill "typescript-best-practices";命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

typescript-best-practices 怎么安装?

在终端执行 npx skills add zatkniz/sporty-group --skill "typescript-best-practices"。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

typescript-best-practices 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

typescript-best-practices 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

typescript-best-practices 是免费的吗?

来源标注的许可证是 MIT。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

typescript-best-practices 用的人多吗?

公开数据是累计安装 210 次,近一周安装 9 次,下载 73 次。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

typescript-best-practices 安全吗?

没有查到第三方扫描结果,安全性无法从公开资料判断,安装前请自行审查源码、依赖和命令行为。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 许可证明确为 MIT,商用和分发边界好判断。

先想清楚的地方

  • 没有第三方扫描结果,安全性只能靠自己读源码判断。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理开发规范类任务、又不想每次都手写提示词的人。

不太适合

  • 要求有安全扫描结论才肯安装的团队。
  • 需要厂商级技术支持和 SLA 的生产系统。

开发规范类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
vercel-react-best-practices

Vercel React 最佳实践 · Codex、Claude

8,490,72025,918操作浏览器MIT通过
web-design-guidelines

网页设计指南 · Codex、Claude

6,686,01625,885需要联网MIT有提醒
remotion-best-practices

Remotion 最佳实践 · Codex、Claude

6,505,6323,027操作浏览器MIT有提醒
supabase-postgres-best-practices

Supabase Postgres 最佳实践 · Codex、Claude

3,175,5232,030需要联网MIT通过
next-best-practices

Next.js 最佳实践 · Codex、Claude

1,848,240841操作浏览器MIT通过
typescript-best-practices

TypeScript 最佳实践 · 本页

210—需要联网MIT未收录

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

name
typescript-best-practices
description
Enforce strict TypeScript standards including centralized type definitions in app/types/, arrow functions only, explicit return types, and lang="ts" in all components. Use when reviewing or creating TypeScript code.

TypeScript Best Practices

Enforce project-wide TypeScript standards and conventions.

When to Use

DO USE when:

  • Writing any new TypeScript code
  • Creating or modifying Vue components
  • Defining new types or interfaces
  • Creating composables or utilities
  • Reviewing code for TypeScript compliance
  • Refactoring JavaScript to TypeScript
  • Questions about type definitions
  • Type organization and structure

DO NOT USE when:

  • Dealing with plain JavaScript (convert to TypeScript first)
  • Configuration files that don't support TypeScript
  • Third-party type definitions (use @types packages)

Critical Standards

⚠️ NON-NEGOTIABLE RULES

  1. Type Location: ALL types MUST be in app/types/ directory

- ✅ import type { User } from '~/types/user' - ❌ Defining types inside components/composables

  1. Vue Components: ALWAYS use lang="ts"

- ✅ <script setup lang="ts"> - ❌ <script setup> without lang

  1. Function Style: ONLY arrow functions

- ✅ const myFunc = (): string => { ... } - ❌ function myFunc() { ... }

  1. Return Types: ALWAYS specify return types

- ✅ const getData = (): Promise<User[]> => { ... } - ❌ const getData = async () => { ... }

  1. Explicit Types: NO implicit any

- ✅ const items: Product[] = [] - ❌ const items = []

  1. Type Exports: ALWAYS export from app/types/

- ✅ All types exported and imported - ❌ Local type definitions

Type Organization Structure

Directory Layout

app/
  types/
    user.ts           # User-related types
    product.ts        # Product types
    api.ts            # API response types
    forms.ts          # Form data types
    state.ts          # State management types
    common.ts         # Shared/utility types
    errors.ts         # Error types
    index.ts          # Optional re-exports

File Naming

  • Use singular for entity types: user.ts, product.ts
  • Use descriptive names: api.ts, forms.ts, state.ts
  • Group related types in same file
  • Export all types from each file

Code Patterns

Component Pattern

// ✅ CORRECT
<script setup lang="ts">
import type { User, Product } from '~/types'

interface Props {
  user: User
  items: Product[]
}

const props = defineProps<Props>()

const formatName = (user: User): string => {
  return `${user.firstName} ${user.lastName}`
}
</script>

Composable Pattern

// ✅ CORRECT
// app/composables/useData.ts
import type { User, ApiResponse } from '~/types'

export const useData = () => {
  const data = ref<User | null>(null)
  
  const fetchData = async (): Promise<User> => {
    const { data: response } = await useFetch<ApiResponse<User>>('/api/user')
    if (!response.value) throw new Error('No data')
    return response.value.data
  }
  
  return { data, fetchData }
}

Store Pattern

// ✅ CORRECT
// app/stores/user.ts
import type { User, LoginCredentials } from '~/types'

export const useUserStore = defineStore('user', () => {
  const user = ref<User | null>(null)
  
  const login = async (creds: LoginCredentials): Promise<void> => {
    // Implementation
  }
  
  return { user: readonly(user), login }
})

Utility Pattern

// ✅ CORRECT
// app/utils/formatters.ts
import type { User, Product } from '~/types'

export const formatUser = (user: User): string => {
  return `${user.firstName} ${user.lastName}`
}

export const calculateTotal = (products: Product[]): number => {
  return products.reduce((sum: number, p: Product): number => 
    sum + p.price, 0
  )
}

Type Definition Patterns

Basic Entity Types

// app/types/user.ts
export interface User {
  id: string
  email: string
  firstName: string
  lastName: string
  role: UserRole
  createdAt: Date
}

export type UserRole = 'admin' | 'user' | 'guest'

API Response Types

// app/types/api.ts
export interface ApiResponse<T> {
  data: T
  message: string
  success: boolean
}

export interface PaginatedResponse<T> {
  items: T[]
  total: number
  page: number
}

Form Types

// app/types/forms.ts
export interface LoginForm {
  email: string
  password: string
}

export interface FormField<T> {
  value: T
  error: string | null
  touched: boolean
}

State Types

// app/types/state.ts
export interface LoadingState {
  isLoading: boolean
  error: Error | null
}

export interface DataState<T> extends LoadingState {
  data: T | null
}

Common Violations & Fixes

❌ Inline Type Definition

<!-- WRONG -->
<script setup lang="ts">
interface User {  // ❌ Type defined inline
  id: string
  name: string
}
</script>

Fix: Move to app/types/user.ts

❌ Missing Return Type

// WRONG
const getData = async () => {  // ❌ No return type
  return data
}

Fix: Add explicit return type

// CORRECT
const getData = async (): Promise<Data> => {
  return data
}

❌ Function Keyword

// WRONG
function handleClick() {  // ❌ function keyword
  // ...
}

Fix: Use arrow function

// CORRECT
const handleClick = (): void => {
  // ...
}

❌ Missing lang="ts"

<!-- WRONG -->
<script setup>  <!-- ❌ No lang="ts" -->
const data = ref()
</script>

Fix: Add lang="ts"

<!-- CORRECT -->
<script setup lang="ts">
const data = ref<string>('')
</script>

❌ Implicit Any

// WRONG
const items = []  // ❌ Implicit any[]
const user = ref()  // ❌ Implicit any

Fix: Add explicit types

// CORRECT
const items: string[] = []
const user = ref<User | null>(null)

Refactoring Checklist

When reviewing or refactoring TypeScript code:

  • [ ] All types defined in app/types/ directory
  • [ ] All Vue components use lang="ts"
  • [ ] All functions are arrow functions
  • [ ] All functions have explicit return types
  • [ ] No function keyword usage
  • [ ] No inline type definitions
  • [ ] No any types (use unknown if needed)
  • [ ] All variables have explicit types
  • [ ] Imports use import type for types
  • [ ] Generic types properly constrained

tsconfig Enforcement

Ensure these are enabled in tsconfig.json:

{
  "compilerOptions": {
    "strict": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true
  }
}

Quick Reference

✅ DO

  • Export all types from app/types/
  • Use lang="ts" in all Vue components
  • Use arrow functions exclusively
  • Specify return types on all functions
  • Use explicit types for all variables
  • Import types with import type
  • Use unknown instead of any
  • Document complex types with JSDoc

❌ DON'T

  • Define types inside components
  • Define types inside composables
  • Use function keyword
  • Omit return types
  • Use implicit any
  • Use any type
  • Define types in non-types files
  • Forget lang="ts" in components

Integration with Project

This TypeScript standard works with:

  • Components: lang="ts" + external types
  • Composables: Arrow functions + return types
  • Stores: Pinia with typed state/actions
  • Utils: Pure functions with explicit types
  • API: Typed requests/responses

Additional Resources

Example Workflow

User: "Create a user profile component"

  1. Define types in app/types/user.ts
  2. Create component with lang="ts"
  3. Import types: import type { User } from '~/types'
  4. Use arrow functions with return types
  5. Verify all TypeScript standards followed

平台分布

weavefox

65.68%
按下载量换算48

Claude Code

28.18%
按下载量换算21

安全审计

暂无安全审计结果可展示。

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills