mcpField
T
tech-stack:add-typescript-best-practices

tech-stack:add-typescript-best-practices

github.com/neolabhq开发1.8k440 次安装10 周前更新
代码仓库

关于 tech-stack:add-typescript-best-practices

这是一个 Claude skill,用指定的 TypeScript 最佳实践内容创建或更新 CLAUDE.md,适合需要原样写入规则而非概括或补充内容的项目。

主要功能

  1. 01创建或更新 CLAUDE.md
  2. 02逐字写入指定内容
  3. 03记录 TypeScript 编码规范

适用场景

  1. 01为项目添加 TypeScript 规则
  2. 02更新现有 CLAUDE.md 指引

安装

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

$npx skills add https://github.com/neolabhq/context-engineering-kit --skill tech-stack:add-typescript-best-practices

安装后在 Claude Code 中输入/tech-stack:add-typescript-best-practices确认已加载。

详细介绍

设置 TypeScript 最佳实践

创建或更新 CLAUDE.md,内容如下,必须严格照原样编写,不要总结或引入任何额外信息:

## Code Style Rules

### General Principles

- **TypeScript**: All code must be strictly typed, leverage TypeScript's type safety features

### Code style rules

- Interfaces over types - use interfaces for object types
- Use enum for constant values, prefer them over string literals
- Export all types by default
- Use type guards instead of type assertions

### Best Practices

#### Library-First Approach

- Common areas where libraries should be preferred:
  - Date/time manipulation → date-fns, dayjs
  - Form validation → joi, yup, zod
  - HTTP requests → axios, got
  - State management → Redux, MobX, Zustand
  - Utility functions → lodash, ramda

#### Code Quality

- Use destructuring of objects where possible:
  - Instead of `const name = user.name` use `const { name } = user`
  - Instead of `const result = await getUser(userId)` use `const { data: user } = await getUser(userId)`
  - Instead of `const parseData = (data) => data.name` use `const parseData = ({ name }) => name`
- Use `ms` package for time related configuration and environment variables, instead of multiplying numbers by 1000

评论

支持 Markdown