本文へスキップ
Skillpedia
一般的なプログラミング75k · #3006

runtime-validation

できること

このスキルは、ネットワーク、保存領域、環境設定、フォームからデータを受け取る箇所を見つけ、スキーマのライブラリを使って実行時のチェックを追加します。想定外のデータによるバグを減らしたい開発者向けです。

使う場面

  • ✓APIやフォームから受け取るデータにチェックを追加するようエージェントに頼むとき。
  • ✓APIが想定と違う形のデータを返したためにアプリが壊れるとき。
  • ✓ローカルストレージや環境変数から読み込むコードを確認し、その値を検査したいとき。

スキルのリンク

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/runtime-validation/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/runtime-validation/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“APIが想定と少し違うデータを送ると、私のアプリが壊れます。データが入ってくる箇所にチェックを追加してください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントは、fetchの呼び出し、ローカルストレージの読み取り、フォームの送信など、データがアプリに入る箇所を見つけます。データの形を確認するスキーマ(例えばZod)を追加し、一致しない場合に分かりやすいエラーを出します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Validate external data at runtime with a schema library

TypeScript gives you confidence at compile time, but data from the network, user input, and storage arrives at runtime as raw, untyped values. A backend schema change, a misconfigured API, or malicious input can produce data that does not match your TypeScript types — and the compiler will never warn you. Runtime validation with a schema library catches these mismatches at the boundary, surfaces clear error messages, and prevents type-unsafe data from propagating through your application.

Quick Reference

  • TypeScript types are compile-time only — they are completely erased at runtime
  • API responses can differ from their declared types without causing a compile error
  • A Zod schema simultaneously validates data and infers the TypeScript type
  • Validate at trust boundaries only — not inside every internal function call

Check

Identify all places in this code where external data enters the application (fetch calls, localStorage reads, env variable access, form submissions) and report which ones lack runtime schema validation.

Fix

Add Zod schemas to validate the external data entry points in this code. Show the schema definition, the validated type inference, and where to call .parse() or .safeParse().

Explain

Explain why TypeScript types do not protect against runtime data mismatches, how Zod bridges compile-time and runtime safety, and when to use .parse() versus .safeParse().

Code Review

Review all external data entry points in this file: API calls, storage reads, environment variable access, and form handling. Flag any location where data is cast to a TypeScript type without a preceding runtime validation step.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/javascript/runtime-validation

よくある質問

TypeScriptの型だけでは、なぜ不十分なのですか?

このスキルによると、TypeScriptの型はコードの実行時に取り除かれるため、実際のデータを実行時に確認できないからです。

検証はどこに置くべきですか?

このスキルは、外部のデータが入ってくる信頼の境界で検証することを勧めており、内部のすべての関数で行うべきではないとしています。

スキーマで何が得られますか?

このスキルによると、Zodのスキーマはデータを確認し、対応するTypeScriptの型も提供します。

詳細

作者による元の説明

Use when reviewing code that calls fetch(), reads from localStorage, accesses process.env, or processes form submissions without explicitly validating the incoming data shape.

repo: thedaviddias/Front-End-Checklist

人気

GitHubのスター
75k
ランキング
#3006
ライセンス
MIT
更新日
2026/10/31

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル