Guides TypeScript type usage: type vs interface decision, avoiding any, and Zod runtime validation. Use when defining types, choosing type patterns, or validating external data. Triggers: "type vs interface", "any", "unknown", "Zod", "运行时验证", "类型".
Guides TypeScript type usage: type vs interface, avoiding any, and Zod runtime validation.
/plugin marketplace add 15195999826/LomoMarketplace/plugin install typescript-style@LomoMarketplaceThis skill inherits all available tools. When active, it can use any tool Claude has access to.
references/zod-patterns.md| 规范 | 项目选择 |
|---|---|
| 默认类型定义 | type(不用 interface) |
| 未知类型 | unknown(禁止 any) |
| 字符串常量 | 联合类型(不用 enum) |
| 外部数据 | Zod 验证(不用 as Type) |
默认用 type
│
├─ 需要声明合并(扩展第三方库)→ interface
├─ 类的契约(implements)→ interface
└─ 其他情况 → type
// ✗ any
function process(data: any) { }
// ✓ unknown + 类型守卫
function process(data: unknown) {
if (typeof data === 'string') {
console.log(data.toUpperCase())
}
}
// 类型谓词
function isUser(v: unknown): v is User {
return typeof v === 'object' && v !== null && 'id' in v
}
外部数据必须验证(API、表单、环境变量、配置文件):
import { z } from 'zod'
const UserSchema = z.object({
id: z.string(),
name: z.string(),
email: z.string().email(),
})
type User = z.infer<typeof UserSchema>
// 验证 API 响应
const user = UserSchema.parse(await res.json())
详细 Zod 模式参见
references/zod-patterns.md
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.