Provide best-practice coding conventions and generate standards-compliant TypeScript code.
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install typescript-skills或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install typescript-skills⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/typescript-skills/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: typescript slug: typescript license: MIT description: > Provide best-practice coding conventions and generate standards-compliant TypeScript code. ---
> Activation: This skill activates whenever the user says or implies TypeScript. It responds > with standards-compliant TypeScript code and can explain any rule on demand.
---
---
"strict": true in tsconfig.json. This turns on noImplicitAny, strictNullChecks, strictFunctionTypes, and more.
self-documenting code.
any: Treat every use of any as tech debt. Prefer unknown when the type istruly not known, or use generics.
const over let; prefer readonly properties and ReadonlyArray / Readonly utility types.
splitting it.
---
| Construct | Convention | Example | | ----------------------- | ----------------------- | -------------------------------- | | Variable / Function | camelCase | getUserName, isActive | | Boolean variable | camelCase with prefix | isLoading, hasAccess, canEdit | | Constant (module) | UPPER_SNAKE_CASE | MAX_RETRY_COUNT, API_BASE_URL| | Constant (local) | camelCase | const defaultTimeout = 3000 | | Class | PascalCase | UserService, HttpClient | | Interface | PascalCase | UserProfile, ApiResponse | | Type alias | PascalCase | UserId, Theme | | Enum | PascalCase | Direction, HttpStatus | | Enum member | PascalCase | Direction.Up, HttpStatus.Ok | | Generic parameter | Single uppercase letter or descriptive PascalCase | T, TKey, TValue | | File name | kebab-case.ts | user-service.ts, api-client.ts| | Test file name | kebab-case.test.ts or kebab-case.spec.ts | user-service.test.ts | | React component file| PascalCase.tsx | UserProfile.tsx | | Private field | camelCase (no _ prefix) | private count: number |
I (e.g., ~~IUser~~ → User).Type or Interface. indices (i, j) or generic type parameters (T, K, V).
IO, ID); 3+ characters use PascalCase (Http, Xml, Api).
---
interface for Object Shapes// ✅ Good — use interface for object shapes
interface User {
readonly id: string;
name: string;
email: string;
}
// ✅ Good — use type for unions, intersections, mapped types
type Status = 'active' | 'inactive' | 'suspended';
type Result<T> = Success<T> | Failure;
type vs interface| Use interface when … | Use type when … | | ---------------------------------------------- | ------------------------------------------ | | Defining the shape of an object or class | Creating union or intersection types | | You want declaration merging | Using mapped / conditional types | | Extending other interfaces | Aliasing primitive or tuple types |
type over interface for function signatures: ```typescript type Comparator
Record instead of { [key: string]: V }.Partial, Pick, Omit, Required) to derive typesrather than duplicating.
---
// ✅ Good — string enum for readability and debuggability
enum Direction {
Up = 'UP',
Down = 'DOWN',
Left = 'LEFT',
Right = 'RIGHT',
}
const Enum or Union Types// ✅ Good — const enum for zero-runtime-cost enums (no reverse mapping needed)
const enum HttpMethod {
Get = 'GET',
Post = 'POST',
Put = 'PUT',
Delete = 'DELETE',
}
// ✅ Also good — string literal union (simpler, tree-shakeable)
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
are needed.
---
// ✅ Good
const maxRetries = 3;
const baseUrl = 'https://api.example.com';
let currentAttempt = 0;
// ❌ Bad — using var
var legacyValue = 'old';
// ❌ Bad — using let when value never changes
let neverReassigned = 42;
const unless the variable needs reassignment; then use let.var.```typescript // ✅ Good const { name, age } = user;
// ❌ Bad const name = user.name; const age = user.age; ```
as const for immutable literal objects / arrays:```typescript const ROUTES = { home: '/', about: '/about', contact: '/contact', } as const; ```
---
// ✅ Good — explicit return type for public functions
function calculateTotal(items: CartItem[]): number {
return items.reduce((sum, item) => sum + item.price * item.quantity, 0);
}
// ✅ Good — arrow function for callbacks / short lambdas
const double = (n: number): number => n * 2;
// ✅ Good — use default parameters instead of optional + fallback
function createUser(name: string, role: Role = Role.Viewer): User {
// ...
}
...
安装 TypeScript 后,可以对 AI 说这些话来触发它
Help me get started with TypeScript
Explains what TypeScript does, walks through the setup, and runs a quick demo based on your current project
Use TypeScript to best-practice coding conventions and generate standards-compliant T...
Invokes TypeScript with the right parameters and returns the result directly in the conversation
What can I do with TypeScript in my developer & devops workflow?
Lists the top use cases for TypeScript, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/typescript-skills/ 目录(个人级,所有项目可用),或 .claude/skills/typescript-skills/(项目级)。重启 AI 客户端后,用 /typescript-skills 主动调用,或让 AI 根据上下文自动发现并使用。
TypeScript 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
TypeScript 可免费安装使用。请查阅仓库了解许可证信息。
Provide best-practice coding conventions and generate standards-compliant TypeScript code.
TypeScript 属于「Developer & DevOps」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my developer & devops tasks using TypeScript
Identifies repetitive steps in your workflow and sets up TypeScript to handle them automatically