web-storage
できること
このスキルは、ウェブページがブラウザーの保存領域をどう使っているかを確認し、そのコードをエラーに対して安全にします。ブラウザーにデータを保存するアプリの開発者向けです。
使う場面
- ✓エラー処理なしでlocalStorageを読み書きしているコードがあるとき。
- ✓アプリがオブジェクトを保存し、読み戻すときに確認していないとき。
- ✓ログインのトークンなどの機密データがブラウザーのlocalStorageに保存されているとき。
スキルのリンク
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/web-storage/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“私のアプリは、プライベートブラウズで設定を保存するとクラッシュします。保存領域のコードを安全にしてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、保存領域の読み書きをエラー処理で囲み、読み込み時にシリアライズされたデータを確認します。また、ブラウザーの保存領域に保存すべきでない機密データを指摘します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Use Web Storage API safely
localStorage and sessionStorage have a 5–10 MB quota per origin, and any write can throw a QuotaExceededError. Private browsing modes in some browsers disable storage entirely and throw on all writes. Applications that don't handle these errors crash silently, leaving users unable to use the app.
Quick Reference
- Always wrap localStorage access in try/catch — storage can be full or disabled
- Serialize objects with JSON.stringify and validate on read with JSON.parse
- Never store sensitive data (tokens, passwords) in localStorage — use httpOnly cookies
- Use sessionStorage for tab-scoped data that shouldn't persist
Check
Find all localStorage and sessionStorage accesses in this file. Check for missing try/catch, unhandled JSON parsing, and any storage of sensitive data.
Fix
Add try/catch error handling to all Web Storage operations and ensure all object values are properly serialized and deserialized.
Explain
Explain the Web Storage API, its limitations, when to use localStorage vs sessionStorage, and what data should never be stored there.
Code Review
Review scripts, client components, and browser execution paths related to Use Web Storage API safely. Flag exact imports, event handlers, runtime side effects, or blocking operations that violate the rule, and state how the change should be verified in the browser.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/javascript/web-storage
よくある質問
保存領域はなぜクラッシュを起こすのですか?
保存領域にはサイズの上限があり、一部のプライベートブラウズのモードでは無効になるため、アプリが扱うべきエラーが書き込みで起きるからです。
sessionStorageがより良い選択になるのはいつですか?
このスキルは、ブラウザーのタブ一つの間だけ残すべきデータにsessionStorageを勧めています。
localStorageに保存すべきでないものは何ですか?
トークンとパスワードです。このスキルは、それらにはhttpOnlyのCookieを使うよう勧めています。
詳細
作者による元の説明
Use when reviewing scripts, client components, bundles, or runtime behavior related to Use Web Storage API safely. Inspect both source code and the browser execution path so fixes target the real bottleneck or bug.
人気
- GitHubのスター
- 75k
- ランキング
- #3084
- ライセンス
- MIT
- 更新日
- 2026/10/31
コメント
- …
このリポジトリの他のスキル
frontendchecklist
75kコマンドラインツールを使って、フロントエンドのコードとライブページを、アクセシビリティ、速度、SEO、セキュリティに関する380以上のルールと照らし合わせて確認します。
frontend-checklist-global
75kフロントエンドのプロジェクトを、386のFront-End Checklistのルールすべてと照らし合わせて監査し、見つかった問題ごとに具体的な修正方法を示します。
404-page
75k見つからないページの画面に役立つリンクがあり、本物の404ステータスを返すかを確認し、迷った訪問者が目的のページを見つけられるようにします。
about-page
75kサイトの運営者が誰かを説明する、分かりやすいAboutページがあるかを確認し、訪問者と検索エンジンからの信頼を高めます。
似ているスキル
angular-developer
280kエージェントがAngularのコードを作成し、プロジェクト構成についてアドバイスできるようにします。新しいプロジェクトの開始、コード部品の作成、パフォーマンスやアクセシビリティの改善に役立ちます。
frontend-a11y
280kエージェントが Web インターフェースを誰にとっても使いやすくするよう支援します。スクリーンリーダーやキーボード操作に対応し、サイトやアプリが適切に動作するようにします。
frontend-patterns
280kエージェントがフロントエンド開発の最新パターンを適用できるようにします。React と Next.js において、パフォーマンスの最適化、状態管理、ベストプラクティスの遵守を行います。