claudeinone-cli 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +16 -1
- package/kit/.claude/.ck.json +9 -0
- package/kit/.claude/.ckignore +12 -0
- package/kit/.claude/agents/accessibility-auditor.md +46 -0
- package/kit/.claude/agents/api-designer.md +43 -0
- package/kit/.claude/agents/backend-developer.md +54 -0
- package/kit/.claude/agents/brainstormer.md +33 -0
- package/kit/.claude/agents/campaign-manager.md +36 -0
- package/kit/.claude/agents/code-reviewer.md +39 -0
- package/kit/.claude/agents/content-creator.md +38 -0
- package/kit/.claude/agents/copywriter.md +42 -0
- package/kit/.claude/agents/database-admin.md +37 -0
- package/kit/.claude/agents/debugger.md +46 -0
- package/kit/.claude/agents/devops-engineer.md +41 -0
- package/kit/.claude/agents/docs-manager.md +33 -0
- package/kit/.claude/agents/email-wizard.md +40 -0
- package/kit/.claude/agents/frontend-developer.md +52 -0
- package/kit/.claude/agents/fullstack-developer.md +55 -0
- package/kit/.claude/agents/git-manager.md +40 -0
- package/kit/.claude/agents/i18n-specialist.md +46 -0
- package/kit/.claude/agents/integration-specialist.md +48 -0
- package/kit/.claude/agents/journal-writer.md +39 -0
- package/kit/.claude/agents/mcp-manager.md +57 -0
- package/kit/.claude/agents/mobile-developer.md +38 -0
- package/kit/.claude/agents/performance-optimizer.md +38 -0
- package/kit/.claude/agents/planner.md +56 -0
- package/kit/.claude/agents/project-manager.md +34 -0
- package/kit/.claude/agents/refactorer.md +43 -0
- package/kit/.claude/agents/researcher.md +45 -0
- package/kit/.claude/agents/risk-analyst.md +33 -0
- package/kit/.claude/agents/scalability-consultant.md +39 -0
- package/kit/.claude/agents/scout.md +25 -0
- package/kit/.claude/agents/security-auditor.md +42 -0
- package/kit/.claude/agents/seo-specialist.md +44 -0
- package/kit/.claude/agents/skill-creator.md +64 -0
- package/kit/.claude/agents/social-media-manager.md +35 -0
- package/kit/.claude/agents/systems-designer.md +35 -0
- package/kit/.claude/agents/technology-strategist.md +43 -0
- package/kit/.claude/agents/tester.md +40 -0
- package/kit/.claude/agents/ui-ux-designer.md +40 -0
- package/kit/.claude/commands/co/ask.md +29 -0
- package/kit/.claude/commands/co/bootstrap-auto-fast.md +28 -0
- package/kit/.claude/commands/co/bootstrap-auto-parallel.md +29 -0
- package/kit/.claude/commands/co/bootstrap-auto.md +30 -0
- package/kit/.claude/commands/co/bootstrap.md +31 -0
- package/kit/.claude/commands/co/brainstorm.md +27 -0
- package/kit/.claude/commands/co/campaign.md +28 -0
- package/kit/.claude/commands/co/changelog.md +25 -0
- package/kit/.claude/commands/co/checkpoint.md +25 -0
- package/kit/.claude/commands/co/ci.md +26 -0
- package/kit/.claude/commands/co/ck-help.md +24 -0
- package/kit/.claude/commands/co/coding-level.md +24 -0
- package/kit/.claude/commands/co/content-cro.md +26 -0
- package/kit/.claude/commands/co/content-enhance.md +26 -0
- package/kit/.claude/commands/co/content-fast.md +24 -0
- package/kit/.claude/commands/co/content-good.md +26 -0
- package/kit/.claude/commands/co/cook.md +33 -0
- package/kit/.claude/commands/co/debug.md +26 -0
- package/kit/.claude/commands/co/deploy.md +25 -0
- package/kit/.claude/commands/co/design-3d.md +27 -0
- package/kit/.claude/commands/co/design-describe.md +25 -0
- package/kit/.claude/commands/co/design-fast.md +25 -0
- package/kit/.claude/commands/co/design-good.md +28 -0
- package/kit/.claude/commands/co/design-screenshot.md +26 -0
- package/kit/.claude/commands/co/design-video.md +26 -0
- package/kit/.claude/commands/co/docker.md +24 -0
- package/kit/.claude/commands/co/docs-api.md +25 -0
- package/kit/.claude/commands/co/docs-init.md +26 -0
- package/kit/.claude/commands/co/docs-readme.md +24 -0
- package/kit/.claude/commands/co/docs-summarize.md +25 -0
- package/kit/.claude/commands/co/docs-update.md +25 -0
- package/kit/.claude/commands/co/env-check.md +25 -0
- package/kit/.claude/commands/co/fix-ci.md +29 -0
- package/kit/.claude/commands/co/fix-fast.md +28 -0
- package/kit/.claude/commands/co/fix-hard.md +33 -0
- package/kit/.claude/commands/co/fix-logs.md +28 -0
- package/kit/.claude/commands/co/fix-types.md +28 -0
- package/kit/.claude/commands/co/fix-ui.md +28 -0
- package/kit/.claude/commands/co/fix.md +27 -0
- package/kit/.claude/commands/co/git-cm.md +26 -0
- package/kit/.claude/commands/co/git-cp.md +26 -0
- package/kit/.claude/commands/co/git-pr.md +26 -0
- package/kit/.claude/commands/co/index.md +24 -0
- package/kit/.claude/commands/co/integrate-polar.md +29 -0
- package/kit/.claude/commands/co/integrate-sepay.md +29 -0
- package/kit/.claude/commands/co/journal.md +27 -0
- package/kit/.claude/commands/co/k8s.md +24 -0
- package/kit/.claude/commands/co/kanban.md +25 -0
- package/kit/.claude/commands/co/lint-fix.md +24 -0
- package/kit/.claude/commands/co/load.md +25 -0
- package/kit/.claude/commands/co/migrate.md +28 -0
- package/kit/.claude/commands/co/mock.md +26 -0
- package/kit/.claude/commands/co/mode.md +24 -0
- package/kit/.claude/commands/co/monitor.md +25 -0
- package/kit/.claude/commands/co/new-feature.md +27 -0
- package/kit/.claude/commands/co/optimize.md +26 -0
- package/kit/.claude/commands/co/plan-archive.md +24 -0
- package/kit/.claude/commands/co/plan-ci.md +28 -0
- package/kit/.claude/commands/co/plan-cro.md +27 -0
- package/kit/.claude/commands/co/plan-fast.md +24 -0
- package/kit/.claude/commands/co/plan-hard.md +27 -0
- package/kit/.claude/commands/co/plan-parallel.md +25 -0
- package/kit/.claude/commands/co/plan-two.md +29 -0
- package/kit/.claude/commands/co/plan-validate.md +27 -0
- package/kit/.claude/commands/co/plan.md +27 -0
- package/kit/.claude/commands/co/pr.md +25 -0
- package/kit/.claude/commands/co/preview.md +26 -0
- package/kit/.claude/commands/co/refactor.md +25 -0
- package/kit/.claude/commands/co/release.md +25 -0
- package/kit/.claude/commands/co/review-a11y.md +24 -0
- package/kit/.claude/commands/co/review-codebase-parallel.md +27 -0
- package/kit/.claude/commands/co/review-codebase.md +27 -0
- package/kit/.claude/commands/co/review-perf.md +24 -0
- package/kit/.claude/commands/co/review-security.md +25 -0
- package/kit/.claude/commands/co/scaffold.md +25 -0
- package/kit/.claude/commands/co/scout.md +26 -0
- package/kit/.claude/commands/co/secure.md +26 -0
- package/kit/.claude/commands/co/seed.md +25 -0
- package/kit/.claude/commands/co/seo-audit.md +24 -0
- package/kit/.claude/commands/co/seo-keywords.md +25 -0
- package/kit/.claude/commands/co/skill-create.md +29 -0
- package/kit/.claude/commands/co/skill-fix-logs.md +28 -0
- package/kit/.claude/commands/co/slide-create.md +24 -0
- package/kit/.claude/commands/co/spawn.md +24 -0
- package/kit/.claude/commands/co/terraform.md +24 -0
- package/kit/.claude/commands/co/test-gen.md +24 -0
- package/kit/.claude/commands/co/test-ui.md +27 -0
- package/kit/.claude/commands/co/test.md +26 -0
- package/kit/.claude/commands/co/use-mcp.md +25 -0
- package/kit/.claude/commands/co/video-script.md +25 -0
- package/kit/.claude/commands/co/watzup.md +25 -0
- package/kit/.claude/commands/co/worktree.md +25 -0
- package/kit/.claude/commands/co/write-blog.md +25 -0
- package/kit/.claude/commands/co/write-copy.md +24 -0
- package/kit/.claude/commands/co/write-email.md +25 -0
- package/kit/.claude/commands/content/content-cro.md +26 -0
- package/kit/.claude/commands/content/content-enhance.md +26 -0
- package/kit/.claude/commands/content/content-fast.md +24 -0
- package/kit/.claude/commands/content/content-good.md +26 -0
- package/kit/.claude/commands/content/enhance.md +26 -0
- package/kit/.claude/commands/content/good.md +26 -0
- package/kit/.claude/commands/core/ask.md +29 -0
- package/kit/.claude/commands/core/bootstrap-auto-fast.md +28 -0
- package/kit/.claude/commands/core/bootstrap-auto-parallel.md +29 -0
- package/kit/.claude/commands/core/bootstrap-auto.md +30 -0
- package/kit/.claude/commands/core/bootstrap.md +31 -0
- package/kit/.claude/commands/core/ck-help.md +24 -0
- package/kit/.claude/commands/core/coding-level.md +24 -0
- package/kit/.claude/commands/core/cook.md +33 -0
- package/kit/.claude/commands/core/debug.md +26 -0
- package/kit/.claude/commands/core/journal.md +27 -0
- package/kit/.claude/commands/core/kanban.md +25 -0
- package/kit/.claude/commands/core/preview.md +26 -0
- package/kit/.claude/commands/core/scout.md +26 -0
- package/kit/.claude/commands/core/test-ui.md +27 -0
- package/kit/.claude/commands/core/test.md +26 -0
- package/kit/.claude/commands/core/use-mcp.md +25 -0
- package/kit/.claude/commands/core/watzup.md +25 -0
- package/kit/.claude/commands/core/worktree.md +25 -0
- package/kit/.claude/commands/design/3d.md +27 -0
- package/kit/.claude/commands/design/design-3d.md +27 -0
- package/kit/.claude/commands/design/design-describe.md +25 -0
- package/kit/.claude/commands/design/design-fast.md +25 -0
- package/kit/.claude/commands/design/design-good.md +28 -0
- package/kit/.claude/commands/design/design-screenshot.md +26 -0
- package/kit/.claude/commands/design/design-video.md +26 -0
- package/kit/.claude/commands/design/good.md +28 -0
- package/kit/.claude/commands/design/video.md +26 -0
- package/kit/.claude/commands/docs/docs-init.md +26 -0
- package/kit/.claude/commands/docs/docs-summarize.md +25 -0
- package/kit/.claude/commands/docs/docs-update.md +25 -0
- package/kit/.claude/commands/docs/init.md +26 -0
- package/kit/.claude/commands/docs/summarize.md +25 -0
- package/kit/.claude/commands/fix/ci.md +29 -0
- package/kit/.claude/commands/fix/fast.md +28 -0
- package/kit/.claude/commands/fix/fix-ci.md +29 -0
- package/kit/.claude/commands/fix/fix-fast.md +28 -0
- package/kit/.claude/commands/fix/fix-hard.md +33 -0
- package/kit/.claude/commands/fix/fix-logs.md +28 -0
- package/kit/.claude/commands/fix/fix-types.md +28 -0
- package/kit/.claude/commands/fix/fix-ui.md +28 -0
- package/kit/.claude/commands/fix/hard.md +33 -0
- package/kit/.claude/commands/fix/logs.md +28 -0
- package/kit/.claude/commands/fix/types.md +28 -0
- package/kit/.claude/commands/fix/ui.md +28 -0
- package/kit/.claude/commands/git/cp.md +26 -0
- package/kit/.claude/commands/git/git-cm.md +26 -0
- package/kit/.claude/commands/git/git-cp.md +26 -0
- package/kit/.claude/commands/git/git-pr.md +26 -0
- package/kit/.claude/commands/integrate/integrate-polar.md +29 -0
- package/kit/.claude/commands/integrate/integrate-sepay.md +29 -0
- package/kit/.claude/commands/integrate/sepay.md +29 -0
- package/kit/.claude/commands/plan/ci.md +28 -0
- package/kit/.claude/commands/plan/cro.md +27 -0
- package/kit/.claude/commands/plan/hard.md +27 -0
- package/kit/.claude/commands/plan/plan-archive.md +24 -0
- package/kit/.claude/commands/plan/plan-ci.md +28 -0
- package/kit/.claude/commands/plan/plan-cro.md +27 -0
- package/kit/.claude/commands/plan/plan-fast.md +24 -0
- package/kit/.claude/commands/plan/plan-hard.md +27 -0
- package/kit/.claude/commands/plan/plan-parallel.md +25 -0
- package/kit/.claude/commands/plan/plan-two.md +29 -0
- package/kit/.claude/commands/plan/plan-validate.md +27 -0
- package/kit/.claude/commands/plan/plan.md +27 -0
- package/kit/.claude/commands/plan/validate.md +27 -0
- package/kit/.claude/commands/skill/fix-logs.md +28 -0
- package/kit/.claude/commands/skill/skill-create.md +29 -0
- package/kit/.claude/commands/skill/skill-fix-logs.md +28 -0
- package/kit/.claude/settings.json +16 -0
- package/kit/.claude/skills/ai-anthropic.md +100 -0
- package/kit/.claude/skills/ai-context-engineering.md +113 -0
- package/kit/.claude/skills/ai-gemini.md +152 -0
- package/kit/.claude/skills/ai-langchain.md +93 -0
- package/kit/.claude/skills/ai-llamaindex.md +179 -0
- package/kit/.claude/skills/ai-mcp-builder.md +101 -0
- package/kit/.claude/skills/ai-openai.md +250 -0
- package/kit/.claude/skills/ai-prompt-engineering.md +173 -0
- package/kit/.claude/skills/ai-rag.md +91 -0
- package/kit/.claude/skills/ai-vectordb.md +215 -0
- package/kit/.claude/skills/analytics-segment.md +161 -0
- package/kit/.claude/skills/api-caching.md +103 -0
- package/kit/.claude/skills/api-documentation.md +50 -0
- package/kit/.claude/skills/api-graphql.md +234 -0
- package/kit/.claude/skills/api-openapi.md +116 -0
- package/kit/.claude/skills/api-pagination-filtering.md +239 -0
- package/kit/.claude/skills/api-rate-limiting.md +179 -0
- package/kit/.claude/skills/api-rest-advanced.md +50 -0
- package/kit/.claude/skills/api-rest.md +217 -0
- package/kit/.claude/skills/api-trpc.md +173 -0
- package/kit/.claude/skills/api-versioning.md +70 -0
- package/kit/.claude/skills/api-webhooks.md +226 -0
- package/kit/.claude/skills/arch-clean-code.md +226 -0
- package/kit/.claude/skills/arch-clean.md +91 -0
- package/kit/.claude/skills/arch-cqrs.md +229 -0
- package/kit/.claude/skills/arch-ddd.md +85 -0
- package/kit/.claude/skills/arch-event-driven.md +189 -0
- package/kit/.claude/skills/arch-microservices.md +80 -0
- package/kit/.claude/skills/arch-monorepo.md +87 -0
- package/kit/.claude/skills/arch-multi-tenant.md +81 -0
- package/kit/.claude/skills/arch-serverless.md +86 -0
- package/kit/.claude/skills/auth-clerk.md +97 -0
- package/kit/.claude/skills/auth-jwt.md +143 -0
- package/kit/.claude/skills/auth-lucia.md +93 -0
- package/kit/.claude/skills/auth-nextauth.md +446 -0
- package/kit/.claude/skills/auth-oauth.md +208 -0
- package/kit/.claude/skills/auth-oauth2.md +110 -0
- package/kit/.claude/skills/auth-passkeys.md +109 -0
- package/kit/.claude/skills/auth-session.md +88 -0
- package/kit/.claude/skills/backend-dotnet.md +414 -0
- package/kit/.claude/skills/backend-express.md +129 -0
- package/kit/.claude/skills/backend-fastify.md +104 -0
- package/kit/.claude/skills/backend-go.md +205 -0
- package/kit/.claude/skills/backend-graphql.md +149 -0
- package/kit/.claude/skills/backend-grpc.md +382 -0
- package/kit/.claude/skills/backend-hono.md +95 -0
- package/kit/.claude/skills/backend-java-spring.md +198 -0
- package/kit/.claude/skills/backend-nodejs-express.md +165 -0
- package/kit/.claude/skills/backend-nodejs.md +143 -0
- package/kit/.claude/skills/backend-php-laravel.md +156 -0
- package/kit/.claude/skills/backend-python-django.md +200 -0
- package/kit/.claude/skills/backend-python-fastapi.md +169 -0
- package/kit/.claude/skills/backend-ruby-rails.md +190 -0
- package/kit/.claude/skills/backend-rust.md +182 -0
- package/kit/.claude/skills/backend-websockets.md +392 -0
- package/kit/.claude/skills/cache-redis.md +195 -0
- package/kit/.claude/skills/caching-strategies.md +100 -0
- package/kit/.claude/skills/cloud-aws.md +165 -0
- package/kit/.claude/skills/cloud-azure.md +187 -0
- package/kit/.claude/skills/cloud-cloudflare.md +74 -0
- package/kit/.claude/skills/cloud-fly.md +94 -0
- package/kit/.claude/skills/cloud-gcp.md +160 -0
- package/kit/.claude/skills/cloud-railway.md +92 -0
- package/kit/.claude/skills/cloud-render.md +70 -0
- package/kit/.claude/skills/cloud-serverless.md +68 -0
- package/kit/.claude/skills/cloud-vercel.md +76 -0
- package/kit/.claude/skills/component-patterns.md +50 -0
- package/kit/.claude/skills/content-management.md +197 -0
- package/kit/.claude/skills/cors-security.md +50 -0
- package/kit/.claude/skills/data-csv-excel.md +210 -0
- package/kit/.claude/skills/database-optimization.md +196 -0
- package/kit/.claude/skills/databases-transactions.md +68 -0
- package/kit/.claude/skills/db-cassandra.md +89 -0
- package/kit/.claude/skills/db-drizzle.md +363 -0
- package/kit/.claude/skills/db-dynamodb.md +83 -0
- package/kit/.claude/skills/db-elasticsearch.md +105 -0
- package/kit/.claude/skills/db-firebase-firestore.md +191 -0
- package/kit/.claude/skills/db-mongodb.md +198 -0
- package/kit/.claude/skills/db-mysql.md +50 -0
- package/kit/.claude/skills/db-neon.md +72 -0
- package/kit/.claude/skills/db-planetscale.md +76 -0
- package/kit/.claude/skills/db-postgresql.md +50 -0
- package/kit/.claude/skills/db-prisma.md +414 -0
- package/kit/.claude/skills/db-redis.md +50 -0
- package/kit/.claude/skills/db-sqlite.md +149 -0
- package/kit/.claude/skills/db-supabase.md +445 -0
- package/kit/.claude/skills/devops-ci-cd.md +271 -0
- package/kit/.claude/skills/devops-database-backup.md +77 -0
- package/kit/.claude/skills/devops-docker.md +93 -0
- package/kit/.claude/skills/devops-github-actions.md +82 -0
- package/kit/.claude/skills/devops-health-checks.md +50 -0
- package/kit/.claude/skills/devops-kubernetes.md +109 -0
- package/kit/.claude/skills/devops-logging.md +163 -0
- package/kit/.claude/skills/devops-monitoring.md +203 -0
- package/kit/.claude/skills/devops-pulumi.md +94 -0
- package/kit/.claude/skills/devops-secrets.md +166 -0
- package/kit/.claude/skills/devops-terraform.md +226 -0
- package/kit/.claude/skills/error-boundaries.md +84 -0
- package/kit/.claude/skills/file-storage.md +50 -0
- package/kit/.claude/skills/frontend-angular.md +104 -0
- package/kit/.claude/skills/frontend-astro.md +94 -0
- package/kit/.claude/skills/frontend-bundle-analysis.md +147 -0
- package/kit/.claude/skills/frontend-forms.md +134 -0
- package/kit/.claude/skills/frontend-htmx.md +86 -0
- package/kit/.claude/skills/frontend-nextjs.md +188 -0
- package/kit/.claude/skills/frontend-pwa.md +105 -0
- package/kit/.claude/skills/frontend-react-hooks.md +238 -0
- package/kit/.claude/skills/frontend-react.md +129 -0
- package/kit/.claude/skills/frontend-remix-advanced.md +106 -0
- package/kit/.claude/skills/frontend-remix.md +101 -0
- package/kit/.claude/skills/frontend-solid.md +99 -0
- package/kit/.claude/skills/frontend-state-management.md +134 -0
- package/kit/.claude/skills/frontend-state.md +106 -0
- package/kit/.claude/skills/frontend-svelte.md +121 -0
- package/kit/.claude/skills/frontend-testing.md +100 -0
- package/kit/.claude/skills/frontend-vite.md +94 -0
- package/kit/.claude/skills/frontend-vue.md +133 -0
- package/kit/.claude/skills/frontend-webpack.md +93 -0
- package/kit/.claude/skills/functional-programming.md +50 -0
- package/kit/.claude/skills/hooks-custom.md +50 -0
- package/kit/.claude/skills/http-server.md +50 -0
- package/kit/.claude/skills/i18n-general.md +89 -0
- package/kit/.claude/skills/i18n-localization.md +191 -0
- package/kit/.claude/skills/i18n-nextjs.md +127 -0
- package/kit/.claude/skills/infrastructure-docker-compose.md +77 -0
- package/kit/.claude/skills/infrastructure-serverless.md +177 -0
- package/kit/.claude/skills/jwt-tokens.md +50 -0
- package/kit/.claude/skills/logging-winston.md +106 -0
- package/kit/.claude/skills/messaging-kafka.md +102 -0
- package/kit/.claude/skills/messaging-rabbitmq.md +50 -0
- package/kit/.claude/skills/mobile-capacitor.md +109 -0
- package/kit/.claude/skills/mobile-expo.md +101 -0
- package/kit/.claude/skills/mobile-flutter.md +259 -0
- package/kit/.claude/skills/mobile-react-native.md +238 -0
- package/kit/.claude/skills/monitoring-apm.md +50 -0
- package/kit/.claude/skills/monitoring-error-tracking.md +217 -0
- package/kit/.claude/skills/nodejs-streams.md +168 -0
- package/kit/.claude/skills/oauth-integration.md +50 -0
- package/kit/.claude/skills/patterns-dependency-injection.md +218 -0
- package/kit/.claude/skills/patterns-factory-singleton.md +209 -0
- package/kit/.claude/skills/patterns-observer-pubsub.md +210 -0
- package/kit/.claude/skills/payment-lemonsqueezy.md +101 -0
- package/kit/.claude/skills/payment-square.md +178 -0
- package/kit/.claude/skills/payment-stripe.md +206 -0
- package/kit/.claude/skills/perf-bundle.md +100 -0
- package/kit/.claude/skills/perf-web-vitals.md +102 -0
- package/kit/.claude/skills/performance-database-connection-pooling.md +67 -0
- package/kit/.claude/skills/performance-metrics.md +73 -0
- package/kit/.claude/skills/performance-optimization.md +208 -0
- package/kit/.claude/skills/performance-web-vitals.md +169 -0
- package/kit/.claude/skills/rate-limiting.md +77 -0
- package/kit/.claude/skills/reactive-programming.md +50 -0
- package/kit/.claude/skills/realtime-database.md +50 -0
- package/kit/.claude/skills/realtime-subscriptions.md +218 -0
- package/kit/.claude/skills/saas-ab-testing.md +90 -0
- package/kit/.claude/skills/saas-analytics.md +113 -0
- package/kit/.claude/skills/saas-billing.md +106 -0
- package/kit/.claude/skills/saas-email.md +88 -0
- package/kit/.claude/skills/saas-feature-flags.md +83 -0
- package/kit/.claude/skills/saas-onboarding.md +96 -0
- package/kit/.claude/skills/saas-user-onboarding.md +207 -0
- package/kit/.claude/skills/security-encryption.md +216 -0
- package/kit/.claude/skills/security-owasp.md +212 -0
- package/kit/.claude/skills/security-secrets-rotation.md +64 -0
- package/kit/.claude/skills/seo-content.md +94 -0
- package/kit/.claude/skills/seo-technical.md +101 -0
- package/kit/.claude/skills/serverless-framework.md +151 -0
- package/kit/.claude/skills/sharding-scaling.md +50 -0
- package/kit/.claude/skills/styling-css-modules.md +219 -0
- package/kit/.claude/skills/styling-styled-components.md +206 -0
- package/kit/.claude/skills/styling-tailwind.md +206 -0
- package/kit/.claude/skills/test-e2e.md +86 -0
- package/kit/.claude/skills/test-integration.md +216 -0
- package/kit/.claude/skills/test-performance.md +162 -0
- package/kit/.claude/skills/test-tdd.md +170 -0
- package/kit/.claude/skills/test-unit.md +301 -0
- package/kit/.claude/skills/testing-accessibility.md +117 -0
- package/kit/.claude/skills/testing-contract.md +75 -0
- package/kit/.claude/skills/testing-e2e-advanced.md +50 -0
- package/kit/.claude/skills/testing-load-stress.md +79 -0
- package/kit/.claude/skills/testing-mutation.md +92 -0
- package/kit/.claude/skills/testing-snapshot.md +50 -0
- package/kit/.claude/skills/testing-vitest.md +172 -0
- package/kit/.claude/skills/tooling-biome.md +91 -0
- package/kit/.claude/skills/tooling-build-tools.md +166 -0
- package/kit/.claude/skills/tooling-bun.md +94 -0
- package/kit/.claude/skills/tooling-eslint.md +103 -0
- package/kit/.claude/skills/tooling-git.md +79 -0
- package/kit/.claude/skills/tooling-monorepo.md +162 -0
- package/kit/.claude/skills/tooling-testing-frameworks.md +207 -0
- package/kit/.claude/skills/tooling-typescript.md +156 -0
- package/kit/.claude/skills/ui-a11y.md +106 -0
- package/kit/.claude/skills/ui-framer.md +106 -0
- package/kit/.claude/skills/ui-gsap.md +102 -0
- package/kit/.claude/skills/ui-radix.md +82 -0
- package/kit/.claude/skills/ui-shadcn.md +463 -0
- package/kit/.claude/skills/ui-tailwind.md +98 -0
- package/kit/.claude/skills/ui-threejs.md +110 -0
- package/kit/.claude/skills/ui-tokens.md +97 -0
- package/kit/.claude/skills/utilities-date-time.md +170 -0
- package/kit/.claude/skills/validation-schemas.md +110 -0
- package/kit/.claude/skills/version-control-git.md +144 -0
- package/kit/.claude/skills/web-accessibility-wcag.md +102 -0
- package/kit/.claude/skills/web-astro.md +197 -0
- package/kit/.claude/skills/web-html-css.md +224 -0
- package/kit/.claude/skills/web-htmx.md +99 -0
- package/kit/.claude/skills/web-nextjs-advanced.md +202 -0
- package/kit/.claude/skills/web-remix.md +194 -0
- package/kit/.claude/skills/web-seo.md +99 -0
- package/kit/.claude/skills/web-svelte.md +234 -0
- package/kit/.claude/skills/websocket-server.md +50 -0
- package/kit/.claude/skills/writing-marketing.md +89 -0
- package/kit/.claude/skills/writing-technical.md +119 -0
- package/kit/CLAUDE.md +206 -0
- package/kit/README.md +150 -0
- package/kit/SKILLS_INDEX.md +188 -0
- package/kit/docs/README.md +3 -0
- package/kit/journals/README.md +3 -0
- package/kit/plans/README.md +3 -0
- package/package.json +3 -1
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# Next.js 15+
|
|
2
|
+
|
|
3
|
+
Full-stack React framework with App Router, Server Actions, and server-side rendering.
|
|
4
|
+
|
|
5
|
+
## App Router Fundamentals
|
|
6
|
+
|
|
7
|
+
### File Structure
|
|
8
|
+
```
|
|
9
|
+
app/
|
|
10
|
+
├── layout.tsx # Root layout (wraps all pages)
|
|
11
|
+
├── page.tsx # Home page (/)
|
|
12
|
+
├── dashboard/
|
|
13
|
+
│ ├── layout.tsx # Dashboard layout (wraps dashboard pages)
|
|
14
|
+
│ ├── page.tsx # /dashboard
|
|
15
|
+
│ └── [id]/
|
|
16
|
+
│ └── page.tsx # /dashboard/[id] (dynamic route)
|
|
17
|
+
├── api/
|
|
18
|
+
│ └── users/
|
|
19
|
+
│ └── route.ts # POST /api/users
|
|
20
|
+
└── (auth)/
|
|
21
|
+
└── login/
|
|
22
|
+
└── page.tsx # /login (grouped route, no URL segment)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Layouts & Nesting
|
|
26
|
+
```typescript
|
|
27
|
+
// app/layout.tsx
|
|
28
|
+
export default function RootLayout({ children }) {
|
|
29
|
+
return (
|
|
30
|
+
<html>
|
|
31
|
+
<body>{children}</body>
|
|
32
|
+
</html>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Layouts don't re-render on navigation, only children do
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Server Components (Default)
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
// Components are server components by default in App Router
|
|
43
|
+
export default async function Page() {
|
|
44
|
+
const data = await fetch('https://api.example.com/data');
|
|
45
|
+
return <div>{data}</div>;
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Benefits:**
|
|
50
|
+
- Access databases directly (no API needed)
|
|
51
|
+
- Keep API keys server-side
|
|
52
|
+
- Reduce JavaScript sent to client
|
|
53
|
+
- Improved performance and SEO
|
|
54
|
+
|
|
55
|
+
## Client Components
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
'use client'; // Directive at top of file
|
|
59
|
+
|
|
60
|
+
import { useState } from 'react';
|
|
61
|
+
|
|
62
|
+
export default function Counter() {
|
|
63
|
+
const [count, setCount] = useState(0);
|
|
64
|
+
return <button onClick={() => setCount(c => c + 1)}>{count}</button>;
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Use when you need:
|
|
69
|
+
- State management (useState, useReducer)
|
|
70
|
+
- Lifecycle hooks (useEffect)
|
|
71
|
+
- Event listeners
|
|
72
|
+
- Browser APIs
|
|
73
|
+
|
|
74
|
+
## Server Actions
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
// app/actions.ts
|
|
78
|
+
'use server';
|
|
79
|
+
|
|
80
|
+
export async function updateUser(formData: FormData) {
|
|
81
|
+
const name = formData.get('name');
|
|
82
|
+
// Access database directly, no API endpoint needed
|
|
83
|
+
const user = await db.user.update({ name });
|
|
84
|
+
revalidatePath('/'); // Revalidate cache after mutation
|
|
85
|
+
return user;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// In component
|
|
89
|
+
'use client';
|
|
90
|
+
import { updateUser } from './actions';
|
|
91
|
+
|
|
92
|
+
export default function Form() {
|
|
93
|
+
return (
|
|
94
|
+
<form action={updateUser}>
|
|
95
|
+
<input name="name" />
|
|
96
|
+
<button type="submit">Save</button>
|
|
97
|
+
</form>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Data Fetching Patterns
|
|
103
|
+
|
|
104
|
+
### Server Components
|
|
105
|
+
```typescript
|
|
106
|
+
// Direct fetch in server component
|
|
107
|
+
async function Posts() {
|
|
108
|
+
const posts = await fetch('...', { next: { revalidate: 3600 } });
|
|
109
|
+
return <PostList posts={posts} />;
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Caching Strategies
|
|
114
|
+
- **Default (Full Cache)**: GET requests cached indefinitely
|
|
115
|
+
- **Revalidate Time**: `revalidate: 3600` (revalidate after 1 hour)
|
|
116
|
+
- **Revalidate On Demand**: `revalidatePath('/blog')` in Server Actions
|
|
117
|
+
- **No Cache**: `cache: 'no-store'`
|
|
118
|
+
|
|
119
|
+
### API Routes
|
|
120
|
+
```typescript
|
|
121
|
+
// app/api/users/route.ts
|
|
122
|
+
export async function GET(request: Request) {
|
|
123
|
+
const data = await db.user.list();
|
|
124
|
+
return Response.json(data);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export async function POST(request: Request) {
|
|
128
|
+
const body = await request.json();
|
|
129
|
+
const user = await db.user.create(body);
|
|
130
|
+
return Response.json(user, { status: 201 });
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Dynamic Routes
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
// app/blog/[slug]/page.tsx
|
|
138
|
+
export async function generateStaticParams() {
|
|
139
|
+
const posts = await db.post.findAll();
|
|
140
|
+
return posts.map(p => ({ slug: p.slug }));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export default function Post({ params }: { params: { slug: string } }) {
|
|
144
|
+
return <h1>{params.slug}</h1>;
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Image Optimization
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
import Image from 'next/image';
|
|
152
|
+
|
|
153
|
+
export default function Hero() {
|
|
154
|
+
return (
|
|
155
|
+
<Image
|
|
156
|
+
src="/hero.jpg"
|
|
157
|
+
alt="Hero"
|
|
158
|
+
width={1200}
|
|
159
|
+
height={600}
|
|
160
|
+
priority // Load immediately (LCP image)
|
|
161
|
+
/>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Performance Features
|
|
167
|
+
|
|
168
|
+
- **Automatic code splitting**: Each route only loads necessary code
|
|
169
|
+
- **Prefetching**: Links prefetch on hover/visibility
|
|
170
|
+
- **Font optimization**: Self-hosted fonts, automatic loading
|
|
171
|
+
- **Image optimization**: Responsive images, modern formats
|
|
172
|
+
- **CSS-in-JS**: Zero-runtime CSS with built-in support
|
|
173
|
+
|
|
174
|
+
## Best Practices
|
|
175
|
+
|
|
176
|
+
1. **Use Server Components by default** - only add 'use client' when needed
|
|
177
|
+
2. **Fetch in Server Components** - eliminates API layer for internal data
|
|
178
|
+
3. **Revalidate cache thoughtfully** - balance freshness with performance
|
|
179
|
+
4. **Organize routes logically** - group related pages with layouts
|
|
180
|
+
5. **Optimize images** - use next/image, responsive sizes
|
|
181
|
+
6. **Handle errors** - create error.tsx and not-found.tsx files
|
|
182
|
+
7. **Use Server Actions** for mutations - cleaner than form submissions
|
|
183
|
+
|
|
184
|
+
## Resources
|
|
185
|
+
|
|
186
|
+
- [Next.js App Router Docs](https://nextjs.org/docs/app)
|
|
187
|
+
- [Server Actions RFC](https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions)
|
|
188
|
+
- [Image Optimization](https://nextjs.org/docs/app/building-your-application/optimizing/images)
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Progressive Web Apps (PWA)
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
PWAs use service workers, web manifests, and modern browser APIs to deliver app-like experiences on the web.
|
|
5
|
+
|
|
6
|
+
## Web App Manifest
|
|
7
|
+
|
|
8
|
+
```json
|
|
9
|
+
// public/manifest.json
|
|
10
|
+
{
|
|
11
|
+
"name": "My App",
|
|
12
|
+
"short_name": "MyApp",
|
|
13
|
+
"description": "A progressive web app",
|
|
14
|
+
"start_url": "/",
|
|
15
|
+
"display": "standalone",
|
|
16
|
+
"background_color": "#ffffff",
|
|
17
|
+
"theme_color": "#000000",
|
|
18
|
+
"icons": [
|
|
19
|
+
{ "src": "/icons/icon-192.png", "sizes": "192x192", "type": "image/png" },
|
|
20
|
+
{ "src": "/icons/icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "any maskable" }
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```html
|
|
26
|
+
<link rel="manifest" href="/manifest.json" />
|
|
27
|
+
<meta name="theme-color" content="#000000" />
|
|
28
|
+
<meta name="apple-mobile-web-app-capable" content="yes" />
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Service Worker (Cache-First)
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
// public/sw.js
|
|
35
|
+
const CACHE_NAME = 'myapp-v1';
|
|
36
|
+
const STATIC_ASSETS = ['/', '/offline.html', '/styles.css'];
|
|
37
|
+
|
|
38
|
+
self.addEventListener('install', (event: ExtendableEvent) => {
|
|
39
|
+
event.waitUntil(
|
|
40
|
+
caches.open(CACHE_NAME).then(cache => cache.addAll(STATIC_ASSETS))
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
self.addEventListener('fetch', (event: FetchEvent) => {
|
|
45
|
+
event.respondWith(
|
|
46
|
+
caches.match(event.request).then(cached => {
|
|
47
|
+
if (cached) return cached;
|
|
48
|
+
return fetch(event.request).catch(() => caches.match('/offline.html') as Promise<Response>);
|
|
49
|
+
})
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Register Service Worker
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
// app/layout.tsx or _app.tsx
|
|
58
|
+
if ('serviceWorker' in navigator) {
|
|
59
|
+
navigator.serviceWorker.register('/sw.js')
|
|
60
|
+
.then(reg => console.log('SW registered:', reg.scope))
|
|
61
|
+
.catch(err => console.error('SW failed:', err));
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Next.js with next-pwa
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npm install next-pwa
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
// next.config.ts
|
|
73
|
+
import withPWA from 'next-pwa';
|
|
74
|
+
|
|
75
|
+
export default withPWA({
|
|
76
|
+
dest: 'public',
|
|
77
|
+
disable: process.env.NODE_ENV === 'development',
|
|
78
|
+
register: true,
|
|
79
|
+
skipWaiting: true,
|
|
80
|
+
})({});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Push Notifications
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
const registration = await navigator.serviceWorker.ready;
|
|
87
|
+
const subscription = await registration.pushManager.subscribe({
|
|
88
|
+
userVisibleOnly: true,
|
|
89
|
+
applicationServerKey: process.env.NEXT_PUBLIC_VAPID_PUBLIC_KEY,
|
|
90
|
+
});
|
|
91
|
+
await fetch('/api/push/subscribe', {
|
|
92
|
+
method: 'POST', body: JSON.stringify(subscription),
|
|
93
|
+
headers: { 'Content-Type': 'application/json' }
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Best Practices
|
|
98
|
+
- Use `maskable` icon purpose for adaptive icons on Android
|
|
99
|
+
- Implement background sync for offline form submissions
|
|
100
|
+
- Cache API responses with network-first strategy, static assets with cache-first
|
|
101
|
+
- Test with Lighthouse PWA audit
|
|
102
|
+
|
|
103
|
+
## Resources
|
|
104
|
+
- [web.dev PWA guide](https://web.dev/explore/progressive-web-apps)
|
|
105
|
+
- [next-pwa](https://github.com/shadowwalker/next-pwa)
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
# React Custom Hooks
|
|
2
|
+
|
|
3
|
+
Creating reusable component logic with hooks.
|
|
4
|
+
|
|
5
|
+
## useLocalStorage
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
function useLocalStorage<T>(key: string, initialValue: T) {
|
|
9
|
+
const [storedValue, setStoredValue] = useState<T>(() => {
|
|
10
|
+
try {
|
|
11
|
+
const item = window.localStorage.getItem(key);
|
|
12
|
+
return item ? JSON.parse(item) : initialValue;
|
|
13
|
+
} catch (error) {
|
|
14
|
+
console.error(error);
|
|
15
|
+
return initialValue;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const setValue = (value: T | ((val: T) => T)) => {
|
|
20
|
+
try {
|
|
21
|
+
const valueToStore = value instanceof Function ? value(storedValue) : value;
|
|
22
|
+
setStoredValue(valueToStore);
|
|
23
|
+
window.localStorage.setItem(key, JSON.stringify(valueToStore));
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error(error);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return [storedValue, setValue] as const;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Usage
|
|
33
|
+
export function UserPreferences() {
|
|
34
|
+
const [theme, setTheme] = useLocalStorage<'light' | 'dark'>('theme', 'light');
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<button onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}>
|
|
38
|
+
Current theme: {theme}
|
|
39
|
+
</button>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## useFetch
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
interface UseFetchResult<T> {
|
|
48
|
+
data: T | null;
|
|
49
|
+
loading: boolean;
|
|
50
|
+
error: Error | null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function useFetch<T>(url: string): UseFetchResult<T> {
|
|
54
|
+
const [data, setData] = useState<T | null>(null);
|
|
55
|
+
const [loading, setLoading] = useState(true);
|
|
56
|
+
const [error, setError] = useState<Error | null>(null);
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
let isMounted = true;
|
|
60
|
+
|
|
61
|
+
const fetchData = async () => {
|
|
62
|
+
try {
|
|
63
|
+
const response = await fetch(url);
|
|
64
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
65
|
+
|
|
66
|
+
const result = await response.json();
|
|
67
|
+
if (isMounted) {
|
|
68
|
+
setData(result);
|
|
69
|
+
setError(null);
|
|
70
|
+
}
|
|
71
|
+
} catch (err) {
|
|
72
|
+
if (isMounted) {
|
|
73
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
74
|
+
}
|
|
75
|
+
} finally {
|
|
76
|
+
if (isMounted) {
|
|
77
|
+
setLoading(false);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
fetchData();
|
|
83
|
+
|
|
84
|
+
return () => {
|
|
85
|
+
isMounted = false;
|
|
86
|
+
};
|
|
87
|
+
}, [url]);
|
|
88
|
+
|
|
89
|
+
return { data, loading, error };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Usage
|
|
93
|
+
export function UserProfile({ userId }: { userId: string }) {
|
|
94
|
+
const { data: user, loading, error } = useFetch(`/api/users/${userId}`);
|
|
95
|
+
|
|
96
|
+
if (loading) return <div>Loading...</div>;
|
|
97
|
+
if (error) return <div>Error: {error.message}</div>;
|
|
98
|
+
if (!user) return <div>Not found</div>;
|
|
99
|
+
|
|
100
|
+
return <div>{user.name}</div>;
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## useDebounce
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
function useDebounce<T>(value: T, delay: number): T {
|
|
108
|
+
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
109
|
+
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
const handler = setTimeout(() => {
|
|
112
|
+
setDebouncedValue(value);
|
|
113
|
+
}, delay);
|
|
114
|
+
|
|
115
|
+
return () => clearTimeout(handler);
|
|
116
|
+
}, [value, delay]);
|
|
117
|
+
|
|
118
|
+
return debouncedValue;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Usage
|
|
122
|
+
export function SearchUsers() {
|
|
123
|
+
const [query, setQuery] = useState('');
|
|
124
|
+
const debouncedQuery = useDebounce(query, 500);
|
|
125
|
+
const { data: results } = useFetch(`/api/search?q=${debouncedQuery}`);
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<div>
|
|
129
|
+
<input
|
|
130
|
+
value={query}
|
|
131
|
+
onChange={(e) => setQuery(e.target.value)}
|
|
132
|
+
placeholder="Search users..."
|
|
133
|
+
/>
|
|
134
|
+
{results && results.map(user => (
|
|
135
|
+
<div key={user.id}>{user.name}</div>
|
|
136
|
+
))}
|
|
137
|
+
</div>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## usePrevious
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
function usePrevious<T>(value: T): T | undefined {
|
|
146
|
+
const ref = useRef<T>();
|
|
147
|
+
|
|
148
|
+
useEffect(() => {
|
|
149
|
+
ref.current = value;
|
|
150
|
+
}, [value]);
|
|
151
|
+
|
|
152
|
+
return ref.current;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Usage
|
|
156
|
+
export function Counter() {
|
|
157
|
+
const [count, setCount] = useState(0);
|
|
158
|
+
const prevCount = usePrevious(count);
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<div>
|
|
162
|
+
<p>Current: {count}</p>
|
|
163
|
+
<p>Previous: {prevCount}</p>
|
|
164
|
+
<button onClick={() => setCount(count + 1)}>Increment</button>
|
|
165
|
+
</div>
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## useAsync
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
interface UseAsyncState<T> {
|
|
174
|
+
status: 'idle' | 'pending' | 'success' | 'error';
|
|
175
|
+
data: T | null;
|
|
176
|
+
error: Error | null;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function useAsync<T>(
|
|
180
|
+
asyncFunction: () => Promise<T>,
|
|
181
|
+
immediate = true
|
|
182
|
+
): UseAsyncState<T> {
|
|
183
|
+
const [state, setState] = useState<UseAsyncState<T>>({
|
|
184
|
+
status: 'idle',
|
|
185
|
+
data: null,
|
|
186
|
+
error: null
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
const execute = useCallback(async () => {
|
|
190
|
+
setState({ status: 'pending', data: null, error: null });
|
|
191
|
+
try {
|
|
192
|
+
const response = await asyncFunction();
|
|
193
|
+
setState({ status: 'success', data: response, error: null });
|
|
194
|
+
} catch (error) {
|
|
195
|
+
setState({
|
|
196
|
+
status: 'error',
|
|
197
|
+
data: null,
|
|
198
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}, [asyncFunction]);
|
|
202
|
+
|
|
203
|
+
useEffect(() => {
|
|
204
|
+
if (immediate) {
|
|
205
|
+
execute();
|
|
206
|
+
}
|
|
207
|
+
}, [execute, immediate]);
|
|
208
|
+
|
|
209
|
+
return state;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Usage
|
|
213
|
+
export function DataLoader() {
|
|
214
|
+
const { status, data, error } = useAsync(
|
|
215
|
+
() => fetch('/api/data').then(r => r.json()),
|
|
216
|
+
true
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
if (status === 'pending') return <div>Loading...</div>;
|
|
220
|
+
if (status === 'error') return <div>Error: {error?.message}</div>;
|
|
221
|
+
if (status === 'success') return <div>{JSON.stringify(data)}</div>;
|
|
222
|
+
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Best Practices
|
|
228
|
+
|
|
229
|
+
✅ **Reusable logic** - Extract component logic
|
|
230
|
+
✅ **Cleanup** - Always cleanup in useEffect
|
|
231
|
+
✅ **Type safety** - Use generics
|
|
232
|
+
✅ **Error handling** - Handle errors properly
|
|
233
|
+
✅ **Memoization** - Use useCallback for functions
|
|
234
|
+
|
|
235
|
+
## Resources
|
|
236
|
+
|
|
237
|
+
- [React Hooks API](https://react.dev/reference/react)
|
|
238
|
+
- [usehooks-ts](https://usehooks-ts.com/)
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# React
|
|
2
|
+
|
|
3
|
+
Modern React development with hooks, composition patterns, and performance optimization.
|
|
4
|
+
|
|
5
|
+
## Core Patterns
|
|
6
|
+
|
|
7
|
+
### Hooks & State Management
|
|
8
|
+
```typescript
|
|
9
|
+
// useState for local component state
|
|
10
|
+
const [count, setCount] = useState(0);
|
|
11
|
+
|
|
12
|
+
// useEffect for side effects
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
document.title = `Count: ${count}`;
|
|
15
|
+
}, [count]);
|
|
16
|
+
|
|
17
|
+
// useCallback for memoized callbacks
|
|
18
|
+
const handleClick = useCallback(() => {
|
|
19
|
+
setCount(c => c + 1);
|
|
20
|
+
}, []);
|
|
21
|
+
|
|
22
|
+
// useMemo for expensive computations
|
|
23
|
+
const expensive = useMemo(() => complexCalculation(data), [data]);
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Component Composition
|
|
27
|
+
- **Functional components**: Prefer over class components
|
|
28
|
+
- **Custom hooks**: Extract reusable logic into hooks
|
|
29
|
+
- **Compound components**: Share state within component tree
|
|
30
|
+
- **Render props**: Alternative pattern for logic sharing
|
|
31
|
+
- **Context API**: For global state (theme, auth, user)
|
|
32
|
+
|
|
33
|
+
### Performance Optimization
|
|
34
|
+
- **React.memo**: Prevent unnecessary re-renders
|
|
35
|
+
- **useCallback/useMemo**: Optimize function/value references
|
|
36
|
+
- **Code splitting**: Lazy load routes and components with React.lazy()
|
|
37
|
+
- **Key prop**: Properly identify list items for reconciliation
|
|
38
|
+
- **Profiler API**: Measure component performance
|
|
39
|
+
|
|
40
|
+
### State Management Patterns
|
|
41
|
+
- **useState**: Local component state
|
|
42
|
+
- **useContext + useState**: Simple global state
|
|
43
|
+
- **Zustand/Jotai**: Lightweight state libraries
|
|
44
|
+
- **Redux Toolkit**: Complex application state
|
|
45
|
+
- **Server state (React Query)**: API caching and synchronization
|
|
46
|
+
|
|
47
|
+
## Best Practices
|
|
48
|
+
|
|
49
|
+
1. **Component Structure**
|
|
50
|
+
- One component per file (or related components in directory)
|
|
51
|
+
- Use descriptive names following PascalCase convention
|
|
52
|
+
- Keep components focused and single-responsibility
|
|
53
|
+
|
|
54
|
+
2. **Hook Rules**
|
|
55
|
+
- Only call hooks at top level of component
|
|
56
|
+
- Call hooks from React functions, not regular functions
|
|
57
|
+
- Use ESLint plugin to enforce rules
|
|
58
|
+
|
|
59
|
+
3. **Prop Drilling Prevention**
|
|
60
|
+
- Use Context API for global state
|
|
61
|
+
- Split components to avoid deep prop drilling
|
|
62
|
+
- Consider state management library for complex apps
|
|
63
|
+
|
|
64
|
+
4. **Rendering Performance**
|
|
65
|
+
- Avoid object/function creation in render
|
|
66
|
+
- Use keys correctly in lists
|
|
67
|
+
- Profile with React DevTools before optimizing
|
|
68
|
+
|
|
69
|
+
5. **Error Handling**
|
|
70
|
+
- Use Error Boundaries for error containment
|
|
71
|
+
- Try-catch in event handlers and async code
|
|
72
|
+
- Provide user-friendly error messages
|
|
73
|
+
|
|
74
|
+
## Common Patterns
|
|
75
|
+
|
|
76
|
+
### Custom Hook Pattern
|
|
77
|
+
```typescript
|
|
78
|
+
function useFormInput(initialValue = '') {
|
|
79
|
+
const [value, setValue] = useState(initialValue);
|
|
80
|
+
return {
|
|
81
|
+
bind: { value, onChange: e => setValue(e.target.value) },
|
|
82
|
+
value,
|
|
83
|
+
clear: () => setValue(''),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Context + Reducer Pattern
|
|
89
|
+
```typescript
|
|
90
|
+
const AppContext = createContext();
|
|
91
|
+
|
|
92
|
+
function AppProvider({ children }) {
|
|
93
|
+
const [state, dispatch] = useReducer(appReducer, initialState);
|
|
94
|
+
return (
|
|
95
|
+
<AppContext.Provider value={{ state, dispatch }}>
|
|
96
|
+
{children}
|
|
97
|
+
</AppContext.Provider>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Conditional Rendering
|
|
103
|
+
```typescript
|
|
104
|
+
// Good patterns
|
|
105
|
+
{condition && <Component />}
|
|
106
|
+
{condition ? <ComponentA /> : <ComponentB />}
|
|
107
|
+
{list.length > 0 ? <List items={list} /> : <Empty />}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Testing
|
|
111
|
+
|
|
112
|
+
Use React Testing Library:
|
|
113
|
+
```typescript
|
|
114
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
115
|
+
|
|
116
|
+
test('button click updates count', () => {
|
|
117
|
+
render(<Counter />);
|
|
118
|
+
const button = screen.getByRole('button');
|
|
119
|
+
fireEvent.click(button);
|
|
120
|
+
expect(screen.getByText(/Count: 1/i)).toBeInTheDocument();
|
|
121
|
+
});
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Resources
|
|
125
|
+
|
|
126
|
+
- [React Official Docs](https://react.dev)
|
|
127
|
+
- [React Hooks API](https://react.dev/reference/react)
|
|
128
|
+
- [React Testing Library](https://testing-library.com/react)
|
|
129
|
+
- [Performance Optimization Guide](https://react.dev/learn/render-and-commit)
|