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.
Files changed (361) hide show
  1. package/README.md +796 -0
  2. package/bin/commands/init.mjs +221 -0
  3. package/bin/init.mjs +21 -0
  4. package/package.json +22 -0
  5. package/template/.opencode/agent-docs/backend/README.md +0 -0
  6. package/template/.opencode/agent-docs/backend/node/BACKEND_PATTERNS.md +82 -0
  7. package/template/.opencode/agent-docs/backend/node/BACKEND_QUICK_START.md +49 -0
  8. package/template/.opencode/agent-docs/frontend/next/README.md +0 -0
  9. package/template/.opencode/agent-docs/frontend/nuxt/API_PATTERNS.md +807 -0
  10. package/template/.opencode/agent-docs/frontend/nuxt/CHEATSHEET.md +676 -0
  11. package/template/.opencode/agent-docs/frontend/nuxt/COMPLETION_REPORT.md +613 -0
  12. package/template/.opencode/agent-docs/frontend/nuxt/EXAMPLES.md +956 -0
  13. package/template/.opencode/agent-docs/frontend/nuxt/INDEX.md +596 -0
  14. package/template/.opencode/agent-docs/frontend/nuxt/MCP_GUIDE.md +881 -0
  15. package/template/.opencode/agent-docs/frontend/nuxt/MENTOR_CURRICULUM_30_DAYS.md +256 -0
  16. package/template/.opencode/agent-docs/frontend/nuxt/MENTOR_CURRICULUM_CHECKLIST.md +156 -0
  17. package/template/.opencode/agent-docs/frontend/nuxt/MENTOR_WEEKLY_ASSIGNMENTS.md +191 -0
  18. package/template/.opencode/agent-docs/frontend/nuxt/QUICK_START.md +509 -0
  19. package/template/.opencode/agent-docs/frontend/nuxt/README.md +506 -0
  20. package/template/.opencode/agent-docs/frontend/nuxt/README_AGENTS.md +140 -0
  21. package/template/.opencode/agent-docs/frontend/nuxt/README_DOCS.md +65 -0
  22. package/template/.opencode/agent-docs/frontend/nuxt/SUMMARY.md +474 -0
  23. package/template/.opencode/agent-docs/frontend/nuxt/TEAM_OPERATING_GUIDE.md +54 -0
  24. package/template/.opencode/agent-docs/frontend/nuxt/TESTING_GUIDE.md +904 -0
  25. package/template/.opencode/agent-docs/frontend/nuxt/WORKFLOWS.md +758 -0
  26. package/template/.opencode/agent-docs/frontend/react/API_PATTERNS.md +187 -0
  27. package/template/.opencode/agent-docs/frontend/react/CHEATSHEET.md +87 -0
  28. package/template/.opencode/agent-docs/frontend/react/INDEX.md +45 -0
  29. package/template/.opencode/agent-docs/frontend/react/QUICK_START.md +43 -0
  30. package/template/.opencode/agent-docs/frontend/react/README.md +159 -0
  31. package/template/.opencode/agent-docs/frontend/vue/README.md +0 -0
  32. package/template/.opencode/agent-docs/mobile/android/README.md +45 -0
  33. package/template/.opencode/agent-docs/mobile/flutter/README.md +44 -0
  34. package/template/.opencode/agents/android-developer.md +418 -0
  35. package/template/.opencode/agents/code-igniter-3-fullstack.md +345 -0
  36. package/template/.opencode/agents/code-reviewer.md +517 -0
  37. package/template/.opencode/agents/database-specialist.md +455 -0
  38. package/template/.opencode/agents/devops-specialist.md +562 -0
  39. package/template/.opencode/agents/flutter-developer.md +556 -0
  40. package/template/.opencode/agents/it-leader.md +911 -0
  41. package/template/.opencode/agents/laravel-advanced.md +691 -0
  42. package/template/.opencode/agents/node-backend-developer.md +343 -0
  43. package/template/.opencode/agents/nuxt-frontend-developer-mentor.md +402 -0
  44. package/template/.opencode/agents/nuxt-frontend-developer.md +1573 -0
  45. package/template/.opencode/agents/react-frontend-developer.md +1017 -0
  46. package/template/.opencode/agents/seo-specialist.md +681 -0
  47. package/template/.opencode/agents/ui-ux-designer.md +783 -0
  48. package/template/.opencode/commands/android-build/command.md +25 -0
  49. package/template/.opencode/commands/android-test/command.md +23 -0
  50. package/template/.opencode/commands/build-fix.md +29 -0
  51. package/template/.opencode/commands/checkpoint.md +74 -0
  52. package/template/.opencode/commands/code-review.md +40 -0
  53. package/template/.opencode/commands/e2e.md +363 -0
  54. package/template/.opencode/commands/eval.md +120 -0
  55. package/template/.opencode/commands/evolve.md +193 -0
  56. package/template/.opencode/commands/flutter-build/command.md +25 -0
  57. package/template/.opencode/commands/flutter-test/command.md +24 -0
  58. package/template/.opencode/commands/go-build.md +183 -0
  59. package/template/.opencode/commands/go-review.md +148 -0
  60. package/template/.opencode/commands/go-test.md +268 -0
  61. package/template/.opencode/commands/gpc-release/command.md +30 -0
  62. package/template/.opencode/commands/instinct-export.md +91 -0
  63. package/template/.opencode/commands/instinct-import.md +142 -0
  64. package/template/.opencode/commands/instinct-status.md +86 -0
  65. package/template/.opencode/commands/learn.md +70 -0
  66. package/template/.opencode/commands/multi-backend.md +158 -0
  67. package/template/.opencode/commands/multi-execute.md +310 -0
  68. package/template/.opencode/commands/multi-frontend.md +158 -0
  69. package/template/.opencode/commands/multi-plan.md +261 -0
  70. package/template/.opencode/commands/multi-workflow.md +183 -0
  71. package/template/.opencode/commands/orchestrate.md +172 -0
  72. package/template/.opencode/commands/plan.md +113 -0
  73. package/template/.opencode/commands/pm2.md +271 -0
  74. package/template/.opencode/commands/python-review.md +297 -0
  75. package/template/.opencode/commands/refactor-clean.md +28 -0
  76. package/template/.opencode/commands/sessions.md +305 -0
  77. package/template/.opencode/commands/setup-pm.md +80 -0
  78. package/template/.opencode/commands/skill-create.md +174 -0
  79. package/template/.opencode/commands/tdd.md +326 -0
  80. package/template/.opencode/commands/test-coverage.md +27 -0
  81. package/template/.opencode/commands/update-codemaps.md +17 -0
  82. package/template/.opencode/commands/update-docs.md +31 -0
  83. package/template/.opencode/commands/verify.md +59 -0
  84. package/template/.opencode/config.example.json +309 -0
  85. package/template/.opencode/config.json +341 -0
  86. package/template/.opencode/contexts/dev.md +20 -0
  87. package/template/.opencode/contexts/research.md +26 -0
  88. package/template/.opencode/contexts/review.md +22 -0
  89. package/template/.opencode/hooks/hooks.json +169 -0
  90. package/template/.opencode/instructions/INSTRUCTIONS.md +388 -0
  91. package/template/.opencode/package.json +5 -0
  92. package/template/.opencode/rules/README.md +82 -0
  93. package/template/.opencode/rules/android/gradle.md +62 -0
  94. package/template/.opencode/rules/android/testing.md +27 -0
  95. package/template/.opencode/rules/common/agents.md +49 -0
  96. package/template/.opencode/rules/common/coding-style.md +48 -0
  97. package/template/.opencode/rules/common/git-workflow.md +45 -0
  98. package/template/.opencode/rules/common/hooks.md +30 -0
  99. package/template/.opencode/rules/common/patterns.md +31 -0
  100. package/template/.opencode/rules/common/performance.md +55 -0
  101. package/template/.opencode/rules/common/security.md +29 -0
  102. package/template/.opencode/rules/common/testing.md +29 -0
  103. package/template/.opencode/rules/flutter/state-management.md +57 -0
  104. package/template/.opencode/rules/flutter/testing.md +42 -0
  105. package/template/.opencode/rules/golang/coding-style.md +26 -0
  106. package/template/.opencode/rules/golang/hooks.md +11 -0
  107. package/template/.opencode/rules/golang/patterns.md +39 -0
  108. package/template/.opencode/rules/golang/security.md +28 -0
  109. package/template/.opencode/rules/golang/testing.md +25 -0
  110. package/template/.opencode/rules/mobile/performance.md +36 -0
  111. package/template/.opencode/rules/python/coding-style.md +37 -0
  112. package/template/.opencode/rules/python/hooks.md +14 -0
  113. package/template/.opencode/rules/python/patterns.md +34 -0
  114. package/template/.opencode/rules/python/security.md +25 -0
  115. package/template/.opencode/rules/python/testing.md +33 -0
  116. package/template/.opencode/rules/typescript/coding-style.md +58 -0
  117. package/template/.opencode/rules/typescript/hooks.md +15 -0
  118. package/template/.opencode/rules/typescript/patterns.md +45 -0
  119. package/template/.opencode/rules/typescript/security.md +21 -0
  120. package/template/.opencode/rules/typescript/testing.md +11 -0
  121. package/template/.opencode/skills/api-documentation/SKILL.md +188 -0
  122. package/template/.opencode/skills/backend-patterns/SKILL.md +587 -0
  123. package/template/.opencode/skills/building-components/SKILL.md +37 -0
  124. package/template/.opencode/skills/building-components/references/accessibility.mdx +819 -0
  125. package/template/.opencode/skills/building-components/references/as-child.mdx +324 -0
  126. package/template/.opencode/skills/building-components/references/composition.mdx +239 -0
  127. package/template/.opencode/skills/building-components/references/data-attributes.mdx +413 -0
  128. package/template/.opencode/skills/building-components/references/definitions.mdx +258 -0
  129. package/template/.opencode/skills/building-components/references/design-tokens.mdx +57 -0
  130. package/template/.opencode/skills/building-components/references/docs.mdx +155 -0
  131. package/template/.opencode/skills/building-components/references/marketplaces.mdx +144 -0
  132. package/template/.opencode/skills/building-components/references/npm.mdx +166 -0
  133. package/template/.opencode/skills/building-components/references/polymorphism.mdx +583 -0
  134. package/template/.opencode/skills/building-components/references/principles.mdx +61 -0
  135. package/template/.opencode/skills/building-components/references/registry.mdx +169 -0
  136. package/template/.opencode/skills/building-components/references/state.mdx +99 -0
  137. package/template/.opencode/skills/building-components/references/styling.mdx +286 -0
  138. package/template/.opencode/skills/building-components/references/types.mdx +191 -0
  139. package/template/.opencode/skills/clickhouse-io/SKILL.md +429 -0
  140. package/template/.opencode/skills/coding-standards/SKILL.md +520 -0
  141. package/template/.opencode/skills/configure-ecc/SKILL.md +298 -0
  142. package/template/.opencode/skills/continuous-learning/SKILL.md +110 -0
  143. package/template/.opencode/skills/continuous-learning/config.json +18 -0
  144. package/template/.opencode/skills/continuous-learning/evaluate-session.sh +60 -0
  145. package/template/.opencode/skills/continuous-learning-v2/SKILL.md +284 -0
  146. package/template/.opencode/skills/continuous-learning-v2/agents/observer.md +137 -0
  147. package/template/.opencode/skills/continuous-learning-v2/agents/start-observer.sh +134 -0
  148. package/template/.opencode/skills/continuous-learning-v2/config.json +41 -0
  149. package/template/.opencode/skills/continuous-learning-v2/hooks/observe.sh +153 -0
  150. package/template/.opencode/skills/continuous-learning-v2/scripts/instinct-cli.py +489 -0
  151. package/template/.opencode/skills/continuous-learning-v2/scripts/test_parse_instinct.py +82 -0
  152. package/template/.opencode/skills/dart-add-unit-test/SKILL.md +122 -0
  153. package/template/.opencode/skills/dart-build-cli-app/SKILL.md +185 -0
  154. package/template/.opencode/skills/dart-collect-coverage/SKILL.md +141 -0
  155. package/template/.opencode/skills/dart-fix-runtime-errors/SKILL.md +166 -0
  156. package/template/.opencode/skills/dart-generate-test-mocks/SKILL.md +155 -0
  157. package/template/.opencode/skills/dart-migrate-to-checks-package/SKILL.md +126 -0
  158. package/template/.opencode/skills/dart-resolve-package-conflicts/SKILL.md +116 -0
  159. package/template/.opencode/skills/dart-run-static-analysis/SKILL.md +104 -0
  160. package/template/.opencode/skills/dart-use-pattern-matching/SKILL.md +146 -0
  161. package/template/.opencode/skills/django-patterns/SKILL.md +733 -0
  162. package/template/.opencode/skills/django-security/SKILL.md +592 -0
  163. package/template/.opencode/skills/django-tdd/SKILL.md +728 -0
  164. package/template/.opencode/skills/django-verification/SKILL.md +460 -0
  165. package/template/.opencode/skills/eval-harness/SKILL.md +227 -0
  166. package/template/.opencode/skills/firebase-basics/SKILL.md +103 -0
  167. package/template/.opencode/skills/firebase-basics/references/additional-skills.md +113 -0
  168. package/template/.opencode/skills/firebase-basics/references/cli-usage.md +31 -0
  169. package/template/.opencode/skills/firebase-basics/references/client-library-usage.md +45 -0
  170. package/template/.opencode/skills/firebase-basics/references/core-concepts.md +61 -0
  171. package/template/.opencode/skills/firebase-basics/references/iac-usage.md +40 -0
  172. package/template/.opencode/skills/firebase-basics/references/iam-security.md +74 -0
  173. package/template/.opencode/skills/firebase-basics/references/mcp-usage.md +63 -0
  174. package/template/.opencode/skills/flutter/SKILL.md +292 -0
  175. package/template/.opencode/skills/flutter-add-integration-test/SKILL.md +163 -0
  176. package/template/.opencode/skills/flutter-add-widget-preview/SKILL.md +145 -0
  177. package/template/.opencode/skills/flutter-add-widget-test/SKILL.md +154 -0
  178. package/template/.opencode/skills/flutter-apply-architecture-best-practices/SKILL.md +162 -0
  179. package/template/.opencode/skills/flutter-build-responsive-layout/SKILL.md +139 -0
  180. package/template/.opencode/skills/flutter-fix-layout-issues/SKILL.md +130 -0
  181. package/template/.opencode/skills/flutter-implement-json-serialization/SKILL.md +153 -0
  182. package/template/.opencode/skills/flutter-setup-declarative-routing/SKILL.md +255 -0
  183. package/template/.opencode/skills/flutter-setup-localization/SKILL.md +210 -0
  184. package/template/.opencode/skills/flutter-use-http-package/SKILL.md +174 -0
  185. package/template/.opencode/skills/frontend-design/SKILL.md +89 -0
  186. package/template/.opencode/skills/frontend-patterns/SKILL.md +631 -0
  187. package/template/.opencode/skills/golang-patterns/SKILL.md +673 -0
  188. package/template/.opencode/skills/golang-testing/SKILL.md +719 -0
  189. package/template/.opencode/skills/impeccable/SKILL.md +165 -0
  190. package/template/.opencode/skills/impeccable/agents/impeccable-asset-producer.md +101 -0
  191. package/template/.opencode/skills/impeccable/reference/adapt.md +190 -0
  192. package/template/.opencode/skills/impeccable/reference/animate.md +175 -0
  193. package/template/.opencode/skills/impeccable/reference/audit.md +133 -0
  194. package/template/.opencode/skills/impeccable/reference/bolder.md +113 -0
  195. package/template/.opencode/skills/impeccable/reference/brand.md +118 -0
  196. package/template/.opencode/skills/impeccable/reference/clarify.md +174 -0
  197. package/template/.opencode/skills/impeccable/reference/codex.md +105 -0
  198. package/template/.opencode/skills/impeccable/reference/cognitive-load.md +106 -0
  199. package/template/.opencode/skills/impeccable/reference/color-and-contrast.md +105 -0
  200. package/template/.opencode/skills/impeccable/reference/colorize.md +154 -0
  201. package/template/.opencode/skills/impeccable/reference/craft.md +123 -0
  202. package/template/.opencode/skills/impeccable/reference/critique.md +273 -0
  203. package/template/.opencode/skills/impeccable/reference/delight.md +302 -0
  204. package/template/.opencode/skills/impeccable/reference/distill.md +111 -0
  205. package/template/.opencode/skills/impeccable/reference/document.md +427 -0
  206. package/template/.opencode/skills/impeccable/reference/extract.md +69 -0
  207. package/template/.opencode/skills/impeccable/reference/harden.md +347 -0
  208. package/template/.opencode/skills/impeccable/reference/heuristics-scoring.md +234 -0
  209. package/template/.opencode/skills/impeccable/reference/interaction-design.md +195 -0
  210. package/template/.opencode/skills/impeccable/reference/layout.md +141 -0
  211. package/template/.opencode/skills/impeccable/reference/live.md +622 -0
  212. package/template/.opencode/skills/impeccable/reference/motion-design.md +109 -0
  213. package/template/.opencode/skills/impeccable/reference/onboard.md +234 -0
  214. package/template/.opencode/skills/impeccable/reference/optimize.md +258 -0
  215. package/template/.opencode/skills/impeccable/reference/overdrive.md +130 -0
  216. package/template/.opencode/skills/impeccable/reference/personas.md +179 -0
  217. package/template/.opencode/skills/impeccable/reference/polish.md +242 -0
  218. package/template/.opencode/skills/impeccable/reference/product.md +62 -0
  219. package/template/.opencode/skills/impeccable/reference/quieter.md +99 -0
  220. package/template/.opencode/skills/impeccable/reference/responsive-design.md +114 -0
  221. package/template/.opencode/skills/impeccable/reference/shape.md +165 -0
  222. package/template/.opencode/skills/impeccable/reference/spatial-design.md +100 -0
  223. package/template/.opencode/skills/impeccable/reference/teach.md +156 -0
  224. package/template/.opencode/skills/impeccable/reference/typeset.md +124 -0
  225. package/template/.opencode/skills/impeccable/reference/typography.md +159 -0
  226. package/template/.opencode/skills/impeccable/reference/ux-writing.md +107 -0
  227. package/template/.opencode/skills/impeccable/scripts/cleanup-deprecated.mjs +284 -0
  228. package/template/.opencode/skills/impeccable/scripts/command-metadata.json +94 -0
  229. package/template/.opencode/skills/impeccable/scripts/critique-storage.mjs +242 -0
  230. package/template/.opencode/skills/impeccable/scripts/design-parser.mjs +820 -0
  231. package/template/.opencode/skills/impeccable/scripts/detect-csp.mjs +198 -0
  232. package/template/.opencode/skills/impeccable/scripts/detect.mjs +21 -0
  233. package/template/.opencode/skills/impeccable/scripts/impeccable-paths.mjs +110 -0
  234. package/template/.opencode/skills/impeccable/scripts/is-generated.mjs +69 -0
  235. package/template/.opencode/skills/impeccable/scripts/live-accept.mjs +595 -0
  236. package/template/.opencode/skills/impeccable/scripts/live-browser-session.js +123 -0
  237. package/template/.opencode/skills/impeccable/scripts/live-browser.js +4860 -0
  238. package/template/.opencode/skills/impeccable/scripts/live-complete.mjs +75 -0
  239. package/template/.opencode/skills/impeccable/scripts/live-completion.mjs +18 -0
  240. package/template/.opencode/skills/impeccable/scripts/live-inject.mjs +446 -0
  241. package/template/.opencode/skills/impeccable/scripts/live-poll.mjs +200 -0
  242. package/template/.opencode/skills/impeccable/scripts/live-resume.mjs +48 -0
  243. package/template/.opencode/skills/impeccable/scripts/live-server.mjs +838 -0
  244. package/template/.opencode/skills/impeccable/scripts/live-session-store.mjs +254 -0
  245. package/template/.opencode/skills/impeccable/scripts/live-status.mjs +47 -0
  246. package/template/.opencode/skills/impeccable/scripts/live-wrap.mjs +632 -0
  247. package/template/.opencode/skills/impeccable/scripts/live.mjs +247 -0
  248. package/template/.opencode/skills/impeccable/scripts/load-context.mjs +141 -0
  249. package/template/.opencode/skills/impeccable/scripts/modern-screenshot.umd.js +14 -0
  250. package/template/.opencode/skills/impeccable/scripts/pin.mjs +214 -0
  251. package/template/.opencode/skills/iterative-retrieval/SKILL.md +202 -0
  252. package/template/.opencode/skills/java-coding-standards/SKILL.md +138 -0
  253. package/template/.opencode/skills/jetpack-compose/.skillfish.json +10 -0
  254. package/template/.opencode/skills/jetpack-compose/SKILL.md +420 -0
  255. package/template/.opencode/skills/jpa-patterns/SKILL.md +141 -0
  256. package/template/.opencode/skills/nutrient-document-processing/SKILL.md +165 -0
  257. package/template/.opencode/skills/nuxt-ui/SKILL.md +334 -0
  258. package/template/.opencode/skills/nuxt-ui/references/components.md +377 -0
  259. package/template/.opencode/skills/nuxt-ui/references/composables.md +127 -0
  260. package/template/.opencode/skills/nuxt-ui/references/layouts/chat.md +266 -0
  261. package/template/.opencode/skills/nuxt-ui/references/layouts/dashboard.md +220 -0
  262. package/template/.opencode/skills/nuxt-ui/references/layouts/docs.md +141 -0
  263. package/template/.opencode/skills/nuxt-ui/references/layouts/editor.md +168 -0
  264. package/template/.opencode/skills/nuxt-ui/references/layouts/page.md +260 -0
  265. package/template/.opencode/skills/nuxt-ui/references/theming.md +427 -0
  266. package/template/.opencode/skills/postgres-patterns/SKILL.md +146 -0
  267. package/template/.opencode/skills/project-guidelines-example/SKILL.md +345 -0
  268. package/template/.opencode/skills/python-patterns/SKILL.md +749 -0
  269. package/template/.opencode/skills/python-testing/SKILL.md +815 -0
  270. package/template/.opencode/skills/security-review/SKILL.md +494 -0
  271. package/template/.opencode/skills/security-review/cloud-infrastructure-security.md +361 -0
  272. package/template/.opencode/skills/shadcn-ui/README.md +248 -0
  273. package/template/.opencode/skills/shadcn-ui/SKILL.md +326 -0
  274. package/template/.opencode/skills/shadcn-ui/examples/auth-layout.tsx +177 -0
  275. package/template/.opencode/skills/shadcn-ui/examples/data-table.tsx +313 -0
  276. package/template/.opencode/skills/shadcn-ui/examples/form-pattern.tsx +177 -0
  277. package/template/.opencode/skills/shadcn-ui/resources/component-catalog.md +481 -0
  278. package/template/.opencode/skills/shadcn-ui/resources/customization-guide.md +516 -0
  279. package/template/.opencode/skills/shadcn-ui/resources/migration-guide.md +463 -0
  280. package/template/.opencode/skills/shadcn-ui/resources/setup-guide.md +412 -0
  281. package/template/.opencode/skills/shadcn-ui/scripts/verify-setup.sh +134 -0
  282. package/template/.opencode/skills/springboot-patterns/SKILL.md +304 -0
  283. package/template/.opencode/skills/springboot-security/SKILL.md +119 -0
  284. package/template/.opencode/skills/springboot-tdd/SKILL.md +157 -0
  285. package/template/.opencode/skills/springboot-verification/SKILL.md +100 -0
  286. package/template/.opencode/skills/strategic-compact/SKILL.md +63 -0
  287. package/template/.opencode/skills/strategic-compact/suggest-compact.sh +52 -0
  288. package/template/.opencode/skills/tdd-workflow/SKILL.md +409 -0
  289. package/template/.opencode/skills/vercel-composition-patterns/AGENTS.md +946 -0
  290. package/template/.opencode/skills/vercel-composition-patterns/SKILL.md +89 -0
  291. package/template/.opencode/skills/vercel-composition-patterns/rules/architecture-avoid-boolean-props.md +100 -0
  292. package/template/.opencode/skills/vercel-composition-patterns/rules/architecture-compound-components.md +112 -0
  293. package/template/.opencode/skills/vercel-composition-patterns/rules/patterns-children-over-render-props.md +87 -0
  294. package/template/.opencode/skills/vercel-composition-patterns/rules/patterns-explicit-variants.md +100 -0
  295. package/template/.opencode/skills/vercel-composition-patterns/rules/react19-no-forwardref.md +42 -0
  296. package/template/.opencode/skills/vercel-composition-patterns/rules/state-context-interface.md +191 -0
  297. package/template/.opencode/skills/vercel-composition-patterns/rules/state-decouple-implementation.md +113 -0
  298. package/template/.opencode/skills/vercel-composition-patterns/rules/state-lift-state.md +125 -0
  299. package/template/.opencode/skills/vercel-react-best-practices/AGENTS.md +2934 -0
  300. package/template/.opencode/skills/vercel-react-best-practices/SKILL.md +136 -0
  301. package/template/.opencode/skills/vercel-react-best-practices/rules/advanced-event-handler-refs.md +55 -0
  302. package/template/.opencode/skills/vercel-react-best-practices/rules/advanced-init-once.md +42 -0
  303. package/template/.opencode/skills/vercel-react-best-practices/rules/advanced-use-latest.md +39 -0
  304. package/template/.opencode/skills/vercel-react-best-practices/rules/async-api-routes.md +38 -0
  305. package/template/.opencode/skills/vercel-react-best-practices/rules/async-defer-await.md +80 -0
  306. package/template/.opencode/skills/vercel-react-best-practices/rules/async-dependencies.md +51 -0
  307. package/template/.opencode/skills/vercel-react-best-practices/rules/async-parallel.md +28 -0
  308. package/template/.opencode/skills/vercel-react-best-practices/rules/async-suspense-boundaries.md +99 -0
  309. package/template/.opencode/skills/vercel-react-best-practices/rules/bundle-barrel-imports.md +59 -0
  310. package/template/.opencode/skills/vercel-react-best-practices/rules/bundle-conditional.md +31 -0
  311. package/template/.opencode/skills/vercel-react-best-practices/rules/bundle-defer-third-party.md +49 -0
  312. package/template/.opencode/skills/vercel-react-best-practices/rules/bundle-dynamic-imports.md +35 -0
  313. package/template/.opencode/skills/vercel-react-best-practices/rules/bundle-preload.md +50 -0
  314. package/template/.opencode/skills/vercel-react-best-practices/rules/client-event-listeners.md +74 -0
  315. package/template/.opencode/skills/vercel-react-best-practices/rules/client-localstorage-schema.md +71 -0
  316. package/template/.opencode/skills/vercel-react-best-practices/rules/client-passive-event-listeners.md +48 -0
  317. package/template/.opencode/skills/vercel-react-best-practices/rules/client-swr-dedup.md +56 -0
  318. package/template/.opencode/skills/vercel-react-best-practices/rules/js-batch-dom-css.md +107 -0
  319. package/template/.opencode/skills/vercel-react-best-practices/rules/js-cache-function-results.md +80 -0
  320. package/template/.opencode/skills/vercel-react-best-practices/rules/js-cache-property-access.md +28 -0
  321. package/template/.opencode/skills/vercel-react-best-practices/rules/js-cache-storage.md +70 -0
  322. package/template/.opencode/skills/vercel-react-best-practices/rules/js-combine-iterations.md +32 -0
  323. package/template/.opencode/skills/vercel-react-best-practices/rules/js-early-exit.md +50 -0
  324. package/template/.opencode/skills/vercel-react-best-practices/rules/js-hoist-regexp.md +45 -0
  325. package/template/.opencode/skills/vercel-react-best-practices/rules/js-index-maps.md +37 -0
  326. package/template/.opencode/skills/vercel-react-best-practices/rules/js-length-check-first.md +49 -0
  327. package/template/.opencode/skills/vercel-react-best-practices/rules/js-min-max-loop.md +82 -0
  328. package/template/.opencode/skills/vercel-react-best-practices/rules/js-set-map-lookups.md +24 -0
  329. package/template/.opencode/skills/vercel-react-best-practices/rules/js-tosorted-immutable.md +57 -0
  330. package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-activity.md +26 -0
  331. package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
  332. package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-conditional-render.md +40 -0
  333. package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-content-visibility.md +38 -0
  334. package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-hoist-jsx.md +46 -0
  335. package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
  336. package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-hydration-suppress-warning.md +30 -0
  337. package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-svg-precision.md +28 -0
  338. package/template/.opencode/skills/vercel-react-best-practices/rules/rendering-usetransition-loading.md +75 -0
  339. package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-defer-reads.md +39 -0
  340. package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-dependencies.md +45 -0
  341. package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-derived-state-no-effect.md +40 -0
  342. package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-derived-state.md +29 -0
  343. package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-functional-setstate.md +74 -0
  344. package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-lazy-state-init.md +58 -0
  345. package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-memo-with-default-value.md +38 -0
  346. package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-memo.md +44 -0
  347. package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-move-effect-to-event.md +45 -0
  348. package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-simple-expression-in-memo.md +35 -0
  349. package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-transitions.md +40 -0
  350. package/template/.opencode/skills/vercel-react-best-practices/rules/rerender-use-ref-transient-values.md +73 -0
  351. package/template/.opencode/skills/vercel-react-best-practices/rules/server-after-nonblocking.md +73 -0
  352. package/template/.opencode/skills/vercel-react-best-practices/rules/server-auth-actions.md +96 -0
  353. package/template/.opencode/skills/vercel-react-best-practices/rules/server-cache-lru.md +41 -0
  354. package/template/.opencode/skills/vercel-react-best-practices/rules/server-cache-react.md +76 -0
  355. package/template/.opencode/skills/vercel-react-best-practices/rules/server-dedup-props.md +65 -0
  356. package/template/.opencode/skills/vercel-react-best-practices/rules/server-parallel-fetching.md +83 -0
  357. package/template/.opencode/skills/vercel-react-best-practices/rules/server-serialization.md +38 -0
  358. package/template/.opencode/skills/verification-loop/SKILL.md +120 -0
  359. package/template/.opencode/skills/web-design-guidelines/SKILL.md +39 -0
  360. package/template/AGENTS.md +32 -0
  361. package/template/opencode.json +354 -0
