Token导航 LogoToken导航TokenDH.com
前端设计需要联网github未标认证来源可访问许可证需确认审计通过

typescript-writeTypeScript write 开发

Agent Skill

typescript-write 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

636

周安装

26

GitHub Stars

1

下载量

204
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/acaprino/alfio-claude-plugins --skill typescript-write

简介

typescript-write 专注于 TypeScript/JavaScript 开发支持,包括类型安全审查与代码重构。

  • 提供命名规范、文件组织最佳实践,支持 JS 转 TS 及接口设计指导。
  • 适合新项目类型定义编写、现有代码类型错误修复及模块 API 设计优化。
  • 安装前需核实仓库访问权限,避免触发未授权的文件读写或网络请求。
  • 建议在本地环境中先行验证生成的代码片段,确保符合团队编码标准。

SKILL.md

TypeScript/JavaScript Development Skill

When to Invoke

  • Writing new TypeScript or JavaScript files
  • Refactoring existing TS/JS code
  • Reviewing code for type safety and best practices
  • Converting JavaScript to TypeScript
  • Designing module APIs and type interfaces
  • Fixing type errors or improving type coverage

Code Style

Naming Conventions

  • camelCase for variables, functions, parameters
  • PascalCase for types, interfaces, classes, enums, React components
  • UPPER_SNAKE_CASE for constants and enum members
  • Prefix interfaces with I only if project convention requires it - otherwise plain PascalCase
  • Boolean variables: use is, has, should, can prefixes (isLoading, hasPermission)
  • Event handlers: handleClick, onSubmit pattern

File Organization

  • One primary export per file when possible
  • Group related types with their implementation
  • Barrel exports (index.ts) for public module APIs only - avoid deep barrel re-exports
  • File naming: kebab-case.ts for utilities, PascalCase.tsx for React components

Import Ordering

  1. Node built-in modules (node:fs, node:path)
  2. External packages (react, lodash)
  3. Internal aliases (@/utils, @/components)
  4. Relative imports (./helpers, ../types)
  5. Type-only imports (import type {Foo})
  • Blank line between each group

TypeScript Patterns

Strict Mode

  • Enable strict: true in tsconfig.json - never disable individual strict checks
  • No // @ts-ignore or // @ts-expect-error without an explanatory comment
  • Prefer unknown over any - narrow with type guards

Proper Typing

  • Avoid any - use unknown and narrow, or define a proper type
  • Prefer interface for object shapes that may be extended
  • Prefer type for unions, intersections, mapped types, and utility types
  • Use readonly for properties that should not be mutated
  • Use as const for literal type inference on objects and arrays

Discriminated Unions

type Result<T> =
  | { success: true; data: T }
  | { success: false; error: Error };

function handle<T>(result: Result<T>) {
  if (result.success) {
    // result.data is T here
    return result.data;
  }
  // result.error is Error here
  throw result.error;
}

Type Guards

// User-defined type guard
function isString(value: unknown): value is string {
  return typeof value === "string";
}

// Assertion function
function assertDefined<T>(value: T | undefined, name: string): asserts value is T {
  if (value === undefined) {
    throw new Error(`Expected ${name} to be defined`);
  }
}

Generic Constraints

// Constrain generics to what you actually need
function getProperty<T, K extends keyof T>(obj: T, key: K): T[K] {
  return obj[key];
}

// Use defaults for common cases
type ApiResponse<T = unknown> = {
  data: T;
  status: number;
  timestamp: string;
};

Utility Types

  • Partial<T> - all properties optional (use for update/patch operations)
  • Required<T> - all properties required
  • Pick<T, K> - select subset of properties
  • Omit<T, K> - exclude properties
  • Record<K, V> - typed key-value map
  • Extract<T, U> / Exclude<T, U> - filter union members
  • Prefer built-in utility types over manual type manipulation

Enums vs Union Types

  • Prefer string union types for simple sets: type Status = "active" | "inactive"
  • Use const enum only if you need numeric values and tree-shaking
  • Use regular enum when you need runtime reverse mapping or iteration

React Patterns

Component Typing

// Function components - type props inline or with interface
interface ButtonProps {
  label: string;
  variant?: "primary" | "secondary";
  onClick: () => void;
  children?: React.ReactNode;
}

function Button({ label, variant = "primary", onClick, children }: ButtonProps) {
  return <button className={variant} onClick={onClick}>{children ?? label}</button>;
}

Hooks Rules

  • Call hooks at the top level only - never inside conditions, loops, or nested functions
  • Custom hooks must start with use prefix
  • Specify dependency arrays accurately - never suppress exhaustive-deps lint
  • Use useCallback for functions passed as props to memoized children
  • Use useMemo for expensive computations - not for every variable

State Management

  • Colocate state as close to where it is used as possible
  • Lift state up only when siblings need to share it
  • Use useReducer for complex state with multiple sub-values or transitions
  • Context for truly global state (theme, auth, locale) - not for frequently changing data

Event Handling

// Type event handlers properly
function handleChange(e: React.ChangeEvent<HTMLInputElement>) {
  setValue(e.target.value);
}

function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
  e.preventDefault();
  // ...
}

Testing

File Naming

  • Test files: *.test.ts or *.spec.ts alongside the source file
  • Or in __tests__/ directory mirroring the source structure
  • Test utilities: test-utils.ts or testing/ directory

Test Structure

describe("calculateTotal", () => {
  it("returns 0 for empty cart", () => {
    expect(calculateTotal([])).toBe(0);
  });

  it("sums item prices with quantities", () => {
    const items = [
      { price: 10, quantity: 2 },
      { price: 5, quantity: 1 },
    ];
    expect(calculateTotal(items)).toBe(25);
  });

  it("throws for negative quantities", () => {
    expect(() => calculateTotal([{ price: 10, quantity: -1 }])).toThrow();
  });
});

Assertion Patterns

  • Use toBe for primitives, toEqual for objects/arrays
  • Use toThrow for error cases - wrap in arrow function
  • Use toHaveBeenCalledWith for spy/mock assertions
  • Prefer specific matchers over generic toBeTruthy/toBeFalsy
  • Type test fixtures and mocks - avoid as any in tests

Mocking

  • Mock external dependencies, not internal implementation
  • Use vi.fn() (Vitest) or jest.fn() for function mocks
  • Use vi.spyOn / jest.spyOn to mock methods while preserving type safety
  • Reset mocks in beforeEach or use afterEach(() => vi.restoreAllMocks())

Common Anti-Patterns

Using any Instead of Proper Types

// BAD
function parse(data: any) { return data.name; }

// GOOD
function parse(data: unknown): string {
  if (typeof data === "object" && data !== null && "name" in data) {
    return String((data as { name: unknown }).name);
  }
  throw new Error("Invalid data");
}

Non-Null Assertion Overuse

// BAD
const name = user!.name!;

// GOOD
if (!user?.name) throw new Error("User name required");
const name = user.name;

Barrel File Performance Issues

// BAD - importing everything through deep barrel
import { Button } from "@/components";  // pulls entire component tree

// GOOD - direct import
import { Button } from "@/components/Button";

Ignoring Return Types

// BAD - return type inferred as complex union
function getData(id: string) {
  if (!id) return null;
  return fetch(`/api/${id}`).then(r => r.json());
}

// GOOD - explicit return type
async function getData(id: string): Promise<ApiResponse | null> {
  if (!id) return null;
  const r = await fetch(`/api/${id}`);
  return r.json() as Promise<ApiResponse>;
}

Mutating Function Parameters

// BAD
function addItem(items: Item[], item: Item) {
  items.push(item);  // mutates input
  return items;
}

// GOOD
function addItem(items: readonly Item[], item: Item): Item[] {
  return [...items, item];
}

Error Handling

Result Pattern

type Result<T, E = Error> =
  | { ok: true; value: T }
  | { ok: false; error: E };

async function fetchUser(id: string): Promise<Result<User>> {
  try {
    const res = await fetch(`/api/users/${id}`);
    if (!res.ok) return { ok: false, error: new Error(`HTTP ${res.status}`) };
    const user = await res.json();
    return { ok: true, value: user };
  } catch (e) {
    return { ok: false, error: e instanceof Error ? e : new Error(String(e)) };
  }
}

Async Error Handling

  • Always try/catch around await calls that can fail
  • Never use .catch() and await on the same promise chain
  • Prefer returning error results over throwing in library code
  • Throw only for programmer errors (assertion failures, invariant violations)
  • Log errors at the boundary, not at every level

Error Boundaries (React)

  • Wrap major UI sections in error boundaries
  • Provide meaningful fallback UI - not blank screens
  • Log errors to monitoring service in componentDidCatch
  • Reset error boundary state on navigation changes

Typed Errors

class NotFoundError extends Error {
  readonly code = "NOT_FOUND" as const;
  constructor(resource: string, id: string) {
    super(`${resource} ${id} not found`);
    this.name = "NotFoundError";
  }
}

class ValidationError extends Error {
  readonly code = "VALIDATION" as const;
  constructor(public readonly fields: Record<string, string>) {
    super("Validation failed");
    this.name = "ValidationError";
  }
}

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.43%
按下载量换算70

Claude

34.23%
按下载量换算70

Cursor

18.65%
按下载量换算38

Gemini CLI

10.33%
按下载量换算21

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

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

安装前确认

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

来源信息

继续浏览同类 Skills