New advertisers: 50% off your first month with code FIRSTMONTHSee slots
miles990 avatar

javascript-typescript

Modern JavaScript and TypeScript development patterns

version
1.0.0
GitHub stars
26
View on GitHub

Add marketplace

/plugin marketplace add miles990/claude-software-skills

Run it inside Claude Code once, then install the plugin below.

Install

/plugin install javascript-typescript@claude-software-skills

Run it inside Claude Code after adding the marketplace.

Files

Discovered from source

JavaScript & TypeScript

Overview

Modern JavaScript (ES6+) and TypeScript patterns for building robust applications.


TypeScript Fundamentals

Type Definitions

// Basic types
type UserId = string;
type Timestamp = number;

// Object types
interface User {
  id: UserId;
  email: string;
  name: string;
  createdAt: Timestamp;
  metadata?: Record<string, unknown>;
}

// Union types
type Status = 'pending' | 'active' | 'inactive';

// Discriminated unions
type Result<T, E = Error> =
  | { success: true; data: T }
  | { success: false; error: E };

// Generic types
interface Repository<T extends { id: string }> {
  find(id: string): Promise<T | null>;
  findAll(filter?: Partial<T>): Promise<T[]>;
  create(data: Omit<T, 'id'>): Promise<T>;
  update(id: string, data: Partial<T>): Promise<T>;
  delete(id: string): Promise<void>;
}

// Utility types
type CreateUserInput = Omit<User, 'id' | 'createdAt'>;
type UpdateUserInput = Partial<Pick<User, 'name' | 'metadata'>>;
type UserKeys = keyof User;

// Conditional types
type Nullable<T> = T | null;
type NonNullableFields<T> = {
  [K in keyof T]-?: NonNullable<T[K]>;
};

// Template literal types
type EventName = `on${Capitalize<string>}`;
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
type ApiRoute = `/${string}`;

Type Guards

// Type predicates
function isUser(obj: unknown): obj is User {
  return (
    typeof obj === 'object' &&
    obj !== null &&
    'id' in obj &&
    'email' in obj &&
    typeof (obj as User).id === 'string'
  );
}

// Discriminated union guards
interface Dog {
  kind: 'dog';
  bark(): void;
}

interface Cat {
  kind: 'cat';
  meow(): void;
}

type Animal = Dog | Cat;

function handleAnimal(animal: Animal) {
  switch (animal.kind) {
    case 'dog':
      animal.bark(); // TypeScript knows this is Dog
      break;
    case 'cat':
      animal.meow(); // TypeScript knows this is Cat
      break;
  }
}

// Assertion functions
function assertIsString(value: unknown): asserts value is string {
  if (typeof value !== 'string') {
    throw new Error('Value must be a string');
  }
}

// Exhaustive checks
function assertNever(x: never): never {
  throw new Error(`Unexpected value: ${x}`);
}

Async Patterns

Promises and Async/Await

// Promise creation
function delay(ms: number): Promise<void> {
  return new Promise((resolve) => setTimeout(resolve, ms));
}

// Async/await with error handling
async function fetchUser(id: string): Promise<Result<User>> {
  try {
    const response = await fetch(`/api/users/${id}`);

    if (!response.ok) {
      return {
        success: false,
        error: new Error(`HTTP ${response.status}`),
      };
    }

    const data = await response.json();
    return { success: true, data };
  } catch (error) {
    return {
      success: false,
      error: error instanceof Error ? error : new Error(String(error)),
    };
  }
}

// Parallel execution
async function fetchAllUsers(ids: string[]): Promise<User[]> {
  const results = await Promise.all(ids.map((id) => fetchUser(id)));

  return results
    .filter((r): r is { success: true; data: User } => r.success)
    .map((r) => r.data);
}

// Promise.allSettled for partial failures
async function fetchUsersSettled(ids: string[]) {
  const results = await Promise.allSettled(
    ids.map((id) => fetch(`/api/users/${id}`).then((r) => r.json()))
  );

  return results.map((result, index) => ({
    id: ids[index],
    status: result.status,
    value: result.status === 'fulfilled' ? result.value : null,
    error: result.status === 'rejected' ? result.reason : null,
  }));
}

// Sequential execution with reduce
async function processSequentially<T, R>(
  items: T[],
  processor: (item: T) => Promise<R>
): Promise<R[]> {
  return items.reduce(async (accPromise, item) => {
    const acc = await accPromise;
    const result = await processor(item);
    return [...acc, result];
  }, Promise.resolve([] as R[]));
}

