Typescript coding conventions
Skill yend724/agent-skills/skills/typescript-coding-conventions
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.From its SKILL.md
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.
- 2 stars2 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.
SKILL.md
3.3 KB, ~1.0k tokens by cl100k_base, 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 のコード例
- 迷いやすいケースの判断基準
What ships with it: 14 files
15.4 KB alongside SKILL.md
rules/
- interface-explicit-export-return.md929 B
- interface-object-params-for-3plus.md819 B
- interface-prefer-result-over-try-catch.md1.9 KB
- module-import-type-only.md798 B
- module-prefer-named-export.md916 B
- naming-boolean-prefix.md635 B
- naming-collection-plurality.md545 B
- naming-constant-screaming-snake-case.md762 B
- naming-function-verb-first.md760 B
- naming-type-pascal-case.md642 B
- naming-variable-camel-case.md589 B
- types-narrow-before-assert.md3.2 KB
- types-no-any.md1.2 KB
- types-parse-boundary-input.md1.9 KB