[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M74PR9N03PD3FZ7Q4SX29EBH":3,"skill-same:01M74PR9N03PD3FZ7Q4SX29EBH":49},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":27,"commitSha":28,"skillDirectory":29,"forksCount":14,"repositoryHtmlUrl":30,"repositoryHomepageUrl":6,"ownerHtmlUrl":31,"ownerBlogUrl":32,"ownerDescription":33,"updatedAt":34,"install":35,"resources":48},"01M74PR9N03PD3FZ7Q4SX29EBH","best-practices",null,"Apply modern web development best practices for security, compatibility, and code quality. Use when asked to \"apply best practices\", \"security audit\", \"modernize code\", \"code quality review\", or \"check for vulnerabilities\".","cmetech\u002Fotto-cli","cmetech","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F118027304?v=4","01M74PNNHCP8T9GH9NWAWHK66N","Corey Ellis","01M74PNNJ1JR5BJQG3JK95RVFT",0,"MIT","https:\u002F\u002Fgithub.com\u002Fcmetech\u002Fotto-cli\u002Fblob\u002Fmain\u002Fsrc\u002Fresources\u002Fskills\u002Fbest-practices\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: best-practices\ndescription: Apply modern web development best practices for security, compatibility, and code quality. Use when asked to \"apply best practices\", \"security audit\", \"modernize code\", \"code quality review\", or \"check for vulnerabilities\".\nlicense: MIT\nmetadata:\n  author: web-quality-skills\n  version: \"1.0\"\n---\n\n# Best practices\n\nModern web development standards based on Lighthouse best practices audits. Covers security, browser compatibility, and code quality patterns.\n\n## Security\n\n### HTTPS everywhere\n\n**Enforce HTTPS:**\n```html\n\u003C!-- ❌ Mixed content -->\n\u003Cimg src=\"http:\u002F\u002Fexample.com\u002Fimage.jpg\">\n\u003Cscript src=\"http:\u002F\u002Fcdn.example.com\u002Fscript.js\">\u003C\u002Fscript>\n\n\u003C!-- ✅ HTTPS only -->\n\u003Cimg src=\"https:\u002F\u002Fexample.com\u002Fimage.jpg\">\n\u003Cscript src=\"https:\u002F\u002Fcdn.example.com\u002Fscript.js\">\u003C\u002Fscript>\n\n\u003C!-- ✅ Protocol-relative (will use page's protocol) -->\n\u003Cimg src=\"\u002F\u002Fexample.com\u002Fimage.jpg\">\n```\n\n**HSTS Header:**\n```\nStrict-Transport-Security: max-age=31536000; includeSubDomains; preload\n```\n\n### Content Security Policy (CSP)\n\n```html\n\u003C!-- Basic CSP via meta tag -->\n\u003Cmeta http-equiv=\"Content-Security-Policy\" \n      content=\"default-src 'self'; \n               script-src 'self' https:\u002F\u002Ftrusted-cdn.com; \n               style-src 'self' 'unsafe-inline';\n               img-src 'self' data: https:;\n               connect-src 'self' https:\u002F\u002Fapi.example.com;\">\n\n\u003C!-- Better: HTTP header -->\n```\n\n**CSP Header (recommended):**\n```\nContent-Security-Policy: \n  default-src 'self';\n  script-src 'self' 'nonce-abc123' https:\u002F\u002Ftrusted.com;\n  style-src 'self' 'nonce-abc123';\n  img-src 'self' data: https:;\n  connect-src 'self' https:\u002F\u002Fapi.example.com;\n  frame-ancestors 'self';\n  base-uri 'self';\n  form-action 'self';\n```\n\n**Using nonces for inline scripts:**\n```html\n\u003Cscript nonce=\"abc123\">\n  \u002F\u002F This inline script is allowed\n\u003C\u002Fscript>\n```\n\n### Security headers\n\n```\n# Prevent clickjacking\nX-Frame-Options: DENY\n\n# Prevent MIME type sniffing\nX-Content-Type-Options: nosniff\n\n# Enable XSS filter (legacy browsers)\nX-XSS-Protection: 1; mode=block\n\n# Control referrer information\nReferrer-Policy: strict-origin-when-cross-origin\n\n# Permissions policy (formerly Feature-Policy)\nPermissions-Policy: geolocation=(), microphone=(), camera=()\n```\n\n### No vulnerable libraries\n\n```bash\n# Check for vulnerabilities\nnpm audit\nyarn audit\n\n# Auto-fix when possible\nnpm audit fix\n\n# Check specific package\nnpm ls lodash\n```\n\n**Keep dependencies updated:**\n```json\n\u002F\u002F package.json\n{\n  \"scripts\": {\n    \"audit\": \"npm audit --audit-level=moderate\",\n    \"update\": \"npm update && npm audit fix\"\n  }\n}\n```\n\n**Known vulnerable patterns to avoid:**\n```javascript\n\u002F\u002F ❌ Prototype pollution vulnerable patterns\nObject.assign(target, userInput);\n_.merge(target, userInput);\n\n\u002F\u002F ✅ Safer alternatives\nconst safeData = JSON.parse(JSON.stringify(userInput));\n```\n\n### Input sanitization\n\n```javascript\n\u002F\u002F ❌ XSS vulnerable\nelement.innerHTML = userInput;\ndocument.write(userInput);\n\n\u002F\u002F ✅ Safe text content\nelement.textContent = userInput;\n\n\u002F\u002F ✅ If HTML needed, sanitize\nimport DOMPurify from 'dompurify';\nelement.innerHTML = DOMPurify.sanitize(userInput);\n```\n\n### Secure cookies\n\n```javascript\n\u002F\u002F ❌ Insecure cookie\ndocument.cookie = \"session=abc123\";\n\n\u002F\u002F ✅ Secure cookie (server-side)\nSet-Cookie: session=abc123; Secure; HttpOnly; SameSite=Strict; Path=\u002F\n```\n\n---\n\n## Browser compatibility\n\n### Doctype declaration\n\n```html\n\u003C!-- ❌ Missing or invalid doctype -->\n\u003CHTML>\n\u003C!DOCTYPE html PUBLIC \"-\u002F\u002FW3C\u002F\u002FDTD HTML 4.01\u002F\u002FEN\">\n\n\u003C!-- ✅ HTML5 doctype -->\n\u003C!DOCTYPE html>\n\u003Chtml lang=\"en\">\n```\n\n### Character encoding\n\n```html\n\u003C!-- ❌ Missing or late charset -->\n\u003Chtml>\n\u003Chead>\n  \u003Ctitle>Page\u003C\u002Ftitle>\n  \u003Cmeta charset=\"UTF-8\">\n\u003C\u002Fhead>\n\n\u003C!-- ✅ Charset as first element in head -->\n\u003Chtml>\n\u003Chead>\n  \u003Cmeta charset=\"UTF-8\">\n  \u003Ctitle>Page\u003C\u002Ftitle>\n\u003C\u002Fhead>\n```\n\n### Viewport meta tag\n\n```html\n\u003C!-- ❌ Missing viewport -->\n\u003Chead>\n  \u003Ctitle>Page\u003C\u002Ftitle>\n\u003C\u002Fhead>\n\n\u003C!-- ✅ Responsive viewport -->\n\u003Chead>\n  \u003Cmeta charset=\"UTF-8\">\n  \u003Cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n  \u003Ctitle>Page\u003C\u002Ftitle>\n\u003C\u002Fhead>\n```\n\n### Feature detection\n\n```javascript\n\u002F\u002F ❌ Browser detection (brittle)\nif (navigator.userAgent.includes('Chrome')) {\n  \u002F\u002F Chrome-specific code\n}\n\n\u002F\u002F ✅ Feature detection\nif ('IntersectionObserver' in window) {\n  \u002F\u002F Use IntersectionObserver\n} else {\n  \u002F\u002F Fallback\n}\n\n\u002F\u002F ✅ Using @supports in CSS\n@supports (display: grid) {\n  .container {\n    display: grid;\n  }\n}\n\n@supports not (display: grid) {\n  .container {\n    display: flex;\n  }\n}\n```\n\n### Polyfills (when needed)\n\n```html\n\u003C!-- Load polyfills conditionally -->\n\u003Cscript>\n  if (!('fetch' in window)) {\n    document.write('\u003Cscript src=\"\u002Fpolyfills\u002Ffetch.js\">\u003C\\\u002Fscript>');\n  }\n\u003C\u002Fscript>\n\n\u003C!-- Or use polyfill.io -->\n\u003Cscript src=\"https:\u002F\u002Fpolyfill.io\u002Fv3\u002Fpolyfill.min.js?features=fetch,IntersectionObserver\">\u003C\u002Fscript>\n```\n\n---\n\n## Deprecated APIs\n\n### Avoid these\n\n```javascript\n\u002F\u002F ❌ document.write (blocks parsing)\ndocument.write('\u003Cscript src=\"...\">\u003C\u002Fscript>');\n\n\u002F\u002F ✅ Dynamic script loading\nconst script = document.createElement('script');\nscript.src = '...';\ndocument.head.appendChild(script);\n\n\u002F\u002F ❌ Synchronous XHR (blocks main thread)\nconst xhr = new XMLHttpRequest();\nxhr.open('GET', url, false); \u002F\u002F false = synchronous\n\n\u002F\u002F ✅ Async fetch\nconst response = await fetch(url);\n\n\u002F\u002F ❌ Application Cache (deprecated)\n\u003Chtml manifest=\"cache.manifest\">\n\n\u002F\u002F ✅ Service Workers\nif ('serviceWorker' in navigator) {\n  navigator.serviceWorker.register('\u002Fsw.js');\n}\n```\n\n### Event listener passive\n\n```javascript\n\u002F\u002F ❌ Non-passive touch\u002Fwheel (may block scrolling)\nelement.addEventListener('touchstart', handler);\nelement.addEventListener('wheel', handler);\n\n\u002F\u002F ✅ Passive listeners (allows smooth scrolling)\nelement.addEventListener('touchstart', handler, { passive: true });\nelement.addEventListener('wheel', handler, { passive: true });\n\n\u002F\u002F ✅ If you need preventDefault, be explicit\nelement.addEventListener('touchstart', handler, { passive: false });\n```\n\n---\n\n## Console & errors\n\n### No console errors\n\n```javascript\n\u002F\u002F ❌ Errors in production\nconsole.log('Debug info'); \u002F\u002F Remove in production\nthrow new Error('Unhandled'); \u002F\u002F Catch all errors\n\n\u002F\u002F ✅ Proper error handling\ntry {\n  riskyOperation();\n} catch (error) {\n  \u002F\u002F Log to error tracking service\n  errorTracker.captureException(error);\n  \u002F\u002F Show user-friendly message\n  showErrorMessage('Something went wrong. Please try again.');\n}\n```\n\n### Error boundaries (React)\n\n```jsx\nclass ErrorBoundary extends React.Component {\n  state = { hasError: false };\n  \n  static getDerivedStateFromError(error) {\n    return { hasError: true };\n  }\n  \n  componentDidCatch(error, info) {\n    errorTracker.captureException(error, { extra: info });\n  }\n  \n  render() {\n    if (this.state.hasError) {\n      return \u003CFallbackUI \u002F>;\n    }\n    return this.props.children;\n  }\n}\n\n\u002F\u002F Usage\n\u003CErrorBoundary>\n  \u003CApp \u002F>\n\u003C\u002FErrorBoundary>\n```\n\n### Global error handler\n\n```javascript\n\u002F\u002F Catch unhandled errors\nwindow.addEventListener('error', (event) => {\n  errorTracker.captureException(event.error);\n});\n\n\u002F\u002F Catch unhandled promise rejections\nwindow.addEventListener('unhandledrejection', (event) => {\n  errorTracker.captureException(event.reason);\n});\n```\n\n---\n\n## Source maps\n\n### Production configuration\n\n```javascript\n\u002F\u002F ❌ Source maps exposed in production\n\u002F\u002F webpack.config.js\nmodule.exports = {\n  devtool: 'source-map', \u002F\u002F Exposes source code\n};\n\n\u002F\u002F ✅ Hidden source maps (uploaded to error tracker)\nmodule.exports = {\n  devtool: 'hidden-source-map',\n};\n\n\u002F\u002F ✅ Or no source maps in production\nmodule.exports = {\n  devtool: process.env.NODE_ENV === 'production' ? false : 'source-map',\n};\n```\n\n---\n\n## Performance best practices\n\n### Avoid blocking patterns\n\n```javascript\n\u002F\u002F ❌ Blocking script\n\u003Cscript src=\"heavy-library.js\">\u003C\u002Fscript>\n\n\u002F\u002F ✅ Deferred script\n\u003Cscript defer src=\"heavy-library.js\">\u003C\u002Fscript>\n\n\u002F\u002F ❌ Blocking CSS import\n@import url('other-styles.css');\n\n\u002F\u002F ✅ Link tags (parallel loading)\n\u003Clink rel=\"stylesheet\" href=\"styles.css\">\n\u003Clink rel=\"stylesheet\" href=\"other-styles.css\">\n```\n\n### Efficient event handlers\n\n```javascript\n\u002F\u002F ❌ Handler on every element\nitems.forEach(item => {\n  item.addEventListener('click', handleClick);\n});\n\n\u002F\u002F ✅ Event delegation\ncontainer.addEventListener('click', (e) => {\n  if (e.target.matches('.item')) {\n    handleClick(e);\n  }\n});\n```\n\n### Memory management\n\n```javascript\n\u002F\u002F ❌ Memory leak (never removed)\nconst handler = () => { \u002F* ... *\u002F };\nwindow.addEventListener('resize', handler);\n\n\u002F\u002F ✅ Cleanup when done\nconst handler = () => { \u002F* ... *\u002F };\nwindow.addEventListener('resize', handler);\n\n\u002F\u002F Later, when component unmounts:\nwindow.removeEventListener('resize', handler);\n\n\u002F\u002F ✅ Using AbortController\nconst controller = new AbortController();\nwindow.addEventListener('resize', handler, { signal: controller.signal });\n\n\u002F\u002F Cleanup:\ncontroller.abort();\n```\n\n---\n\n## Code quality\n\n### Valid HTML\n\n```html\n\u003C!-- ❌ Invalid HTML -->\n\u003Cdiv id=\"header\">\n\u003Cdiv id=\"header\"> \u003C!-- Duplicate ID -->\n\n\u003Cul>\n  \u003Cdiv>Item\u003C\u002Fdiv> \u003C!-- Invalid child -->\n\u003C\u002Ful>\n\n\u003Ca href=\"\u002F\">\u003Cbutton>Click\u003C\u002Fbutton>\u003C\u002Fa> \u003C!-- Invalid nesting -->\n\n\u003C!-- ✅ Valid HTML -->\n\u003Cheader id=\"site-header\">\n\u003C\u002Fheader>\n\n\u003Cul>\n  \u003Cli>Item\u003C\u002Fli>\n\u003C\u002Ful>\n\n\u003Ca href=\"\u002F\" class=\"button\">Click\u003C\u002Fa>\n```\n\n### Semantic HTML\n\n```html\n\u003C!-- ❌ Non-semantic -->\n\u003Cdiv class=\"header\">\n  \u003Cdiv class=\"nav\">\n    \u003Cdiv class=\"nav-item\">Home\u003C\u002Fdiv>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003Cdiv class=\"main\">\n  \u003Cdiv class=\"article\">\n    \u003Cdiv class=\"title\">Headline\u003C\u002Fdiv>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\n\u003C!-- ✅ Semantic HTML5 -->\n\u003Cheader>\n  \u003Cnav>\n    \u003Ca href=\"\u002F\">Home\u003C\u002Fa>\n  \u003C\u002Fnav>\n\u003C\u002Fheader>\n\u003Cmain>\n  \u003Carticle>\n    \u003Ch1>Headline\u003C\u002Fh1>\n  \u003C\u002Farticle>\n\u003C\u002Fmain>\n```\n\n### Image aspect ratios\n\n```html\n\u003C!-- ❌ Distorted images -->\n\u003Cimg src=\"photo.jpg\" width=\"300\" height=\"100\">\n\u003C!-- If actual ratio is 4:3, this squishes the image -->\n\n\u003C!-- ✅ Preserve aspect ratio -->\n\u003Cimg src=\"photo.jpg\" width=\"300\" height=\"225\">\n\u003C!-- Actual 4:3 dimensions -->\n\n\u003C!-- ✅ CSS object-fit for flexibility -->\n\u003Cimg src=\"photo.jpg\" style=\"width: 300px; height: 200px; object-fit: cover;\">\n```\n\n---\n\n## Permissions & privacy\n\n### Request permissions properly\n\n```javascript\n\u002F\u002F ❌ Request on page load (bad UX, often denied)\nnavigator.geolocation.getCurrentPosition(success, error);\n\n\u002F\u002F ✅ Request in context, after user action\nfindNearbyButton.addEventListener('click', async () => {\n  \u002F\u002F Explain why you need it\n  if (await showPermissionExplanation()) {\n    navigator.geolocation.getCurrentPosition(success, error);\n  }\n});\n```\n\n### Permissions policy\n\n```html\n\u003C!-- Restrict powerful features -->\n\u003Cmeta http-equiv=\"Permissions-Policy\" \n      content=\"geolocation=(), camera=(), microphone=()\">\n\n\u003C!-- Or allow for specific origins -->\n\u003Cmeta http-equiv=\"Permissions-Policy\" \n      content=\"geolocation=(self 'https:\u002F\u002Fmaps.example.com')\">\n```\n\n---\n\n## Audit checklist\n\n### Security (critical)\n- [ ] HTTPS enabled, no mixed content\n- [ ] No vulnerable dependencies (`npm audit`)\n- [ ] CSP headers configured\n- [ ] Security headers present\n- [ ] No exposed source maps\n\n### Compatibility\n- [ ] Valid HTML5 doctype\n- [ ] Charset declared first in head\n- [ ] Viewport meta tag present\n- [ ] No deprecated APIs used\n- [ ] Passive event listeners for scroll\u002Ftouch\n\n### Code quality\n- [ ] No console errors\n- [ ] Valid HTML (no duplicate IDs)\n- [ ] Semantic HTML elements used\n- [ ] Proper error handling\n- [ ] Memory cleanup in components\n\n### UX\n- [ ] No intrusive interstitials\n- [ ] Permission requests in context\n- [ ] Clear error messages\n- [ ] Appropriate image aspect ratios\n\n## Tools\n\n| Tool | Purpose |\n|------|---------|\n| `npm audit` | Dependency vulnerabilities |\n| [SecurityHeaders.com](https:\u002F\u002Fsecurityheaders.com) | Header analysis |\n| [W3C Validator](https:\u002F\u002Fvalidator.w3.org) | HTML validation |\n| Lighthouse | Best practices audit |\n| [Observatory](https:\u002F\u002Fobservatory.mozilla.org) | Security scan |\n\n## References\n\n- [MDN Web Security](https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FWeb\u002FSecurity)\n- [OWASP Top 10](https:\u002F\u002Fowasp.org\u002Fwww-project-top-ten\u002F)\n- [Web Quality Audit](..\u002Fweb-quality-audit\u002FSKILL.md)\n","# Best practices\n\nModern web development standards based on Lighthouse best practices audits. Covers security, browser compatibility, and code quality patterns.\n\n## Security\n\n### HTTPS everywhere\n\n**Enforce HTTPS:**\n```html\n\u003C!-- ❌ Mixed content -->\n\u003Cimg src=\"http:\u002F\u002Fexample.com\u002Fimage.jpg\">\n\u003Cscript src=\"http:\u002F\u002Fcdn.example.com\u002Fscript.js\">\u003C\u002Fscript>\n\n\u003C!-- ✅ HTTPS only -->\n\u003Cimg src=\"https:\u002F\u002Fexample.com\u002Fimage.jpg\">\n\u003Cscript src=\"https:\u002F\u002Fcdn.example.com\u002Fscript.js\">\u003C\u002Fscript>\n\n\u003C!-- ✅ Protocol-relative (will use page's protocol) -->\n\u003Cimg src=\"\u002F\u002Fexample.com\u002Fimage.jpg\">\n```\n\n**HSTS Header:**\n```\nStrict-Transport-Security: max-age=31536000; includeSubDomains; preload\n```\n\n### Content Security Policy (CSP)\n\n```html\n\u003C!-- Basic CSP via meta tag -->\n\u003Cmeta http-equiv=\"Content-Security-Policy\" \n      content=\"default-src 'self'; \n               script-src 'self' https:\u002F\u002Ftrusted-cdn.com; \n               style-src 'self' 'unsafe-inline';\n               img-src 'self' data: https:;\n               connect-src 'self' https:\u002F\u002Fapi.example.com;\">\n\n\u003C!-- Better: HTTP header -->\n```\n\n**CSP Header (recommended):**\n```\nContent-Security-Policy: \n  default-src 'self';\n  script-src 'self' 'nonce-abc123' https:\u002F\u002Ftrusted.com;\n  style-src 'self' 'nonce-abc123';\n  img-src 'self' data: https:;\n  connect-src 'self' https:\u002F\u002Fapi.example.com;\n  frame-ancestors 'self';\n  base-uri 'self';\n  form-action 'self';\n```\n\n**Using nonces for inline scripts:**\n```html\n\u003Cscript nonce=\"abc123\">\n  \u002F\u002F This inline script is allowed\n\u003C\u002Fscript>\n```\n\n### Security headers\n\n```\n# Prevent clickjacking\nX-Frame-Options: DENY\n\n# Prevent MIME type sniffing\nX-Content-Type-Options: nosniff\n\n# Enable XSS filter (legacy browsers)\nX-XSS-Protection: 1; mode=block\n\n# Control referrer information\nReferrer-Policy: strict-origin-when-cross-origin\n\n# Permissions policy (formerly Feature-Policy)\nPermissions-Policy: geolocation=(), microphone=(), camera=()\n```\n\n### No vulnerable libraries\n\n```bash\n# Check for vulnerabilities\nnpm audit\nyarn audit\n\n# Auto-fix when possible\nnpm audit fix\n\n# Check specific package\nnpm ls lodash\n```\n\n**Keep dependencies updated:**\n```json\n\u002F\u002F package.json\n{\n  \"scripts\": {\n    \"audit\": \"npm audit --audit-level=moderate\",\n    \"update\": \"npm update && npm audit fix\"\n  }\n}\n```\n\n**Known vulnerable patterns to avoid:**\n```javascript\n\u002F\u002F ❌ Prototype pollution vulnerable patterns\nObject.assign(target, userInput);\n_.merge(target, userInput);\n\n\u002F\u002F ✅ Safer alternatives\nconst safeData = JSON.parse(JSON.stringify(userInput));\n```\n\n### Input sanitization\n\n```javascript\n\u002F\u002F ❌ XSS vulnerable\nelement.innerHTML = userInput;\ndocument.write(userInput);\n\n\u002F\u002F ✅ Safe text content\nelement.textContent = userInput;\n\n\u002F\u002F ✅ If HTML needed, sanitize\nimport DOMPurify from 'dompurify';\nelement.innerHTML = DOMPurify.sanitize(userInput);\n```\n\n### Secure cookies\n\n```javascript\n\u002F\u002F ❌ Insecure cookie\ndocument.cookie = \"session=abc123\";\n\n\u002F\u002F ✅ Secure cookie (server-side)\nSet-Cookie: session=abc123; Secure; HttpOnly; SameSite=Strict; Path=\u002F\n```\n\n---\n\n## Browser compatibility\n\n### Doctype declaration\n\n```html\n\u003C!-- ❌ Missing or invalid doctype -->\n\u003CHTML>\n\u003C!DOCTYPE html PUBLIC \"-\u002F\u002FW3C\u002F\u002FDTD HTML 4.01\u002F\u002FEN\">\n\n\u003C!-- ✅ HTML5 doctype -->\n\u003C!DOCTYPE html>\n\u003Chtml lang=\"en\">\n```\n\n### Character encoding\n\n```html\n\u003C!-- ❌ Missing or late charset -->\n\u003Chtml>\n\u003Chead>\n  \u003Ctitle>Page\u003C\u002Ftitle>\n  \u003Cmeta charset=\"UTF-8\">\n\u003C\u002Fhead>\n\n\u003C!-- ✅ Charset as first element in head -->\n\u003Chtml>\n\u003Chead>\n  \u003Cmeta charset=\"UTF-8\">\n  \u003Ctitle>Page\u003C\u002Ftitle>\n\u003C\u002Fhead>\n```\n\n### Viewport meta tag\n\n```html\n\u003C!-- ❌ Missing viewport -->\n\u003Chead>\n  \u003Ctitle>Page\u003C\u002Ftitle>\n\u003C\u002Fhead>\n\n\u003C!-- ✅ Responsive viewport -->\n\u003Chead>\n  \u003Cmeta charset=\"UTF-8\">\n  \u003Cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n  \u003Ctitle>Page\u003C\u002Ftitle>\n\u003C\u002Fhead>\n```\n\n### Feature detection\n\n```javascript\n\u002F\u002F ❌ Browser detection (brittle)\nif (navigator.userAgent.includes('Chrome')) {\n  \u002F\u002F Chrome-specific code\n}\n\n\u002F\u002F ✅ Feature detection\nif ('IntersectionObserver' in window) {\n  \u002F\u002F Use IntersectionObserver\n} else {\n  \u002F\u002F Fallback\n}\n\n\u002F\u002F ✅ Using @supports in CSS\n@supports (display: grid) {\n  .container {\n    display: grid;\n  }\n}\n\n@supports not (display: grid) {\n  .container {\n    display: flex;\n  }\n}\n```\n\n### Polyfills (when needed)\n\n```html\n\u003C!-- Load polyfills conditionally -->\n\u003Cscript>\n  if (!('fetch' in window)) {\n    document.write('\u003Cscript src=\"\u002Fpolyfills\u002Ffetch.js\">\u003C\\\u002Fscript>');\n  }\n\u003C\u002Fscript>\n\n\u003C!-- Or use polyfill.io -->\n\u003Cscript src=\"https:\u002F\u002Fpolyfill.io\u002Fv3\u002Fpolyfill.min.js?features=fetch,IntersectionObserver\">\u003C\u002Fscript>\n```\n\n---\n\n## Deprecated APIs\n\n### Avoid these\n\n```javascript\n\u002F\u002F ❌ document.write (blocks parsing)\ndocument.write('\u003Cscript src=\"...\">\u003C\u002Fscript>');\n\n\u002F\u002F ✅ Dynamic script loading\nconst script = document.createElement('script');\nscript.src = '...';\ndocument.head.appendChild(script);\n\n\u002F\u002F ❌ Synchronous XHR (blocks main thread)\nconst xhr = new XMLHttpRequest();\nxhr.open('GET', url, false); \u002F\u002F false = synchronous\n\n\u002F\u002F ✅ Async fetch\nconst response = await fetch(url);\n\n\u002F\u002F ❌ Application Cache (deprecated)\n\u003Chtml manifest=\"cache.manifest\">\n\n\u002F\u002F ✅ Service Workers\nif ('serviceWorker' in navigator) {\n  navigator.serviceWorker.register('\u002Fsw.js');\n}\n```\n\n### Event listener passive\n\n```javascript\n\u002F\u002F ❌ Non-passive touch\u002Fwheel (may block scrolling)\nelement.addEventListener('touchstart', handler);\nelement.addEventListener('wheel', handler);\n\n\u002F\u002F ✅ Passive listeners (allows smooth scrolling)\nelement.addEventListener('touchstart', handler, { passive: true });\nelement.addEventListener('wheel', handler, { passive: true });\n\n\u002F\u002F ✅ If you need preventDefault, be explicit\nelement.addEventListener('touchstart', handler, { passive: false });\n```\n\n---\n\n## Console & errors\n\n### No console errors\n\n```javascript\n\u002F\u002F ❌ Errors in production\nconsole.log('Debug info'); \u002F\u002F Remove in production\nthrow new Error('Unhandled'); \u002F\u002F Catch all errors\n\n\u002F\u002F ✅ Proper error handling\ntry {\n  riskyOperation();\n} catch (error) {\n  \u002F\u002F Log to error tracking service\n  errorTracker.captureException(error);\n  \u002F\u002F Show user-friendly message\n  showErrorMessage('Something went wrong. Please try again.');\n}\n```\n\n### Error boundaries (React)\n\n```jsx\nclass ErrorBoundary extends React.Component {\n  state = { hasError: false };\n  \n  static getDerivedStateFromError(error) {\n    return { hasError: true };\n  }\n  \n  componentDidCatch(error, info) {\n    errorTracker.captureException(error, { extra: info });\n  }\n  \n  render() {\n    if (this.state.hasError) {\n      return \u003CFallbackUI \u002F>;\n    }\n    return this.props.children;\n  }\n}\n\n\u002F\u002F Usage\n\u003CErrorBoundary>\n  \u003CApp \u002F>\n\u003C\u002FErrorBoundary>\n```\n\n### Global error handler\n\n```javascript\n\u002F\u002F Catch unhandled errors\nwindow.addEventListener('error', (event) => {\n  errorTracker.captureException(event.error);\n});\n\n\u002F\u002F Catch unhandled promise rejections\nwindow.addEventListener('unhandledrejection', (event) => {\n  errorTracker.captureException(event.reason);\n});\n```\n\n---\n\n## Source maps\n\n### Production configuration\n\n```javascript\n\u002F\u002F ❌ Source maps exposed in production\n\u002F\u002F webpack.config.js\nmodule.exports = {\n  devtool: 'source-map', \u002F\u002F Exposes source code\n};\n\n\u002F\u002F ✅ Hidden source maps (uploaded to error tracker)\nmodule.exports = {\n  devtool: 'hidden-source-map',\n};\n\n\u002F\u002F ✅ Or no source maps in production\nmodule.exports = {\n  devtool: process.env.NODE_ENV === 'production' ? false : 'source-map',\n};\n```\n\n---\n\n## Performance best practices\n\n### Avoid blocking patterns\n\n```javascript\n\u002F\u002F ❌ Blocking script\n\u003Cscript src=\"heavy-library.js\">\u003C\u002Fscript>\n\n\u002F\u002F ✅ Deferred script\n\u003Cscript defer src=\"heavy-library.js\">\u003C\u002Fscript>\n\n\u002F\u002F ❌ Blocking CSS import\n@import url('other-styles.css');\n\n\u002F\u002F ✅ Link tags (parallel loading)\n\u003Clink rel=\"stylesheet\" href=\"styles.css\">\n\u003Clink rel=\"stylesheet\" href=\"other-styles.css\">\n```\n\n### Efficient event handlers\n\n```javascript\n\u002F\u002F ❌ Handler on every element\nitems.forEach(item => {\n  item.addEventListener('click', handleClick);\n});\n\n\u002F\u002F ✅ Event delegation\ncontainer.addEventListener('click', (e) => {\n  if (e.target.matches('.item')) {\n    handleClick(e);\n  }\n});\n```\n\n### Memory management\n\n```javascript\n\u002F\u002F ❌ Memory leak (never removed)\nconst handler = () => { \u002F* ... *\u002F };\nwindow.addEventListener('resize', handler);\n\n\u002F\u002F ✅ Cleanup when done\nconst handler = () => { \u002F* ... *\u002F };\nwindow.addEventListener('resize', handler);\n\n\u002F\u002F Later, when component unmounts:\nwindow.removeEventListener('resize', handler);\n\n\u002F\u002F ✅ Using AbortController\nconst controller = new AbortController();\nwindow.addEventListener('resize', handler, { signal: controller.signal });\n\n\u002F\u002F Cleanup:\ncontroller.abort();\n```\n\n---\n\n## Code quality\n\n### Valid HTML\n\n```html\n\u003C!-- ❌ Invalid HTML -->\n\u003Cdiv id=\"header\">\n\u003Cdiv id=\"header\"> \u003C!-- Duplicate ID -->\n\n\u003Cul>\n  \u003Cdiv>Item\u003C\u002Fdiv> \u003C!-- Invalid child -->\n\u003C\u002Ful>\n\n\u003Ca href=\"\u002F\">\u003Cbutton>Click\u003C\u002Fbutton>\u003C\u002Fa> \u003C!-- Invalid nesting -->\n\n\u003C!-- ✅ Valid HTML -->\n\u003Cheader id=\"site-header\">\n\u003C\u002Fheader>\n\n\u003Cul>\n  \u003Cli>Item\u003C\u002Fli>\n\u003C\u002Ful>\n\n\u003Ca href=\"\u002F\" class=\"button\">Click\u003C\u002Fa>\n```\n\n### Semantic HTML\n\n```html\n\u003C!-- ❌ Non-semantic -->\n\u003Cdiv class=\"header\">\n  \u003Cdiv class=\"nav\">\n    \u003Cdiv class=\"nav-item\">Home\u003C\u002Fdiv>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\u003Cdiv class=\"main\">\n  \u003Cdiv class=\"article\">\n    \u003Cdiv class=\"title\">Headline\u003C\u002Fdiv>\n  \u003C\u002Fdiv>\n\u003C\u002Fdiv>\n\n\u003C!-- ✅ Semantic HTML5 -->\n\u003Cheader>\n  \u003Cnav>\n    \u003Ca href=\"\u002F\">Home\u003C\u002Fa>\n  \u003C\u002Fnav>\n\u003C\u002Fheader>\n\u003Cmain>\n  \u003Carticle>\n    \u003Ch1>Headline\u003C\u002Fh1>\n  \u003C\u002Farticle>\n\u003C\u002Fmain>\n```\n\n### Image aspect ratios\n\n```html\n\u003C!-- ❌ Distorted images -->\n\u003Cimg src=\"photo.jpg\" width=\"300\" height=\"100\">\n\u003C!-- If actual ratio is 4:3, this squishes the image -->\n\n\u003C!-- ✅ Preserve aspect ratio -->\n\u003Cimg src=\"photo.jpg\" width=\"300\" height=\"225\">\n\u003C!-- Actual 4:3 dimensions -->\n\n\u003C!-- ✅ CSS object-fit for flexibility -->\n\u003Cimg src=\"photo.jpg\" style=\"width: 300px; height: 200px; object-fit: cover;\">\n```\n\n---\n\n## Permissions & privacy\n\n### Request permissions properly\n\n```javascript\n\u002F\u002F ❌ Request on page load (bad UX, often denied)\nnavigator.geolocation.getCurrentPosition(success, error);\n\n\u002F\u002F ✅ Request in context, after user action\nfindNearbyButton.addEventListener('click', async () => {\n  \u002F\u002F Explain why you need it\n  if (await showPermissionExplanation()) {\n    navigator.geolocation.getCurrentPosition(success, error);\n  }\n});\n```\n\n### Permissions policy\n\n```html\n\u003C!-- Restrict powerful features -->\n\u003Cmeta http-equiv=\"Permissions-Policy\" \n      content=\"geolocation=(), camera=(), microphone=()\">\n\n\u003C!-- Or allow for specific origins -->\n\u003Cmeta http-equiv=\"Permissions-Policy\" \n      content=\"geolocation=(self 'https:\u002F\u002Fmaps.example.com')\">\n```\n\n---\n\n## Audit checklist\n\n### Security (critical)\n- [ ] HTTPS enabled, no mixed content\n- [ ] No vulnerable dependencies (`npm audit`)\n- [ ] CSP headers configured\n- [ ] Security headers present\n- [ ] No exposed source maps\n\n### Compatibility\n- [ ] Valid HTML5 doctype\n- [ ] Charset declared first in head\n- [ ] Viewport meta tag present\n- [ ] No deprecated APIs used\n- [ ] Passive event listeners for scroll\u002Ftouch\n\n### Code quality\n- [ ] No console errors\n- [ ] Valid HTML (no duplicate IDs)\n- [ ] Semantic HTML elements used\n- [ ] Proper error handling\n- [ ] Memory cleanup in components\n\n### UX\n- [ ] No intrusive interstitials\n- [ ] Permission requests in context\n- [ ] Clear error messages\n- [ ] Appropriate image aspect ratios\n\n## Tools\n\n| Tool | Purpose |\n|------|---------|\n| `npm audit` | Dependency vulnerabilities |\n| [SecurityHeaders.com](https:\u002F\u002Fsecurityheaders.com) | Header analysis |\n| [W3C Validator](https:\u002F\u002Fvalidator.w3.org) | HTML validation |\n| Lighthouse | Best practices audit |\n| [Observatory](https:\u002F\u002Fobservatory.mozilla.org) | Security scan |\n\n## References\n\n- [MDN Web Security](https:\u002F\u002Fdeveloper.mozilla.org\u002Fen-US\u002Fdocs\u002FWeb\u002FSecurity)\n- [OWASP Top 10](https:\u002F\u002Fowasp.org\u002Fwww-project-top-ten\u002F)\n- [Web Quality Audit](..\u002Fweb-quality-audit\u002FSKILL.md)\n",{"name":5,"license":15,"metadata":24,"description":7},{"author":25,"version":26},"web-quality-skills","1.0","main","e62d23e713a36a0570f7f5c3ee69868b1131e548","src\u002Fresources\u002Fskills\u002Fbest-practices","https:\u002F\u002Fgithub.com\u002Fcmetech\u002Fotto-cli","https:\u002F\u002Fgithub.com\u002Fcmetech","https:\u002F\u002Fwww.cmetech.io","Corey Ellis is a seasoned data engineer with over 20 years of experience in the field. He is the founder of CME Technologies LLC.","2026-06-17 22:50:56",{"source":8,"skillName":5,"commands":36,"prompt":46,"zipAvailable":47},[37,40,43],{"tool":38,"command":39},"npx","npx skills add cmetech\u002Fotto-cli --skill best-practices",{"tool":41,"command":42},"bunx","bunx skills add cmetech\u002Fotto-cli --skill best-practices",{"tool":44,"command":45},"pnpm","pnpm dlx skills add cmetech\u002Fotto-cli --skill best-practices","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fcmetech\u002Fotto-cli\u002Fblob\u002Fmain\u002Fsrc\u002Fresources\u002Fskills\u002Fbest-practices\u002FSKILL.md",true,[],[50,57,64,71,78,85],{"skillNo":51,"name":52,"nameZh":6,"description":53,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":54,"categories":55,"keywords":56,"publishedAt":19},"01M74PWE6AVSD8RDS1M3Q6TH95","write-milestone-brief","Synthesize the current conversation into a milestone brief (PRD). Writes to `M###-CONTEXT.md` by default, or files a GitHub issue only with explicit user confirmation. Use when asked to \"turn this into a PRD\", \"draft a milestone brief\", \"capture this context\", \"write it up\", or when enough has been discussed to commit the plan to paper. Does not interview — it synthesizes what is already known.","https:\u002F\u002Fgithub.com\u002Fcmetech\u002Fotto-cli\u002Fblob\u002Fmain\u002Fsrc\u002Fresources\u002Fskills\u002Fwrite-milestone-brief\u002FSKILL.md",[],[],{"skillNo":58,"name":59,"nameZh":6,"description":60,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":19},"01M74PWB6CEEQPGS9HRQY4QQPZ","write-docs","Collaborative document authoring workflow for proposals, technical specs, decision docs, README sections, ADRs, and long-form prose that must work for fresh readers. Use when asked to \"write the docs\", \"draft a proposal\", \"write a spec\", \"write an RFC\", \"write the README\", or when a document needs to be understandable by someone without this session's context. Three stages: gather context, iterate on structure, reader-test for a stranger.","https:\u002F\u002Fgithub.com\u002Fcmetech\u002Fotto-cli\u002Fblob\u002Fmain\u002Fsrc\u002Fresources\u002Fskills\u002Fwrite-docs\u002FSKILL.md",[],[],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M74PW7SJQ8H516MDBQ7WV1BN","web-quality-audit","Comprehensive web quality audit covering performance, accessibility, SEO, and best practices. Use when asked to \"audit my site\", \"review web quality\", \"run lighthouse audit\", \"check page quality\", or \"optimize my website\".","https:\u002F\u002Fgithub.com\u002Fcmetech\u002Fotto-cli\u002Fblob\u002Fmain\u002Fsrc\u002Fresources\u002Fskills\u002Fweb-quality-audit\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M74PW5JAA6D34Z8QBN1HQ014","web-design-guidelines","Review UI code for Web Interface Guidelines compliance. Use when asked to \"review my UI\", \"check accessibility\", \"audit design\", \"review UX\", or \"check my site against best practices\".","https:\u002F\u002Fgithub.com\u002Fcmetech\u002Fotto-cli\u002Fblob\u002Fmain\u002Fsrc\u002Fresources\u002Fskills\u002Fweb-design-guidelines\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M74PW1YP2Y03GMDYD443BVHQ","verify-before-complete","Block completion claims until verification evidence has been produced in the current message. Use before marking a task\u002Fslice\u002Fmilestone complete, before creating a commit or PR, before saying \"it works\" or \"tests pass\", and any time you are about to claim work is done. The rule is: evidence before claims, always — running the verification must happen now, not \"earlier in the session\". Fresh output or no claim.","https:\u002F\u002Fgithub.com\u002Fcmetech\u002Fotto-cli\u002Fblob\u002Fmain\u002Fsrc\u002Fresources\u002Fskills\u002Fverify-before-complete\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":19},"01M74PVXR5GE8HE55YWEG7ENBP","userinterface-wiki","UI\u002FUX best practices for web interfaces. Use when reviewing animations, CSS, audio, typography, UX patterns, prefetching, or icon implementations. Covers 11 categories from animation principles to typography. Outputs file:line findings.","https:\u002F\u002Fgithub.com\u002Fcmetech\u002Fotto-cli\u002Fblob\u002Fmain\u002Fsrc\u002Fresources\u002Fskills\u002Fuserinterface-wiki\u002FSKILL.md",[],[]]