Async Iterators

// Async generator
async function* paginate<T>(
  fetcher: (page: number) => Promise<{ data: T[]; hasMore: boolean }>
): AsyncGenerator<T[], void, unknown> {
  let page = 1;
  let hasMore = true;

  while (hasMore) {
    const result = await fetcher(page);
    yield result.data;
    hasMore = result.hasMore;
    page++;
  }
}

// Using async iterator
async function getAllItems() {
  const items: Item[] = [];

  for await (const batch of paginate(fetchPage)) {
    items.push(...batch);
  }

  return items;
}

// Async iterator utilities
async function* map<T, R>(
  iterable: AsyncIterable<T>,
  fn: (item: T) => R | Promise<R>
): AsyncGenerator<R> {
  for await (const item of iterable) {
    yield await fn(item);
  }
}

async function* filter<T>(
  iterable: AsyncIterable<T>,
  predicate: (item: T) => boolean | Promise<boolean>
): AsyncGenerator<T> {
  for await (const item of iterable) {
    if (await predicate(item)) {
      yield item;
    }
  }
}

async function* take<T>(
  iterable: AsyncIterable<T>,
  count: number
): AsyncGenerator<T> {
  let taken = 0;
  for await (const item of iterable) {
    if (taken >= count) break;
    yield item;
    taken++;
  }
}

Functional Patterns

Higher-Order Functions

// Currying
const add = (a: number) => (b: number) => a + b;
const add5 = add(5);
console.log(add5(3)); // 8

// Pipe and compose
const pipe =
  <T>(...fns: Array<(arg: T) => T>) =>
  (value: T): T =>
    fns.reduce((acc, fn) => fn(acc), value);

const compose =
  <T>(...fns: Array<(arg: T) => T>) =>
  (value: T): T =>
    fns.reduceRight((acc, fn) => fn(acc), value);

// Usage
const processString = pipe(
  (s: string) => s.trim(),
  (s: string) => s.toLowerCase(),
  (s: string) => s.replace(/\s+/g, '-')
);

// Memoization
function memoize<Args extends unknown[], Result>(
  fn: (...args: Args) => Result
): (...args: Args) => Result {
  const cache = new Map<string, Result>();

  return (...args: Args): Result => {
    const key = JSON.stringify(args);

    if (cache.has(key)) {
      return cache.get(key)!;
    }

    const result = fn(...args);
    cache.set(key, result);
    return result;
  };
}

// Debounce
function debounce<T extends (...args: any[]) => any>(
  fn: T,
  delay: number
): (...args: Parameters<T>) => void {
  let timeoutId: ReturnType<typeof setTimeout>;

  return (...args: Parameters<T>) => {
    clearTimeout(timeoutId);
    timeoutId = setTimeout(() => fn(...args), delay);
  };
}

// Throttle
function throttle<T extends (...args: any[]) => any>(
  fn: T,
  limit: number
): (...args: Parameters<T>) => void {
  let inThrottle = false;

  return (...args: Parameters<T>) => {
    if (!inThrottle) {
      fn(...args);
      inThrottle = true;
      setTimeout(() => (inThrottle = false), limit);
    }
  };
}

Immutable Data Patterns

// Object updates
const updateUser = (user: User, updates: Partial<User>): User => ({
  ...user,
  ...updates,
});

// Nested updates
interface State {
  users: Record<string, User>;
  settings: {
    theme: string;
    notifications: boolean;
  };
}

const updateNestedState = (
  state: State,
  userId: string,
  userUpdate: Partial<User>
): State => ({
  ...state,
  users: {
    ...state.users,
    [userId]: {
      ...state.users[userId],
      ...userUpdate,
    },
  },
});

// Array operations (immutable)
const addItem = <T>(arr: T[], item: T): T[] => [...arr, item];
const removeItem = <T>(arr: T[], index: number): T[] => [
  ...arr.slice(0, index),
  ...arr.slice(index + 1),
];
const updateItem = <T>(arr: T[], index: number, item: T): T[] => [
  ...arr.slice(0, index),
  item,
  ...arr.slice(index + 1),
];

Modern JavaScript Features

Destructuring and Spread

// Object destructuring with defaults and rename
const { name, email, role = 'user', id: odentifier } = user;

