mirror of
https://github.com/davila7/claude-code-templates.git
synced 2026-09-19 01:30:23 +08:00
41cbbea00c
- Split components.json: índice sin content (1.9 MB / 249 KB br vs 15.6 MB / 4.15 MB br).
Generador produce component-content/{type}/{slug}.json por componente y auto-copia
a dashboard/public/. Página de detalle carga contenido on-demand via fetchComponentContent().
- Restaurar cabeceras de caché y seguridad perdidas en la migración Vercel→Cloudflare:
_headers con Cache-Control max-age=86400 para JSONs, immutable para _astro/*,
y HSTS, X-Frame-Options, Referrer-Policy, Permissions-Policy en todas las rutas.
- Eliminar dashboard/vercel.json (config muerta desde migración a Cloudflare Pages).
- Diferir hidratación: ClerkIsland y AuthButton client:load → client:idle;
SaveToCollectionButton → client:visible.
- Eliminar gpt-tokenizer del bundle del navegador: reemplazado por estimación chars/4.
- Actualizar .claude/rules/dashboard.md para reflejar hosting en Cloudflare Pages.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 line
4.8 KiB
JSON
1 line
4.8 KiB
JSON
{"content": "{\n \"description\": \"Enforce Next.js best practices, proper file structure, component patterns, and TypeScript usage with automated code reviews and suggestions. Validates Next.js App Router conventions, Server/Client component patterns, proper imports, and TypeScript usage. Provides real-time feedback on code quality and adherence to Next.js best practices.\",\n \"hooks\": {\n \"PostToolUse\": [\n {\n \"matcher\": \"Write|Edit|MultiEdit\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"bash -c 'input=$(cat); FILE_PATH=$(echo \\\"$input\\\" | jq -r \\\".tool_input.file_path // empty\\\"); SUCCESS=$(echo \\\"$input\\\" | jq -r \\\".tool_response.success // false\\\"); if [ \\\"$SUCCESS\\\" = \\\"true\\\" ] && [[ \\\"$FILE_PATH\\\" =~ \\\\.(js|jsx|ts|tsx)$ ]] && [[ ! \\\"$FILE_PATH\\\" =~ node_modules ]]; then echo \\\"🔍 Next.js Code Quality Enforcer: Reviewing $FILE_PATH...\\\"; ISSUES=0; if [ -f \\\"$FILE_PATH\\\" ]; then if [[ \\\"$FILE_PATH\\\" =~ app/.* ]]; then echo \\\"📁 App Router file detected: $FILE_PATH\\\"; if [[ \\\"$FILE_PATH\\\" =~ page\\\\.(js|jsx|ts|tsx)$ ]] && ! grep -q \\\"export default function\\\" \\\"$FILE_PATH\\\" 2>/dev/null && ! grep -q \\\"export default async function\\\" \\\"$FILE_PATH\\\" 2>/dev/null; then echo \\\"❌ Page component must export default function\\\" >&2; ((ISSUES++)); fi; if [[ \\\"$FILE_PATH\\\" =~ layout\\\\.(js|jsx|ts|tsx)$ ]] && ! grep -q \\\"children\\\" \\\"$FILE_PATH\\\" 2>/dev/null; then echo \\\"❌ Layout component should accept children prop\\\" >&2; ((ISSUES++)); fi; if [[ \\\"$FILE_PATH\\\" =~ page\\\\.(js|jsx|ts|tsx)$ ]] && ! grep -q \\\"Metadata\\\" \\\"$FILE_PATH\\\" 2>/dev/null && ! grep -q \\\"metadata\\\" \\\"$FILE_PATH\\\" 2>/dev/null; then echo \\\"⚠️ Consider adding metadata export for SEO\\\"; fi; if grep -q \\\"use client\\\" \\\"$FILE_PATH\\\" 2>/dev/null; then echo \\\"🖥️ Client Component detected\\\"; if ! grep -E \\\"(useState|useEffect|onClick|onChange|onSubmit)\\\" \\\"$FILE_PATH\\\" 2>/dev/null; then echo \\\"⚠️ Client component without interactivity - consider Server Component\\\"; fi; else echo \\\"🚀 Server Component (default)\\\"; if grep -E \\\"(useState|useEffect|onClick|onChange|onSubmit)\\\" \\\"$FILE_PATH\\\" 2>/dev/null; then echo \\\"❌ Interactive features in Server Component - add \\\\\\\"use client\\\\\\\" directive\\\" >&2; ((ISSUES++)); fi; fi; fi; if [[ \\\"$FILE_PATH\\\" =~ \\\\.(jsx|tsx)$ ]]; then if ! grep -q \\\"import.*React\\\" \\\"$FILE_PATH\\\" 2>/dev/null && grep -q \\\"<\\\" \\\"$FILE_PATH\\\" 2>/dev/null; then echo \\\"⚠️ JSX without React import (Next.js 17+ handles this automatically)\\\"; fi; if ! grep -q \\\"FC\\\\|FunctionComponent\\\" \\\"$FILE_PATH\\\" 2>/dev/null && grep -q \\\"props\\\" \\\"$FILE_PATH\\\" 2>/dev/null && [[ \\\"$FILE_PATH\\\" =~ \\\\.tsx$ ]]; then echo \\\"💡 Consider using React.FC or explicit prop types for TypeScript\\\"; fi; fi; if [[ \\\"$FILE_PATH\\\" =~ \\\\.js$ ]] && [ -f \\\"tsconfig.json\\\" ]; then echo \\\"📝 JavaScript file in TypeScript project: $FILE_PATH\\\"; echo \\\"💡 Consider migrating to TypeScript for better type safety\\\"; fi; if grep -q \\\"next/image\\\" \\\"$FILE_PATH\\\" 2>/dev/null; then echo \\\"✅ Using next/image for optimized images\\\"; elif grep -q \\\"<img\\\" \\\"$FILE_PATH\\\" 2>/dev/null; then echo \\\"🖼️ Regular <img> tag detected\\\"; echo \\\"💡 Consider using next/image for better performance\\\"; fi; if grep -q \\\"next/link\\\" \\\"$FILE_PATH\\\" 2>/dev/null; then echo \\\"✅ Using next/link for navigation\\\"; elif grep -q \\\"<a href=\\\" \\\"$FILE_PATH\\\" 2>/dev/null && ! grep -q \\\"http\\\" \\\"$FILE_PATH\\\" 2>/dev/null; then echo \\\"🔗 Regular <a> tag for internal links detected\\\"; echo \\\"💡 Use next/link for internal navigation\\\"; fi; if grep -q \\\"getServerSideProps\\\\|getStaticProps\\\" \\\"$FILE_PATH\\\" 2>/dev/null; then echo \\\"⚠️ Pages Router data fetching methods detected\\\"; echo \\\"💡 Consider migrating to App Router with Server Components\\\"; fi; if grep -q \\\"className=.*{\\\" \\\"$FILE_PATH\\\" 2>/dev/null; then echo \\\"🎨 Dynamic className detected\\\"; if ! grep -q \\\"clsx\\\\|classnames\\\\|cn(\\\" \\\"$FILE_PATH\\\" 2>/dev/null; then echo \\\"💡 Consider using clsx or similar utility for className concatenation\\\"; fi; fi; if [ $ISSUES -eq 0 ]; then echo \\\"✅ Code quality check passed for $FILE_PATH\\\"; else echo \\\"❌ Found $ISSUES code quality issues in $FILE_PATH\\\" >&2; exit 2; fi; else echo \\\"❌ File $FILE_PATH not found\\\"; fi; else echo \\\"ℹ️ Code quality check skipped (not a JavaScript/TypeScript file or failed operation)\\\"; fi'\",\n \"timeout\": 20\n }\n ]\n }\n ]\n }\n}"} |