@jhm1909/ag-kit 0.1.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 (320) hide show
  1. package/.agent/ARCHITECTURE.md +189 -0
  2. package/.agent/known-registries.json +181 -0
  3. package/.agent/mcp_config.json +19 -0
  4. package/.agent/rules/clean-code.md +107 -0
  5. package/.agent/rules/documents.md +177 -0
  6. package/.agent/rules/git-workflow.md +68 -0
  7. package/.agent/rules/nano-banana.md +46 -0
  8. package/.agent/rules/research.md +35 -0
  9. package/.agent/rules/skill-loading.md +100 -0
  10. package/.agent/rules/skill-suggestion.md +47 -0
  11. package/.agent/rules/testing.md +52 -0
  12. package/.agent/rules/workflow-advisor.md +108 -0
  13. package/.agent/rules/workflow-skill-convention.md +127 -0
  14. package/.agent/skills/ai-engineer/SKILL.md +824 -0
  15. package/.agent/skills/ai-engineer/references/agentic-patterns.md +329 -0
  16. package/.agent/skills/ai-engineer/references/evaluation.md +493 -0
  17. package/.agent/skills/ai-engineer/references/llm.md +490 -0
  18. package/.agent/skills/ai-engineer/references/rag-advanced.md +444 -0
  19. package/.agent/skills/ai-engineer/references/serving-optimization.md +531 -0
  20. package/.agent/skills/ai-engineer/vector-db/README.md +137 -0
  21. package/.agent/skills/app-builder/SKILL.md +75 -0
  22. package/.agent/skills/app-builder/agent-coordination.md +71 -0
  23. package/.agent/skills/app-builder/feature-building.md +53 -0
  24. package/.agent/skills/app-builder/project-detection.md +34 -0
  25. package/.agent/skills/app-builder/scaffolding.md +118 -0
  26. package/.agent/skills/app-builder/tech-stack.md +41 -0
  27. package/.agent/skills/app-builder/templates/SKILL.md +39 -0
  28. package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
  29. package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
  30. package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
  31. package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
  32. package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
  33. package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
  34. package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
  35. package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
  36. package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
  37. package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
  38. package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
  39. package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
  40. package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
  41. package/.agent/skills/backend-developer/SKILL.md +763 -0
  42. package/.agent/skills/backend-developer/references/general-patterns.md +65 -0
  43. package/.agent/skills/backend-developer/references/go-echo.md +68 -0
  44. package/.agent/skills/backend-developer/references/go-gin.md +76 -0
  45. package/.agent/skills/backend-developer/references/java-springboot.md +83 -0
  46. package/.agent/skills/backend-developer/references/node-express.md +64 -0
  47. package/.agent/skills/backend-developer/references/node-nestjs.md +69 -0
  48. package/.agent/skills/backend-developer/references/python-django.md +67 -0
  49. package/.agent/skills/backend-developer/references/python-fastapi.md +80 -0
  50. package/.agent/skills/blockchain-engineer/SKILL.md +975 -0
  51. package/.agent/skills/blockchain-engineer/references/deployment.md +28 -0
  52. package/.agent/skills/blockchain-engineer/references/evm.md +14 -0
  53. package/.agent/skills/blockchain-engineer/references/mechanisms.md +32 -0
  54. package/.agent/skills/blockchain-engineer/references/solidity.md +32 -0
  55. package/.agent/skills/business-analysis/SKILL.md +85 -0
  56. package/.agent/skills/business-analysis/references/best-practices/diagrams.md +141 -0
  57. package/.agent/skills/business-analysis/references/domains/ai-agent.md +94 -0
  58. package/.agent/skills/business-analysis/references/domains/blockchain-dapp.md +86 -0
  59. package/.agent/skills/business-analysis/references/domains/ecommerce.md +77 -0
  60. package/.agent/skills/business-analysis/references/domains/education.md +42 -0
  61. package/.agent/skills/business-analysis/references/domains/fintech.md +44 -0
  62. package/.agent/skills/business-analysis/references/domains/fnb.md +82 -0
  63. package/.agent/skills/business-analysis/references/domains/healthtech.md +44 -0
  64. package/.agent/skills/business-analysis/references/domains/internal-tools.md +38 -0
  65. package/.agent/skills/business-analysis/references/domains/marketplace.md +52 -0
  66. package/.agent/skills/business-analysis/references/domains/saas.md +36 -0
  67. package/.agent/skills/business-analysis/references/workflows/collaboration.md +41 -0
  68. package/.agent/skills/business-analysis/scripts/verify_mermaid.py +86 -0
  69. package/.agent/skills/business-analysis/templates/brd.md +46 -0
  70. package/.agent/skills/business-analysis/templates/change-request.md +41 -0
  71. package/.agent/skills/business-analysis/templates/prd-functional.md +38 -0
  72. package/.agent/skills/business-analysis/templates/use-case.md +40 -0
  73. package/.agent/skills/business-analysis/templates/user-story-detailed.md +36 -0
  74. package/.agent/skills/code-review/SKILL.md +113 -0
  75. package/.agent/skills/code-review/references/code-review-reception.md +209 -0
  76. package/.agent/skills/code-review/references/differential_review.md +59 -0
  77. package/.agent/skills/code-review/references/requesting-code-review.md +105 -0
  78. package/.agent/skills/code-review/references/spec_compliance.md +43 -0
  79. package/.agent/skills/code-review/references/verification-before-completion.md +139 -0
  80. package/.agent/skills/context-engineering/SKILL.md +68 -0
  81. package/.agent/skills/context-engineering/references/context-compression.md +84 -0
  82. package/.agent/skills/context-engineering/references/context-degradation.md +93 -0
  83. package/.agent/skills/context-engineering/references/context-fundamentals.md +75 -0
  84. package/.agent/skills/context-engineering/references/context-optimization.md +82 -0
  85. package/.agent/skills/context-engineering/references/evaluation.md +89 -0
  86. package/.agent/skills/context-engineering/references/memory-systems.md +88 -0
  87. package/.agent/skills/context-engineering/references/multi-agent-patterns.md +90 -0
  88. package/.agent/skills/context-engineering/references/project-development.md +97 -0
  89. package/.agent/skills/context-engineering/references/tool-design.md +86 -0
  90. package/.agent/skills/debugging/SKILL.md +60 -0
  91. package/.agent/skills/debugging/references/defense-in-depth.md +130 -0
  92. package/.agent/skills/debugging/references/root-cause-tracing.md +177 -0
  93. package/.agent/skills/debugging/references/systematic-debugging.md +295 -0
  94. package/.agent/skills/debugging/references/verification-before-completion.md +142 -0
  95. package/.agent/skills/designer/SKILL.md +159 -0
  96. package/.agent/skills/designer/concepts/apple-glass.md +48 -0
  97. package/.agent/skills/designer/concepts/aurora-gradients.md +26 -0
  98. package/.agent/skills/designer/concepts/bento-grids.md +14 -0
  99. package/.agent/skills/designer/concepts/claymorphism.md +27 -0
  100. package/.agent/skills/designer/concepts/neo-brutalism.md +32 -0
  101. package/.agent/skills/designer/data/app-interface.csv +31 -0
  102. package/.agent/skills/designer/data/charts.csv +26 -0
  103. package/.agent/skills/designer/data/colors.csv +162 -0
  104. package/.agent/skills/designer/data/design.csv +1776 -0
  105. package/.agent/skills/designer/data/icons.csv +106 -0
  106. package/.agent/skills/designer/data/landing.csv +35 -0
  107. package/.agent/skills/designer/data/products.csv +162 -0
  108. package/.agent/skills/designer/data/react-performance.csv +45 -0
  109. package/.agent/skills/designer/data/styles.csv +85 -0
  110. package/.agent/skills/designer/data/typography.csv +74 -0
  111. package/.agent/skills/designer/data/ui-reasoning.csv +162 -0
  112. package/.agent/skills/designer/data/ux-guidelines.csv +100 -0
  113. package/.agent/skills/designer/references/accessibility.md +172 -0
  114. package/.agent/skills/designer/references/branding.md +88 -0
  115. package/.agent/skills/designer/references/color-theory.md +139 -0
  116. package/.agent/skills/designer/references/creation.md +118 -0
  117. package/.agent/skills/designer/references/design-systems.md +219 -0
  118. package/.agent/skills/designer/references/frontend_design_aesthetics.md +57 -0
  119. package/.agent/skills/designer/references/layout.md +200 -0
  120. package/.agent/skills/designer/references/motion.md +92 -0
  121. package/.agent/skills/designer/references/review.md +100 -0
  122. package/.agent/skills/designer/references/trends.md +209 -0
  123. package/.agent/skills/designer/references/typography.md +190 -0
  124. package/.agent/skills/designer/scripts/remove_background.py +135 -0
  125. package/.agent/skills/designer/scripts/ui-search/__pycache__/core.cpython-314.pyc +0 -0
  126. package/.agent/skills/designer/scripts/ui-search/__pycache__/design_system.cpython-314.pyc +0 -0
  127. package/.agent/skills/designer/scripts/ui-search/core.py +217 -0
  128. package/.agent/skills/designer/scripts/ui-search/design_system.py +1067 -0
  129. package/.agent/skills/designer/scripts/ui-search/search.py +114 -0
  130. package/.agent/skills/designer/templates/design-motion-spec.md +30 -0
  131. package/.agent/skills/devops-engineer/SKILL.md +90 -0
  132. package/.agent/skills/devops-engineer/docker-compose/README.md +47 -0
  133. package/.agent/skills/devops-engineer/references/ci-cd-pipelines.md +76 -0
  134. package/.agent/skills/devops-engineer/references/cloud-providers.md +57 -0
  135. package/.agent/skills/devops-engineer/references/codebase-normalization.md +104 -0
  136. package/.agent/skills/devops-engineer/references/container-orchestration.md +69 -0
  137. package/.agent/skills/devops-engineer/references/iac-tools.md +63 -0
  138. package/.agent/skills/devops-engineer/references/observability-security.md +45 -0
  139. package/.agent/skills/devops-engineer/references/vercel-supabase.md +17 -0
  140. package/.agent/skills/devops-engineer/templates/release-notes.md +8 -0
  141. package/.agent/skills/frontend-developer/SKILL.md +125 -0
  142. package/.agent/skills/frontend-developer/react-nextjs/README.md +90 -0
  143. package/.agent/skills/frontend-developer/references/angular.md +52 -0
  144. package/.agent/skills/frontend-developer/references/composition_patterns.md +60 -0
  145. package/.agent/skills/frontend-developer/references/core-performance.md +68 -0
  146. package/.agent/skills/frontend-developer/references/modern-signals.md +43 -0
  147. package/.agent/skills/frontend-developer/references/react_performance_rules.md +55 -0
  148. package/.agent/skills/frontend-developer/references/vue-nuxt.md +55 -0
  149. package/.agent/skills/frontend-developer/scripts/validate_compliance.py +65 -0
  150. package/.agent/skills/frontend-developer/threejs/README.md +89 -0
  151. package/.agent/skills/frontend-developer/threejs/animation.md +552 -0
  152. package/.agent/skills/frontend-developer/threejs/fundamentals.md +488 -0
  153. package/.agent/skills/frontend-developer/threejs/geometry.md +548 -0
  154. package/.agent/skills/frontend-developer/threejs/interaction.md +660 -0
  155. package/.agent/skills/frontend-developer/threejs/lighting.md +481 -0
  156. package/.agent/skills/frontend-developer/threejs/loaders.md +623 -0
  157. package/.agent/skills/frontend-developer/threejs/materials.md +520 -0
  158. package/.agent/skills/frontend-developer/threejs/postprocessing.md +602 -0
  159. package/.agent/skills/frontend-developer/threejs/router.json +181 -0
  160. package/.agent/skills/frontend-developer/threejs/shaders.md +642 -0
  161. package/.agent/skills/frontend-developer/threejs/textures.md +628 -0
  162. package/.agent/skills/game-development/2d-games/SKILL.md +119 -0
  163. package/.agent/skills/game-development/3d-games/SKILL.md +135 -0
  164. package/.agent/skills/game-development/SKILL.md +167 -0
  165. package/.agent/skills/game-development/game-art/SKILL.md +185 -0
  166. package/.agent/skills/game-development/game-audio/SKILL.md +190 -0
  167. package/.agent/skills/game-development/game-design/SKILL.md +129 -0
  168. package/.agent/skills/game-development/mobile-games/SKILL.md +108 -0
  169. package/.agent/skills/game-development/multiplayer/SKILL.md +132 -0
  170. package/.agent/skills/game-development/pc-games/SKILL.md +144 -0
  171. package/.agent/skills/game-development/vr-ar/SKILL.md +123 -0
  172. package/.agent/skills/game-development/web-games/SKILL.md +150 -0
  173. package/.agent/skills/lead-architect/SKILL.md +85 -0
  174. package/.agent/skills/lead-architect/references/application-architecture.md +70 -0
  175. package/.agent/skills/lead-architect/references/infrastructure.md +51 -0
  176. package/.agent/skills/lead-architect/references/process.md +42 -0
  177. package/.agent/skills/lead-architect/references/system-architecture.md +62 -0
  178. package/.agent/skills/lead-architect/references/web-fullstack.md +82 -0
  179. package/.agent/skills/lead-architect/templates/adr.md +62 -0
  180. package/.agent/skills/lead-architect/templates/rfc.md +46 -0
  181. package/.agent/skills/lead-architect/templates/sdd.md +62 -0
  182. package/.agent/skills/lead-architect/templates/technical-spec.md +61 -0
  183. package/.agent/skills/marketer/SKILL.md +66 -0
  184. package/.agent/skills/marketer/remotion-best-practices/SKILL.md +58 -0
  185. package/.agent/skills/marketer/remotion-best-practices/rules/3d.md +86 -0
  186. package/.agent/skills/marketer/remotion-best-practices/rules/animations.md +29 -0
  187. package/.agent/skills/marketer/remotion-best-practices/rules/assets/charts-bar-chart.tsx +173 -0
  188. package/.agent/skills/marketer/remotion-best-practices/rules/assets/text-animations-typewriter.tsx +100 -0
  189. package/.agent/skills/marketer/remotion-best-practices/rules/assets/text-animations-word-highlight.tsx +108 -0
  190. package/.agent/skills/marketer/remotion-best-practices/rules/assets.md +78 -0
  191. package/.agent/skills/marketer/remotion-best-practices/rules/audio.md +172 -0
  192. package/.agent/skills/marketer/remotion-best-practices/rules/calculate-metadata.md +104 -0
  193. package/.agent/skills/marketer/remotion-best-practices/rules/can-decode.md +75 -0
  194. package/.agent/skills/marketer/remotion-best-practices/rules/charts.md +58 -0
  195. package/.agent/skills/marketer/remotion-best-practices/rules/compositions.md +146 -0
  196. package/.agent/skills/marketer/remotion-best-practices/rules/display-captions.md +126 -0
  197. package/.agent/skills/marketer/remotion-best-practices/rules/extract-frames.md +229 -0
  198. package/.agent/skills/marketer/remotion-best-practices/rules/fonts.md +152 -0
  199. package/.agent/skills/marketer/remotion-best-practices/rules/get-audio-duration.md +58 -0
  200. package/.agent/skills/marketer/remotion-best-practices/rules/get-video-dimensions.md +68 -0
  201. package/.agent/skills/marketer/remotion-best-practices/rules/get-video-duration.md +58 -0
  202. package/.agent/skills/marketer/remotion-best-practices/rules/gifs.md +138 -0
  203. package/.agent/skills/marketer/remotion-best-practices/rules/images.md +130 -0
  204. package/.agent/skills/marketer/remotion-best-practices/rules/import-srt-captions.md +67 -0
  205. package/.agent/skills/marketer/remotion-best-practices/rules/lottie.md +68 -0
  206. package/.agent/skills/marketer/remotion-best-practices/rules/measuring-dom-nodes.md +35 -0
  207. package/.agent/skills/marketer/remotion-best-practices/rules/measuring-text.md +143 -0
  208. package/.agent/skills/marketer/remotion-best-practices/rules/sequencing.md +106 -0
  209. package/.agent/skills/marketer/remotion-best-practices/rules/tailwind.md +11 -0
  210. package/.agent/skills/marketer/remotion-best-practices/rules/text-animations.md +20 -0
  211. package/.agent/skills/marketer/remotion-best-practices/rules/timing.md +179 -0
  212. package/.agent/skills/marketer/remotion-best-practices/rules/transcribe-captions.md +19 -0
  213. package/.agent/skills/marketer/remotion-best-practices/rules/transitions.md +122 -0
  214. package/.agent/skills/marketer/remotion-best-practices/rules/trimming.md +53 -0
  215. package/.agent/skills/marketer/remotion-best-practices/rules/videos.md +171 -0
  216. package/.agent/skills/mcp-builder/SKILL.md +76 -0
  217. package/.agent/skills/mcp-builder/references/evaluation.md +602 -0
  218. package/.agent/skills/mcp-builder/references/mcp_best_practices.md +249 -0
  219. package/.agent/skills/mcp-builder/references/node_mcp_server.md +970 -0
  220. package/.agent/skills/mcp-builder/references/python_mcp_server.md +719 -0
  221. package/.agent/skills/mobile-developer/SKILL.md +83 -0
  222. package/.agent/skills/mobile-developer/api-routes/SKILL.md +389 -0
  223. package/.agent/skills/mobile-developer/building-ui/SKILL.md +335 -0
  224. package/.agent/skills/mobile-developer/building-ui/references/animations.md +220 -0
  225. package/.agent/skills/mobile-developer/building-ui/references/controls.md +270 -0
  226. package/.agent/skills/mobile-developer/building-ui/references/form-sheet.md +227 -0
  227. package/.agent/skills/mobile-developer/building-ui/references/gradients.md +106 -0
  228. package/.agent/skills/mobile-developer/building-ui/references/icons.md +213 -0
  229. package/.agent/skills/mobile-developer/building-ui/references/media.md +198 -0
  230. package/.agent/skills/mobile-developer/building-ui/references/route-structure.md +229 -0
  231. package/.agent/skills/mobile-developer/building-ui/references/search.md +248 -0
  232. package/.agent/skills/mobile-developer/building-ui/references/storage.md +121 -0
  233. package/.agent/skills/mobile-developer/building-ui/references/tabs.md +368 -0
  234. package/.agent/skills/mobile-developer/building-ui/references/visual-effects.md +197 -0
  235. package/.agent/skills/mobile-developer/building-ui/references/webgpu-three.md +605 -0
  236. package/.agent/skills/mobile-developer/cicd-workflows/SKILL.md +107 -0
  237. package/.agent/skills/mobile-developer/cicd-workflows/scripts/fetch.js +109 -0
  238. package/.agent/skills/mobile-developer/cicd-workflows/scripts/package.json +11 -0
  239. package/.agent/skills/mobile-developer/cicd-workflows/scripts/validate.js +84 -0
  240. package/.agent/skills/mobile-developer/data-fetching/SKILL.md +508 -0
  241. package/.agent/skills/mobile-developer/deployment/SKILL.md +207 -0
  242. package/.agent/skills/mobile-developer/deployment/references/app-store-metadata.md +479 -0
  243. package/.agent/skills/mobile-developer/deployment/references/ios-app-store.md +355 -0
  244. package/.agent/skills/mobile-developer/deployment/references/play-store.md +246 -0
  245. package/.agent/skills/mobile-developer/deployment/references/testflight.md +58 -0
  246. package/.agent/skills/mobile-developer/deployment/references/workflows.md +200 -0
  247. package/.agent/skills/mobile-developer/dev-client/SKILL.md +181 -0
  248. package/.agent/skills/mobile-developer/tailwind-setup/SKILL.md +501 -0
  249. package/.agent/skills/mobile-developer/upgrading-expo/SKILL.md +116 -0
  250. package/.agent/skills/mobile-developer/upgrading-expo/references/new-architecture.md +79 -0
  251. package/.agent/skills/mobile-developer/upgrading-expo/references/react-19.md +79 -0
  252. package/.agent/skills/mobile-developer/upgrading-expo/references/react-compiler.md +59 -0
  253. package/.agent/skills/mobile-developer/use-dom/SKILL.md +434 -0
  254. package/.agent/skills/modern-python/SKILL.md +122 -0
  255. package/.agent/skills/project-manager/SKILL.md +110 -0
  256. package/.agent/skills/project-manager/references/ba-collaboration.md +62 -0
  257. package/.agent/skills/project-manager/references/discovery_process.md +52 -0
  258. package/.agent/skills/project-manager/references/jobs_to_be_done.md +51 -0
  259. package/.agent/skills/project-manager/references/prd_development.md +52 -0
  260. package/.agent/skills/project-manager/references/rules-guide.md +55 -0
  261. package/.agent/skills/project-manager/references/skill-creation.md +98 -0
  262. package/.agent/skills/project-manager/references/strategic-frameworks.md +62 -0
  263. package/.agent/skills/project-manager/references/task-decomposition.md +194 -0
  264. package/.agent/skills/project-manager/references/workflows-guide.md +44 -0
  265. package/.agent/skills/project-manager/router.json +160 -0
  266. package/.agent/skills/project-manager/scripts/compare_skill.py +177 -0
  267. package/.agent/skills/project-manager/scripts/encoding_utils.py +36 -0
  268. package/.agent/skills/project-manager/scripts/init_skill.py +190 -0
  269. package/.agent/skills/project-manager/scripts/quick_validate.py +123 -0
  270. package/.agent/skills/project-manager/templates/pm-strategy-one-pager.md +6 -0
  271. package/.agent/skills/project-manager/templates/prd-strategic.md +38 -0
  272. package/.agent/skills/project-manager/templates/skill-questionnaire.md +118 -0
  273. package/.agent/skills/project-manager/templates/user-story-simple.md +14 -0
  274. package/.agent/skills/prompt-engineer/SKILL.md +319 -0
  275. package/.agent/skills/prompt-engineer/skill-creator/README.md +47 -0
  276. package/.agent/skills/qa-tester/SKILL.md +142 -0
  277. package/.agent/skills/qa-tester/assets/README.md +8 -0
  278. package/.agent/skills/qa-tester/references/accessibility_testing.md +35 -0
  279. package/.agent/skills/qa-tester/references/agent_browser.md +38 -0
  280. package/.agent/skills/qa-tester/references/automation/api_testing.md +23 -0
  281. package/.agent/skills/qa-tester/references/automation/best_practices.md +14 -0
  282. package/.agent/skills/qa-tester/references/automation/jest_vitest.md +26 -0
  283. package/.agent/skills/qa-tester/references/automation/playwright.md +30 -0
  284. package/.agent/skills/qa-tester/references/e2e_testing.md +46 -0
  285. package/.agent/skills/qa-tester/references/integration_testing.md +39 -0
  286. package/.agent/skills/qa-tester/references/performance_testing.md +44 -0
  287. package/.agent/skills/qa-tester/references/property_based_testing.md +44 -0
  288. package/.agent/skills/qa-tester/references/security_audit.md +53 -0
  289. package/.agent/skills/qa-tester/references/security_testing.md +30 -0
  290. package/.agent/skills/qa-tester/references/sharp_edges.md +49 -0
  291. package/.agent/skills/qa-tester/references/static_analysis.md +52 -0
  292. package/.agent/skills/qa-tester/references/supply_chain_audit.md +54 -0
  293. package/.agent/skills/qa-tester/references/test_case_standards.md +96 -0
  294. package/.agent/skills/qa-tester/references/test_report_template.md +32 -0
  295. package/.agent/skills/qa-tester/references/unit_testing.md +50 -0
  296. package/.agent/skills/qa-tester/references/visual_testing.md +32 -0
  297. package/.agent/skills/qa-tester/templates/uat-plan.md +34 -0
  298. package/.agent/skills/research-first/SKILL.md +118 -0
  299. package/.agent/skills-manifest.json +264 -0
  300. package/.agent/workflows/absorb.md +176 -0
  301. package/.agent/workflows/bootstrap.md +91 -0
  302. package/.agent/workflows/brainstorm.md +168 -0
  303. package/.agent/workflows/break-tasks.md +77 -0
  304. package/.agent/workflows/commit.md +349 -0
  305. package/.agent/workflows/custom-behavior.md +64 -0
  306. package/.agent/workflows/debug.md +65 -0
  307. package/.agent/workflows/development.md +49 -0
  308. package/.agent/workflows/documentation.md +221 -0
  309. package/.agent/workflows/gen-tests.md +53 -0
  310. package/.agent/workflows/guide.md +196 -0
  311. package/.agent/workflows/implement-feature.md +182 -0
  312. package/.agent/workflows/install-skill.md +193 -0
  313. package/.agent/workflows/qa.md +54 -0
  314. package/.agent/workflows/ui-ux-design.md +108 -0
  315. package/LICENSE +21 -0
  316. package/README.md +258 -0
  317. package/cli/index.js +345 -0
  318. package/cli/migrate-skills.js +113 -0
  319. package/cli/verify.js +291 -0
  320. package/package.json +49 -0