// Nested destructuring
const {
  address: { city, country },
} = user;

// Array destructuring
const [first, second, ...rest] = items;
const [, , third] = items; // Skip elements

// Function parameter destructuring
function createUser({
  name,
  email,
  role = 'user',
}: {
  name: string;
  email: string;
  role?: string;
}) {
  return { id: generateId(), name, email, role };
}

// Spread for merging
const merged = { ...defaults, ...overrides };
const combined = [...arr1, ...arr2];

Optional Chaining and Nullish Coalescing

// Optional chaining
const city = user?.address?.city;
const firstItem = items?.[0];
const result = callback?.();

// Nullish coalescing (only null/undefined)
const value = input ?? defaultValue;

// Combining them
const displayName = user?.profile?.displayName ?? user?.name ?? 'Anonymous';

// Logical assignment operators
let config = { timeout: 0 };
config.timeout ||= 5000; // Assigns if falsy (won't assign, 0 is falsy)
config.timeout ??= 5000; // Assigns if null/undefined (won't assign)
config.retries ??= 3; // Assigns (undefined)

Error Handling

// Custom error classes
class AppError extends Error {
  constructor(
    message: string,
    public code: string,
    public statusCode: number = 500
  ) {
    super(message);
    this.name = 'AppError';
    Error.captureStackTrace(this, this.constructor);
  }
}

class ValidationError extends AppError {
  constructor(
    message: string,
    public fields: Record<string, string[]>
  ) {
    super(message, 'VALIDATION_ERROR', 400);
    this.name = 'ValidationError';
  }
}

// Result type pattern (no exceptions)
type Result<T, E = Error> =
  | { ok: true; value: T }
  | { ok: false; error: E };

function ok<T>(value: T): Result<T, never> {
  return { ok: true, value };
}

function err<E>(error: E): Result<never, E> {
  return { ok: false, error };
}

// Using Result
function parseJSON<T>(json: string): Result<T, SyntaxError> {
  try {
    return ok(JSON.parse(json));
  } catch (e) {
    return err(e as SyntaxError);
  }
}

// Chaining Results
function map<T, U, E>(result: Result<T, E>, fn: (value: T) => U): Result<U, E> {
  return result.ok ? ok(fn(result.value)) : result;
}

function flatMap<T, U, E>(
  result: Result<T, E>,
  fn: (value: T) => Result<U, E>
): Result<U, E> {
  return result.ok ? fn(result.value) : result;
}

Module Patterns

// Named exports
export const API_URL = 'https://api.example.com';
export function fetchData() {}
export class ApiClient {}

// Default export
export default class Logger {}

// Re-exports
export { UserService } from './user-service';
export { default as Logger } from './logger';
export * from './types';
export * as utils from './utils';

// Dynamic imports
async function loadModule() {
  const { default: Chart } = await import('./chart');
  return new Chart();
}

// Conditional imports
const adapter = await import(
  process.env.NODE_ENV === 'test' ? './mock-adapter' : './real-adapter'
);

Related Skills

  • [[frontend]] - React/Next.js development
  • [[backend]] - Node.js server development
  • [[testing]] - Jest, Vitest testing

From the miles990/claude-software-skills README

Claude Software Skills

55 modular software development skills for Claude Code - from architecture to deployment

Skills Categories Plugin

┌─────────────────────────────────────────────────────────────────┐
│                  Claude Software Skills                         │
│                                                                 │
│   ┌──────────────┐  ┌──────────────┐  ┌──────────────┐         │
│   │   Software   │  │   Software   │  │ Development  │         │
│   │    Design    │  │ Engineering  │  │    Stacks    │         │
│   │      6       │  │      8       │  │      8       │         │
│   └──────────────┘  └──────────────┘  └──────────────┘         │
│                                                                 │
│   ┌──────────────┐  ┌──────────────┐  ┌──────────────┐         │
│   │    Tools &   │  │   Domain     │  │ Programming  │         │
│   │ Integrations │  │ Applications │  │  Languages   │         │
│   │      9       │  │     12       │  │     12       │         │
│   └──────────────┘  └──────────────┘  └──────────────┘         │
│                                                                 │
│              AI 自動識別任務 → 載入對應領域知識                 │
└─────────────────────────────────────────────────────────────────┘

