All skills
jwynia avatar

/typescript-best-practices

@99a8797
by J Wyniajwynia/agent-skills160 stars
20

Guide AI agents through TypeScript coding best practices including type safety, error handling, code organization, and architecture patterns. This skill should be used when generating TypeScript code, reviewing TypeScript files, creating new TypeScript modules, refactoring JavaScript to TypeScript, or when the user asks about TypeScript patterns, types, or coding standards. Keywords: typescript, types, coding standards, best practices, type safety, generics, architecture, refactoring.

Use this Skill: https://skilld.dev/gh/jwynia/agent-skills/typescript-best-practices

This session only. Nothing lands on disk.

assetstemplatesmodule-template.ts.md

≈666 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Module Template

Starter template for a TypeScript utility module with proper types and structure.

Template

/**
 * ${ModuleName}
 *
 * ${description}
 *
 * @module ${module-name}
 */

// === Types ===

/**
 * Configuration options for ${moduleName}
 */
export interface ${ModuleName}Options {
  /**
   * Description of option
   * @default defaultValue
   */
  readonly option1?: string;

  /**
   * Another option
   */
  readonly option2?: number;
}

/**
 * Result of ${moduleName} operations
 */
export interface ${ModuleName}Result<T> {
  readonly success: boolean;
  readonly data?: T;
  readonly error?: ${ModuleName}Error;
}

/**
 * Error information
 */
export interface ${ModuleName}Error {
  readonly code: string;
  readonly message: string;
}

// === Constants ===

/**
 * Default options
 */
const DEFAULT_OPTIONS: Required<${ModuleName}Options> = {
  option1: "default",
  option2: 0,
};

// === Implementation ===

/**
 * Main function for ${moduleName}
 *
 * @param input - The input to process
 * @param options - Configuration options
 * @returns Result containing processed data or error
 *
 * @example
 * ```typescript
 * import { ${functionName} } from "./${module-name}";
 *
 * const result = ${functionName}("input");
 * if (result.success) {
 *   console.log(result.data);
 * }
 * ```
 */
export function ${functionName}<T>(
  input: T,
  options: Partial<${ModuleName}Options> = {}
): ${ModuleName}Result<T> {
  const opts = { ...DEFAULT_OPTIONS, ...options };

  try {
    // TODO: Implement logic
    return {
      success: true,
      data: input,
    };
  } catch (error) {
    return {
      success: false,
      error: {
        code: "PROCESSING_ERROR",
        message: error instanceof Error ? error.message : String(error),
      },
    };
  }
}

/**
 * Type guard for validating input
 *
 * @param value - Value to validate
 * @returns True if value is valid input
 */
export function isValid${ModuleName}Input(value: unknown): value is string {
  return typeof value === "string" && value.length > 0;
}

// === Exports ===

export type {
  ${ModuleName}Options,
  ${ModuleName}Result,
  ${ModuleName}Error,
};

Usage

  1. Copy the template to your project

  2. Replace placeholders:

    • ${ModuleName} - PascalCase name (e.g., StringUtils)
    • ${moduleName} - camelCase name (e.g., stringUtils)
    • ${module-name} - kebab-case name (e.g., string-utils)
    • ${functionName} - Main function name (e.g., processString)
    • ${description} - Module description
  3. Implement the logic in the main function

  4. Add additional functions as needed

  5. Update types to match your domain

Source: SKILL.md on GitHub

1 warning14d5 checks · Risk SAFE
  • Gen Agent Trust Hub14d

    This skill provides educational documentation and Deno-based utility scripts for TypeScript development, including tools for code analysis, module scaffolding, and type generation. It operates entirely on local files and contains no malicious code or network operations.

  • Socket14d

    No alerts

  • Snyk14d

    Risk: LOW · No issues

  • Runlayer7mo

    18/18 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 99a8797. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Dormantupdated 8 months ago
compatibility
Requires Deno for analysis scripts. Applicable to any TypeScript codebase.
Other metadata
metadata
{
  "author": "agent-skills",
  "version": "1.0",
  "type": "utility",
  "mode": "assistive",
  "domain": "development"
}

README badge

README badge for jwynia/agent-skills/typescript-best-practices