opencode-agent-kit 1.0.0
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/README.md +796 -0
- package/bin/commands/init.mjs +221 -0
- package/bin/init.mjs +21 -0
- package/package.json +22 -0
- package/template/.opencode/agent-docs/backend/README.md +0 -0
- package/template/.opencode/agent-docs/backend/node/BACKEND_PATTERNS.md +82 -0
- package/template/.opencode/agent-docs/backend/node/BACKEND_QUICK_START.md +49 -0
- package/template/.opencode/agent-docs/frontend/next/README.md +0 -0
- package/template/.opencode/agent-docs/frontend/nuxt/API_PATTERNS.md +807 -0
- package/template/.opencode/agent-docs/frontend/nuxt/CHEATSHEET.md +676 -0
- package/template/.opencode/agent-docs/frontend/nuxt/COMPLETION_REPORT.md +613 -0
- package/template/.opencode/agent-docs/frontend/nuxt/EXAMPLES.md +956 -0
- package/template/.opencode/agent-docs/frontend/nuxt/INDEX.md +596 -0
- package/template/.opencode/agent-docs/frontend/nuxt/MCP_GUIDE.md +881 -0
- package/template/.opencode/agent-docs/frontend/nuxt/MENTOR_CURRICULUM_30_DAYS.md +256 -0
- package/template/.opencode/agent-docs/frontend/nuxt/MENTOR_CURRICULUM_CHECKLIST.md +156 -0
- package/template/.opencode/agent-docs/frontend/nuxt/MENTOR_WEEKLY_ASSIGNMENTS.md +191 -0
- package/template/.opencode/agent-docs/frontend/nuxt/QUICK_START.md +509 -0
- package/template/.opencode/agent-docs/frontend/nuxt/README.md +506 -0
- package/template/.opencode/agent-docs/frontend/nuxt/README_AGENTS.md +140 -0
- package/template/.opencode/agent-docs/frontend/nuxt/README_DOCS.md +65 -0
- package/template/.opencode/agent-docs/frontend/nuxt/SUMMARY.md +474 -0
- package/template/.opencode/agent-docs/frontend/nuxt/TEAM_OPERATING_GUIDE.md +54 -0
- package/template/.opencode/agent-docs/frontend/nuxt/TESTING_GUIDE.md +904 -0
- package/template/.opencode/agent-docs/frontend/nuxt/WORKFLOWS.md +758 -0
- package/template/.opencode/agent-docs/frontend/react/API_PATTERNS.md +187 -0
- package/template/.opencode/agent-docs/frontend/react/CHEATSHEET.md +87 -0
- package/template/.opencode/agent-docs/frontend/react/INDEX.md +45 -0
- package/template/.opencode/agent-docs/frontend/react/QUICK_START.md +43 -0
- package/template/.opencode/agent-docs/frontend/react/README.md +159 -0
- package/template/.opencode/agent-docs/frontend/vue/README.md +0 -0
- package/template/.opencode/agent-docs/mobile/android/README.md +45 -0
- package/template/.opencode/agent-docs/mobile/flutter/README.md +44 -0
- package/template/.opencode/agents/android-developer.md +418 -0
- package/template/.opencode/agents/code-igniter-3-fullstack.md +345 -0
- package/template/.opencode/agents/code-reviewer.md +517 -0
- package/template/.opencode/agents/database-specialist.md +455 -0
- package/template/.opencode/agents/devops-specialist.md +562 -0
- package/template/.opencode/agents/flutter-developer.md +556 -0
- package/template/.opencode/agents/it-leader.md +911 -0
- package/template/.opencode/agents/laravel-advanced.md +691 -0
- package/template/.opencode/agents/node-backend-developer.md +343 -0
- package/template/.opencode/agents/nuxt-frontend-developer-mentor.md +402 -0
- package/template/.opencode/agents/nuxt-frontend-developer.md +1573 -0
- package/template/.opencode/agents/react-frontend-developer.md +1017 -0
- package/template/.opencode/agents/seo-specialist.md +681 -0
- package/template/.opencode/agents/ui-ux-designer.md +783 -0
- package/template/.opencode/commands/android-build/command.md +25 -0
- package/template/.opencode/commands/android-test/command.md +23 -0
- package/template/.opencode/commands/build-fix.md +29 -0
- package/template/.opencode/commands/checkpoint.md +74 -0
- package/template/.opencode/commands/code-review.md +40 -0
- package/template/.opencode/commands/e2e.md +363 -0
- package/template/.opencode/commands/eval.md +120 -0
- package/template/.opencode/commands/evolve.md +193 -0
- package/template/.opencode/commands/flutter-build/command.md +25 -0
- package/template/.opencode/commands/flutter-test/command.md +24 -0
- package/template/.opencode/commands/go-build.md +183 -0
- package/template/.opencode/commands/go-review.md +148 -0
- package/template/.opencode/commands/go-test.md +268 -0
- package/template/.opencode/commands/gpc-release/command.md +30 -0
- package/template/.opencode/commands/instinct-export.md +91 -0
- package/template/.opencode/commands/instinct-import.md +142 -0
- package/template/.opencode/commands/instinct-status.md +86 -0
- package/template/.opencode/commands/learn.md +70 -0
- package/template/.opencode/commands/multi-backend.md +158 -0
- package/template/.opencode/commands/multi-execute.md +310 -0
- package/template/.opencode/commands/multi-frontend.md +158 -0
- package/template/.opencode/commands/multi-plan.md +261 -0
- package/template/.opencode/commands/multi-workflow.md +183 -0
- package/template/.opencode/commands/orchestrate.md +172 -0
- package/template/.opencode/commands/plan.md +113 -0
- package/template/.opencode/commands/pm2.md +271 -0
- package/template/.opencode/commands/python-review.md +297 -0
- package/template/.opencode/commands/refactor-clean.md +28 -0
- package/template/.opencode/commands/sessions.md +305 -0
- package/template/.opencode/commands/setup-pm.md +80 -0
- package/template/.opencode/commands/skill-create.md +174 -0
- package/template/.opencode/commands/tdd.md +326 -0
- package/template/.opencode/commands/test-coverage.md +27 -0
- package/template/.opencode/commands/update-codemaps.md +17 -0
- package/template/.opencode/commands/update-docs.md +31 -0
- package/template/.opencode/commands/verify.md +59 -0
- package/template/.opencode/config.example.json +309 -0
- package/template/.opencode/config.json +341 -0
- package/template/.opencode/contexts/dev.md +20 -0
- package/template/.opencode/contexts/research.md +26 -0
- package/template/.opencode/contexts/review.md +22 -0
- package/template/.opencode/hooks/hooks.json +169 -0
- package/template/.opencode/instructions/INSTRUCTIONS.md +388 -0
- package/template/.opencode/package.json +5 -0
- package/template/.opencode/rules/README.md +82 -0
- package/template/.opencode/rules/android/gradle.md +62 -0
- package/template/.opencode/rules/android/testing.md +27 -0
- package/template/.opencode/rules/common/agents.md +49 -0
- package/template/.opencode/rules/common/coding-style.md +48 -0
- package/template/.opencode/rules/common/git-workflow.md +45 -0
- package/template/.opencode/rules/common/hooks.md +30 -0
- package/template/.opencode/rules/common/patterns.md +31 -0
- package/template/.opencode/rules/common/performance.md +55 -0
- package/template/.opencode/rules/common/security.md +29 -0
- package/template/.opencode/rules/common/testing.md +29 -0
- package/template/.opencode/rules/flutter/state-management.md +57 -0
- package/template/.opencode/rules/flutter/testing.md +42 -0
- package/template/.opencode/rules/golang/coding-style.md +26 -0
- package/template/.opencode/rules/golang/hooks.md +11 -0
- package/template/.opencode/rules/golang/patterns.md +39 -0
- package/template/.opencode/rules/golang/security.md +28 -0
- package/template/.opencode/rules/golang/testing.md +25 -0
- package/template/.opencode/rules/mobile/performance.md +36 -0
- package/template/.opencode/rules/python/coding-style.md +37 -0
- package/template/.opencode/rules/python/hooks.md +14 -0
- package/template/.opencode/rules/python/patterns.md +34 -0
- package/template/.opencode/rules/python/security.md +25 -0
- package/template/.opencode/rules/python/testing.md +33 -0
- package/template/.opencode/rules/typescript/coding-style.md +58 -0
- package/template/.opencode/rules/typescript/hooks.md +15 -0
- package/template/.opencode/rules/typescript/patterns.md +45 -0
- package/template/.opencode/rules/typescript/security.md +21 -0
- package/template/.opencode/rules/typescript/testing.md +11 -0
- package/template/.opencode/skills/api-documentation/SKILL.md +188 -0
- package/template/.opencode/skills/backend-patterns/SKILL.md +587 -0
- package/template/.opencode/skills/building-components/SKILL.md +37 -0
- package/template/.opencode/skills/building-components/references/accessibility.mdx +819 -0
- package/template/.opencode/skills/building-components/references/as-child.mdx +324 -0
- package/template/.opencode/skills/building-components/references/composition.mdx +239 -0
- package/template/.opencode/skills/building-components/references/data-attributes.mdx +413 -0
- package/template/.opencode/skills/building-components/references/definitions.mdx +258 -0
- package/template/.opencode/skills/building-components/references/design-tokens.mdx +57 -0
- package/template/.opencode/skills/building-components/references/docs.mdx +155 -0
- package/template/.opencode/skills/building-components/references/marketplaces.mdx +144 -0
- package/template/.opencode/skills/building-components/references/npm.mdx +166 -0
- package/template/.opencode/skills/building-components/references/polymorphism.mdx +583 -0
- package/template/.opencode/skills/building-components/references/principles.mdx +61 -0
- package/template/.opencode/skills/building-components/references/registry.mdx +169 -0
- package/template/.opencode/skills/building-components/references/state.mdx +99 -0
- package/template/.opencode/skills/building-components/references/styling.mdx +286 -0
- package/template/.opencode/skills/building-components/references/types.mdx +191 -0
- package/template/.opencode/skills/clickhouse-io/SKILL.md +429 -0
- package/template/.opencode/skills/coding-standards/SKILL.md +520 -0
- package/template/.opencode/skills/configure-ecc/SKILL.md +298 -0
- package/template/.opencode/skills/continuous-learning/SKILL.md +110 -0
- package/template/.opencode/skills/continuous-learning/config.json +18 -0
- package/template/.opencode/skills/continuous-learning/evaluate-session.sh +60 -0
- package/template/.opencode/skills/continuous-learning-v2/SKILL.md +284 -0
- package/template/.opencode/skills/continuous-learning-v2/agents/observer.md +137 -0
- package/template/.opencode/skills/continuous-learning-v2/agents/start-observer.sh +134 -0
- package/template/.opencode/skills/continuous-learning-v2/config.json +41 -0
- package/template/.opencode/skills/continuous-learning-v2/hooks/observe.sh +153 -0
- package/template/.opencode/skills/continuous-learning-v2/scripts/instinct-cli.py +489 -0
- package/template/.opencode/skills/continuous-learning-v2/scripts/test_parse_instinct.py +82 -0
- package/template/.opencode/skills/dart-add-unit-test/SKILL.md +122 -0
- package/template/.opencode/skills/dart-build-cli-app/SKILL.md +185 -0
- package/template/.opencode/skills/dart-collect-coverage/SKILL.md +141 -0
- package/template/.opencode/skills/dart-fix-runtime-errors/SKILL.md +166 -0
- package/template/.opencode/skills/dart-generate-test-mocks/SKILL.md +155 -0
- package/template/.opencode/skills/dart-migrate-to-checks-package/SKILL.md +126 -0
- package/template/.opencode/skills/dart-resolve-package-conflicts/SKILL.md +116 -0
- package/template/.opencode/skills/dart-run-static-analysis/SKILL.md +104 -0
- package/template/.opencode/skills/dart-use-pattern-matching/SKILL.md +146 -0
- package/template/.opencode/skills/django-patterns/SKILL.md +733 -0
- package/template/.opencode/skills/django-security/SKILL.md +592 -0
- package/template/.opencode/skills/django-tdd/SKILL.md +728 -0
- package/template/.opencode/skills/django-verification/SKILL.md +460 -0
- package/template/.opencode/skills/eval-harness/SKILL.md +227 -0
- package/template/.opencode/skills/firebase-basics/SKILL.md +103 -0
- package/template/.opencode/skills/firebase-basics/references/additional-skills.md +113 -0
- package/template/.opencode/skills/firebase-basics/references/cli-usage.md +31 -0
- package/template/.opencode/skills/firebase-basics/references/client-library-usage.md +45 -0
- package/template/.opencode/skills/firebase-basics/references/core-concepts.md +61 -0
- package/template/.opencode/skills/firebase-basics/references/iac-usage.md +40 -0
- package/template/.opencode/skills/firebase-basics/references/iam-security.md +74 -0
- package/template/.opencode/skills/firebase-basics/references/mcp-usage.md +63 -0
- package/template/.opencode/skills/flutter/SKILL.md +292 -0
- package/template/.opencode/skills/flutter-add-integration-test/SKILL.md +163 -0
- package/template/.opencode/skills/flutter-add-widget-preview/SKILL.md +145 -0
- package/template/.opencode/skills/flutter-add-widget-test/SKILL.md +154 -0
- package/template/.opencode/skills/flutter-apply-architecture-best-practices/SKILL.md +162 -0
- package/template/.opencode/skills/flutter-build-responsive-layout/SKILL.md +139 -0
- package/template/.opencode/skills/flutter-fix-layout-issues/SKILL.md +130 -0
- package/template/.opencode/skills/flutter-implement-json-serialization/SKILL.md +153 -0
- package/template/.opencode/skills/flutter-setup-declarative-routing/SKILL.md +255 -0
- package/template/.opencode/skills/flutter-setup-localization/SKILL.md +210 -0
- package/template/.opencode/skills/flutter-use-http-package/SKILL.md +174 -0
- package/template/.opencode/skills/frontend-design/SKILL.md +89 -0
- package/template/.opencode/skills/frontend-patterns/SKILL.md +631 -0
- package/template/.opencode/skills/golang-patterns/SKILL.md +673 -0
- package/template/.opencode/skills/golang-testing/SKILL.md +719 -0
- package/template/.opencode/skills/impeccable/SKILL.md +165 -0
- package/template/.opencode/skills/impeccable/agents/impeccable-asset-producer.md +101 -0
- package/template/.opencode/skills/impeccable/reference/adapt.md +190 -0
- package/template/.opencode/skills/impeccable/reference/animate.md +175 -0
- package/template/.opencode/skills/impeccable/reference/audit.md +133 -0
- package/template/.opencode/skills/impeccable/reference/bolder.md +113 -0
- package/template/.opencode/skills/impeccable/reference/brand.md +118 -0
- package/template/.opencode/skills/impeccable/reference/clarify.md +174 -0
- package/template/.opencode/skills/impeccable/reference/codex.md +105 -0
- package/template/.opencode/skills/impeccable/reference/cognitive-load.md +106 -0
- package/template/.opencode/skills/impeccable/reference/color-and-contrast.md +105 -0
- package/template/.opencode/skills/impeccable/reference/colorize.md +154 -0
- package/template/.opencode/skills/impeccable/reference/craft.md +123 -0
- package/template/.opencode/skills/impeccable/reference/critique.md +273 -0
- package/template/.opencode/skills/impeccable/reference/delight.md +302 -0
- package/template/.opencode/skills/impeccable/reference/distill.md +111 -0
- package/template/.opencode/skills/impeccable/reference/document.md +427 -0
- package/template/.opencode/skills/impeccable/reference/extract.md +69 -0
- package/template/.opencode/skills/impeccable/reference/harden.md +347 -0
- package/template/.opencode/skills/impeccable/reference/heuristics-scoring.md +234 -0
- package/template/.opencode/skills/impeccable/reference/interaction-design.md +195 -0
- package/template/.opencode/skills/impeccable/reference/layout.md +141 -0
- package/template/.opencode/skills/impeccable/reference/live.md +622 -0
- package/template/.opencode/skills/impeccable/reference/motion-design.md +109 -0
- package/template/.opencode/skills/impeccable/reference/onboard.md +234 -0
- package/template/.opencode/skills/impeccable/reference/optimize.md +258 -0
- package/template/.opencode/skills/impeccable/reference/overdrive.md +130 -0
- package/template/.opencode/skills/impeccable/reference/personas.md +179 -0
- package/template/.opencode/skills/impeccable/reference/polish.md +242 -0
- package/template/.opencode/skills/impeccable/reference/product.md +62 -0
- package/template/.opencode/skills/impeccable/reference/quieter.md +99 -0
- package/template/.opencode/skills/impeccable/reference/responsive-design.md +114 -0
- package/template/.opencode/skills/impeccable/reference/shape.md +165 -0
- package/template/.opencode/skills/impeccable/reference/spatial-design.md +100 -0
- package/template/.opencode/skills/impeccable/reference/teach.md +156 -0
- package/template/.opencode/skills/impeccable/reference/typeset.md +124 -0
- package/template/.opencode/skills/impeccable/reference/typography.md +159 -0
- package/template/.opencode/skills/impeccable/reference/ux-writing.md +107 -0
- package/template/.opencode/skills/impeccable/scripts/cleanup-deprecated.mjs +284 -0
- package/template/.opencode/skills/impeccable/scripts/command-metadata.json +94 -0
- package/template/.opencode/skills/impeccable/scripts/critique-storage.mjs +242 -0
- package/template/.opencode/skills/impeccable/scripts/design-parser.mjs +820 -0
- package/template/.opencode/skills/impeccable/scripts/detect-csp.mjs +198 -0
- package/template/.opencode/skills/impeccable/scripts/detect.mjs +21 -0
- package/template/.opencode/skills/impeccable/scripts/impeccable-paths.mjs +110 -0
- package/template/.opencode/skills/impeccable/scripts/is-generated.mjs +69 -0
- package/template/.opencode/skills/impeccable/scripts/live-accept.mjs +595 -0
- package/template/.opencode/skills/impeccable/scripts/live-browser-session.js +123 -0
- package/template/.opencode/skills/impeccable/scripts/live-browser.js +4860 -0
- package/template/.opencode/skills/impeccable/scripts/live-complete.mjs +75 -0
- package/template/.opencode/skills/impeccable/scripts/live-completion.mjs +18 -0
- package/template/.opencode/skills/impeccable/scripts/live-inject.mjs +446 -0
- package/template/.opencode/skills/impeccable/scripts/live-poll.mjs +200 -0
- package/template/.opencode/skills/impeccable/scripts/live-resume.mjs +48 -0
- package/template/.opencode/skills/impeccable/scripts/live-server.mjs +838 -0
- package/template/.opencode/skills/impeccable/scripts/live-session-store.mjs +254 -0
- package/template/.opencode/skills/impeccable/scripts/live-status.mjs +47 -0
- package/template/.opencode/skills/impeccable/scripts/live-wrap.mjs +632 -0
- package/template/.opencode/skills/impeccable/scripts/live.mjs +247 -0
- package/template/.opencode/skills/impeccable/scripts/load-context.mjs +141 -0
- package/template/.opencode/skills/impeccable/scripts/modern-screenshot.umd.js +14 -0
- package/template/.opencode/skills/impeccable/scripts/pin.mjs +214 -0
- package/template/.opencode/skills/iterative-retrieval/SKILL.md +202 -0
- package/template/.opencode/skills/java-coding-standards/SKILL.md +138 -0
- package/template/.opencode/skills/jetpack-compose/.skillfish.json +10 -0
- package/template/.opencode/skills/jetpack-compose/SKILL.md +420 -0
- package/template/.opencode/skills/jpa-patterns/SKILL.md +141 -0
- package/template/.opencode/skills/nutrient-document-processing/SKILL.md +165 -0
- package/template/.opencode/skills/nuxt-ui/SKILL.md +334 -0
- package/template/.opencode/skills/nuxt-ui/references/components.md +377 -0
- package/template/.opencode/skills/nuxt-ui/references/composables.md +127 -0
- package/template/.opencode/skills/nuxt-ui/references/layouts/chat.md +266 -0
- package/template/.opencode/skills/nuxt-ui/references/layouts/dashboard.md +220 -0
- package/template/.opencode/skills/nuxt-ui/references/layouts/docs.md +141 -0
- package/template/.opencode/skills/nuxt-ui/references/layouts/editor.md +168 -0
- package/template/.opencode/skills/nuxt-ui/references/layouts/page.md +260 -0
- package/template/.opencode/skills/nuxt-ui/references/theming.md +427 -0
- package/template/.opencode/skills/postgres-patterns/SKILL.md +146 -0
- package/template/.opencode/skills/project-guidelines-example/SKILL.md +345 -0
- package/template/.opencode/skills/python-patterns/SKILL.md +749 -0
- package/template/.opencode/skills/python-testing/SKILL.md +815 -0
- package/template/.opencode/skills/security-review/SKILL.md +494 -0
- package/template/.opencode/skills/security-review/cloud-infrastructure-security.md +361 -0
- package/template/.opencode/skills/shadcn-ui/README.md +248 -0
- package/template/.opencode/skills/shadcn-ui/SKILL.md +326 -0
- package/template/.opencode/skills/shadcn-ui/examples/auth-layout.tsx +177 -0
- package/template/.opencode/skills/shadcn-ui/examples/data-table.tsx +313 -0
- package/template/.opencode/skills/shadcn-ui/examples/form-pattern.tsx +177 -0
- package/template/.opencode/skills/shadcn-ui/resources/component-catalog.md +481 -0
- package/template/.opencode/skills/shadcn-ui/resources/customization-guide.md +516 -0
- package/template/.opencode/skills/shadcn-ui/resources/migration-guide.md +463 -0
- package/template/.opencode/skills/shadcn-ui/resources/setup-guide.md +412 -0
- package/template/.opencode/skills/shadcn-ui/scripts/verify-setup.sh +134 -0
- package/template/.opencode/skills/springboot-patterns/SKILL.md +304 -0
- package/template/.opencode/skills/springboot-security/SKILL.md +119 -0
- package/template/.opencode/skills/springboot-tdd/SKILL.md +157 -0
- package/template/.opencode/skills/springboot-verification/SKILL.md +100 -0
- package/template/.opencode/skills/strategic-compact/SKILL.md +63 -0
- package/template/.opencode/skills/strategic-compact/suggest-compact.sh +52 -0
- package/template/.opencode/skills/tdd-workflow/SKILL.md +409 -0
- package/template/.opencode/skills/vercel-composition-patterns/AGENTS.md +946 -0
- package/template/.opencode/skills/vercel-composition-patterns/SKILL.md +89 -0
- package/template/.opencode/skills/vercel-composition-patterns/rules/architecture-avoid-boolean-props.md +100 -0
- package/template/.opencode/skills/vercel-composition-patterns/rules/architecture-compound-components.md +112 -0
- package/template/.opencode/skills/vercel-composition-patterns/rules/patterns-children-over-render-props.md +87 -0
- package/template/.opencode/skills/vercel-composition-patterns/rules/patterns-explicit-variants.md +100 -0
- package/template/.opencode/skills/vercel-composition-patterns/rules/react19-no-forwardref.md +42 -0
- package/template/.opencode/skills/vercel-composition-patterns/rules/state-context-interface.md +191 -0
- package/template/.opencode/skills/vercel-composition-patterns/rules/state-decouple-implementation.md +113 -0
- package/template/.opencode/skills/vercel-composition-patterns/rules/state-lift-state.md +125 -0
- package/template/.opencode/skills/vercel-react-best-practices/AGENTS.md +2934 -0
- package/template/.opencode/skills/vercel-react-best-practices/SKILL.md +136 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/advanced-event-handler-refs.md +55 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/advanced-init-once.md +42 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/advanced-use-latest.md +39 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/async-api-routes.md +38 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/async-defer-await.md +80 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/async-dependencies.md +51 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/async-parallel.md +28 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/async-suspense-boundaries.md +99 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/bundle-barrel-imports.md +59 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/bundle-conditional.md +31 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/bundle-defer-third-party.md +49 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/bundle-dynamic-imports.md +35 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/bundle-preload.md +50 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/client-event-listeners.md +74 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/client-localstorage-schema.md +71 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/client-passive-event-listeners.md +48 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/client-swr-dedup.md +56 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/js-batch-dom-css.md +107 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/js-cache-function-results.md +80 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/js-cache-property-access.md +28 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/js-cache-storage.md +70 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/js-combine-iterations.md +32 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/js-early-exit.md +50 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/js-hoist-regexp.md +45 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/js-index-maps.md +37 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/js-length-check-first.md +49 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/js-min-max-loop.md +82 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/js-set-map-lookups.md +24 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/js-tosorted-immutable.md +57 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-activity.md +26 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-conditional-render.md +40 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-content-visibility.md +38 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-hoist-jsx.md +46 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-hydration-suppress-warning.md +30 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-svg-precision.md +28 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-usetransition-loading.md +75 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-defer-reads.md +39 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-dependencies.md +45 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-derived-state-no-effect.md +40 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-derived-state.md +29 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-functional-setstate.md +74 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-lazy-state-init.md +58 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +38 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-memo.md +44 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-move-effect-to-event.md +45 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-transitions.md +40 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-use-ref-transient-values.md +73 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/server-after-nonblocking.md +73 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/server-auth-actions.md +96 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/server-cache-lru.md +41 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/server-cache-react.md +76 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/server-dedup-props.md +65 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/server-parallel-fetching.md +83 -0
- package/template/.opencode/skills/vercel-react-best-practices/rules/server-serialization.md +38 -0
- package/template/.opencode/skills/verification-loop/SKILL.md +120 -0
- package/template/.opencode/skills/web-design-guidelines/SKILL.md +39 -0
- package/template/AGENTS.md +32 -0
- package/template/opencode.json +354 -0
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: flutter
|
|
3
|
+
description: Comprehensive Flutter patterns, architecture, state management, testing, and platform integration for production-grade cross-platform apps.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Flutter Patterns & Best Practices
|
|
7
|
+
|
|
8
|
+
Comprehensive reference for building production-grade Flutter applications.
|
|
9
|
+
|
|
10
|
+
## Architecture Patterns
|
|
11
|
+
|
|
12
|
+
### Clean Architecture Layer Structure
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
lib/
|
|
16
|
+
├── core/ # Shared utilities, constants, theme
|
|
17
|
+
├── data/
|
|
18
|
+
│ ├── datasources/ # Remote (API) + Local (DB) sources
|
|
19
|
+
│ ├── models/ # JSON serializable models (fromJson/toJson)
|
|
20
|
+
│ └── repositories/ # Repository implementations
|
|
21
|
+
├── domain/
|
|
22
|
+
│ ├── entities/ # Pure Dart domain objects
|
|
23
|
+
│ ├── repositories/ # Abstract repository interfaces
|
|
24
|
+
│ └── usecases/ # Business logic use cases
|
|
25
|
+
├── presentation/
|
|
26
|
+
│ ├── providers/ # State notifiers (Bloc/Riverpod)
|
|
27
|
+
│ ├── screens/ # Screen-level widgets
|
|
28
|
+
│ └── widgets/ # Reusable widgets
|
|
29
|
+
├── di/ # Dependency injection setup
|
|
30
|
+
├── main.dart
|
|
31
|
+
└── app.dart
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Repository Pattern (Offline-First)
|
|
35
|
+
|
|
36
|
+
```dart
|
|
37
|
+
abstract class ProductRepository {
|
|
38
|
+
Future<Either<Failure, List<Product>>> getProducts();
|
|
39
|
+
Future<Either<Failure, Product>> getProduct(String id);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
class ProductRepositoryImpl implements ProductRepository {
|
|
43
|
+
final ProductRemoteDataSource remote;
|
|
44
|
+
final ProductLocalDataSource local;
|
|
45
|
+
|
|
46
|
+
ProductRepositoryImpl({required this.remote, required this.local});
|
|
47
|
+
|
|
48
|
+
@override
|
|
49
|
+
Future<Either<Failure, List<Product>>> getProducts() async {
|
|
50
|
+
try {
|
|
51
|
+
final remoteProducts = await remote.getProducts();
|
|
52
|
+
await local.cacheProducts(remoteProducts);
|
|
53
|
+
return Right(remoteProducts);
|
|
54
|
+
} on ServerException {
|
|
55
|
+
try {
|
|
56
|
+
final localProducts = await local.getCachedProducts();
|
|
57
|
+
return Right(localProducts);
|
|
58
|
+
} on CacheException {
|
|
59
|
+
return Left(CacheFailure());
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## State Management
|
|
67
|
+
|
|
68
|
+
### Riverpod
|
|
69
|
+
|
|
70
|
+
```dart
|
|
71
|
+
// Provider definition
|
|
72
|
+
final productRepositoryProvider = Provider<ProductRepository>((ref) {
|
|
73
|
+
return ProductRepositoryImpl(
|
|
74
|
+
remote: ref.watch(productRemoteDataSourceProvider),
|
|
75
|
+
local: ref.watch(productLocalDataSourceProvider),
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// AsyncNotifierProvider
|
|
80
|
+
final productsProvider = AsyncNotifierProvider<ProductsNotifier, List<Product>>(
|
|
81
|
+
ProductsNotifier.new,
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
class ProductsNotifier extends AsyncNotifier<List<Product>> {
|
|
85
|
+
@override
|
|
86
|
+
Future<List<Product>> build() async {
|
|
87
|
+
final repo = ref.read(productRepositoryProvider);
|
|
88
|
+
return repo.getProducts();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
Future<void> addProduct(Product product) async { }
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// In widget
|
|
95
|
+
class ProductList extends ConsumerWidget {
|
|
96
|
+
@override
|
|
97
|
+
Widget build(BuildContext context, WidgetRef ref) {
|
|
98
|
+
final productsAsync = ref.watch(productsProvider);
|
|
99
|
+
return productsAsync.when(
|
|
100
|
+
data: (products) => ListView.builder(/*...*/),
|
|
101
|
+
loading: () => const CircularProgressIndicator(),
|
|
102
|
+
error: (e, _) => Text('Error: $e'),
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Bloc
|
|
109
|
+
|
|
110
|
+
```dart
|
|
111
|
+
// Event
|
|
112
|
+
sealed class ProductEvent {}
|
|
113
|
+
final class LoadProducts extends ProductEvent {}
|
|
114
|
+
final class SearchProducts extends ProductEvent {
|
|
115
|
+
final String query;
|
|
116
|
+
SearchProducts(this.query);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// State
|
|
120
|
+
sealed class ProductState {}
|
|
121
|
+
final class ProductInitial extends ProductState {}
|
|
122
|
+
final class ProductLoading extends ProductState {}
|
|
123
|
+
final class ProductLoaded extends ProductState {
|
|
124
|
+
final List<Product> products;
|
|
125
|
+
ProductLoaded(this.products);
|
|
126
|
+
}
|
|
127
|
+
final class ProductError extends ProductState {
|
|
128
|
+
final String message;
|
|
129
|
+
ProductError(this.message);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Bloc
|
|
133
|
+
class ProductBloc extends Bloc<ProductEvent, ProductState> {
|
|
134
|
+
final ProductRepository _repository;
|
|
135
|
+
ProductBloc(this._repository) : super(ProductInitial()) {
|
|
136
|
+
on<LoadProducts>(_onLoadProducts);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
Future<void> _onLoadProducts(LoadProducts event, Emitter<ProductState> emit) async {
|
|
140
|
+
emit(ProductLoading());
|
|
141
|
+
final result = await _repository.getProducts();
|
|
142
|
+
result.fold(
|
|
143
|
+
(failure) => emit(ProductError(failure.message)),
|
|
144
|
+
(products) => emit(ProductLoaded(products)),
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Navigation (GoRouter)
|
|
151
|
+
|
|
152
|
+
```dart
|
|
153
|
+
final router = GoRouter(
|
|
154
|
+
initialLocation: '/products',
|
|
155
|
+
routes: [
|
|
156
|
+
ShellRoute(
|
|
157
|
+
builder: (context, state, child) => MainShell(child: child),
|
|
158
|
+
routes: [
|
|
159
|
+
GoRoute(
|
|
160
|
+
path: '/products',
|
|
161
|
+
builder: (context, state) => const ProductListScreen(),
|
|
162
|
+
routes: [
|
|
163
|
+
GoRoute(
|
|
164
|
+
path: ':id',
|
|
165
|
+
builder: (context, state) => ProductDetailScreen(
|
|
166
|
+
id: state.pathParameters['id']!,
|
|
167
|
+
),
|
|
168
|
+
),
|
|
169
|
+
],
|
|
170
|
+
),
|
|
171
|
+
GoRoute(
|
|
172
|
+
path: '/cart',
|
|
173
|
+
builder: (context, state) => const CartScreen(),
|
|
174
|
+
),
|
|
175
|
+
],
|
|
176
|
+
),
|
|
177
|
+
],
|
|
178
|
+
);
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Testing Strategy
|
|
182
|
+
|
|
183
|
+
| Layer | Test Type | Tools |
|
|
184
|
+
|-------|-----------|-------|
|
|
185
|
+
| Domain (entities, usecases) | Unit test | `flutter_test`, `mocktail` |
|
|
186
|
+
| Data (repositories, datasources) | Unit + Integration | `mocktail`, `http` mocking |
|
|
187
|
+
| Presentation (providers, blocs) | Unit (bloc test) | `bloc_test`, `riverpod` test utils |
|
|
188
|
+
| Widgets | Widget test | `WidgetTester`, `Finder` |
|
|
189
|
+
| Full app | Integration test | `integration_test` package |
|
|
190
|
+
| Visual | Golden test | `golden_toolkit`, `alchemist` |
|
|
191
|
+
|
|
192
|
+
### Widget Test Example
|
|
193
|
+
|
|
194
|
+
```dart
|
|
195
|
+
testWidgets('ProductList shows loading state', (tester) async {
|
|
196
|
+
await tester.pumpWidget(
|
|
197
|
+
MaterialApp(
|
|
198
|
+
home: BlocProvider(
|
|
199
|
+
create: (_) => ProductBloc(mockRepo)..add(LoadProducts()),
|
|
200
|
+
child: ProductListScreen(),
|
|
201
|
+
),
|
|
202
|
+
),
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
expect(find.byType(CircularProgressIndicator), findsOneWidget);
|
|
206
|
+
|
|
207
|
+
await tester.pumpAndSettle();
|
|
208
|
+
|
|
209
|
+
expect(find.text('Product 1'), findsOneWidget);
|
|
210
|
+
});
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Platform Integration
|
|
214
|
+
|
|
215
|
+
### Method Channel
|
|
216
|
+
|
|
217
|
+
```dart
|
|
218
|
+
// Dart side
|
|
219
|
+
class PlatformService {
|
|
220
|
+
static const _channel = MethodChannel('com.example.app/platform');
|
|
221
|
+
|
|
222
|
+
Future<String> getDeviceId() async {
|
|
223
|
+
try {
|
|
224
|
+
return await _channel.invokeMethod('getDeviceId');
|
|
225
|
+
} on PlatformException catch (e) {
|
|
226
|
+
throw PlatformException(code: e.code, message: e.message);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Firebase Integration
|
|
233
|
+
|
|
234
|
+
```dart
|
|
235
|
+
void main() async {
|
|
236
|
+
WidgetsFlutterBinding.ensureInitialized();
|
|
237
|
+
await Firebase.initializeApp(
|
|
238
|
+
options: DefaultFirebaseOptions.currentPlatform,
|
|
239
|
+
);
|
|
240
|
+
runApp(const MyApp());
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Material Design 3 Theming
|
|
245
|
+
|
|
246
|
+
```dart
|
|
247
|
+
class AppTheme {
|
|
248
|
+
static ThemeData light() {
|
|
249
|
+
final colorScheme = ColorScheme.fromSeed(
|
|
250
|
+
seedColor: const Color(0xFF6750A4),
|
|
251
|
+
brightness: Brightness.light,
|
|
252
|
+
);
|
|
253
|
+
return ThemeData(
|
|
254
|
+
useMaterial3: true,
|
|
255
|
+
colorScheme: colorScheme,
|
|
256
|
+
fontFamily: 'Inter',
|
|
257
|
+
appBarTheme: AppBarTheme(
|
|
258
|
+
centerTitle: true,
|
|
259
|
+
backgroundColor: colorScheme.surface,
|
|
260
|
+
),
|
|
261
|
+
cardTheme: CardTheme(
|
|
262
|
+
elevation: 0,
|
|
263
|
+
shape: RoundedRectangleBorder(
|
|
264
|
+
borderRadius: BorderRadius.circular(12),
|
|
265
|
+
),
|
|
266
|
+
),
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
static ThemeData dark() {
|
|
271
|
+
final colorScheme = ColorScheme.fromSeed(
|
|
272
|
+
seedColor: const Color(0xFF6750A4),
|
|
273
|
+
brightness: Brightness.dark,
|
|
274
|
+
);
|
|
275
|
+
return ThemeData(
|
|
276
|
+
useMaterial3: true,
|
|
277
|
+
colorScheme: colorScheme,
|
|
278
|
+
fontFamily: 'Inter',
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
## Performance Best Practices
|
|
285
|
+
|
|
286
|
+
1. **const constructors** — Always use `const` for widgets that don't change
|
|
287
|
+
2. **RepaintBoundary** — Wrap complex animations with `RepaintBoundary`
|
|
288
|
+
3. **ListView.builder** — Use builder instead of `ListView(children: [...])`
|
|
289
|
+
4. **Image caching** — Use `cached_network_image` or `ImageCache`
|
|
290
|
+
5. **Avoid rebuilds** — Use `const`, `Selector` (Bloc), `select` (Riverpod)
|
|
291
|
+
6. **Lazy loading** — Use `flutter_bloc` `Emitter` or Riverpod `AsyncNotifier` for pagination
|
|
292
|
+
7. **Memory** — Dispose controllers, streams, and subscriptions in `dispose()`
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: flutter-add-integration-test
|
|
3
|
+
description: Configures Flutter Driver for app interaction and converts MCP actions into permanent integration tests. Use when adding integration testing to a project, exploring UI components via MCP, or automating user flows with the integration_test package.
|
|
4
|
+
metadata:
|
|
5
|
+
model: models/gemini-3.1-pro-preview
|
|
6
|
+
last_modified: Tue, 21 Apr 2026 18:29:20 GMT
|
|
7
|
+
---
|
|
8
|
+
# Implementing Flutter Integration Tests
|
|
9
|
+
|
|
10
|
+
## Contents
|
|
11
|
+
- [Project Setup and Dependencies](#project-setup-and-dependencies)
|
|
12
|
+
- [Interactive Exploration via MCP](#interactive-exploration-via-mcp)
|
|
13
|
+
- [Test Authoring Guidelines](#test-authoring-guidelines)
|
|
14
|
+
- [Execution and Profiling](#execution-and-profiling)
|
|
15
|
+
- [Workflow: End-to-End Integration Testing](#workflow-end-to-end-integration-testing)
|
|
16
|
+
- [Examples](#examples)
|
|
17
|
+
|
|
18
|
+
## Project Setup and Dependencies
|
|
19
|
+
|
|
20
|
+
Configure the project to support integration testing and Flutter Driver extensions.
|
|
21
|
+
|
|
22
|
+
1. Add required development dependencies to `pubspec.yaml`:
|
|
23
|
+
```bash
|
|
24
|
+
flutter pub add 'dev:integration_test:{"sdk":"flutter"}'
|
|
25
|
+
flutter pub add 'dev:flutter_test:{"sdk":"flutter"}'
|
|
26
|
+
```
|
|
27
|
+
2. Enable the Flutter Driver extension in your application entry point (typically `lib/main.dart` or a dedicated `lib/main_test.dart`):
|
|
28
|
+
- Import `package:flutter_driver/driver_extension.dart`.
|
|
29
|
+
- Call `enableFlutterDriverExtension();` before `runApp()`.
|
|
30
|
+
3. Add `Key` parameters (e.g., `ValueKey('login_button')`) to critical widgets in the application code to ensure reliable targeting during tests.
|
|
31
|
+
|
|
32
|
+
## Interactive Exploration via MCP
|
|
33
|
+
|
|
34
|
+
Use the Dart/Flutter MCP server tools to interactively explore and manipulate the application state before writing static tests.
|
|
35
|
+
|
|
36
|
+
- **Launch**: Execute `launch_app` with `target: "lib/main_test.dart"` to start the application and acquire the DTD URI.
|
|
37
|
+
- **Inspect**: Execute `get_widget_tree` to discover available `Key`s, `Text` nodes, and widget `Type`s.
|
|
38
|
+
- **Interact**: Execute `tap`, `enter_text`, and `scroll` to simulate user flows.
|
|
39
|
+
- **Wait**: Always execute `waitFor` or verify state with `get_health` when navigating or triggering animations.
|
|
40
|
+
- **Troubleshoot Unmounted Widgets**: If a widget is not found in the tree, it may be lazily loaded in a `SliverList` or `ListView`. Execute `scroll` or `scrollIntoView` to force the widget to mount before interacting with it.
|
|
41
|
+
|
|
42
|
+
## Test Authoring Guidelines
|
|
43
|
+
|
|
44
|
+
Structure integration tests using the `flutter_test` API paradigm.
|
|
45
|
+
|
|
46
|
+
- Create a dedicated `integration_test/` directory at the project root.
|
|
47
|
+
- Name all test files using the `<name>_test.dart` convention.
|
|
48
|
+
- Initialize the binding by calling `IntegrationTestWidgetsFlutterBinding.ensureInitialized();` at the start of `main()`.
|
|
49
|
+
- Load the application UI using `await tester.pumpWidget(MyApp());`.
|
|
50
|
+
- Trigger frames and wait for animations to complete using `await tester.pumpAndSettle();` after interactions like `tester.tap()`.
|
|
51
|
+
- Assert widget visibility using `expect(find.byKey(ValueKey('foo')), findsOneWidget);` or `findsNothing`.
|
|
52
|
+
- Scroll to specific off-screen widgets using `await tester.scrollUntilVisible(itemFinder, 500.0, scrollable: listFinder);`.
|
|
53
|
+
|
|
54
|
+
**Conditional Logic for Legacy `flutter_driver`:**
|
|
55
|
+
- If maintaining or migrating legacy `flutter_driver` tests, use `driver.waitFor()`, `driver.waitForAbsent()`, `driver.tap()`, and `driver.scroll()` instead of the `WidgetTester` APIs.
|
|
56
|
+
|
|
57
|
+
## Execution and Profiling
|
|
58
|
+
|
|
59
|
+
Execute tests using the `flutter drive` command. Require a host driver script located in `test_driver/integration_test.dart` that calls `integrationDriver()`.
|
|
60
|
+
|
|
61
|
+
**Conditional Execution Targets:**
|
|
62
|
+
- **If testing on Chrome:** Launch `chromedriver --port=4444` in a separate terminal, then run:
|
|
63
|
+
`flutter drive --driver=test_driver/integration_test.dart --target=integration_test/app_test.dart -d chrome`
|
|
64
|
+
- **If testing headless web:** Run with `-d web-server`.
|
|
65
|
+
- **If testing on Android (Local):** Run `flutter drive --driver=test_driver/integration_test.dart --target=integration_test/app_test.dart`.
|
|
66
|
+
- **If testing on Firebase Test Lab (Android):**
|
|
67
|
+
1. Build debug APK: `flutter build apk --debug`
|
|
68
|
+
2. Build test APK: `./gradlew app:assembleAndroidTest`
|
|
69
|
+
3. Upload both APKs to the Firebase Test Lab console.
|
|
70
|
+
|
|
71
|
+
## Workflow: End-to-End Integration Testing
|
|
72
|
+
|
|
73
|
+
Copy and follow this checklist to implement and verify integration tests.
|
|
74
|
+
|
|
75
|
+
- [ ] **Task Progress: Setup**
|
|
76
|
+
- [ ] Add `integration_test` and `flutter_test` to `pubspec.yaml`.
|
|
77
|
+
- [ ] Inject `enableFlutterDriverExtension()` into the app entry point.
|
|
78
|
+
- [ ] Assign `ValueKey`s to target widgets.
|
|
79
|
+
- [ ] **Task Progress: Exploration**
|
|
80
|
+
- [ ] Run `launch_app` via MCP.
|
|
81
|
+
- [ ] Map the widget tree using `get_widget_tree`.
|
|
82
|
+
- [ ] Validate interaction paths using MCP tools (`tap`, `enter_text`).
|
|
83
|
+
- [ ] **Task Progress: Authoring**
|
|
84
|
+
- [ ] Create `integration_test/app_test.dart`.
|
|
85
|
+
- [ ] Write test cases using `WidgetTester` APIs.
|
|
86
|
+
- [ ] Create `test_driver/integration_test.dart` with `integrationDriver()`.
|
|
87
|
+
- [ ] **Task Progress: Execution & Feedback Loop**
|
|
88
|
+
- [ ] Run `flutter drive --driver=test_driver/integration_test.dart --target=integration_test/app_test.dart`.
|
|
89
|
+
- [ ] **Feedback Loop**: Review test output -> If `PumpAndSettleTimedOutException` occurs, check for infinite animations -> If widget not found, add `scrollUntilVisible` -> Re-run test until passing.
|
|
90
|
+
|
|
91
|
+
## Examples
|
|
92
|
+
|
|
93
|
+
### Standard Integration Test (`integration_test/app_test.dart`)
|
|
94
|
+
|
|
95
|
+
```dart
|
|
96
|
+
import 'package:flutter/material.dart';
|
|
97
|
+
import 'package:flutter_test/flutter_test.dart';
|
|
98
|
+
import 'package:integration_test/integration_test.dart';
|
|
99
|
+
import 'package:my_app/main.dart';
|
|
100
|
+
|
|
101
|
+
void main() {
|
|
102
|
+
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
|
103
|
+
|
|
104
|
+
group('End-to-end test', () {
|
|
105
|
+
testWidgets('tap on the floating action button, verify counter', (tester) async {
|
|
106
|
+
// Load app widget.
|
|
107
|
+
await tester.pumpWidget(const MyApp());
|
|
108
|
+
|
|
109
|
+
// Verify the counter starts at 0.
|
|
110
|
+
expect(find.text('0'), findsOneWidget);
|
|
111
|
+
|
|
112
|
+
// Find the floating action button to tap on.
|
|
113
|
+
final fab = find.byKey(const ValueKey('increment'));
|
|
114
|
+
|
|
115
|
+
// Emulate a tap on the floating action button.
|
|
116
|
+
await tester.tap(fab);
|
|
117
|
+
|
|
118
|
+
// Trigger a frame and wait for animations.
|
|
119
|
+
await tester.pumpAndSettle();
|
|
120
|
+
|
|
121
|
+
// Verify the counter increments by 1.
|
|
122
|
+
expect(find.text('1'), findsOneWidget);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Host Driver Script (`test_driver/integration_test.dart`)
|
|
129
|
+
|
|
130
|
+
```dart
|
|
131
|
+
import 'package:integration_test/integration_test_driver.dart';
|
|
132
|
+
|
|
133
|
+
Future<void> main() => integrationDriver();
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Performance Profiling Driver Script (`test_driver/perf_driver.dart`)
|
|
137
|
+
|
|
138
|
+
Use this driver script if you wrap your test actions in `binding.traceAction()` to capture performance metrics.
|
|
139
|
+
|
|
140
|
+
```dart
|
|
141
|
+
import 'package:flutter_driver/flutter_driver.dart' as driver;
|
|
142
|
+
import 'package:integration_test/integration_test_driver.dart';
|
|
143
|
+
|
|
144
|
+
Future<void> main() {
|
|
145
|
+
return integrationDriver(
|
|
146
|
+
responseDataCallback: (data) async {
|
|
147
|
+
if (data != null) {
|
|
148
|
+
final timeline = driver.Timeline.fromJson(
|
|
149
|
+
data['scrolling_timeline'] as Map<String, dynamic>,
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
final summary = driver.TimelineSummary.summarize(timeline);
|
|
153
|
+
|
|
154
|
+
await summary.writeTimelineToFile(
|
|
155
|
+
'scrolling_timeline',
|
|
156
|
+
pretty: true,
|
|
157
|
+
includeSummary: true,
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
```
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: flutter-add-widget-preview
|
|
3
|
+
description: Adds interactive widget previews to the project using the previews.dart system. Use when creating new UI components or updating existing screens to ensure consistent design and interactive testing.
|
|
4
|
+
metadata:
|
|
5
|
+
model: models/gemini-3.1-pro-preview
|
|
6
|
+
last_modified: Tue, 21 Apr 2026 20:05:23 GMT
|
|
7
|
+
---
|
|
8
|
+
# Previewing Flutter Widgets
|
|
9
|
+
|
|
10
|
+
## Contents
|
|
11
|
+
- [Preview Guidelines](#preview-guidelines)
|
|
12
|
+
- [Handling Limitations](#handling-limitations)
|
|
13
|
+
- [Workflows](#workflows)
|
|
14
|
+
- [Examples](#examples)
|
|
15
|
+
|
|
16
|
+
## Preview Guidelines
|
|
17
|
+
|
|
18
|
+
Use the Flutter Widget Previewer to render widgets in real-time, isolated from the full application context.
|
|
19
|
+
|
|
20
|
+
- **Target Elements:** Apply the `@Preview` annotation to top-level functions, static methods within a class, or public widget constructors/factories that have no required arguments and return a `Widget` or `WidgetBuilder`.
|
|
21
|
+
- **Imports:** Always import `package:flutter/widget_previews.dart` to access the preview annotations.
|
|
22
|
+
- **Custom Annotations:** Extend the `Preview` class to create custom annotations that inject common properties (e.g., themes, wrappers) across multiple widgets.
|
|
23
|
+
- **Multiple Configurations:** Apply multiple `@Preview` annotations to a single target to generate multiple preview instances. Alternatively, extend `MultiPreview` to encapsulate common multi-preview configurations.
|
|
24
|
+
- **Runtime Transformations:** Override the `transform()` method in custom `Preview` or `MultiPreview` classes to modify preview configurations dynamically at runtime (e.g., generating names based on dynamic values, which is impossible in a `const` context).
|
|
25
|
+
|
|
26
|
+
## Handling Limitations
|
|
27
|
+
|
|
28
|
+
Adhere to the following constraints when authoring previewable widgets, as the Widget Previewer runs in a web environment:
|
|
29
|
+
|
|
30
|
+
- **No Native APIs:** Do not use native plugins or APIs from `dart:io` or `dart:ffi`. Widgets with transitive dependencies on `dart:io` or `dart:ffi` will throw exceptions upon invocation. Use conditional imports to mock or bypass these in preview mode.
|
|
31
|
+
- **Asset Paths:** Use package-based paths for assets loaded via `dart:ui` `fromAsset` APIs (e.g., `packages/my_package_name/assets/my_image.png` instead of `assets/my_image.png`).
|
|
32
|
+
- **Public Callbacks:** Ensure all callback arguments provided to preview annotations are public and constant to satisfy code generation requirements.
|
|
33
|
+
- **Constraints:** Apply explicit constraints using the `size` parameter in the `@Preview` annotation if your widget is unconstrained, as the previewer defaults to constraining them to approximately half the viewport.
|
|
34
|
+
|
|
35
|
+
## Workflows
|
|
36
|
+
|
|
37
|
+
### Creating a Widget Preview
|
|
38
|
+
Copy and track this checklist when implementing a new widget preview:
|
|
39
|
+
|
|
40
|
+
- [ ] Import `package:flutter/widget_previews.dart`.
|
|
41
|
+
- [ ] Identify a valid target (top-level function, static method, or parameter-less public constructor).
|
|
42
|
+
- [ ] Apply the `@Preview` annotation to the target.
|
|
43
|
+
- [ ] Configure preview parameters (`name`, `group`, `size`, `theme`, `brightness`, etc.) as needed.
|
|
44
|
+
- [ ] If applying the same configuration to multiple widgets, extract the configuration into a custom class extending `Preview`.
|
|
45
|
+
|
|
46
|
+
### Interacting with Previews
|
|
47
|
+
Follow the appropriate conditional workflow to launch and interact with the Widget Previewer:
|
|
48
|
+
|
|
49
|
+
**If using a supported IDE (Android Studio, IntelliJ, VS Code with Flutter 3.38+):**
|
|
50
|
+
1. Launch the IDE. The Widget Previewer starts automatically.
|
|
51
|
+
2. Open the "Flutter Widget Preview" tab in the sidebar.
|
|
52
|
+
3. Toggle "Filter previews by selected file" at the bottom left if you want to view previews outside the currently active file.
|
|
53
|
+
|
|
54
|
+
**If using the Command Line:**
|
|
55
|
+
1. Navigate to the Flutter project's root directory.
|
|
56
|
+
2. Run `flutter widget-preview start`.
|
|
57
|
+
3. View the automatically opened Chrome environment.
|
|
58
|
+
|
|
59
|
+
**Feedback Loop: Preview Iteration**
|
|
60
|
+
1. Modify the widget code or preview configuration.
|
|
61
|
+
2. Observe the automatic update in the Widget Previewer.
|
|
62
|
+
3. If global state (e.g., static initializers) was modified: Click the global hot restart button at the bottom right.
|
|
63
|
+
4. If only the local widget state needs resetting: Click the individual hot restart button on the specific preview card.
|
|
64
|
+
5. Review errors in the IDE/CLI console -> fix -> repeat.
|
|
65
|
+
|
|
66
|
+
## Examples
|
|
67
|
+
|
|
68
|
+
### Basic Preview
|
|
69
|
+
```dart
|
|
70
|
+
import 'package:flutter/widget_previews.dart';
|
|
71
|
+
import 'package:flutter/material.dart';
|
|
72
|
+
|
|
73
|
+
@Preview(name: 'My Sample Text', group: 'Typography')
|
|
74
|
+
Widget mySampleText() {
|
|
75
|
+
return const Text('Hello, World!');
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Custom Preview with Runtime Transformation
|
|
80
|
+
```dart
|
|
81
|
+
import 'package:flutter/widget_previews.dart';
|
|
82
|
+
import 'package:flutter/material.dart';
|
|
83
|
+
|
|
84
|
+
final class TransformativePreview extends Preview {
|
|
85
|
+
const TransformativePreview({
|
|
86
|
+
super.name,
|
|
87
|
+
super.group,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
PreviewThemeData _themeBuilder() {
|
|
91
|
+
return PreviewThemeData(
|
|
92
|
+
materialLight: ThemeData.light(),
|
|
93
|
+
materialDark: ThemeData.dark(),
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@override
|
|
98
|
+
Preview transform() {
|
|
99
|
+
final originalPreview = super.transform();
|
|
100
|
+
final builder = originalPreview.toBuilder();
|
|
101
|
+
|
|
102
|
+
builder
|
|
103
|
+
..name = 'Transformed - ${originalPreview.name}'
|
|
104
|
+
..theme = _themeBuilder;
|
|
105
|
+
|
|
106
|
+
return builder.toPreview();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@TransformativePreview(name: 'Custom Themed Button')
|
|
111
|
+
Widget myButton() => const ElevatedButton(onPressed: null, child: Text('Click'));
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### MultiPreview Implementation
|
|
115
|
+
```dart
|
|
116
|
+
import 'package:flutter/widget_previews.dart';
|
|
117
|
+
import 'package:flutter/material.dart';
|
|
118
|
+
|
|
119
|
+
/// Creates light and dark mode previews automatically.
|
|
120
|
+
final class MultiBrightnessPreview extends MultiPreview {
|
|
121
|
+
const MultiBrightnessPreview({required this.name});
|
|
122
|
+
|
|
123
|
+
final String name;
|
|
124
|
+
|
|
125
|
+
@override
|
|
126
|
+
List<Preview> get previews => const [
|
|
127
|
+
Preview(brightness: Brightness.light),
|
|
128
|
+
Preview(brightness: Brightness.dark),
|
|
129
|
+
];
|
|
130
|
+
|
|
131
|
+
@override
|
|
132
|
+
List<Preview> transform() {
|
|
133
|
+
final previews = super.transform();
|
|
134
|
+
return previews.map((preview) {
|
|
135
|
+
final builder = preview.toBuilder()
|
|
136
|
+
..group = 'Brightness'
|
|
137
|
+
..name = '$name - ${preview.brightness!.name}';
|
|
138
|
+
return builder.toPreview();
|
|
139
|
+
}).toList();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@MultiBrightnessPreview(name: 'Primary Card')
|
|
144
|
+
Widget cardPreview() => const Card(child: Padding(padding: EdgeInsets.all(8.0), child: Text('Content')));
|
|
145
|
+
```
|