Features

  • MCP Compatible - Works with Claude Code, Cursor, and other MCP clients
  • Semantic Search - Claude automatically finds relevant skills for your task
  • Cross-Domain Integration - Skills work together seamlessly
  • Best Practices Built-In - Each skill includes patterns and anti-patterns
  • Modular Architecture - Use only what you need
  • Sharp Edges - Proactive warnings about common pitfalls with detection patterns
  • Validations - Executable code quality rules with regex/ast patterns
  • Collaboration - Skills declare relationships for smart delegation and context passing

Installation

Plugin Marketplace (Recommended)

# 1. Add marketplace (GitHub format: owner/repo)
/plugin marketplace add miles990/claude-software-skills

# 2. Open plugin management interface, view available plugins in Discover tab
/plugin

# 3. Install specific skills (choose what you need)
/plugin install frontend@claude-software-skills
/plugin install backend@claude-software-skills
/plugin install api-design@claude-software-skills

# Or mention skill name in conversation, Claude will auto-load

Supported GitHub formats:

# Short format (recommended)
/plugin marketplace add miles990/claude-software-skills

# HTTPS URL
/plugin marketplace add https://github.com/miles990/claude-software-skills.git

# Specify branch or tag
/plugin marketplace add miles990/claude-software-skills#main

Plugin commands:

CommandDescription
/pluginOpen interactive plugin management interface
/plugin install <name>@<marketplace>Install specific plugin
/plugin disable <name>@<marketplace>Temporarily disable plugin
/plugin uninstall <name>@<marketplace>Completely remove plugin

Available Skills

Software Design (6 skills)

SkillDescription
architecture-patternsSoftware architecture patterns and best practices
design-patternsClassic and modern software design patterns
api-designRESTful, GraphQL, gRPC, and API best practices
system-designScalability, availability, and distributed systems design
data-designData modeling, schema design, and data architecture
ux-principlesUser experience design principles for developers

Software Engineering (8 skills)

SkillDescription
code-qualityClean code principles, SOLID, and code review practices
testing-strategiesUnit, integration, E2E testing and TDD practices
devops-cicdCI/CD pipelines, infrastructure as code, and deployment
performance-optimizationProfiling, optimization techniques, and best practices
security-practicesOWASP Top 10, authentication, and secure coding
reliability-engineeringSRE principles, observability, and incident management
documentationTechnical writing, API docs, and documentation best practices
internationalizationi18n/l10n architecture design and multi-language support

Development Stacks (8 skills)

SkillDescription
frontendModern frontend with React, Vue, and web technologies
backendBackend with Node.js, Express, NestJS, and server patterns
mobileMobile with React Native, Flutter, and native patterns
databaseDatabase design, SQL, NoSQL, and data management
cloud-platformsAWS, GCP, Azure services and cloud-native development
ai-ml-integrationAI/ML APIs, LLM integration, and intelligent apps
realtime-systemsWebSocket, real-time communication, event-driven
edge-iotEdge computing, IoT protocols, and embedded systems

Tools & Integrations (9 skills)

SkillDescription
git-workflowsGit version control, branching, and collaboration
project-managementAgile, Scrum, Kanban, and issue tracking
development-environmentIDE setup, dev containers, and local development
monitoring-loggingApplication monitoring, logging, and alerting
api-toolsAPI testing, documentation, and development tools
automation-scriptsBuild automation, task runners, and scripting
auto-dev-setupAuto-Dev workflow for Human-in-the-Loop automation
claude-code-pluginClaude Code Plugin development and marketplace management
claude-code-sdkClaude Code SDK for AI-powered applications

Domain Applications (12 skills)

SkillDescription
application-patternsCommon application development patterns
e-commerceE-commerce platforms, payments, shopping cart
saas-platformsSaaS architecture, multi-tenancy, subscriptions
content-platformsCMS, blogging platforms, content management
communication-systemsEmail, notifications, messaging systems
developer-toolsCLI tools, SDKs, developer experience
game-developmentGame development patterns and architectures
flameFlame Engine 2D game development for Flutter
flame-coreFlame Engine core - components, input, collision
flame-systemsFlame Engine 14 game systems
flame-templatesGame templates - RPG, Platformer, Roguelike
desktop-appsDesktop apps with Electron and Tauri

Programming Languages (12 skills)

SkillDescription
javascript-typescriptModern JavaScript and TypeScript patterns
pythonPython programming patterns and best practices
goGo programming patterns and idioms
rustRust patterns and ownership concepts
java-kotlinJava and Kotlin programming patterns
csharp-dotnetC# and .NET development patterns
cppModern C++ programming patterns and idioms
rubyRuby programming patterns and idioms
phpModern PHP programming patterns
swiftSwift patterns for iOS and macOS
shell-bashShell scripting and Bash programming
sqlSQL patterns for database querying and design

Other Installation Methods

Clone to Skills Directory

# Clone to your skills directory
git clone https://github.com/miles990/claude-software-skills.git ~/.claude/skills/software-skills

Claude will automatically discover and use the skills when relevant to your tasks.

With MCP Server

This repository is compatible with claude-skills-mcp:

# Install the MCP server
pip install claude-skills-mcp

# Add this repository as a skill source
# The server will load skills from ~/.claude/skills/

Cursor IDE

Add to your Cursor MCP settings:

{
  "mcpServers": {
    "software-skills": {
      "command": "npx",
      "args": ["-y", "claude-skills-mcp"],
      "env": {
        "SKILLS_PATH": "/path/to/claude-software-skills"
      }
    }
  }
}

Manual Reference

Simply clone and reference the SKILL.md files in your prompts:

git clone https://github.com/miles990/claude-software-skills.git

Auto-Dev: Automated Development Workflow

One-click setup for GitHub Actions automated development workflow, let Claude help you complete development tasks.

Quick Setup

Using API Key:

curl -fsSL https://raw.githubusercontent.com/miles990/claude-software-skills/main/scripts/setup-auto-dev-apikey.sh | bash

Using Claude Max (OAuth):

curl -fsSL https://raw.githubusercontent.com/miles990/claude-software-skills/main/scripts/setup-auto-dev-max.sh | bash

Post-Installation Setup

VersionSetup Method
API KeyGet Key from console.anthropic.com, set in GitHub Secrets ANTHROPIC_API_KEY
Claude MaxRun claude /install-github-app for auto OAuth Token setup

Usage

  • Issue Trigger: Create Issue → Add auto-dev label
  • Comment Trigger: Comment @claude [instruction] on any Issue/PR

Detailed docs: AUTO-DEV.md

Usage Examples

User: Help me design a microservices architecture for an e-commerce platform

Claude: [Automatically uses architecture-patterns + e-commerce + api-design skills]
User: Review this Python code for performance issues

Claude: [Automatically uses python + performance-optimization + code-quality skills]
User: Set up CI/CD for a React + Node.js monorepo

Claude: [Automatically uses devops-cicd + frontend + backend + git-workflows skills]

Directory Structure

claude-software-skills/
├── .claude-plugin/          # Plugin configuration
│   └── marketplace.json     # Lists all 55 skills as individual plugins
├── .github/
│   └── workflows/           # CI/CD automation
├── software-design/         # Architecture & design skills
├── software-engineering/    # Development practices
├── development-stacks/      # Tech stack skills
├── tools-integrations/      # Developer tools
├── domain-applications/     # Domain-specific patterns
├── programming-languages/   # Language-specific skills
├── docs/
│   ├── SKILL-TEMPLATE.md    # Template for new skills
│   └── software-skills.md
├── CONTRIBUTING.md
├── LICENSE
└── README.md

How It Works

Each skill module contains a SKILL.md file with:

  1. Metadata - Name, description, tags for semantic search
  2. Key Concepts - Core knowledge and terminology
  3. Best Practices - Recommended approaches with examples
  4. Common Pitfalls - What to avoid and why
  5. Patterns & Anti-patterns - Do's and don'ts with code
  6. Tools & Resources - Recommended tools and references
  7. Decision Guide - When to use this skill

When you describe a task, Claude:

  1. Searches for relevant skills using semantic matching
  2. Loads the appropriate SKILL.md files
  3. Applies the knowledge to your specific context
  4. Follows best practices while avoiding common pitfalls

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Adding a New Skill

  1. Create a directory under the appropriate category
  2. Add a SKILL.md following our template
  3. Include practical examples and best practices
  4. Submit a pull request

License

MIT License - See LICENSE for details.

Related Projects


Built for developers, by developers, with Claude

Details

Marketplace
miles990/claude-software-skills
Source
programming-languages/javascript-typescript
Category
Community
Listed since
Apr 6, 2026

More from miles990/claude-software-skills

All 56

Similar to javascript-typescript