@@ -0,0 +1,155 @@
1
+ ---
2
+ name: dart-generate-test-mocks
3
+ description: Define and generate mock objects for external dependencies using `package:mockito` and `build_runner`. Use when unit testing classes that depend on complex external services like APIs or databases.
4
+ metadata:
5
+ model: models/gemini-3.1-pro-preview
6
+ last_modified: Fri, 24 Apr 2026 15:13:58 GMT
7
+ ---
8
+ # Testing and Mocking Dart Applications
9
+
10
+ ## Contents
11
+ - [Structuring Code for Testability](#structuring-code-for-testability)
12
+ - [Managing Dependencies](#managing-dependencies)
13
+ - [Generating Mocks](#generating-mocks)
14
+ - [Implementing Unit Tests](#implementing-unit-tests)
15
+ - [Workflow: Creating and Running Mocked Tests](#workflow-creating-and-running-mocked-tests)
16
+ - [Examples](#examples)
17
+
18
+ ## Structuring Code for Testability
19
+ Design Dart classes to support dependency injection. Isolate complex external dependencies (like API clients or databases) so they can be replaced with mock objects during testing.
20
+
21
+ - Inject external services (e.g., `http.Client`) through class constructors.
22
+ - Represent URLs strictly as `Uri` objects using `Uri.parse(string)`.
23
+ - Utilize Dart's object-oriented features (classes, mixins) to define clear interfaces for external interactions.
24
+
25
+ ## Managing Dependencies
26
+ Configure the `pubspec.yaml` file with the necessary testing and code generation packages.
27
+
28
+ - Add runtime dependencies (e.g., `package:http`) using `dart pub add http`.
29
+ - Add testing dependencies using `dart pub add dev:test dev:mockito dev:build_runner`.
30
+ - Import HTTP libraries with a prefix to avoid namespace collisions: `import 'package:http/http.dart' as http;`.
31
+
32
+ ## Generating Mocks
33
+ Use `package:mockito` and `build_runner` to automatically generate mock classes for fixed scenarios and behavior verification.
34
+
35
+ - Always use the `@GenerateNiceMocks` annotation (preferable to `@GenerateMocks` to avoid missing stub exceptions).
36
+ - Place the annotation in the test file, passing a list of `MockSpec<Type>()` objects.
37
+ - Import the generated file using the `.mocks.dart` extension.
38
+ - Execute `build_runner` to generate the mock files: `dart run build_runner build`.
39
+
40
+ ## Implementing Unit Tests
41
+ Isolate the system under test using the generated mock objects. Use `package:test` to structure the test suite.
42
+
43
+ - **Stubbing:** Configure mock behavior before interacting with the system under test.
44
+ - Use `when(mock.method()).thenReturn(value)` for synchronous methods.
45
+ - **CRITICAL:** Always use `thenAnswer((_) async => value)` for methods returning a `Future` or `Stream`. Never use `thenReturn` for asynchronous returns.
46
+ - **Verification:** Assert that the system under test interacted with the mock object correctly.
47
+ - Use `verify(mock.method()).called(1)` to check exact invocation counts.
48
+ - Use argument matchers like `any`, `anyNamed`, or `captureAny` for flexible verification.
49
+
50
+ ## Workflow: Creating and Running Mocked Tests
51
+
52
+ Use the following checklist to implement and verify mocked unit tests.
53
+
54
+ ### Task Progress
55
+ - [ ] 1. Identify the external dependency to mock (e.g., `http.Client`).
56
+ - [ ] 2. Inject the dependency into the target class constructor.
57
+ - [ ] 3. Create a test file (e.g., `target_test.dart`) and add `@GenerateNiceMocks([MockSpec<Dependency>()])`.
58
+ - [ ] 4. Add the `part` or `import` directive for the generated `.mocks.dart` file.
59
+ - [ ] 5. Run `dart run build_runner build` to generate the mock classes.
60
+ - [ ] 6. Write the test cases using `group()` and `test()`.
61
+ - [ ] 7. Stub required behaviors using `when()`.
62
+ - [ ] 8. Execute the target method.
63
+ - [ ] 9. Verify interactions using `verify()` and assert outcomes using `expect()`.
64
+ - [ ] 10. Run the test suite using `dart test`.
65
+
66
+ ### Feedback Loop: Test Failures
67
+ If tests fail or `build_runner` encounters errors:
68
+ 1. **Run validator:** Execute `dart test` or `dart run build_runner build`.
69
+ 2. **Review errors:** Check for missing stubs, mismatched argument matchers, or syntax errors in the generated files.
70
+ 3. **Fix:**
71
+ - If a mock method throws an unexpected null error, ensure you used `@GenerateNiceMocks`.
72
+ - If an async stub throws an `ArgumentError`, change `thenReturn` to `thenAnswer`.
73
+ - If `build_runner` fails, ensure the `.mocks.dart` import matches the file name exactly.
74
+ 4. Repeat until all tests pass.
75
+
76
+ ## Examples
77
+
78
+ ### High-Fidelity Mocking and Testing Example
79
+
80
+ **1. System Under Test (`lib/api_service.dart`)**
81
+ ```dart
82
+ import 'dart:convert';
83
+ import 'package:http/http.dart' as http;
84
+
85
+ class ApiService {
86
+ final http.Client client;
87
+
88
+ ApiService(this.client);
89
+
90
+ Future<String> fetchData(String urlString) async {
91
+ final uri = Uri.parse(urlString);
92
+ final response = await client.get(uri);
93
+
94
+ if (response.statusCode == 200) {
95
+ return jsonDecode(response.body)['data'];
96
+ } else {
97
+ throw Exception('Failed to load data');
98
+ }
99
+ }
100
+ }
101
+ ```
102
+
103
+ **2. Test Implementation (`test/api_service_test.dart`)**
104
+ ```dart
105
+ import 'package:test/test.dart';
106
+ import 'package:mockito/annotations.dart';
107
+ import 'package:mockito/mockito.dart';
108
+ import 'package:http/http.dart' as http;
109
+ import 'package:my_app/api_service.dart';
110
+
111
+ // Generate the mock class for http.Client
112
+ @GenerateNiceMocks([MockSpec<http.Client>()])
113
+ import 'api_service_test.mocks.dart';
114
+
115
+ void main() {
116
+ group('ApiService', () {
117
+ late ApiService apiService;
118
+ late MockClient mockHttpClient;
119
+
120
+ setUp(() {
121
+ mockHttpClient = MockClient();
122
+ apiService = ApiService(mockHttpClient);
123
+ });
124
+
125
+ test('returns data if the http call completes successfully', () async {
126
+ // Arrange: Stub the async HTTP GET request using thenAnswer
127
+ when(mockHttpClient.get(any)).thenAnswer(
128
+ (_) async => http.Response('{"data": "Success"}', 200),
129
+ );
130
+
131
+ // Act
132
+ final result = await apiService.fetchData('https://api.example.com/data');
133
+
134
+ // Assert
135
+ expect(result, 'Success');
136
+
137
+ // Verify the mock was called with the correct Uri
138
+ verify(mockHttpClient.get(Uri.parse('https://api.example.com/data'))).called(1);
139
+ });
140
+
141
+ test('throws an exception if the http call completes with an error', () {
142
+ // Arrange
143
+ when(mockHttpClient.get(any)).thenAnswer(
144
+ (_) async => http.Response('Not Found', 404),
145
+ );
146
+
147
+ // Act & Assert
148
+ expect(
149
+ apiService.fetchData('https://api.example.com/data'),
150
+ throwsException,
151
+ );
152
+ });
153
+ });
154
+ }
155
+ ```
@@ -0,0 +1,126 @@
1
+ ---
2
+ name: dart-migrate-to-checks-package
3
+ description: Replace the usage of `expect` and similar functions from `package:matcher` to `package:checks` equivalents.
4
+ metadata:
5
+ model: models/gemini-3.1-pro-preview
6
+ last_modified: Fri, 24 Apr 2026 15:15:22 GMT
7
+ ---
8
+ # Migrating Dart Tests to Package Checks
9
+
10
+ ## Contents
11
+ - [Dependency Management](#dependency-management)
12
+ - [Syntax Migration Guidelines](#syntax-migration-guidelines)
13
+ - [Utilizing Dart MCP Tools](#utilizing-dart-mcp-tools)
14
+ - [Migration Workflow](#migration-workflow)
15
+ - [Examples](#examples)
16
+
17
+ ## Dependency Management
18
+ Manage dependencies using the Dart Tooling MCP Server `pub` tool or standard CLI commands.
19
+
20
+ - Add `package:checks` as a `dev_dependency` using `dart pub add dev:checks`.
21
+ - Remove `package:matcher` if it is explicitly listed in the `pubspec.yaml` (note: it is often transitively included by `package:test`, which is fine).
22
+ - Import `package:checks/checks.dart` in all test files undergoing migration.
23
+
24
+ ## Syntax Migration Guidelines
25
+ Transition test assertions from the `package:matcher` syntax to the literate API provided by `package:checks`.
26
+
27
+ - **Basic Equality:** Replace `expect(actual, equals(expected))` or `expect(actual, expected)` with `check(actual).equals(expected)`.
28
+ - **Type Checking:** Replace `expect(actual, isA<Type>())` with `check(actual).isA<Type>()`.
29
+ - **Property Extraction:** Replace `expect(actual.property, expected)` with `check(actual).has((a) => a.property, 'property name').equals(expected)`.
30
+ - **Cascades for Multiple Checks:** Use Dart's cascade operator (`..`) to chain multiple expectations on a single subject.
31
+ - **Asynchronous Expectations:**
32
+ - If checking a `Future`, `await` the `check` call: `await check(someFuture).completes((r) => r.equals(expected));`.
33
+ - If checking a `Stream`, wrap it in a `StreamQueue` for multiple checks, or use `.withQueue` for single/broadcast checks.
34
+
35
+ ## Utilizing Dart MCP Tools
36
+ Leverage the Dart MCP Server tools to automate and validate the migration process.
37
+
38
+ - Use `pub` to run `dart pub get` or `dart pub add`.
39
+ - Use `analyze_files` to run static analysis on the project or specific paths.
40
+ - Use `run_tests` to execute Dart or Flutter tests with an agent-centric UX. ALWAYS use this instead of shell commands like `dart test`.
41
+ - Use `dart_fix` to apply automated fixes if applicable.
42
+
43
+ ## Migration Workflow
44
+
45
+ Copy and use the following checklist to track progress when migrating a test suite:
46
+
47
+ - [ ] **Task Progress**
48
+ - [ ] Add `package:checks` as a dev dependency.
49
+ - [ ] Identify all test files using `package:matcher` (`expect` calls).
50
+ - [ ] Import `package:checks/checks.dart` in target test files.
51
+ - [ ] Rewrite all `expect(...)` statements to `check(...)` statements.
52
+ - [ ] Run static analyzer (`analyze_files`).
53
+ - [ ] Run tests (`run_tests`).
54
+
55
+ ### Feedback Loop: Static Analysis
56
+ 1. Run the `analyze_files` tool on the modified test directories.
57
+ 2. Review any static analysis warnings or errors (e.g., missing imports, incorrect generic types on `isA`, unawaited futures).
58
+ 3. Fix the warnings.
59
+ 4. Repeat until the analyzer returns zero issues.
60
+
61
+ ### Feedback Loop: Test Validation
62
+ 1. Run the `run_tests` tool.
63
+ 2. If tests fail, review the failure output. `package:checks` provides detailed context (e.g., `Which: has length of <2>`).
64
+ 3. Adjust the `check()` expectations or the underlying code to resolve the failure.
65
+ 4. Repeat until all tests pass.
66
+
67
+ ## Examples
68
+
69
+ ### Basic Assertions
70
+ **Input (`matcher`):**
71
+ ```dart
72
+ expect(someList.length, 1);
73
+ expect(someString, startsWith('a'));
74
+ expect(someObject, isA<Map>());
75
+ ```
76
+
77
+ **Output (`checks`):**
78
+ ```dart
79
+ check(someList).length.equals(1);
80
+ check(someString).startsWith('a');
81
+ check(someObject).isA<Map>();
82
+ ```
83
+
84
+ ### Composed Expectations
85
+ **Input (`matcher`):**
86
+ ```dart
87
+ expect('foo,bar,baz', allOf([
88
+ contains('foo'),
89
+ isNot(startsWith('bar')),
90
+ endsWith('baz')
91
+ ]));
92
+ ```
93
+
94
+ **Output (`checks`):**
95
+ ```dart
96
+ check('foo,bar,baz')
97
+ ..contains('foo')
98
+ ..not((s) => s.startsWith('bar'))
99
+ ..endsWith('baz');
100
+ ```
101
+
102
+ ### Asynchronous Futures
103
+ **Input (`matcher`):**
104
+ ```dart
105
+ expect(Future.value(10), completion(equals(10)));
106
+ expect(Future.error('oh no'), throwsA(equals('oh no')));
107
+ ```
108
+
109
+ **Output (`checks`):**
110
+ ```dart
111
+ await check(Future.value(10)).completes((it) => it.equals(10));
112
+ await check(Future.error('oh no')).throws<String>().equals('oh no');
113
+ ```
114
+
115
+ ### Asynchronous Streams
116
+ **Input (`matcher`):**
117
+ ```dart
118
+ var stdout = StreamQueue(Stream.fromIterable(['Ready', 'Go']));
119
+ await expectLater(stdout, emitsThrough('Ready'));
120
+ ```
121
+
122
+ **Output (`checks`):**
123
+ ```dart
124
+ var stdout = StreamQueue(Stream.fromIterable(['Ready', 'Go']));
125
+ await check(stdout).emitsThrough((it) => it.equals('Ready'));
126
+ ```
@@ -0,0 +1,116 @@
1
+ ---
2
+ name: dart-resolve-package-conflicts
3
+ description: Workflow for fixing package version conflicts. Use this when `pub get` fails due to incompatible package versions.
4
+ metadata:
5
+ model: models/gemini-3.1-pro-preview
6
+ last_modified: Fri, 24 Apr 2026 15:11:14 GMT
7
+ ---
8
+ # Managing Dart Dependencies
9
+
10
+ ## Contents
11
+ - [Core Concepts](#core-concepts)
12
+ - [Version Constraints](#version-constraints)
13
+ - [Workflow: Auditing Dependencies](#workflow-auditing-dependencies)
14
+ - [Workflow: Upgrading Dependencies](#workflow-upgrading-dependencies)
15
+ - [Workflow: Resolving Version Conflicts](#workflow-resolving-version-conflicts)
16
+ - [Examples](#examples)
17
+
18
+ ## Core Concepts
19
+
20
+ Dart enforces a strict single-version rule for dependencies: a project and all its transitive dependencies must resolve to a single, shared version of any given package. This prevents runtime type mismatches but introduces the risk of "version lock."
21
+
22
+ To mitigate version lock, Dart relies on version constraints rather than pinned versions in the `pubspec.yaml`. The `pubspec.lock` file maintains the exact resolved versions for reproducible builds.
23
+
24
+ Understand the output columns of `dart pub outdated`:
25
+ * **Current:** The version currently recorded in `pubspec.lock`.
26
+ * **Upgradable:** The latest version allowed by the constraints in `pubspec.yaml`. `dart pub upgrade` resolves to this.
27
+ * **Resolvable:** The absolute latest version that can be resolved when factoring in all other dependencies in the project.
28
+ * **Latest:** The latest published version of the package (excluding prereleases).
29
+
30
+ ## Version Constraints
31
+
32
+ * **Use Caret Syntax:** Always use caret syntax (e.g., `^1.2.3`) for dependencies in `pubspec.yaml`. This allows `pub` to select newer, non-breaking versions (up to, but not including, the next major version) during resolution.
33
+ * **Tighten Dev Dependencies:** Set the lower bound of `dev_dependencies` to the exact version currently used. This reduces resolution complexity and prevents older, incompatible dev tools from being selected.
34
+ * **Enforce Lockfiles in CI:** Use `dart pub get --enforce-lockfile` in CI/CD pipelines to ensure the exact versions tested locally are used in production.
35
+
36
+ ## Workflow: Auditing Dependencies
37
+
38
+ Run this workflow periodically to identify stale packages that may impact stability or performance.
39
+
40
+ **Task Progress:**
41
+ - [ ] Run `dart pub outdated`.
42
+ - [ ] Review the **Upgradable** column to identify packages that can be updated without modifying `pubspec.yaml`.
43
+ - [ ] Review the **Resolvable** column to identify packages that require constraint modifications in `pubspec.yaml` to update.
44
+ - [ ] Identify any packages marked as retracted or discontinued.
45
+
46
+ ## Workflow: Upgrading Dependencies
47
+
48
+ Use conditional logic based on the audit results to upgrade dependencies.
49
+
50
+ **Task Progress:**
51
+ - [ ] **If updating to "Upgradable" versions:**
52
+ - [ ] Run `dart pub upgrade`.
53
+ - [ ] Run `dart pub upgrade --tighten` to automatically update the lower bounds in `pubspec.yaml` to match the newly resolved versions.
54
+ - [ ] **If updating to "Resolvable" versions (Major updates):**
55
+ - [ ] Manually edit `pubspec.yaml` to bump the version constraint to match the "Resolvable" column (e.g., change `^0.11.0` to `^0.12.1`).
56
+ - [ ] Run `dart pub upgrade` to resolve the new constraints and update `pubspec.lock`.
57
+ - [ ] **Feedback Loop:**
58
+ - [ ] Run `dart analyze` -> review errors -> fix breaking API changes.
59
+ - [ ] Run `dart test` -> review failures -> fix regressions.
60
+
61
+ ## Workflow: Resolving Version Conflicts
62
+
63
+ When `pub` cannot find a set of concrete versions that satisfy all constraints, or when dealing with a retracted package version, manipulate the lockfile surgically.
64
+
65
+ **NEVER** delete the entire `pubspec.lock` file and run `dart pub get`. This causes uncontrolled upgrades across the entire dependency graph.
66
+
67
+ **Task Progress:**
68
+ - [ ] Open `pubspec.lock`.
69
+ - [ ] Locate the specific YAML block for the conflicting or retracted package.
70
+ - [ ] Delete ONLY that package's entry from the lockfile.
71
+ - [ ] Run `dart pub get` to fetch the newest compatible, non-retracted version for that specific package.
72
+ - [ ] **Feedback Loop:**
73
+ - [ ] Run `dart pub deps` -> verify the dependency graph resolves correctly.
74
+ - [ ] If resolution fails, identify the transitive dependency causing the lock, update its constraint in `pubspec.yaml`, and retry.
75
+
76
+ ## Examples
77
+
78
+ ### Tightening Constraints
79
+ When `dart pub outdated` shows a package is resolvable to a higher minor/patch version, use the `--tighten` flag to update the `pubspec.yaml` automatically.
80
+
81
+ **Input (`pubspec.yaml`):**
82
+ ```yaml
83
+ dependencies:
84
+ http: ^0.13.0
85
+ ```
86
+
87
+ **Command:**
88
+ ```bash
89
+ dart pub upgrade --tighten http
90
+ ```
91
+
92
+ **Output (`pubspec.yaml`):**
93
+ ```yaml
94
+ dependencies:
95
+ http: ^0.13.5
96
+ ```
97
+
98
+ ### Surgical Lockfile Removal
99
+ If `package_a` is retracted or locked in a conflict, remove only its block from `pubspec.lock`.
100
+
101
+ **Before (`pubspec.lock`):**
102
+ ```yaml
103
+ packages:
104
+ package_a:
105
+ dependency: "direct main"
106
+ description:
107
+ name: package_a
108
+ url: "https://pub.dev"
109
+ source: hosted
110
+ version: "1.0.0" # Retracted version
111
+ package_b:
112
+ dependency: "direct main"
113
+ # ...
114
+ ```
115
+
116
+ **Action:** Delete the `package_a` block entirely. Leave `package_b` untouched. Run `dart pub get`.
@@ -0,0 +1,104 @@
1
+ ---
2
+ name: dart-run-static-analysis
3
+ description: Execute `dart analyze` to identify warnings and errors, and use `dart fix --apply` to automatically resolve mechanical lint issues. Use during development to ensure code quality and before committing changes.
4
+ metadata:
5
+ model: models/gemini-3.1-pro-preview
6
+ last_modified: Fri, 24 Apr 2026 15:09:34 GMT
7
+ ---
8
+ # Analyzing and Fixing Dart Code
9
+
10
+ ## Contents
11
+ - [Analysis Configuration](#analysis-configuration)
12
+ - [Diagnostic Suppression](#diagnostic-suppression)
13
+ - [Workflow: Executing Static Analysis](#workflow-executing-static-analysis)
14
+ - [Workflow: Applying Automated Fixes](#workflow-applying-automated-fixes)
15
+ - [Examples](#examples)
16
+
17
+ ## Analysis Configuration
18
+
19
+ Configure the Dart analyzer using the `analysis_options.yaml` file located at the package root.
20
+
21
+ - **Base Configuration:** Always include a standard rule set (e.g., `package:lints/recommended.yaml` or `package:flutter_lints/flutter.yaml`) using the `include:` directive.
22
+ - **Strict Type Checks:** Enable strict type checks under the `analyzer: language:` node to prevent implicit downcasts and dynamic inferences. Set `strict-casts: true`, `strict-inference: true`, and `strict-raw-types: true`.
23
+ - **Linter Rules:** Explicitly enable or disable specific rules under the `linter: rules:` node. Use a key-value map (`rule_name: true/false`) when overriding included rules, or a list (`- rule_name`) when defining a fresh set. Do not mix list and map syntax in the same `rules` block.
24
+ - **Formatter Configuration:** Configure `dart format` behavior under the `formatter:` node. Set `page_width` (default 80) and `trailing_commas` (`automate` or `preserve`).
25
+ - **Analyzer Plugins:** Enable custom diagnostics by adding plugins under the `analyzer: plugins:` node. Ensure the plugin package is added as a `dev_dependency` in `pubspec.yaml`.
26
+
27
+ ## Diagnostic Suppression
28
+
29
+ When a diagnostic (lint or warning) yields a false positive or applies to generated code, suppress it explicitly.
30
+
31
+ - **File-level Exclusion:** Use the `analyzer: exclude:` node in `analysis_options.yaml` to exclude entire files or directories (e.g., `**/*.g.dart`) using glob patterns.
32
+ - **File-level Suppression:** Add `// ignore_for_file: <diagnostic_code>` at the top of a Dart file to suppress specific diagnostics for the entire file. Use `// ignore_for_file: type=lint` to suppress all linter rules.
33
+ - **Line-level Suppression:** Add `// ignore: <diagnostic_code>` on the line directly above the offending code, or appended to the end of the offending line.
34
+ - **Pubspec Suppression:** Add `# ignore: <diagnostic_code>` above the offending line in `pubspec.yaml` files (e.g., `# ignore: sort_pub_dependencies`).
35
+ - **Plugin Diagnostics:** Prefix the diagnostic code with the plugin name when suppressing plugin-specific issues (e.g., `// ignore: some_plugin/some_code`).
36
+
37
+ ## Workflow: Executing Static Analysis
38
+
39
+ Use this workflow to identify type-related bugs, style violations, and potential runtime errors.
40
+
41
+ **Task Progress:**
42
+ - [ ] 1. Verify `analysis_options.yaml` exists at the project root.
43
+ - [ ] 2. Run the analyzer using the `analyze_files` MCP tool (if available) or the CLI command `dart analyze <target_directory>`.
44
+ - [ ] 3. Review the diagnostic output.
45
+ - [ ] 4. If info-level issues must be treated as failures, append the `--fatal-infos` flag.
46
+ - [ ] 5. Resolve reported errors manually or proceed to the Automated Fixes workflow.
47
+
48
+ ## Workflow: Applying Automated Fixes
49
+
50
+ Use this workflow to resolve outdated API usages, apply quick fixes, and migrate code (e.g., Dart 3 migrations).
51
+
52
+ **Task Progress:**
53
+ - [ ] 1. Execute a dry run to preview proposed changes using the `dart_fix` MCP tool or CLI command `dart fix --dry-run`.
54
+ - [ ] 2. Review the proposed fixes to ensure they align with the intended architecture.
55
+ - [ ] 3. If additional fixes are required, verify that the corresponding linter rules are enabled in `analysis_options.yaml`.
56
+ - [ ] 4. Apply the fixes using the `dart_fix` MCP tool or CLI command `dart fix --apply`.
57
+ - [ ] 5. Format the modified code using the `dart_format` MCP tool or CLI command `dart format .`.
58
+ - [ ] 6. Run the static analysis workflow to verify all diagnostics are resolved.
59
+
60
+ ## Examples
61
+
62
+ ### Comprehensive `analysis_options.yaml`
63
+
64
+ ```yaml
65
+ include: package:flutter_lints/recommended.yaml
66
+
67
+ analyzer:
68
+ exclude:
69
+ - "**/*.g.dart"
70
+ - "lib/generated/**"
71
+ language:
72
+ strict-casts: true
73
+ strict-inference: true
74
+ strict-raw-types: true
75
+ errors:
76
+ todo: ignore
77
+ invalid_assignment: warning
78
+ missing_return: error
79
+
80
+ linter:
81
+ rules:
82
+ avoid_shadowing_type_parameters: false
83
+ await_only_futures: true
84
+ use_super_parameters: true
85
+
86
+ formatter:
87
+ page_width: 100
88
+ trailing_commas: preserve
89
+ ```
90
+
91
+ ### Inline Diagnostic Suppression
92
+
93
+ ```dart
94
+ // Suppress for the entire file
95
+ // ignore_for_file: unused_local_variable, dead_code
96
+
97
+ void processData() {
98
+ // Suppress for a specific line
99
+ // ignore: invalid_assignment
100
+ int x = '';
101
+
102
+ const y = 10; // ignore: constant_identifier_names
103
+ }
104
+ ```
@@ -0,0 +1,146 @@
1
+ ---
2
+ name: dart-use-pattern-matching
3
+ description: Use switch expressions and pattern matching where appropriate
4
+ metadata:
5
+ model: models/gemini-3.1-pro-preview
6
+ last_modified: Fri, 24 Apr 2026 15:08:55 GMT
7
+ ---
8
+ # Implementing Dart Patterns
9
+
10
+ ## Contents
11
+ - [Pattern Selection Strategy](#pattern-selection-strategy)
12
+ - [Switch Statements vs. Expressions](#switch-statements-vs-expressions)
13
+ - [Core Pattern Implementations](#core-pattern-implementations)
14
+ - [Workflows](#workflows)
15
+ - [Examples](#examples)
16
+
17
+ ## Pattern Selection Strategy
18
+
19
+ Apply specific pattern types based on the data structure and desired outcome. Follow these conditional guidelines:
20
+
21
+ * **If validating and extracting from deserialized data (e.g., JSON):** Use Map and List patterns to simultaneously check structure and destructure key-value pairs.
22
+ * **If handling multiple return values:** Use Record patterns to destructure fields directly into local variables.
23
+ * **If executing type-specific behavior (Algebraic Data Types):** Use Object patterns combined with `sealed` classes to ensure exhaustiveness.
24
+ * **If matching numeric ranges or conditions:** Use Relational (`>=`, `<=`) and Logical-and (`&&`) patterns.
25
+ * **If multiple cases share logic:** Use Logical-or (`||`) patterns to share a single case body or guard clause.
26
+ * **If ignoring specific values:** Use the Wildcard pattern (`_`) or a non-matching Rest element (`...`) in collections.
27
+
28
+ ## Switch Statements vs. Expressions
29
+
30
+ Select the appropriate switch construct based on the execution context:
31
+
32
+ * **If producing a value:** Use a **switch expression**.
33
+ * Syntax: `switch (value) { pattern => expression, }`
34
+ * Rule: Each case must be a single expression. No implicit fallthrough. Must be exhaustive.
35
+ * **If executing statements or side effects:** Use a **switch statement**.
36
+ * Syntax: `switch (value) { case pattern: statements; }`
37
+ * Rule: Empty cases fall through to the next case. Non-empty cases implicitly break (no `break` keyword required).
38
+
39
+ ## Core Pattern Implementations
40
+
41
+ Implement patterns using the following syntax and rules:
42
+
43
+ * **Logical-or (`||`):** `pattern1 || pattern2`. Both branches must define the exact same set of variables.
44
+ * **Logical-and (`&&`):** `pattern1 && pattern2`. Branches must *not* define overlapping variables.
45
+ * **Relational:** `==`, `!=`, `<`, `>`, `<=`, `>=` followed by a constant expression.
46
+ * **Cast (`as`):** `pattern as Type`. Throws if the value does not match the type. Use to forcibly assert types during destructuring.
47
+ * **Null-check (`?`):** `pattern?`. Fails the match if the value is null. Binds the variable to the non-nullable base type.
48
+ * **Null-assert (`!`):** `pattern!`. Throws if the value is null.
49
+ * **Variable:** `var name` or `Type name`. Binds the matched value to a new local variable.
50
+ * **Wildcard (`_`):** Matches any value and discards it.
51
+ * **List:** `[pattern1, pattern2]`. Matches lists of exact length unless a Rest element (`...` or `...var rest`) is used.
52
+ * **Map:** `{"key": pattern}`. Matches maps containing the specified keys. Ignores unmatched keys.
53
+ * **Record:** `(pattern1, named: pattern2)`. Matches records of the exact shape. Use `:var name` to infer the getter name.
54
+ * **Object:** `ClassName(field: pattern)`. Matches instances of `ClassName`. Use `:var field` to infer the getter name.
55
+
56
+ ## Workflows
57
+
58
+ ### Task Progress: Implementing Pattern Matching
59
+ Copy this checklist to track progress when implementing complex pattern matching logic:
60
+
61
+ - [ ] Identify the data structure being evaluated (JSON, Record, Class, Enum).
62
+ - [ ] Select the appropriate switch construct (Expression for values, Statement for side-effects).
63
+ - [ ] Define the required patterns (Object, Map, List, Record).
64
+ - [ ] Extract required data using Variable patterns (`var x`, `:var y`).
65
+ - [ ] Apply Guard clauses (`when condition`) for logic that cannot be expressed via patterns.
66
+ - [ ] Handle unmatched cases using a Wildcard (`_`) or `default` clause (if not using a sealed class).
67
+ - [ ] Run exhaustiveness validator.
68
+
69
+ ### Feedback Loop: Exhaustiveness Checking
70
+ When switching over `sealed` classes or enums, you must ensure all subtypes are handled.
71
+
72
+ 1. **Run validator:** Execute `dart analyze`.
73
+ 2. **Review errors:** Look for "The type 'X' is not exhaustively matched by the switch cases" errors.
74
+ 3. **Fix:** Add the missing Object patterns for the unhandled subtypes, or add a Wildcard (`_`) case if a default fallback is acceptable.
75
+
76
+ ## Examples
77
+
78
+ ### JSON Validation and Destructuring
79
+ Use Map and List patterns to validate structure and extract data in a single step.
80
+
81
+ **Input:**
82
+ ```dart
83
+ var data = {
84
+ 'user': ['Lily', 13],
85
+ };
86
+ ```
87
+
88
+ **Implementation:**
89
+ ```dart
90
+ if (data case {'user': [String name, int age]}) {
91
+ print('User $name is $age years old.');
92
+ } else {
93
+ print('Invalid JSON structure.');
94
+ }
95
+ ```
96
+
97
+ ### Algebraic Data Types (Sealed Classes)
98
+ Use Object patterns with switch expressions to handle family types exhaustively.
99
+
100
+ **Implementation:**
101
+ ```dart
102
+ sealed class Shape {}
103
+
104
+ class Square implements Shape {
105
+ final double length;
106
+ Square(this.length);
107
+ }
108
+
109
+ class Circle implements Shape {
110
+ final double radius;
111
+ Circle(this.radius);
112
+ }
113
+
114
+ // Switch expression guarantees exhaustiveness due to `sealed` modifier.
115
+ double calculateArea(Shape shape) => switch (shape) {
116
+ Square(length: var l) => l * l,
117
+ Circle(:var radius) => math.pi * radius * radius,
118
+ };
119
+ ```
120
+
121
+ ### Variable Swapping and Destructuring
122
+ Use variable assignment patterns to swap values or extract record fields without temporary variables.
123
+
124
+ **Implementation:**
125
+ ```dart
126
+ var (a, b) = ('left', 'right');
127
+ (b, a) = (a, b); // Swap values
128
+
129
+ // Destructuring a function return
130
+ var (name, age) = getUserInfo();
131
+ ```
132
+
133
+ ### Guard Clauses and Logical-or
134
+ Use `when` to evaluate arbitrary conditions after a pattern matches.
135
+
136
+ **Implementation:**
137
+ ```dart
138
+ switch (shape) {
139
+ case Square(size: var s) || Circle(size: var s) when s > 0:
140
+ print('Valid symmetric shape with size $s');
141
+ case Square() || Circle():
142
+ print('Invalid or empty shape');
143
+ default:
144
+ print('Unknown shape');
145
+ }
146
+ ```