Agent skill

typescript-dev

TypeScript development best practices, code quality tools, and documentation templates. Activated when working with .ts, .tsx files or TypeScript projects.

Stars 232
Forks 15

Install this agent skill to your Project

npx add-skill https://github.com/aiskillstore/marketplace/tree/main/skills/cain96/typescript-dev

SKILL.md

TypeScript Development Expert

This skill supports TypeScript project development.

🎯 Core Rules

Package Management

  • Required: Use pnpm as package manager
  • Do not use npm or yarn

Type Safety

  • tsconfig.json: strict: true required
  • Null Handling: Leverage optional chaining ?. and nullish coalescing ??
  • Imports: Use ES modules, avoid require()
  • NO ANY: Do not use any type in production code

Best Practices

  • Type Inference: Let TypeScript infer when obvious
  • Generics: Use for reusable components
  • Union Types: Prefer union types over enums for string literals
  • Utility Types: Leverage built-in types (Partial, Pick, Omit)

Documentation

  • Required: Use TSDoc format for documentation comments
  • Public APIs only: Document exported functions, classes, and interfaces
  • Self-documenting code: Prefer clear naming over excessive comments
  • Document when necessary: Add TSDoc only when the code intent isn't obvious from the signature

🛠️ Code Quality Tools

Development Workflow

bash
# Format code
pnpm run format

# Run linter
pnpm run lint

# Type check
pnpm tsc --noEmit

# Run tests with coverage
pnpm test -- --coverage

🎯 Quality Checklist

Check these during code review:

  • Public APIs have TSDoc comments (when intent isn't clear from signature)
  • No any type usage
  • Proper error handling
  • Test coverage above 80%
  • Type inference properly leveraged
  • Utility Types utilized
  • Optional chaining (?.) and Nullish coalescing (??) used
  • ES modules used (avoid require())

🚀 Common Patterns

Error Handling

typescript
// Good: Clear error types
class ValidationError extends Error {
  constructor(message: string, public field: string) {
    super(message);
    this.name = 'ValidationError';
  }
}

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

Async/Await

typescript
// Good: With error handling
async function fetchUserData(id: string): Promise<Result<UserData>> {
  try {
    const response = await fetch(`/api/users/${id}`);
    const data = await response.json();
    return { success: true, data };
  } catch (error) {
    return { success: false, error: error as Error };
  }
}

Type Guards

typescript
// Good: Custom type guard
function isUserProfile(value: unknown): value is UserProfile {
  return (
    typeof value === 'object' &&
    value !== null &&
    'id' in value &&
    'username' in value
  );
}

💡 Performance Tips

  1. Avoid unnecessary re-renders (React)

    • Use React.memo for expensive components
    • Use useMemo / useCallback appropriately
  2. Lazy Loading

    • Dynamic imports for code splitting
    • React.lazy() for components
  3. Type-only imports

    typescript
    import type { UserProfile } from './types';
    

🔍 Common Anti-patterns to Avoid

Don't:

typescript
// Using any type
function process(data: any) { }

// Implicit any
function getValue(obj, key) { }

// Excessive type assertions
const user = data as User;

Do:

typescript
// Proper type definitions
function process(data: UserData) { }

// Explicit types
function getValue<T>(obj: T, key: keyof T) { }

// Use type guards
if (isUser(data)) {
  // data is User here
}

Expand your agent's capabilities with these related and highly-rated skills.

aiskillstore/marketplace

perigon-backend

Perigon ASP.NET Core + EF Core + Aspire conventions

232 15
Explore
aiskillstore/marketplace

perigon-agent

Pointers for Copilot/agents to apply Perigon conventions

232 15
Explore
aiskillstore/marketplace

perigon-angular

Angular 21+ standalone/Material/signal conventions for Perigon WebApp

232 15
Explore
aiskillstore/marketplace

fastapi-mastery

Comprehensive FastAPI development skill covering REST API creation, routing, request/response handling, validation, authentication, database integration, middleware, and deployment. Use when working with FastAPI projects, building APIs, implementing CRUD operations, setting up authentication/authorization, integrating databases (SQL/NoSQL), adding middleware, handling WebSockets, or deploying FastAPI applications. Triggered by requests involving .py files with FastAPI code, API endpoint creation, Pydantic models, or FastAPI-specific features.

232 15
Explore
aiskillstore/marketplace

context7-efficient

Token-efficient library documentation fetcher using Context7 MCP with 86.8% token savings through intelligent shell pipeline filtering. Fetches code examples, API references, and best practices for JavaScript, Python, Go, Rust, and other libraries. Use when users ask about library documentation, need code examples, want API usage patterns, are learning a new framework, need syntax reference, or troubleshooting with library-specific information. Triggers include questions like "Show me React hooks", "How do I use Prisma", "What's the Next.js routing syntax", or any request for library/framework documentation.

232 15
Explore
aiskillstore/marketplace

browser-use

Browser automation using Playwright MCP. Navigate websites, fill forms, click elements, take screenshots, and extract data. Use when tasks require web browsing, form submission, web scraping, UI testing, or any browser interaction.

232 15
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results