المهارات writing-types
📦

writing-types

آمن

为 Next.js 编写 TypeScript 类型

手动编写 TypeScript 类型容易出错,并可能导致代码库中的模式不一致。本技能提供创建模块化、可维护类型定义的指南,以提高代码质量和类型安全性。

يدعم: Claude Codex Code(CC)
📊 70 كافٍ
1

تنزيل ZIP المهارة

2

رفع في Claude

اذهب إلى Settings → Capabilities → Skills → Upload skill

3

فعّل وابدأ الاستخدام

اختبرها

استخدام "writing-types". Write types for a product with id, name, price, description, and category

النتيجة المتوقعة:

  • ```typescript
  • // types/product.ts
  • export type ProductId = string;
  •  
  • export interface Product {
  • id: ProductId;
  • name: string;
  • price: number;
  • description: string;
  • category: string;
  • }
  • ```

استخدام "writing-types". Create types for a user profile with optional avatar and required email

النتيجة المتوقعة:

  • ```typescript
  • // types/user.ts
  • export interface UserProfile {
  • id: string;
  • email: string;
  • displayName: string;
  • avatarUrl?: string;
  • createdAt: Date;
  • }
  • ```

التدقيق الأمني

آمن
v1 • 1/23/2026

All static findings are false positives. The SKILL.md file contains only markdown documentation with inline code formatting. Backticks are used for path references, not shell execution. No cryptographic algorithms, network calls, or dangerous code patterns present.

1
الملفات التي تم فحصها
15
الأسطر التي تم تحليلها
2
النتائج
1
إجمالي عمليات التدقيق
مشكلات متوسطة المخاطر (2)
False Positive: Backtick Pattern Misclassified
Markdown inline code formatting (backticks) was misidentified as Ruby/shell backtick execution. Lines 3 and 8 use backticks for code path references, not command execution.
False Positive: Cryptographic Pattern Error
Static scanner incorrectly flagged 'Weak cryptographic algorithm' at line 3. No cryptographic code exists in this file.
تم تدقيقه بواسطة: claude

درجة الجودة

38
الهندسة المعمارية
100
قابلية الصيانة
85
المحتوى
30
المجتمع
95
الأمان
91
الامتثال للمواصفات

ماذا يمكنك بناءه

新数据模型类型

向 Next.js 应用程序添加新数据模型时,使用此技能生成遵循项目约定的干净、模块化类型定义。

API 响应类型

通过描述期望的数据结构为 API 响应创建类型定义。该技能帮助将类型组织成可管理的文件。

重构遗留类型

分解大型类型文件时,使用此技能将类型重构为更小的、专注的模块,同时保持类型安全性。

جرّب هذه الموجهات

基本类型请求
Write TypeScript types for a user object with the following properties: id, name, email, createdAt. Keep it modular and follow the writing-types skill guidelines.
API 响应类型
Create type definitions for a paginated API response that includes items array, total count, page number, and hasMore flag. Use separate files if the types exceed 50 lines.
带关系的复杂对象
Write types for a blog post that includes an author reference, tags array, and nested comments. Separate the types into modular files following the skill rules.
模块组织请求
Generate all TypeScript types needed for a todo list feature including Todo, TodoList, and UserTodoPreferences. Organize them into modular files under the types directory.

أفضل الممارسات

  • 使用描述性的类型名称并将关注点分离到模块化文件中
  • 将每个类型文件保持在 50 行以内以提高可维护性
  • 从 index 文件导出类型以便于导入

تجنب

  • 将所有类型放在一个单一的 monolithic types.ts 文件中
  • 使用过于通用的类型如 'any' 或 'object'
  • 定义复杂的嵌套类型而不将其分解成更小的部分

الأسئلة المتكررة

类型文件的最大文件大小建议是多少?
该技能建议将每个类型文件保持在 50 行代码以内,以提高可维护性和代码审查效率。
我应该使用接口还是类型来定义?
接口和类型都有效。对于可能扩展的对象形状使用接口,对于联合类型、基本类型或复杂组合使用类型。
我应该如何组织相关类型?
将相关类型分组在同一个文件或目录中。使用 index.ts 文件重新导出类型以便于导入。
这个技能可以生成泛型类型吗?
该技能可以在请求中指定类型参数时生成泛型类型。请具体说明你需要的泛型约束。
我可以将此技能用于 React 组件 props 吗?
是的,你可以请求 React 组件的属性类型。描述组件的 props 和它接受的任何事件处理程序。
如何处理循环类型引用?
对于循环引用,使用接口扩展或带前向声明的类型别名。该技能可以帮助正确构建这些模式。

تفاصيل المطور

المؤلف

Emz1998

الترخيص

MIT

مرجع

main

بنية الملفات

📄 SKILL.md