← スキル一覧に戻る

utils
by narehart
⭐ 0🍴 0📅 2026年1月8日
SKILL.md
name: utils description: Create utility functions with one function per file
Utility Functions
Write utility functions in src/utils/ that provide pure, reusable logic.
Requirements
- File naming: camelCase matching function name (e.g.,
findFreePosition.ts) - One function per file - enforced by ESLint
- No world/store access - pure functions only
Pattern
/**
* Function Name
*
* Brief description of what the function does.
*/
import { SOME_CONSTANT } from '../constants/domain';
import type { SomeType } from '../types/domain';
interface FunctionNameProps {
requiredParam: string;
optionalParam?: number | undefined;
}
interface FunctionNameReturn {
result: string;
metadata: number;
}
export function functionName(props: FunctionNameProps): FunctionNameReturn {
const { requiredParam, optionalParam } = props;
// Implementation
const result = requiredParam.toUpperCase();
const metadata = optionalParam ?? 0;
return { result, metadata };
}
Rules
- One function per file - File name matches function name
- Props interface - All parameters via single props object (unless single primitive)
- Return interface - Define return type for complex returns
- Pure functions - No side effects, no world/store access
- JSDoc header - Brief description at top of file
Shared Types
Use shared props types from src/types/ to reduce duplication:
import type { GridDimensionsProps, ItemDimensionsProps } from '../types/inventory';
interface MyFunctionProps extends GridDimensionsProps, ItemDimensionsProps {
additionalProp: string;
}
Simple Functions
For simple single-parameter functions, skip the props object:
// OK for simple cases
export function capitalizeString(value: string): string {
return value.charAt(0).toUpperCase() + value.slice(1);
}
Examples
Good utils:
findFreePosition- finds available grid positionisSpaceFree- checks if grid cells are unoccupiedshuffleArray- randomizes array orderrandomInt- generates random integer in range
Bad (belong elsewhere):
getEquippedItems- needs world access (use query)moveItem- mutates world (use system)GRID_SIZE- constant value (use constants)
スコア
総合スコア
50/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です