Skip to main content

localstorage-patterns

Standardized patterns for localStorage utilities, including key naming conventions, error handling, and testing strategies. Use when creating or modifying localStorage utilities, when localStorage key mismatches occur, or when testing storage functionality. This codebase uses camelCase keys (e.g., pixelGameSettings, not pixel-game-settings).

소스 정보

저장소
pmarashian/cursor-agent-skills
최근 소스 활동
2026년 2월 13일 19:51
감지된 SKILL.md 언어
영어
스타
2
포크
1

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

파일 탐색기
4 개 파일

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
name
localStorage-patterns
description
Standardized patterns for localStorage utilities, including key naming conventions, error handling, and testing strategies. Use when creating or modifying localStorage utilities, when localStorage key mismatches occur, or when testing storage functionality. This codebase uses camelCase keys (e.g., pixelGameSettings, not pixel-game-settings).
# localStorage Patterns ## Overview Standardize localStorage utility creation with consistent key naming, error handling, and testing patterns. ## Key Naming Conventions **This codebase uses camelCase**: `pixelGameSettings` (not `pixel-game-settings`) **Before using localStorage**: 1. Read the storage utility file to find the correct key name 2. Check for constants file with exported storage keys 3. Verify key format matches codebase (camelCase) 4. Don't assume naming conventions - check actual implementation See `references/key-naming.md` for detailed naming patterns. ## Error Handling Pattern Always include error handling: 1. **Check localStorage availability**: `typeof Storage !== 'undefined'` 2. **Wrap JSON.parse in try-catch** 3. **Validate parsed data structure** 4. **Fallback to defaults on any error** 5. **Log warnings for debugging** See `references/error-handling.md` for complete error handling pattern. ## Testing Strategies - Use test seam commands to manipulate localStorage - Test both empty state and populated state - Verify persistence across page reloads - Test quota exceeded scenarios (if applicable) ## Code Structure - Separate storage utilities by domain (settings, highScores) - Export storage keys as constants - Use consistent API: `load*()`, `save*()`, `get*()` - Include JSDoc comments ## Template See `assets/template.ts` for localStorage utility template. ## Resources - `references/key-naming.md` - camelCase vs kebab-case patterns - `references/error-handling.md` - Availability checks, JSON parsing, validation - `assets/template.ts` - Template for localStorage utilities
GitHub에서 보기