with one click
test-lib
Create, run, and fix unit tests for libraries and utility modules.
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Create, run, and fix unit tests for libraries and utility modules.
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
Single entry point that reads any input and routes it to signal / backlog / issue / existing issue or PR follow-up, then carries it through to implementation.
.docs/ documentation management.
Canonical templates and operating rules for writing GitHub Issues and Pull Requests (PR templates included despite the name).
| name | test-lib |
| description | Create, run, and fix unit tests for libraries and utility modules. |
| user-invocable | true |
| disable-model-invocation | true |
| model | claude-opus-4-6 |
| effort | xhigh |
| metadata | {"type":"task","author":"shigurenimo","description":"ライブラリ・ユーティリティモジュールの単体テストを作成・実行・修正するスキル。--full で全探索モード、無指定で main 差分モード。サブエージェントに作業を委任する。","design":"テスト可否を判断して単体テストを作成し実行と修正まで回すコード生成スキル。司令塔が並列サブエージェントに委任しテスト品質が問われるため品質を優先する。","dev":true,"tags":["tools"]} |
ライブラリ・ユーティリティの単体テストを作成・実行・修正する。
メインエージェントは司令塔として動作し、実際の作業はサブエージェントに委任する。
--full - 全探索モード (探索対象ディレクトリ内の全ファイルを対象)flowchart TD
A[戦略ファイル確認] --> B{--full?}
B -->|Yes| C[全探索モード]
B -->|No| D[差分モード]
C --> E[探索対象ディレクトリから全ファイル取得]
D --> F[git diff main で差分ファイル取得]
E --> G[ファイル一覧を統合]
F --> G
G --> H[除外パターンでフィルタ]
H --> I[テスト済みファイルを除外]
I --> J[サブエージェントで並列テスト作成]
J --> K{テスト可能?}
K -->|可能| L[テスト作成]
K -->|不可能| M[理由を報告]
L --> N[テスト実行]
M --> O[戦略ファイルに除外追加]
N --> P{パス?}
P -->|失敗| Q[修正]
Q --> N
P -->|成功| R[完了]
O --> R
最初に .claude/strategies/test-lib.md を確認する。
ファイルが存在しない場合は、コードベースを探索して作成する。
戦略ファイルには以下が定義されている:
main ブランチとの差分ファイルを取得する。
git diff --name-only main -- '*.ts' | grep -v '\.test\.ts$' | grep -v '\.d\.ts$'
取得したファイルのうち、戦略ファイルの探索対象ディレクトリに含まれるもののみを対象とする。
探索対象ディレクトリごとにサブエージェント (Explore) を並列起動する。
各サブエージェントへの指示:
指定ディレクトリ内の全 .ts ファイルを列挙する。
除外: *.test.ts, *.d.ts, index.ts
結果をファイルパスのリストで返す。
メインエージェントは全サブエージェントの結果を統合してファイル一覧を作成する。
戦略ファイルの除外パターンに該当するファイルを除外する。
既存の *.test.ts ファイルを探し、対応するソースファイルをテスト済みとして除外する。
残ったファイルごとにサブエージェント (general-purpose) を並列起動する。
各サブエージェントへの指示:
ファイル: {ファイルパス}
このファイルを読んで以下を判断する:
テスト可能な条件:
- 純粋関数である (外部依存なし)
- 入力と出力が明確
- 副作用がない
テスト不可能な条件:
- React Hook (use* で始まる)
- 外部APIを呼び出す
- React/Three.js などのランタイム依存
- Request/Response オブジェクト依存
- 型定義のみ
テスト可能な場合:
- 同じディレクトリに *.test.ts を作成
- テストランナー: bun:test
- テストタイトルは日本語
- 正常系、境界値、異常系のテストを書く
- 作成したテストファイルのパスを報告
テスト不可能な場合:
- 理由を具体的に報告 (例: "useTranslation Hook を使用している")
- ファイルパスと理由のペアで報告
サブエージェントからの報告を集約する。
テスト不可能だったファイルと理由を戦略ファイルの除外パターンに追加する。
追加形式:
- `ファイル名.ts` - 理由
bun test <ディレクトリ>
失敗したテストがあれば修正する。
全テストがパスするまで繰り返す。
*.test.tsimport { expect, test } from "bun:test"
import { targetFunction } from "@/path/to/target-function"
test("正常系: 期待する入力で正しい結果を返す", () => {
const result = targetFunction({ input: "valid" })
expect(result).toBe("expected")
})
test("境界値: 空文字を渡すと空文字を返す", () => {
const result = targetFunction({ input: "" })
expect(result).toBe("")
})
test("異常系: nullを渡すとデフォルト値を返す", () => {
const result = targetFunction({ input: null })
expect(result).toBe("default")
})
テスト作成中に以下を発見したら .claude/strategies/test-lib.md を更新する: