本文へスキップ
Skillpedia
WebサイトとUI(フロントエンド)75k · #3084

web-storage

できること

このスキルは、ウェブページがブラウザーの保存領域をどう使っているかを確認し、そのコードをエラーに対して安全にします。ブラウザーにデータを保存するアプリの開発者向けです。

使う場面

  • ✓エラー処理なしでlocalStorageを読み書きしているコードがあるとき。
  • ✓アプリがオブジェクトを保存し、読み戻すときに確認していないとき。
  • ✓ログインのトークンなどの機密データがブラウザーのlocalStorageに保存されているとき。

スキルのリンク

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

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

使い方

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

貼り付け用メッセージ

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

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.

repo: thedaviddias/Front-End-Checklist

人気

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

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

0

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

コメント

  • …

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

似ているスキル