金色时刻 · 15:48
让好资源,触手可及
AGENT SKILL

best-practices

best-practices 是面向软件开发的 Agent Skill,来自 HoangNguyen0403/agent-skills-standard。查看技能说明、操作步骤与使用约定,并通过原项目了解详细用法。

Idiomatic TypeScript patterns for clean, maintainable code.

SKILL.md

下载 MD ↓
nameTypeScript Best Practices
descriptionIdiomatic TypeScript patterns for clean, maintainable code.
metadata{"labels": ["typescript", "best-practices", "idioms", "conventions"], "triggers": {"files": ["**/*.ts", "**/*.tsx"], "keywords": ["class", "function", "module", "import", "export", "async", "promise"]}}

TypeScript Best Practices

Priority: P1 (OPERATIONAL)

Implementation Guidelines

  • Naming: Classes/Types=PascalCase, vars/funcs=camelCase, consts=UPPER_SNAKE. Prefix I only if needed.
  • Functions: Arrows for callbacks; regular for exports. Always type public API returns.
  • Modules: Named exports only. Import order: external → internal → relative.
  • Async: Use async/await, not raw Promises. Promise.all() for parallel.
  • Classes: Explicit access modifiers. Favor composition. Use readonly.
  • Types: Use never for exhaustiveness, asserts for runtime checks.
  • Optional: Use ?:, not | undefined.
  • Imports: Use import type for tree-shaking.

Anti-Patterns

  • No Default Exports: Use named exports.
  • No Implicit Returns: Specify return types.
  • No Unused Variables: Enable noUnusedLocals.
  • No require: Use ES6 import.
  • No Empty Interfaces: Use type or non-empty interface.
  • Use any: Never use any, use unknown only when necessary.

Reference & Examples

See references/examples.md for code samples including:

  • Immutable Interfaces
  • Exhaustiveness Checking
  • Assertion Functions
  • Dependency Injection Patterns
  • Import Organization

Related Topics

language | tooling | security

来源:HoangNguyen0403/agent-skills-standard · MIT 许可 · 许可原文 · MD 为来源页保存的历史版本