Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
One-time setup that gathers your project's design context and saves it to CLAUDE.md for future sessions.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
reference/harden.md
1Designs that only work with perfect data aren't production-ready. Harden the interface against the inputs, errors, languages, and network conditions that real users will throw at it.23## Assess Hardening Needs45Identify weaknesses and edge cases:671. **Test with extreme inputs**:8- Very long text (names, descriptions, titles)9- Very short text (empty, single character)10- Special characters (emoji, RTL text, accents)11- Large numbers (millions, billions)12- Many items (1000+ list items, 50+ options)13- No data (empty states)14152. **Test error scenarios**:16- Network failures (offline, slow, timeout)17- API errors (400, 401, 403, 404, 500)18- Validation errors19- Permission errors20- Rate limiting21- Concurrent operations22233. **Test internationalization**:24- Long translations (German is often 30% longer than English)25- RTL languages (Arabic, Hebrew)26- Character sets (Chinese, Japanese, Korean, emoji)27- Date/time formats28- Number formats (1,000 vs 1.000)29- Currency symbols3031**CRITICAL**: Designs that only work with perfect data aren't production-ready. Harden against reality.3233## Hardening Dimensions3435Systematically improve resilience:3637### Text Overflow & Wrapping3839**Long text handling**:40```css41/* Single line with ellipsis */42.truncate {43overflow: hidden;44text-overflow: ellipsis;45white-space: nowrap;46}4748/* Multi-line with clamp */49.line-clamp {50display: -webkit-box;51-webkit-line-clamp: 3;52-webkit-box-orient: vertical;53overflow: hidden;54}5556/* Allow wrapping */57.wrap {58word-wrap: break-word;59overflow-wrap: break-word;60hyphens: auto;61}62```6364**Flex/Grid overflow**:65```css66/* Prevent flex items from overflowing */67.flex-item {68min-width: 0; /* Allow shrinking below content size */69overflow: hidden;70}7172/* Prevent grid items from overflowing */73.grid-item {74min-width: 0;75min-height: 0;76}77```7879**Responsive text sizing**:80- Use `clamp()` for fluid typography81- Set minimum readable sizes (14px on mobile)82- Test text scaling (zoom to 200%)83- Ensure containers expand with text8485### Internationalization (i18n)8687**Text expansion**:88- Add 30-40% space budget for translations89- Use flexbox/grid that adapts to content90- Test with longest language (usually German)91- Avoid fixed widths on text containers9293```jsx94// ❌ Bad: Assumes short English text95<button className="w-24">Submit</button>9697// ✅ Good: Adapts to content98<button className="px-4 py-2">Submit</button>99```100101**RTL (Right-to-Left) support**:102```css103/* Use logical properties */104margin-inline-start: 1rem; /* Not margin-left */105padding-inline: 1rem; /* Not padding-left/right */106border-inline-end: 1px solid; /* Not border-right */107108/* Or use dir attribute */109[dir="rtl"] .arrow { transform: scaleX(-1); }110```111112**Character set support**:113- Use UTF-8 encoding everywhere114- Test with Chinese/Japanese/Korean (CJK) characters115- Test with emoji (they can be 2-4 bytes)116- Handle different scripts (Latin, Cyrillic, Arabic, etc.)117118**Date/Time formatting**:119```javascript120// ✅ Use Intl API for proper formatting121new Intl.DateTimeFormat('en-US').format(date); // 1/15/2024122new Intl.DateTimeFormat('de-DE').format(date); // 15.1.2024123124new Intl.NumberFormat('en-US', {125style: 'currency',126currency: 'USD'127}).format(1234.56); // $1,234.56128```129130**Pluralization**:131```javascript132// ❌ Bad: Assumes English pluralization133`${count} item${count !== 1 ? 's' : ''}`134135// ✅ Good: Use proper i18n library136t('items', { count }) // Handles complex plural rules137```138139### Error Handling140141**Network errors**:142- Show clear error messages143- Provide retry button144- Explain what happened145- Offer offline mode (if applicable)146- Handle timeout scenarios147148```jsx149// Error states with recovery150{error && (151<ErrorMessage>152<p>Failed to load data. {error.message}</p>153<button onClick={retry}>Try again</button>154</ErrorMessage>155)}156```157158**Form validation errors**:159- Inline errors near fields160- Clear, specific messages161- Suggest corrections162- Don't block submission unnecessarily163- Preserve user input on error164165**API errors**:166- Handle each status code appropriately167- 400: Show validation errors168- 401: Redirect to login169- 403: Show permission error170- 404: Show not found state171- 429: Show rate limit message172- 500: Show generic error, offer support173174**Graceful degradation**:175- Core functionality works without JavaScript176- Images have alt text177- Progressive enhancement178- Fallbacks for unsupported features179180### Edge Cases & Boundary Conditions181182**Empty states**:183- No items in list184- No search results185- No notifications186- No data to display187- Provide clear next action188189**Loading states**:190- Initial load191- Pagination load192- Refresh193- Show what's loading ("Loading your projects...")194- Time estimates for long operations195196**Large datasets**:197- Pagination or virtual scrolling198- Search/filter capabilities199- Performance optimization200- Don't load all 10,000 items at once201202**Concurrent operations**:203- Prevent double-submission (disable button while loading)204- Handle race conditions205- Optimistic updates with rollback206- Conflict resolution207208**Permission states**:209- No permission to view210- No permission to edit211- Read-only mode212- Clear explanation of why213214**Browser compatibility**:215- Polyfills for modern features216- Fallbacks for unsupported CSS217- Feature detection (not browser detection)218- Test in target browsers219220### Input Validation & Sanitization221222**Client-side validation**:223- Required fields224- Format validation (email, phone, URL)225- Length limits226- Pattern matching227- Custom validation rules228229**Server-side validation** (always):230- Never trust client-side only231- Validate and sanitize all inputs232- Protect against injection attacks233- Rate limiting234235**Constraint handling**:236```html237<!-- Set clear constraints -->238<input239type="text"240maxlength="100"241pattern="[A-Za-z0-9]+"242required243aria-describedby="username-hint"244/>245<small id="username-hint">246Letters and numbers only, up to 100 characters247</small>248```249250### Accessibility Resilience251252**Keyboard navigation**:253- All functionality accessible via keyboard254- Logical tab order255- Focus management in modals256- Skip links for long content257258**Screen reader support**:259- Proper ARIA labels260- Announce dynamic changes (live regions)261- Descriptive alt text262- Semantic HTML263264**Motion sensitivity**:265```css266@media (prefers-reduced-motion: reduce) {267* {268animation-duration: 0.01ms !important;269animation-iteration-count: 1 !important;270transition-duration: 0.01ms !important;271}272}273```274275**High contrast mode**:276- Test in Windows high contrast mode277- Don't rely only on color278- Provide alternative visual cues279280### Performance Resilience281282**Slow connections**:283- Progressive image loading284- Skeleton screens285- Optimistic UI updates286- Offline support (service workers)287288**Memory leaks**:289- Clean up event listeners290- Cancel subscriptions291- Clear timers/intervals292- Abort pending requests on unmount293294**Throttling & Debouncing**:295```javascript296// Debounce search input297const debouncedSearch = debounce(handleSearch, 300);298299// Throttle scroll handler300const throttledScroll = throttle(handleScroll, 100);301```302303## Testing Strategies304305**Manual testing**:306- Test with extreme data (very long, very short, empty)307- Test in different languages308- Test offline309- Test slow connection (throttle to 3G)310- Test with screen reader311- Test keyboard-only navigation312- Test on old browsers313314**Automated testing**:315- Unit tests for edge cases316- Integration tests for error scenarios317- E2E tests for critical paths318- Visual regression tests319- Accessibility tests (axe, WAVE)320321**IMPORTANT**: Hardening is about expecting the unexpected. Real users will do things you never imagined.322323**NEVER**:324- Assume perfect input (validate everything)325- Ignore internationalization (design for global)326- Leave error messages generic ("Error occurred")327- Forget offline scenarios328- Trust client-side validation alone329- Use fixed widths for text330- Assume English-length text331- Block entire interface when one component errors332333## Verify Hardening334335Test thoroughly with edge cases:336337- **Long text**: Try names with 100+ characters338- **Emoji**: Use emoji in all text fields339- **RTL**: Test with Arabic or Hebrew340- **CJK**: Test with Chinese/Japanese/Korean341- **Network issues**: Disable internet, throttle connection342- **Large datasets**: Test with 1000+ items343- **Concurrent actions**: Click submit 10 times rapidly344- **Errors**: Force API errors, test all error states345- **Empty**: Remove all data, test empty states346347When edge cases are covered, hand off to `$impeccable polish` for the final pass.348