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,82 @@
1
+ """Tests for parse_instinct_file() — verifies content after frontmatter is preserved."""
2
+
3
+ import importlib.util
4
+ import os
5
+
6
+ # Load instinct-cli.py (hyphenated filename requires importlib)
7
+ _spec = importlib.util.spec_from_file_location(
8
+ "instinct_cli",
9
+ os.path.join(os.path.dirname(__file__), "instinct-cli.py"),
10
+ )
11
+ _mod = importlib.util.module_from_spec(_spec)
12
+ _spec.loader.exec_module(_mod)
13
+ parse_instinct_file = _mod.parse_instinct_file
14
+
15
+
16
+ MULTI_SECTION = """\
17
+ ---
18
+ id: instinct-a
19
+ trigger: "when coding"
20
+ confidence: 0.9
21
+ domain: general
22
+ ---
23
+
24
+ ## Action
25
+ Do thing A.
26
+
27
+ ## Examples
28
+ - Example A1
29
+
30
+ ---
31
+ id: instinct-b
32
+ trigger: "when testing"
33
+ confidence: 0.7
34
+ domain: testing
35
+ ---
36
+
37
+ ## Action
38
+ Do thing B.
39
+ """
40
+
41
+
42
+ def test_multiple_instincts_preserve_content():
43
+ result = parse_instinct_file(MULTI_SECTION)
44
+ assert len(result) == 2
45
+ assert "Do thing A." in result[0]["content"]
46
+ assert "Example A1" in result[0]["content"]
47
+ assert "Do thing B." in result[1]["content"]
48
+
49
+
50
+ def test_single_instinct_preserves_content():
51
+ content = """\
52
+ ---
53
+ id: solo
54
+ trigger: "when reviewing"
55
+ confidence: 0.8
56
+ domain: review
57
+ ---
58
+
59
+ ## Action
60
+ Check for security issues.
61
+
62
+ ## Evidence
63
+ Prevents vulnerabilities.
64
+ """
65
+ result = parse_instinct_file(content)
66
+ assert len(result) == 1
67
+ assert "Check for security issues." in result[0]["content"]
68
+ assert "Prevents vulnerabilities." in result[0]["content"]
69
+
70
+
71
+ def test_empty_content_no_error():
72
+ content = """\
73
+ ---
74
+ id: empty
75
+ trigger: "placeholder"
76
+ confidence: 0.5
77
+ domain: general
78
+ ---
79
+ """
80
+ result = parse_instinct_file(content)
81
+ assert len(result) == 1
82
+ assert result[0]["content"] == ""
@@ -0,0 +1,122 @@
1
+ ---
2
+ name: dart-add-unit-test
3
+ description: Write and organize unit tests for functions, methods, and classes using `package:test`. Use when creating new logic or fixing bugs to ensure code remains correct and regression-free.
4
+ metadata:
5
+ model: models/gemini-3.1-pro-preview
6
+ last_modified: Fri, 24 Apr 2026 15:07:58 GMT
7
+ ---
8
+ # Testing Dart and Flutter Applications
9
+
10
+ ## Contents
11
+ - [Structuring Test Files](#structuring-test-files)
12
+ - [Writing Tests](#writing-tests)
13
+ - [Executing Tests](#executing-tests)
14
+ - [Test Implementation Workflow](#test-implementation-workflow)
15
+ - [Examples](#examples)
16
+
17
+ ## Structuring Test Files
18
+ Organize test files to mirror the `lib` directory structure to maintain predictability.
19
+
20
+ * Place all test code within the `test` directory at the root of the package.
21
+ * Append `_test.dart` to the end of all test file names (e.g., `lib/src/utils.dart` should be tested in `test/src/utils_test.dart`).
22
+ * If writing integration tests, place them in an `integration_test` directory at the root of the package.
23
+
24
+ ## Writing Tests
25
+ Utilize `package:test` as the standard testing library for Dart applications.
26
+
27
+ * Import `package:test/test.dart` (or `package:flutter_test/flutter_test.dart` for Flutter).
28
+ * Group related tests using the `group()` function to provide shared context.
29
+ * Define individual test cases using the `test()` function.
30
+ * Validate outcomes using the `expect()` function alongside matchers (e.g., `equals()`, `isTrue`, `throwsA()`).
31
+ * Write asynchronous tests using standard `async`/`await` syntax. The test runner automatically waits for the `Future` to complete.
32
+ * Manage test setup and teardown using `setUp()` and `tearDown()` callbacks.
33
+ * If testing code that relies on dependency injection, use `package:mockito` alongside `package:test` to generate mock objects, configure fixed scenarios, and verify interactions.
34
+
35
+ ## Executing Tests
36
+ Select the appropriate test runner based on the project type and test location.
37
+
38
+ * If working on a pure Dart project, execute tests using the `dart test` command.
39
+ * If working on a Flutter project, execute tests using the `flutter test` command.
40
+ * If running integration tests, explicitly specify the directory path, as the default runner ignores it: `dart test integration_test` or `flutter test integration_test`.
41
+
42
+ ## Test Implementation Workflow
43
+
44
+ Follow this sequential workflow when implementing new test suites. Copy the checklist to track your progress.
45
+
46
+ ### Task Progress
47
+ - [ ] 1. Create the test file in the `test/` directory, ensuring the `_test.dart` suffix.
48
+ - [ ] 2. Import `package:test/test.dart` and the target library.
49
+ - [ ] 3. Define a `main()` function.
50
+ - [ ] 4. Initialize shared resources or mocks using `setUp()`.
51
+ - [ ] 5. Write `test()` cases grouped by functionality using `group()`.
52
+ - [ ] 6. Execute the test suite using the appropriate CLI command.
53
+ - [ ] 7. **Feedback Loop**: Run test -> Review stack trace for failures -> Fix implementation or assertions -> Re-run until passing.
54
+
55
+ ## Examples
56
+
57
+ ### Standard Unit Test Suite
58
+ Demonstrates grouping, setup, synchronous, and asynchronous testing.
59
+
60
+ ```dart
61
+ import 'package:test/test.dart';
62
+ import 'package:my_package/calculator.dart';
63
+
64
+ void main() {
65
+ group('Calculator', () {
66
+ late Calculator calc;
67
+
68
+ setUp(() {
69
+ calc = Calculator();
70
+ });
71
+
72
+ test('adds two numbers correctly', () {
73
+ expect(calc.add(2, 3), equals(5));
74
+ });
75
+
76
+ test('handles asynchronous operations', () async {
77
+ final result = await calc.fetchRemoteValue();
78
+ expect(result, isNotNull);
79
+ expect(result, greaterThan(0));
80
+ });
81
+ });
82
+ }
83
+ ```
84
+
85
+ ### Mocking with Mockito
86
+ Demonstrates configuring a mock object for dependency injection testing.
87
+
88
+ ```dart
89
+ import 'package:test/test.dart';
90
+ import 'package:mockito/mockito.dart';
91
+ import 'package:mockito/annotations.dart';
92
+ import 'package:my_package/api_client.dart';
93
+ import 'package:my_package/data_service.dart';
94
+
95
+ // Generate the mock using build_runner: dart run build_runner build
96
+ @GenerateNiceMocks([MockSpec<ApiClient>()])
97
+ import 'data_service_test.mocks.dart';
98
+
99
+ void main() {
100
+ group('DataService', () {
101
+ late MockApiClient mockApiClient;
102
+ late DataService dataService;
103
+
104
+ setUp(() {
105
+ mockApiClient = MockApiClient();
106
+ dataService = DataService(apiClient: mockApiClient);
107
+ });
108
+
109
+ test('returns parsed data on successful API call', () async {
110
+ // Configure the mock
111
+ when(mockApiClient.get('/data')).thenAnswer((_) async => '{"id": 1}');
112
+
113
+ // Execute the system under test
114
+ final result = await dataService.fetchData();
115
+
116
+ // Verify outcomes and interactions
117
+ expect(result.id, equals(1));
118
+ verify(mockApiClient.get('/data')).called(1);
119
+ });
120
+ });
121
+ }
122
+ ```
@@ -0,0 +1,185 @@
1
+ ---
2
+ name: dart-build-cli-app
3
+ description: Entrypoint structure, exit codes, cross-platform scripts. Use when building command line utilities, scripts, or applications.
4
+ metadata:
5
+ model: models/gemini-3.1-pro-preview
6
+ last_modified: Fri, 04 May 2026 17:41:00 GMT
7
+ ---
8
+ # Building Dart CLI Applications
9
+
10
+ ## Contents
11
+ - [Project Setup & Architecture](#project-setup--architecture)
12
+ - [Argument Parsing & Command Routing](#argument-parsing--command-routing)
13
+ - [Execution & Error Handling](#execution--error-handling)
14
+ - [Testing CLI Applications](#testing-cli-applications)
15
+ - [Compilation & Distribution](#compilation--distribution)
16
+ - [Workflows](#workflows)
17
+ - [Examples](#examples)
18
+
19
+ ## Project Setup & Architecture
20
+
21
+ Initialize new CLI projects using the official Dart template to ensure standard directory structures.
22
+
23
+ * Run `dart create -t cli <project_name>` to scaffold a console application with basic argument parsing.
24
+ * Place executable entry points (files containing `main()`) exclusively in the `bin/` directory.
25
+ * Place internal implementation logic in `lib/src/` and expose public APIs via `lib/<project_name>.dart`.
26
+ * Enforce formatting in CI environments by running `dart format . --set-exit-if-changed`. This returns exit code 1 if formatting violations exist.
27
+
28
+ ## Argument Parsing & Command Routing
29
+
30
+ Import the `args` package to manage command-line arguments, flags, and subcommands.
31
+
32
+ * If building a simple script: Use `ArgParser` directly to define flags (`addFlag`) and options (`addOption`).
33
+ * If building a complex, multi-command CLI (like `git`): Implement `CommandRunner` and extend `Command` for each subcommand.
34
+ * Define global arguments on the `CommandRunner.argParser` and command-specific arguments on the individual `Command.argParser`.
35
+ * Catch `UsageException` to gracefully handle invalid arguments and display the automatically generated help text.
36
+ * **Validate Help Text Accuracy**: Ensure the help text provides all necessary information to run the tool. If the help text references a compiled executable name, and the user needs to add it to their PATH to run it that way, provide clear instructions on how to do so in the help text or description.
37
+
38
+ ## Execution & Error Handling
39
+
40
+ Leverage the `io` and `stack_trace` packages to build robust, production-ready CLI tools.
41
+
42
+ * Use the `io` package's `ExitCode` enum to return standard POSIX exit codes (e.g., `ExitCode.success.code`, `ExitCode.usage.code`).
43
+ * Use `sharedStdIn` from the `io` package if multiple asynchronous listeners need sequential access to standard input.
44
+ * Wrap the application execution in `Chain.capture()` from the `stack_trace` package to track asynchronous stack chains.
45
+ * Format output stack traces using `Trace.terse` or `Chain.terse` to strip noisy core library frames and present readable errors to the user.
46
+ * **Do not swallow exceptions** in lower-level logic or storage classes unless recovery is possible. Let them bubble up or rethrow them so higher-level commands know operations failed.
47
+ * **Fail fast and with non-zero exit codes**: Ensure operation failures result in descriptive error messages to `stderr` and appropriate non-zero exit codes (e.g., using `exit(1)` or triggering a 64 exit code after a caught `UsageException`).
48
+
49
+ ## Testing CLI Applications
50
+
51
+ > [!IMPORTANT]
52
+ > **All new commands and significant features must be covered by automated tests.** Manual verification is not sufficient for testing logic. However, manual verification of help text and user experience (UX) is still required to ensure the interface is intuitive and correct.
53
+
54
+ Use `test_process` and `test_descriptor` to write high-fidelity integration tests for your CLI.
55
+
56
+ * Define expected filesystem states using `test_descriptor` (`d.dir`, `d.file`).
57
+ * Create the mock filesystem before execution using `await d.Descriptor.create()`.
58
+ * Spawn the CLI process using `TestProcess.start('dart', ['run', 'bin/cli.dart', ...args])`.
59
+ * Validate standard output and error streams using `StreamQueue` matchers (e.g., `emitsThrough`, `emits`).
60
+ * Assert the final exit code using `await process.shouldExit(0)`.
61
+ * Validate resulting filesystem mutations using `await d.Descriptor.validate()`.
62
+
63
+ ## Compilation & Distribution
64
+
65
+ Select the appropriate compilation target based on your distribution requirements.
66
+
67
+ * **If testing locally during development:** Use `dart run bin/cli.dart`. This uses the JIT compiler for rapid iteration.
68
+ * **If bundling code assets and dynamic libraries:** Use `dart build cli`. This runs build hooks and outputs to `build/cli/_/bundle/`.
69
+ * **If distributing a standalone native executable:** Use `dart compile exe bin/cli.dart -o <output_path>`. This bundles the Dart runtime and machine code into a single file.
70
+ * **If distributing multiple apps with strict disk space limits:** Use `dart compile aot-snapshot bin/cli.dart`. Run the resulting `.aot` file using `dartaotruntime`.
71
+
72
+ <details>
73
+ <summary>Cross-Compilation Targets (Linux Only)</summary>
74
+
75
+ Dart supports cross-compiling to Linux from macOS, Windows, or Linux hosts.
76
+ Use the `--target-os` and `--target-arch` flags with `dart compile exe` or `dart compile aot-snapshot`.
77
+
78
+ * `--target-os=linux` (Only Linux is currently supported as a cross-compilation target)
79
+ * `--target-arch=arm64` (64-bit ARM)
80
+ * `--target-arch=x64` (x86-64)
81
+ * `--target-arch=arm` (32-bit ARM)
82
+ * `--target-arch=riscv64` (64-bit RISC-V)
83
+
84
+ Example: `dart compile exe --target-os=linux --target-arch=arm64 bin/cli.dart`
85
+ </details>
86
+
87
+ ## Workflows
88
+
89
+ ### Task Progress: Implement a New CLI Command
90
+ - [ ] Create a new class extending `Command` in `lib/src/commands/`.
91
+ - [ ] Define the `name` and `description` properties.
92
+ - [ ] Register command-specific flags in the constructor using `argParser.addFlag()` or `argParser.addOption()`.
93
+ - [ ] Implement the `run()` method with the core logic.
94
+ - [ ] Register the new command in the `CommandRunner` instance in `bin/cli.dart` using `addCommand()`.
95
+ - [ ] Create tests for the new command in the `test/` directory using `test_process` or standard tests.
96
+ - [ ] Run validator -> Execute `dart run bin/cli.dart help <command_name>` to verify help text generation.
97
+ - [ ] Verify final UX: Compile the application using `dart compile exe` and run the resulting executable to verify the target user experience (e.g., `./bin/cli <command>`).
98
+
99
+ ### Task Progress: Compile and Release Native Executable
100
+ - [ ] Run validator -> Execute `dart format . --set-exit-if-changed` to ensure code formatting.
101
+ - [ ] Run validator -> Execute `dart analyze` to ensure no static analysis errors.
102
+ - [ ] Run validator -> Execute `dart test` to pass all integration tests.
103
+ - [ ] Compile for host OS: `dart compile exe bin/cli.dart -o build/cli-host`
104
+ - [ ] Compile for Linux (if host is macOS/Windows): `dart compile exe --target-os=linux --target-arch=x64 bin/cli.dart -o build/cli-linux-x64`
105
+
106
+ ## Examples
107
+
108
+ ### Example: CommandRunner Implementation
109
+
110
+ ```dart
111
+ import 'dart:io';
112
+ import 'package:args/command_runner.dart';
113
+ import 'package:stack_trace/stack_trace.dart';
114
+
115
+ class CommitCommand extends Command {
116
+ @override
117
+ final String name = 'commit';
118
+ @override
119
+ final String description = 'Record changes to the repository.';
120
+
121
+ CommitCommand() {
122
+ argParser.addFlag('all', abbr: 'a', help: 'Commit all changed files.');
123
+ }
124
+
125
+ @override
126
+ Future<void> run() async {
127
+ final commitAll = argResults?['all'] as bool? ?? false;
128
+ print('Committing... (All: $commitAll)');
129
+ }
130
+ }
131
+
132
+ void main(List<String> args) {
133
+ Chain.capture(() async {
134
+ final runner = CommandRunner('dgit', 'Distributed version control.')
135
+ ..addCommand(CommitCommand());
136
+
137
+ await runner.run(args);
138
+ }, onError: (error, chain) {
139
+ if (error is UsageException) {
140
+ stderr.writeln(error.message);
141
+ stderr.writeln(error.usage);
142
+ exit(64); // ExitCode.usage.code
143
+ } else {
144
+ stderr.writeln('Fatal error: $error');
145
+ stderr.writeln(chain.terse);
146
+ exit(1);
147
+ }
148
+ });
149
+ }
150
+ ```
151
+
152
+ ### Example: Integration Testing with Subprocesses
153
+
154
+ ```dart
155
+ import 'package:test/test.dart';
156
+ import 'package:test_process/test_process.dart';
157
+ import 'package:test_descriptor/test_descriptor.dart' as d;
158
+
159
+ void main() {
160
+ test('CLI formats output correctly and modifies filesystem', () async {
161
+ // 1. Setup mock filesystem
162
+ await d.dir('project', [
163
+ d.file('config.json', '{"key": "value"}')
164
+ ]).create();
165
+
166
+ // 2. Spawn the CLI process
167
+ final process = await TestProcess.start(
168
+ 'dart',
169
+ ['run', 'bin/cli.dart', 'process', '--path', '${d.sandbox}/project']
170
+ );
171
+
172
+ // 3. Validate stdout stream
173
+ await expectLater(process.stdout, emitsThrough('Processing complete.'));
174
+
175
+ // 4. Validate exit code
176
+ await process.shouldExit(0);
177
+
178
+ // 5. Validate filesystem mutations
179
+ await d.dir('project', [
180
+ d.file('config.json', '{"key": "value"}'),
181
+ d.file('output.log', 'Success')
182
+ ]).validate();
183
+ });
184
+ }
185
+ ```
@@ -0,0 +1,141 @@
1
+ ---
2
+ name: dart-collect-coverage
3
+ description: Collect coverage using the coverage packge and create an LCOV report
4
+ metadata:
5
+ model: models/gemini-3.1-pro-preview
6
+ last_modified: Fri, 24 Apr 2026 15:14:32 GMT
7
+ ---
8
+ # Implementing Dart and Flutter Test Coverage
9
+
10
+ ## Contents
11
+ - [Testing Fundamentals](#testing-fundamentals)
12
+ - [Coverage Directives](#coverage-directives)
13
+ - [Workflow: Configuring and Generating Coverage Reports](#workflow-configuring-and-generating-coverage-reports)
14
+ - [Workflow: Advanced Manual Coverage Collection](#workflow-advanced-manual-coverage-collection)
15
+ - [Examples](#examples)
16
+
17
+ ## Testing Fundamentals
18
+
19
+ Structure your test suites using the standard Dart testing paradigms. Use `package:test` for Dart projects and `flutter_test` for Flutter projects.
20
+
21
+ - **Unit Tests:** Verify individual functions, methods, or classes.
22
+ - **Component/Widget Tests:** Verify component behavior, layout, and interaction using mock objects (`package:mockito`).
23
+ - **Integration Tests:** Verify entire app flows on simulated or real devices.
24
+
25
+ ## Coverage Directives
26
+
27
+ Exclude specific lines, blocks, or entire files from coverage metrics using inline comments. Pass the `--check-ignore` flag during formatting to enforce these directives.
28
+
29
+ - Ignore a single line: `// coverage:ignore-line`
30
+ - Ignore a block of code: `// coverage:ignore-start` and `// coverage:ignore-end`
31
+ - Ignore an entire file: `// coverage:ignore-file`
32
+
33
+ ## Workflow: Configuring and Generating Coverage Reports
34
+
35
+ Follow this sequential workflow to add the coverage package, execute tests, and generate an LCOV report.
36
+
37
+ **Task Progress Checklist:**
38
+ - [ ] 1. Add `coverage` as a `dev_dependency`.
39
+ - [ ] 2. Execute the automated coverage script.
40
+ - [ ] 3. Validate the LCOV output.
41
+
42
+ ### 1. Add Dependencies
43
+ Add the `coverage` package as a `dev_dependency` to your project. Do not add it to standard dependencies.
44
+
45
+ If working in a standard Dart project:
46
+ ```bash
47
+ dart pub add dev:coverage
48
+ ```
49
+
50
+ If working in a Flutter project:
51
+ ```bash
52
+ flutter pub add dev:coverage
53
+ ```
54
+
55
+ ### 2. Collect Coverage and Generate LCOV
56
+ Use the bundled `test_with_coverage` script. This script automatically runs all tests, collects the JSON coverage data from the Dart VM, and formats it into an LCOV report.
57
+
58
+ ```bash
59
+ dart run coverage:test_with_coverage
60
+ ```
61
+ *Note: If working within a Dart workspace (monorepo), specify the test directories explicitly (e.g., `dart run coverage:test_with_coverage -- pkgs/foo/test pkgs/bar/test`).*
62
+
63
+ ### 3. Feedback Loop: Validate Output
64
+ **Run validator -> review errors -> fix:**
65
+ 1. Verify that the `coverage/` directory was created in the project root.
66
+ 2. Ensure `coverage/coverage.json` (raw data) and `coverage/lcov.info` (formatted report) exist.
67
+ 3. If coverage is missing for specific files, ensure they are imported and executed by your test files, or add `// coverage:ignore-file` if they are intentionally excluded.
68
+
69
+ ## Workflow: Advanced Manual Coverage Collection
70
+
71
+ If you require granular control over the VM service, isolate pausing, or need branch/function-level coverage, use the manual collection workflow.
72
+
73
+ **Task Progress Checklist:**
74
+ - [ ] 1. Run tests with VM service enabled.
75
+ - [ ] 2. Collect raw JSON coverage.
76
+ - [ ] 3. Format JSON to LCOV.
77
+
78
+ ### 1. Run Tests with VM Service
79
+ Execute tests while pausing isolates on exit and exposing the VM service on a specific port (e.g., 8181).
80
+
81
+ ```bash
82
+ dart run --pause-isolates-on-exit --disable-service-auth-codes --enable-vm-service=8181 test &
83
+ ```
84
+
85
+ ### 2. Collect Raw Coverage
86
+ Extract the coverage data from the running VM service and output it to a JSON file.
87
+
88
+ ```bash
89
+ dart run coverage:collect_coverage --wait-paused --uri=http://127.0.0.1:8181/ -o coverage/coverage.json --resume-isolates
90
+ ```
91
+ *Optional: Append `--function-coverage` and `--branch-coverage` to gather deeper metrics (requires Dart VM 2.17.0+).*
92
+
93
+ ### 3. Format to LCOV
94
+ Convert the raw JSON data into the standard LCOV format.
95
+
96
+ ```bash
97
+ dart run coverage:format_coverage --packages=.dart_tool/package_config.json --lcov -i coverage/coverage.json -o coverage/lcov.info --check-ignore
98
+ ```
99
+
100
+ ## Examples
101
+
102
+ ### Example: `pubspec.yaml` Configuration
103
+ Ensure your `pubspec.yaml` reflects the `coverage` package strictly under `dev_dependencies`.
104
+
105
+ ```yaml
106
+ name: my_dart_app
107
+ environment:
108
+ sdk: ^3.0.0
109
+
110
+ dependencies:
111
+ path: ^1.8.0
112
+
113
+ dev_dependencies:
114
+ test: ^1.24.0
115
+ coverage: ^1.15.0
116
+ ```
117
+
118
+ ### Example: Applying Ignore Directives
119
+ Use ignore directives to prevent generated code or untestable edge cases from lowering coverage scores.
120
+
121
+ ```dart
122
+ // coverage:ignore-file
123
+ import 'package:meta/meta.dart';
124
+
125
+ class SystemConfig {
126
+ final String env;
127
+
128
+ SystemConfig(this.env);
129
+
130
+ // coverage:ignore-start
131
+ void legacyInit() {
132
+ print('Deprecated initialization');
133
+ }
134
+ // coverage:ignore-end
135
+
136
+ bool isProduction() {
137
+ if (env == 'prod') return true;
138
+ return false; // coverage:ignore-line
139
+ }
140
+ }
141
+ ```
@@ -0,0 +1,166 @@
1
+ ---
2
+ name: dart-fix-runtime-errors
3
+ description: Uses get_runtime_errors and lsp to fetch an active stack trace, locate the failing line, apply a fix, and verify resolution via hot_reload.
4
+ metadata:
5
+ model: models/gemini-3.1-pro-preview
6
+ last_modified: Fri, 24 Apr 2026 15:13:22 GMT
7
+ ---
8
+ # Resolving Dart Static Analysis Errors
9
+
10
+ ## Contents
11
+ - [Core Concepts & Guidelines](#core-concepts--guidelines)
12
+ - [Type System & Soundness](#type-system--soundness)
13
+ - [Null Safety](#null-safety)
14
+ - [Error Handling](#error-handling)
15
+ - [Workflows](#workflows)
16
+ - [Workflow: Static Analysis Resolution](#workflow-static-analysis-resolution)
17
+ - [Examples](#examples)
18
+
19
+ ## Core Concepts & Guidelines
20
+
21
+ ### Type System & Soundness
22
+ Enforce Dart's sound type system to prevent runtime invalid states.
23
+
24
+ * **Method Overrides:** Maintain sound return types (covariant) and parameter types (contravariant). Never tighten a parameter type in a subclass unless explicitly marked with the `covariant` keyword.
25
+ * **Generics & Collections:** Add explicit type annotations to generic classes (e.g., `List<T>`, `Map<K, V>`). Never assign a `List<dynamic>` to a typed list (e.g., `List<Cat>`).
26
+ * **Downcasting:** Avoid implicit downcasts from `dynamic`. Use explicit casts (e.g., `as List<Cat>`) when necessary, but ensure the underlying runtime type matches to prevent `TypeError` exceptions.
27
+ * **Strict Casts:** Enable `strict-casts: true` in `analysis_options.yaml` under `analyzer: language:` to force explicit casting and catch implicit downcast errors at compile time.
28
+
29
+ ### Null Safety
30
+ Eliminate static errors related to null safety by correctly managing variable initialization and nullability.
31
+
32
+ * **Modifiers:** Apply `?` for nullable types, `!` for null assertions, and `required` for named parameters that cannot be null.
33
+ * **Late Initialization:** Use the `late` keyword for non-nullable variables guaranteed to be initialized before use. Apply this specifically to top-level or instance variables where Dart's control flow analysis cannot definitively prove initialization.
34
+ * **Wildcards:** Use the `_` wildcard variable (Dart 3.7+) for non-binding local variables or parameters to avoid unused variable warnings.
35
+
36
+ ### Error Handling
37
+ Distinguish between recoverable exceptions and unrecoverable errors.
38
+
39
+ * **Catching:** Catch `Exception` subtypes for recoverable failures.
40
+ * **Errors:** Never explicitly catch `Error` or its subtypes (e.g., `TypeError`, `ArgumentError`). Errors indicate programming bugs that must be fixed, not caught. Enforce this by enabling the `avoid_catching_errors` linter rule.
41
+ * **Rethrowing:** Use `rethrow` inside a `catch` block to propagate an exception while preserving its original stack trace.
42
+
43
+ ## Workflows
44
+
45
+ ### Workflow: Static Analysis Resolution
46
+
47
+ Use this sequential workflow to identify, fix, and verify static analysis errors in a Dart project. Copy the checklist to track your progress.
48
+
49
+ **Task Progress:**
50
+ - [ ] 1. Run static analyzer.
51
+ - [ ] 2. Apply automated fixes.
52
+ - [ ] 3. Resolve remaining errors manually.
53
+ - [ ] 4. Verify fixes (Feedback Loop).
54
+
55
+ **1. Run static analyzer**
56
+ Execute the Dart analyzer to identify all static errors in the target directory or file.
57
+ ```bash
58
+ dart analyze . --fatal-infos
59
+ ```
60
+
61
+ **2. Apply automated fixes**
62
+ Use the `dart fix` tool to automatically resolve standard linting and analysis issues.
63
+ ```bash
64
+ # Preview changes
65
+ dart fix --dry-run
66
+ # Apply changes
67
+ dart fix --apply
68
+ ```
69
+
70
+ **3. Resolve remaining errors manually**
71
+ Review the remaining analyzer output and apply conditional logic based on the error type:
72
+
73
+ * **If the error is a Null Safety issue (e.g., "Property cannot be accessed on a nullable receiver"):**
74
+ * Verify if the variable can logically be null.
75
+ * If yes, use optional chaining (`?.`) or provide a fallback (`??`).
76
+ * If no, and initialization is guaranteed elsewhere, mark the declaration with `late`.
77
+ * **If the error is a Type Mismatch (e.g., "The argument type 'List<dynamic>' can't be assigned..."):**
78
+ * Trace the variable's initialization.
79
+ * Add explicit generic type annotations to the instantiation (e.g., `<int>[]` instead of `[]`).
80
+ * **If the error is an Invalid Override (e.g., "The parameter type doesn't match the overridden method"):**
81
+ * Widen the parameter type to match the superclass, OR
82
+ * Add the `covariant` keyword to the parameter if tightening the type is intentionally required by the domain logic.
83
+
84
+ **4. Verify fixes (Feedback Loop)**
85
+ Run the validator. Review errors. Fix.
86
+ ```bash
87
+ dart analyze .
88
+ dart test
89
+ ```
90
+ * **If `dart analyze` reports errors:** Return to Step 3.
91
+ * **If `dart test` fails with a `TypeError`:** You have introduced an invalid explicit cast (`as T`) or accessed an uninitialized `late` variable. Locate the runtime failure and correct the type hierarchy or initialization order.
92
+
93
+ ## Examples
94
+
95
+ ### Example: Fixing Dynamic List Assignments
96
+ **Input (Fails Static Analysis):**
97
+ ```dart
98
+ void printInts(List<int> a) => print(a);
99
+
100
+ void main() {
101
+ final list = []; // Inferred as List<dynamic>
102
+ list.add(1);
103
+ list.add(2);
104
+ printInts(list); // Error: List<dynamic> can't be assigned to List<int>
105
+ }
106
+ ```
107
+
108
+ **Output (Passes Static Analysis):**
109
+ ```dart
110
+ void printInts(List<int> a) => print(a);
111
+
112
+ void main() {
113
+ final list = <int>[]; // Explicitly typed
114
+ list.add(1);
115
+ list.add(2);
116
+ printInts(list);
117
+ }
118
+ ```
119
+
120
+ ### Example: Fixing Method Overrides (Contravariance)
121
+ **Input (Fails Static Analysis):**
122
+ ```dart
123
+ class Animal {
124
+ void chase(Animal a) {}
125
+ }
126
+
127
+ class Cat extends Animal {
128
+ @override
129
+ void chase(Mouse a) {} // Error: Tightening parameter type
130
+ }
131
+ ```
132
+
133
+ **Output (Passes Static Analysis):**
134
+ ```dart
135
+ class Animal {
136
+ void chase(Animal a) {}
137
+ }
138
+
139
+ class Cat extends Animal {
140
+ @override
141
+ void chase(covariant Mouse a) {} // Explicitly marked covariant
142
+ }
143
+ ```
144
+
145
+ ### Example: Fixing Null Safety with `late`
146
+ **Input (Fails Static Analysis):**
147
+ ```dart
148
+ class Thermometer {
149
+ String temperature; // Error: Non-nullable instance field must be initialized
150
+
151
+ void read() {
152
+ temperature = '20C';
153
+ }
154
+ }
155
+ ```
156
+
157
+ **Output (Passes Static Analysis):**
158
+ ```dart
159
+ class Thermometer {
160
+ late String temperature; // Defers initialization check to runtime
161
+
162
+ void read() {
163
+ temperature = '20C';
164
+ }
165
+ }
166
+ ```