Typescript coding conventions
Skill yend724/agent-skills/skills/typescript-coding-conventions
This repository contains Agent Skills published by yend724.
npx -y skills add yend724/agent-skills --skill typescript-coding-conventionsAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 3 stars3 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
General TypeScript coding conventions for type safety, exported API design, and module structure. Auto-triggers when writing or refactoring TypeScript code outside framework-specific rules.
SKILL.md
3.3 KB, as published. Nobody here has run it
TypeScript Coding Conventions
TypeScript 全般のコーディング規約集。型安全性、公開インターフェースの明示性、モジュール構造、命名規則を中心に定義する。
When to Apply
以下の作業時に自動で参照する:
- TypeScript ファイルの新規作成
- JavaScript から TypeScript への移行
- 型エラー修正や型定義の改善
- exported function / utility / service の設計
- import / export 構造の整理
Compatibility
TypeScript 5.0+ / ES2022+
Rule Categories
| Category | Prefix |
|---|---|
| 型安全性 | types- |
| インターフェース設計 | interface- |
| モジュール構成 | module- |
| 命名規則 | naming- |
Quick Reference
型安全性
- types-no-any -
anyを避け、unknownとジェネリクスを優先する - types-narrow-before-assert -
as constを除き、asアサーションは可能な限り避ける - types-parse-boundary-input - 外部入力や不確実なデータは
zodやvalibotなどで parse してから扱う
インターフェース設計
- interface-explicit-export-return - export する関数は戻り値型を明示する
- interface-object-params-for-3plus - 引数が 3 つ以上なら object parameter を検討する
- interface-prefer-result-over-try-catch - 通常フローの失敗は
try/catchよりResult型で表現する
モジュール構成
- module-import-type-only - 型の import は
import typeを使う - module-prefer-named-export - default export より named export を優先する
命名規則
- naming-variable-camel-case - 変数名は
camelCaseを基本にする - naming-boolean-prefix - boolean は
is/has/canなどの述語で始める - naming-collection-plurality - collection は複数形、要素は単数形でそろえる
- naming-function-verb-first - 関数名は動詞から始め、振る舞いを表す
- naming-type-pascal-case - 型・interface・class・enum は
PascalCaseにする - naming-constant-screaming-snake-case -
SCREAMING_SNAKE_CASEは真に固定された定数だけに使う
How to Use
個別ルールの詳細は rules/ ディレクトリ内のファイルを参照。上記 Quick Reference のリンクから各ルールにアクセスできる。
各ルールファイルには以下を含める:
- ルールの説明と根拠
- Bad / Good のコード例
- 迷いやすいケースの判断基準