@@ -0,0 +1,975 @@
1
+ ---
2
+ name: blockchain-engineer
3
+ description: >
4
+ Smart contracts, protocol architecture, and security auditing. Use for EVM/Solana, tokenomics, and DeFi.
5
+ license: MIT
6
+ compatibility: Claude Code, Cursor, Gemini CLI, GitHub Copilot
7
+ metadata:
8
+ author: jhm1909
9
+ version: "2.0.0"
10
+ domain: blockchain
11
+ estimated_tokens: 30000
12
+ ---
13
+
14
+ # Blockchain Engineer
15
+
16
+ Decentralized systems with focus on security, scalability, and economic robustness.
17
+
18
+ ## Knowledge Graph
19
+
20
+ - **extends**: [[backend-developer]]
21
+ - **requires**: []
22
+ - **suggests**: [[devops-engineer]], [[lead-architect]]
23
+ - **conflicts**: []
24
+ - **enhances**: [[backend-developer]] (web3 integration)
25
+ - **moc**: [[blockchain-moc]]
26
+
27
+ ---
28
+
29
+ ## 1. Blockchain Fundamentals
30
+
31
+ ### 1.1 Consensus Mechanisms
32
+
33
+ | Mechanism | Throughput | Finality | Use Case |
34
+ |:----------|:-----------|:---------|:---------|
35
+ | **Proof of Work (PoW)** | ~7 TPS | Probabilistic | Bitcoin, high security |
36
+ | **Proof of Stake (PoS)** | ~1000 TPS | Probabilistic | Ethereum 2.0, energy efficient |
37
+ | **Delegated PoS (DPoS)** | ~3000 TPS | Fast | EOS, governance focused |
38
+ | **Proof of Authority (PoA)** | ~1000 TPS | Immediate | Private/consortium chains |
39
+ | **Byzantine Fault Tolerant** | ~10k TPS | Immediate | Enterprise (Hyperledger) |
40
+
41
+ ### 1.2 EVM Architecture
42
+
43
+ ```
44
+ ┌─────────────────────────────────────────┐
45
+ │ Smart Contract │
46
+ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
47
+ │ │Storage │ │Memory │ │Stack │ │
48
+ │ │Persistent│ │Temporary│ │256-bit │ │
49
+ │ │$20k/32B │ │$3/gas │ │1024 max │ │
50
+ │ └─────────┘ └─────────┘ └─────────┘ │
51
+ └─────────────────────────────────────────┘
52
+
53
+ ┌─────────────────────────────────────────┐
54
+ │ EVM Execution │
55
+ │ - Turing complete │
56
+ │ - Gas-metered (10M gas limit/block) │
57
+ │ - Deterministic │
58
+ └─────────────────────────────────────────┘
59
+ ```
60
+
61
+ **Gas Costs (Berlin/London)**
62
+ - `SSTORE` (new slot): 20,000 gas
63
+ - `SSTORE` (update): 5,000 gas
64
+ - `SLOAD`: 2,100 gas (warm) / 2,100 gas (cold)
65
+ - `CALL`: 2,600 gas + memory
66
+ - `CREATE`: 32,000 gas + code deposit
67
+
68
+ ### 1.3 Account Model
69
+
70
+ **Ethereum (Account-Based)**
71
+ ```solidity
72
+ // Externally Owned Account (EOA)
73
+ {
74
+ nonce: 42,
75
+ balance: 1.5 ether,
76
+ codeHash: 0x0, // Empty for EOA
77
+ storageRoot: ...
78
+ }
79
+
80
+ // Contract Account
81
+ {
82
+ nonce: 0,
83
+ balance: 10 ether,
84
+ codeHash: keccak256(bytecode),
85
+ storageRoot: merkleRoot(storage)
86
+ }
87
+ ```
88
+
89
+ **Bitcoin (UTXO-Based)**
90
+ - Each output is a coin that can be spent
91
+ - Transaction consumes inputs, creates outputs
92
+ - No account state, just coin ownership
93
+
94
+ ---
95
+
96
+ ## 2. Smart Contract Development
97
+
98
+ ### 2.1 Solidity Best Practices
99
+
100
+ ```solidity
101
+ // SPDX-License-Identifier: MIT
102
+ pragma solidity ^0.8.19;
103
+
104
+ import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
105
+ import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
106
+ import "@openzeppelin/contracts/access/Ownable.sol";
107
+
108
+ /**
109
+ * @title SecureToken
110
+ * @notice Example of secure ERC20 implementation
111
+ */
112
+ contract SecureToken is ERC20, ReentrancyGuard, Ownable {
113
+ // ============ State Variables ============
114
+
115
+ // Use private with getter functions
116
+ mapping(address => uint256) private _stakes;
117
+
118
+ // Immutable for gas savings
119
+ uint256 public immutable maxSupply;
120
+
121
+ // Constant for compile-time values
122
+ uint256 public constant REWARD_RATE = 100; // basis points
123
+
124
+ // Gap for upgradeable contracts
125
+ uint256[50] private __gap;
126
+
127
+ // ============ Events ============
128
+
129
+ event Staked(address indexed user, uint256 amount);
130
+ event Unstaked(address indexed user, uint256 amount, uint256 reward);
131
+
132
+ // ============ Errors (Gas Efficient) ============
133
+
134
+ error InsufficientBalance(uint256 available, uint256 required);
135
+ error StakeLocked(uint256 unlockTime);
136
+ error InvalidAmount();
137
+
138
+ // ============ Modifiers ============
139
+
140
+ modifier validAmount(uint256 amount) {
141
+ if (amount == 0) revert InvalidAmount();
142
+ _;
143
+ }
144
+
145
+ // ============ Constructor ============
146
+
147
+ constructor(
148
+ string memory name,
149
+ string memory symbol,
150
+ uint256 _maxSupply
151
+ ) ERC20(name, symbol) {
152
+ maxSupply = _maxSupply;
153
+ _mint(msg.sender, _maxSupply / 10); // 10% to deployer
154
+ }
155
+
156
+ // ============ External Functions ============
157
+
158
+ /**
159
+ * @notice Stake tokens to earn rewards
160
+ * @param amount Amount to stake
161
+ */
162
+ function stake(uint256 amount)
163
+ external
164
+ nonReentrant
165
+ validAmount(amount)
166
+ {
167
+ if (balanceOf(msg.sender) < amount) {
168
+ revert InsufficientBalance(balanceOf(msg.sender), amount);
169
+ }
170
+
171
+ // Update state before external calls (Checks-Effects-Interactions)
172
+ _stakes[msg.sender] += amount;
173
+ _updateStakeTime(msg.sender);
174
+
175
+ // External call last
176
+ _transfer(msg.sender, address(this), amount);
177
+
178
+ emit Staked(msg.sender, amount);
179
+ }
180
+
181
+ /**
182
+ * @notice Unstake tokens and claim rewards
183
+ */
184
+ function unstake() external nonReentrant {
185
+ uint256 staked = _stakes[msg.sender];
186
+ if (staked == 0) revert InvalidAmount();
187
+
188
+ uint256 reward = _calculateReward(msg.sender);
189
+
190
+ // Effects
191
+ _stakes[msg.sender] = 0;
192
+
193
+ // Interactions (external calls last)
194
+ _transfer(address(this), msg.sender, staked);
195
+ _mint(msg.sender, reward);
196
+
197
+ emit Unstaked(msg.sender, staked, reward);
198
+ }
199
+
200
+ // ============ View Functions ============
201
+
202
+ function getStakeInfo(address user)
203
+ external
204
+ view
205
+ returns (uint256 staked, uint256 pendingReward)
206
+ {
207
+ staked = _stakes[user];
208
+ pendingReward = _calculateReward(user);
209
+ }
210
+
211
+ // ============ Internal Functions ============
212
+
213
+ function _calculateReward(address user) internal view returns (uint256) {
214
+ // Implementation
215
+ return (_stakes[user] * REWARD_RATE * _getStakeDuration(user)) / 10000;
216
+ }
217
+ }
218
+ ```
219
+
220
+ ### 2.2 Security Patterns
221
+
222
+ **Checks-Effects-Interactions**
223
+ ```solidity
224
+ // ❌ WRONG: External call before state update
225
+ function withdraw() external {
226
+ (bool success, ) = msg.sender.call{value: balances[msg.sender]}("");
227
+ require(success, "Transfer failed");
228
+ balances[msg.sender] = 0; // Too late!
229
+ }
230
+
231
+ // ✅ CORRECT: Checks -> Effects -> Interactions
232
+ function withdraw() external {
233
+ uint256 amount = balances[msg.sender]; // Check
234
+ require(amount > 0, "No balance");
235
+
236
+ balances[msg.sender] = 0; // Effect
237
+
238
+ (bool success, ) = msg.sender.call{value: amount}(""); // Interaction
239
+ require(success, "Transfer failed");
240
+ }
241
+ ```
242
+
243
+ **Reentrancy Guard**
244
+ ```solidity
245
+ // Using OpenZeppelin
246
+ import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
247
+
248
+ contract Secure is ReentrancyGuard {
249
+ function withdraw() external nonReentrant {
250
+ // Safe from reentrancy
251
+ }
252
+ }
253
+
254
+ // Manual implementation
255
+ modifier nonReentrant() {
256
+ require(!_locked, "Reentrant call");
257
+ _locked = true;
258
+ _;
259
+ _locked = false;
260
+ }
261
+ ```
262
+
263
+ **Pull Over Push**
264
+ ```solidity
265
+ // ❌ WRONG: Push payments (can fail, block execution)
266
+ function distributeRewards() external {
267
+ for (uint i = 0; i < users.length; i++) {
268
+ users[i].call{value: rewards[users[i]]}(""); // Can fail
269
+ }
270
+ }
271
+
272
+ // ✅ CORRECT: Pull payments (user withdraws)
273
+ function claimReward() external {
274
+ uint256 reward = pendingRewards[msg.sender];
275
+ require(reward > 0, "No reward");
276
+ pendingRewards[msg.sender] = 0;
277
+ (bool success, ) = msg.sender.call{value: reward}("");
278
+ require(success, "Transfer failed");
279
+ }
280
+ ```
281
+
282
+ **Integer Overflow Protection**
283
+ ```solidity
284
+ // Solidity 0.8+ has built-in overflow checks
285
+ // For 0.8+, explicit checks not needed
286
+
287
+ // For unchecked blocks (gas optimization)
288
+ function batchTransfer(address[] calldata recipients, uint256 amount) external {
289
+ uint256 total = recipients.length * amount; // Can overflow!
290
+ require(balanceOf[msg.sender] >= total, "Insufficient balance");
291
+
292
+ unchecked {
293
+ for (uint i = 0; i < recipients.length; i++) {
294
+ _transfer(msg.sender, recipients[i], amount);
295
+ }
296
+ }
297
+ }
298
+ ```
299
+
300
+ ### 2.3 Access Control
301
+
302
+ ```solidity
303
+ // Role-based access control
304
+ import "@openzeppelin/contracts/access/AccessControl.sol";
305
+
306
+ contract Governed is AccessControl {
307
+ bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
308
+ bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");
309
+ bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
310
+
311
+ constructor() {
312
+ _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
313
+ }
314
+
315
+ function mint(address to, uint256 amount) external onlyRole(MINTER_ROLE) {
316
+ _mint(to, amount);
317
+ }
318
+
319
+ function pause() external onlyRole(PAUSER_ROLE) {
320
+ _pause();
321
+ }
322
+ }
323
+
324
+ // Multi-sig pattern
325
+ contract MultiSig {
326
+ address[] public owners;
327
+ uint256 public required;
328
+
329
+ mapping(bytes32 => bool) public executed;
330
+ mapping(bytes32 => mapping(address => bool)) public confirmed;
331
+
332
+ modifier onlyOwner() {
333
+ require(isOwner[msg.sender], "Not owner");
334
+ _;
335
+ }
336
+
337
+ function submitTransaction(address to, uint256 value, bytes calldata data)
338
+ external
339
+ onlyOwner
340
+ returns (bytes32 txHash)
341
+ {
342
+ txHash = keccak256(abi.encode(to, value, data, nonce++));
343
+ // ... implementation
344
+ }
345
+
346
+ function confirmTransaction(bytes32 txHash) external onlyOwner {
347
+ confirmed[txHash][msg.sender] = true;
348
+ if (getConfirmationCount(txHash) >= required) {
349
+ executeTransaction(txHash);
350
+ }
351
+ }
352
+ }
353
+ ```
354
+
355
+ ---
356
+
357
+ ## 3. Gas Optimization
358
+
359
+ ### 3.1 Storage Optimization
360
+
361
+ ```solidity
362
+ // ❌ WRONG: Inefficient packing
363
+ contract Inefficient {
364
+ uint256 a; // 32 bytes
365
+ uint128 b; // 16 bytes - new slot
366
+ uint128 c; // 16 bytes - same slot as b
367
+ uint256 d; // 32 bytes - new slot
368
+ // Total: 3 slots = 96 bytes
369
+ }
370
+
371
+ // ✅ CORRECT: Pack variables
372
+ contract Efficient {
373
+ uint128 b; // 16 bytes
374
+ uint128 c; // 16 bytes - packed with b
375
+ uint256 a; // 32 bytes
376
+ uint256 d; // 32 bytes
377
+ // Total: 2 slots = 64 bytes
378
+ }
379
+
380
+ // Mappings vs Arrays
381
+ contract DataStructure {
382
+ // Array: O(n) search, can have duplicates
383
+ address[] public users;
384
+
385
+ // Mapping: O(1) lookup, no duplicates
386
+ mapping(address => bool) public isUser;
387
+
388
+ // Combination for iteration + lookup
389
+ address[] public userList;
390
+ mapping(address => uint256) public userIndex;
391
+ }
392
+ ```
393
+
394
+ ### 3.2 Memory vs Storage
395
+
396
+ ```solidity
397
+ contract MemoryOptimization {
398
+ uint256[] public data;
399
+
400
+ // ❌ WRONG: Storage read in loop
401
+ function sum() external view returns (uint256) {
402
+ uint256 total;
403
+ for (uint i = 0; i < data.length; i++) {
404
+ total += data[i]; // SLOAD each iteration
405
+ }
406
+ return total;
407
+ }
408
+
409
+ // ✅ CORRECT: Cache in memory
410
+ function sumOptimized() external view returns (uint256) {
411
+ uint256 total;
412
+ uint256[] memory _data = data; // One SLOAD
413
+ for (uint i = 0; i < _data.length; i++) {
414
+ total += _data[i]; // MLOAD (much cheaper)
415
+ }
416
+ return total;
417
+ }
418
+
419
+ // Unchecked for counters
420
+ function process() external {
421
+ uint256 len = items.length;
422
+ for (uint256 i = 0; i < len; ) {
423
+ processItem(items[i]);
424
+ unchecked { ++i; } // Save overflow check gas
425
+ }
426
+ }
427
+ }
428
+ ```
429
+
430
+ ### 3.3 Calldata Optimization
431
+
432
+ ```solidity
433
+ // Use calldata for read-only external function params
434
+ function processArray(uint256[] calldata data) external pure {
435
+ // calldata is cheaper than memory for external calls
436
+ for (uint i = 0; i < data.length; i++) {
437
+ // process data[i]
438
+ }
439
+ }
440
+
441
+ // Short circuit evaluation
442
+ modifier onlyAuthorized() {
443
+ require(
444
+ isAdmin[msg.sender] || hasRole[OPERATOR][msg.sender],
445
+ "Not authorized"
446
+ );
447
+ _;
448
+ // Put most likely condition first
449
+ }
450
+ ```
451
+
452
+ ---
453
+
454
+ ## 4. Upgradeability Patterns
455
+
456
+ ### 4.1 Proxy Patterns
457
+
458
+ **Transparent Proxy**
459
+ ```solidity
460
+ // Proxy contract
461
+ contract TransparentProxy {
462
+ address public implementation;
463
+ address public admin;
464
+
465
+ constructor(address _implementation) {
466
+ implementation = _implementation;
467
+ admin = msg.sender;
468
+ }
469
+
470
+ fallback() external payable {
471
+ require(msg.sender != admin, "Admin cannot call fallback");
472
+ _delegate(implementation);
473
+ }
474
+
475
+ function upgradeTo(address newImplementation) external {
476
+ require(msg.sender == admin, "Only admin");
477
+ implementation = newImplementation;
478
+ }
479
+
480
+ function _delegate(address impl) internal {
481
+ assembly {
482
+ calldatacopy(0, 0, calldatasize())
483
+ let result := delegatecall(gas(), impl, 0, calldatasize(), 0, 0)
484
+ returndatacopy(0, 0, returndatasize())
485
+ switch result
486
+ case 0 { revert(0, returndatasize()) }
487
+ default { return(0, returndatasize()) }
488
+ }
489
+ }
490
+ }
491
+
492
+ // Implementation (Logic) contract
493
+ contract LogicV1 is Initializable {
494
+ uint256 public value;
495
+
496
+ function initialize(uint256 _value) public initializer {
497
+ value = _value;
498
+ }
499
+
500
+ function setValue(uint256 _value) external {
501
+ value = _value;
502
+ }
503
+ }
504
+ ```
505
+
506
+ **UUPS (Universal Upgradeable Proxy Standard)**
507
+ ```solidity
508
+ // UUPS puts upgrade logic in implementation
509
+ // More gas efficient, but requires careful implementation
510
+
511
+ import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
512
+ import "@openzeppelin/contracts/access/Ownable.sol";
513
+
514
+ contract MyContract is Initializable, OwnableUpgradeable, UUPSUpgradeable {
515
+ function initialize() public initializer {
516
+ __Ownable_init();
517
+ __UUPSUpgradeable_init();
518
+ }
519
+
520
+ function _authorizeUpgrade(address newImplementation) internal override onlyOwner {}
521
+ }
522
+ ```
523
+
524
+ **Diamond Pattern (EIP-2535)**
525
+ ```solidity
526
+ // Multiple implementation contracts (facets)
527
+ // Unlimited contract size, granular upgrades
528
+
529
+ struct DiamondStorage {
530
+ mapping(bytes4 => address) facets;
531
+ address owner;
532
+ }
533
+
534
+ function diamondStorage() internal pure returns (DiamondStorage storage ds) {
535
+ bytes32 position = keccak256("diamond.storage");
536
+ assembly {
537
+ ds.slot := position
538
+ }
539
+ }
540
+
541
+ // Add/replace/remove functions dynamically
542
+ function diamondCut(FacetCut[] calldata cuts) external {
543
+ // Implementation
544
+ }
545
+ ```
546
+
547
+ ---
548
+
549
+ ## 5. DeFi Protocols
550
+
551
+ ### 5.1 Automated Market Maker (AMM)
552
+
553
+ ```solidity
554
+ // Constant Product AMM (Uniswap V2 style)
555
+ contract SimpleAMM {
556
+ IERC20 public token0;
557
+ IERC20 public token1;
558
+
559
+ uint256 public reserve0;
560
+ uint256 public reserve1;
561
+
562
+ // k = x * y (constant product)
563
+ function getK() public view returns (uint256) {
564
+ return reserve0 * reserve1;
565
+ }
566
+
567
+ // Swap with 0.3% fee
568
+ function swap(address tokenIn, uint256 amountIn) external returns (uint256 amountOut) {
569
+ require(tokenIn == address(token0) || tokenIn == address(token1), "Invalid token");
570
+
571
+ bool isToken0 = tokenIn == address(token0);
572
+ (uint256 reserveIn, uint256 reserveOut) = isToken0
573
+ ? (reserve0, reserve1)
574
+ : (reserve1, reserve0);
575
+
576
+ // Calculate output with fee
577
+ uint256 amountInWithFee = amountIn * 997 / 1000;
578
+ amountOut = (reserveOut * amountInWithFee) / (reserveIn + amountInWithFee);
579
+
580
+ // Update reserves
581
+ if (isToken0) {
582
+ reserve0 += amountIn;
583
+ reserve1 -= amountOut;
584
+ } else {
585
+ reserve1 += amountIn;
586
+ reserve0 -= amountOut;
587
+ }
588
+
589
+ // Transfer tokens
590
+ IERC20(tokenIn).transferFrom(msg.sender, address(this), amountIn);
591
+ IERC20(isToken0 ? token1 : token0).transfer(msg.sender, amountOut);
592
+ }
593
+
594
+ // Add liquidity
595
+ function addLiquidity(uint256 amount0, uint256 amount1) external {
596
+ if (reserve0 == 0 && reserve1 == 0) {
597
+ // Initial liquidity
598
+ reserve0 = amount0;
599
+ reserve1 = amount1;
600
+ } else {
601
+ // Maintain ratio
602
+ require(
603
+ amount0 * reserve1 == amount1 * reserve0,
604
+ "Invalid ratio"
605
+ );
606
+ reserve0 += amount0;
607
+ reserve1 += amount1;
608
+ }
609
+
610
+ token0.transferFrom(msg.sender, address(this), amount0);
611
+ token1.transferFrom(msg.sender, address(this), amount1);
612
+ }
613
+ }
614
+ ```
615
+
616
+ ### 5.2 Lending Protocol
617
+
618
+ ```solidity
619
+ // Simplified lending with over-collateralization
620
+ contract SimpleLending {
621
+ struct Market {
622
+ IERC20 token;
623
+ uint256 collateralFactor; // e.g., 7500 = 75%
624
+ uint256 supplyIndex;
625
+ uint256 borrowIndex;
626
+ uint256 totalSupplies;
627
+ uint256 totalBorrows;
628
+ }
629
+
630
+ struct Account {
631
+ uint256 supplyBalance;
632
+ uint256 borrowBalance;
633
+ }
634
+
635
+ mapping(address => Market) public markets;
636
+ mapping(address => mapping(address => Account)) public accounts;
637
+
638
+ // Supply assets to earn interest
639
+ function supply(address market, uint256 amount) external {
640
+ accrueInterest(market);
641
+
642
+ Market storage m = markets[market];
643
+ Account storage a = accounts[market][msg.sender];
644
+
645
+ a.supplyBalance = a.supplyBalance * m.supplyIndex / 1e18 + amount;
646
+ m.totalSupplies += amount;
647
+
648
+ m.token.transferFrom(msg.sender, address(this), amount);
649
+ }
650
+
651
+ // Borrow against collateral
652
+ function borrow(address market, uint256 amount) external {
653
+ accrueInterest(market);
654
+
655
+ require(getAccountLiquidity(msg.sender) >= amount, "Insufficient collateral");
656
+
657
+ Market storage m = markets[market];
658
+ Account storage a = accounts[market][msg.sender];
659
+
660
+ a.borrowBalance = a.borrowBalance * m.borrowIndex / 1e18 + amount;
661
+ m.totalBorrows += amount;
662
+
663
+ m.token.transfer(msg.sender, amount);
664
+ }
665
+
666
+ // Calculate account liquidity
667
+ function getAccountLiquidity(address user) public view returns (uint256) {
668
+ uint256 collateralValue;
669
+ uint256 borrowValue;
670
+
671
+ // Sum collateral across all markets
672
+ // Sum borrows across all markets
673
+ // Return collateral * factor - borrows
674
+
675
+ return collateralValue * 7500 / 10000 - borrowValue;
676
+ }
677
+
678
+ // Liquidation
679
+ function liquidate(address borrower, address market) external {
680
+ require(getAccountLiquidity(borrower) < 0, "Account healthy");
681
+
682
+ // Seize collateral at discount (e.g., 8%)
683
+ // Repay borrow on behalf of borrower
684
+ }
685
+ }
686
+ ```
687
+
688
+ ### 5.3 Yield Farming
689
+
690
+ ```solidity
691
+ contract YieldFarm is ReentrancyGuard {
692
+ IERC20 public stakingToken;
693
+ IERC20 public rewardToken;
694
+
695
+ uint256 public rewardPerBlock;
696
+ uint256 public lastRewardBlock;
697
+ uint256 public accRewardPerShare;
698
+
699
+ struct UserInfo {
700
+ uint256 amount;
701
+ uint256 rewardDebt;
702
+ }
703
+
704
+ mapping(address => UserInfo) public users;
705
+ uint256 public totalStaked;
706
+
707
+ function updatePool() public {
708
+ if (block.number <= lastRewardBlock) return;
709
+
710
+ if (totalStaked == 0) {
711
+ lastRewardBlock = block.number;
712
+ return;
713
+ }
714
+
715
+ uint256 blocks = block.number - lastRewardBlock;
716
+ uint256 reward = blocks * rewardPerBlock;
717
+ accRewardPerShare += reward * 1e12 / totalStaked;
718
+ lastRewardBlock = block.number;
719
+ }
720
+
721
+ function deposit(uint256 amount) external nonReentrant {
722
+ updatePool();
723
+
724
+ UserInfo storage user = users[msg.sender];
725
+
726
+ // Claim pending rewards
727
+ if (user.amount > 0) {
728
+ uint256 pending = user.amount * accRewardPerShare / 1e12 - user.rewardDebt;
729
+ rewardToken.transfer(msg.sender, pending);
730
+ }
731
+
732
+ stakingToken.transferFrom(msg.sender, address(this), amount);
733
+ user.amount += amount;
734
+ totalStaked += amount;
735
+ user.rewardDebt = user.amount * accRewardPerShare / 1e12;
736
+ }
737
+
738
+ function withdraw(uint256 amount) external nonReentrant {
739
+ updatePool();
740
+
741
+ UserInfo storage user = users[msg.sender];
742
+ require(user.amount >= amount, "Insufficient balance");
743
+
744
+ // Claim rewards
745
+ uint256 pending = user.amount * accRewardPerShare / 1e12 - user.rewardDebt;
746
+ rewardToken.transfer(msg.sender, pending);
747
+
748
+ user.amount -= amount;
749
+ totalStaked -= amount;
750
+ user.rewardDebt = user.amount * accRewardPerShare / 1e12;
751
+
752
+ stakingToken.transfer(msg.sender, amount);
753
+ }
754
+ }
755
+ ```
756
+
757
+ ---
758
+
759
+ ## 6. Testing & Security
760
+
761
+ ### 6.1 Testing Frameworks
762
+
763
+ **Foundry (Recommended)**
764
+ ```solidity
765
+ // SPDX-License-Identifier: MIT
766
+ pragma solidity ^0.8.19;
767
+
768
+ import "forge-std/Test.sol";
769
+ import "../src/Token.sol";
770
+
771
+ contract TokenTest is Test {
772
+ Token token;
773
+ address alice = address(1);
774
+ address bob = address(2);
775
+
776
+ function setUp() public {
777
+ token = new Token("Test", "TST", 1000000 ether);
778
+ token.transfer(alice, 1000 ether);
779
+ }
780
+
781
+ function testTransfer() public {
782
+ vm.prank(alice);
783
+ token.transfer(bob, 100 ether);
784
+
785
+ assertEq(token.balanceOf(bob), 100 ether);
786
+ assertEq(token.balanceOf(alice), 900 ether);
787
+ }
788
+
789
+ function testTransferInsufficientBalance() public {
790
+ vm.prank(bob); // bob has 0 tokens
791
+ vm.expectRevert("Insufficient balance");
792
+ token.transfer(alice, 100 ether);
793
+ }
794
+
795
+ // Fuzz testing
796
+ function testFuzzTransfer(uint256 amount) public {
797
+ vm.assume(amount <= 1000 ether); // Bound input
798
+
799
+ vm.prank(alice);
800
+ token.transfer(bob, amount);
801
+
802
+ assertEq(token.balanceOf(bob), amount);
803
+ }
804
+
805
+ // Invariant testing
806
+ function invariantTotalSupply() public {
807
+ assertEq(token.totalSupply(), 1000000 ether);
808
+ }
809
+
810
+ // Fork testing
811
+ function testWithMainnet() public {
812
+ vm.createSelectFork("https://eth-mainnet.g.alchemy.com/v2/...");
813
+
814
+ // Test against real mainnet state
815
+ IERC20 usdc = IERC20(0xA0b86a33E6Cb19d3C91d8C8c3D0f1E62b68DEe34);
816
+ // ...
817
+ }
818
+ }
819
+ ```
820
+
821
+ **Hardhat + TypeScript**
822
+ ```typescript
823
+ import { expect } from "chai";
824
+ import { ethers } from "hardhat";
825
+
826
+ describe("Token", function () {
827
+ let token: Token;
828
+ let owner: SignerWithAddress;
829
+ let addr1: SignerWithAddress;
830
+
831
+ beforeEach(async function () {
832
+ [owner, addr1] = await ethers.getSigners();
833
+ const Token = await ethers.getContractFactory("Token");
834
+ token = await Token.deploy("Test", "TST", ethers.utils.parseEther("1000000"));
835
+ });
836
+
837
+ it("Should transfer tokens", async function () {
838
+ await token.transfer(addr1.address, ethers.utils.parseEther("100"));
839
+ expect(await token.balanceOf(addr1.address)).to.equal(
840
+ ethers.utils.parseEther("100")
841
+ );
842
+ });
843
+
844
+ // Time manipulation
845
+ it("Should handle time-based functions", async function () {
846
+ await network.provider.send("evm_increaseTime", [86400]); // +1 day
847
+ await network.provider.send("evm_mine");
848
+
849
+ // Test time-sensitive logic
850
+ });
851
+ });
852
+ ```
853
+
854
+ ### 6.2 Security Tools
855
+
856
+ ```bash
857
+ # Static analysis
858
+ slither contracts/ --solc-remaps @openzeppelin=node_modules/@openzeppelin
859
+
860
+ # Fuzzing
861
+ echidna contracts/Token.sol --contract Token
862
+
863
+ # Formal verification
864
+ # Certora, VerX for mathematical proofs
865
+
866
+ # Gas reporting
867
+ forge test --gas-report
868
+ ```
869
+
870
+ ### 6.3 Common Vulnerabilities
871
+
872
+ | Vulnerability | Prevention |
873
+ |:--------------|:-----------|
874
+ | **Reentrancy** | Checks-Effects-Interactions, ReentrancyGuard |
875
+ | **Integer Overflow** | Solidity 0.8+, SafeMath (pre-0.8) |
876
+ | **Access Control** | Ownable, AccessControl, custom modifiers |
877
+ | **Front-running** | Commit-reveal, time locks |
878
+ | **Oracle Manipulation** | Chainlink, TWAP, multi-source |
879
+ | **Flash Loan Attacks** | Stateful checks, time delays |
880
+ | **DoS** | Pull over push, gas limits |
881
+
882
+ ---
883
+
884
+ ## 7. Cross-Chain Development
885
+
886
+ ### 7.1 Bridge Patterns
887
+
888
+ ```solidity
889
+ // Lock-and-Mint bridge
890
+ contract Bridge {
891
+ mapping(bytes32 => bool) public processedHashes;
892
+
893
+ // Lock on source chain
894
+ function lock(uint256 amount, address recipient) external {
895
+ token.transferFrom(msg.sender, address(this), amount);
896
+
897
+ emit Lock(msg.sender, amount, recipient, block.chainid);
898
+ }
899
+
900
+ // Mint on destination (requires validators/MPC)
901
+ function mint(
902
+ address recipient,
903
+ uint256 amount,
904
+ bytes32 lockHash,
905
+ bytes[] calldata signatures
906
+ ) external {
907
+ require(!processedHashes[lockHash], "Already processed");
908
+ require(verifySignatures(lockHash, signatures), "Invalid signatures");
909
+
910
+ processedHashes[lockHash] = true;
911
+ wrappedToken.mint(recipient, amount);
912
+ }
913
+ }
914
+ ```
915
+
916
+ ### 7.2 Layer 2 Integration
917
+
918
+ | L2 | Type | Key Features |
919
+ |:---|:-----|:-------------|
920
+ | **Optimism** | Optimistic Rollup | EVM equivalent, 7-day withdrawal |
921
+ | **Arbitrum** | Optimistic Rollup | Stylus (WASM), multi-round fraud proofs |
922
+ | **Base** | Optimistic Rollup | Coinbase, low fees |
923
+ | **zkSync** | ZK Rollup | Native account abstraction, Solidity |
924
+ | **StarkNet** | ZK Rollup | Cairo lang, STARK proofs |
925
+ | **Polygon zkEVM** | ZK Rollup | EVM equivalent, fast finality |
926
+
927
+ ---
928
+
929
+ ## 8. Development Workflow
930
+
931
+ ### 8.1 Deployment
932
+
933
+ ```bash
934
+ # Foundry
935
+ forge script script/Deploy.s.sol --rpc-url $RPC_URL --private-key $PK --broadcast --verify
936
+
937
+ # Hardhat
938
+ npx hardhat run scripts/deploy.ts --network mainnet
939
+
940
+ # Create2 deterministic deployment
941
+ # Same address on any chain
942
+ ```
943
+
944
+ ### 8.2 Verification
945
+
946
+ ```bash
947
+ # Etherscan verification
948
+ forge verify-contract $ADDRESS src/Token.sol:Token --etherscan-api-key $KEY
949
+
950
+ # Sourcify (decentralized)
951
+ # Verifies on multiple explorers automatically
952
+ ```
953
+
954
+ ### 8.3 Monitoring
955
+
956
+ ```solidity
957
+ // Events for indexing
958
+ event Transfer(address indexed from, address indexed to, uint256 value);
959
+ event Approval(address indexed owner, address indexed spender, uint256 value);
960
+
961
+ // Use Tenderly, Forta, OpenZeppelin Defender for monitoring
962
+ ```
963
+
964
+ ---
965
+
966
+ ## Related Skills
967
+
968
+ - [[backend-developer]] — API and service layer integration
969
+ - [[devops-engineer]] — Infrastructure, CI/CD for smart contracts
970
+ - [[lead-architect]] — System design, tokenomics, protocol architecture
971
+ - [[security-auditor]] — Deep security analysis and formal verification
972
+
973
+ ---
974
+
975
+ *Extends [[backend-developer]] | Part of [[blockchain-moc]]*