@hivehub/rulebook 5.1.3 → 5.2.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 (374) hide show
  1. package/.claude/commands/continue.md +33 -33
  2. package/.claude/commands/ralph-config.md +112 -112
  3. package/.claude/commands/ralph-history.md +110 -110
  4. package/.claude/commands/ralph-init.md +72 -72
  5. package/.claude/commands/ralph-pause-resume.md +105 -105
  6. package/.claude/commands/ralph-run.md +101 -101
  7. package/.claude/commands/ralph-status.md +76 -76
  8. package/.claude/commands/rulebook-decision-create.md +55 -55
  9. package/.claude/commands/rulebook-decision-list.md +15 -15
  10. package/.claude/commands/rulebook-knowledge-add.md +41 -41
  11. package/.claude/commands/rulebook-knowledge-list.md +15 -15
  12. package/.claude/commands/rulebook-learn-capture.md +48 -48
  13. package/.claude/commands/rulebook-learn-list.md +13 -13
  14. package/.claude/commands/rulebook-memory-save.md +48 -48
  15. package/.claude/commands/rulebook-memory-search.md +47 -47
  16. package/.claude/commands/rulebook-task-apply.md +85 -67
  17. package/.claude/commands/rulebook-task-archive.md +103 -94
  18. package/.claude/commands/rulebook-task-create.md +93 -93
  19. package/.claude/commands/rulebook-task-list.md +42 -42
  20. package/.claude/commands/rulebook-task-show.md +52 -52
  21. package/.claude/commands/rulebook-task-validate.md +53 -53
  22. package/.claude-plugin/marketplace.json +28 -28
  23. package/.claude-plugin/plugin.json +8 -8
  24. package/README.md +25 -43
  25. package/dist/cli/commands.d.ts.map +1 -1
  26. package/dist/cli/commands.js +11 -0
  27. package/dist/cli/commands.js.map +1 -1
  28. package/dist/core/agent-template-engine.js +28 -28
  29. package/dist/core/generator.js +28 -28
  30. package/dist/core/task-manager.d.ts +23 -0
  31. package/dist/core/task-manager.d.ts.map +1 -1
  32. package/dist/core/task-manager.js +161 -27
  33. package/dist/core/task-manager.js.map +1 -1
  34. package/dist/index.js +0 -0
  35. package/dist/mcp/rulebook-server.js +3 -3
  36. package/dist/mcp/rulebook-server.js.map +1 -1
  37. package/dist/memory/memory-store.js +91 -91
  38. package/package.json +21 -22
  39. package/templates/agents/accessibility-reviewer.md +43 -43
  40. package/templates/agents/api-designer.md +42 -42
  41. package/templates/agents/architect.md +51 -51
  42. package/templates/agents/build-engineer.md +36 -36
  43. package/templates/agents/code-reviewer.md +47 -47
  44. package/templates/agents/compiler/codegen-debugger.md +34 -34
  45. package/templates/agents/compiler/stdlib-engineer.md +28 -28
  46. package/templates/agents/compiler/test-coverage-guardian.md +31 -31
  47. package/templates/agents/context-intelligence.md +52 -52
  48. package/templates/agents/database-architect.md +41 -41
  49. package/templates/agents/devops-engineer.md +42 -42
  50. package/templates/agents/docs-writer.md +38 -38
  51. package/templates/agents/game-engine/cpp-core-expert.md +35 -35
  52. package/templates/agents/game-engine/render-engineer.md +22 -22
  53. package/templates/agents/game-engine/shader-engineer.md +38 -38
  54. package/templates/agents/game-engine/systems-integration.md +43 -43
  55. package/templates/agents/generic/code-reviewer.md +41 -41
  56. package/templates/agents/generic/docs-writer.md +25 -25
  57. package/templates/agents/generic/project-manager.md +36 -36
  58. package/templates/agents/generic/researcher.md +34 -34
  59. package/templates/agents/generic/test-engineer.md +41 -41
  60. package/templates/agents/i18n-engineer.md +42 -42
  61. package/templates/agents/implementer.md +42 -42
  62. package/templates/agents/migration-engineer.md +42 -42
  63. package/templates/agents/mobile/platform-specialist.md +22 -22
  64. package/templates/agents/mobile/ui-engineer.md +22 -22
  65. package/templates/agents/performance-engineer.md +49 -49
  66. package/templates/agents/refactoring-agent.md +41 -41
  67. package/templates/agents/researcher.md +38 -38
  68. package/templates/agents/security-reviewer.md +40 -40
  69. package/templates/agents/team-lead.md +37 -37
  70. package/templates/agents/tester.md +48 -48
  71. package/templates/agents/ux-reviewer.md +43 -43
  72. package/templates/agents/web-app/api-designer.md +22 -22
  73. package/templates/agents/web-app/backend-engineer.md +30 -30
  74. package/templates/agents/web-app/database-engineer.md +22 -22
  75. package/templates/agents/web-app/frontend-engineer.md +29 -29
  76. package/templates/agents/web-app/security-reviewer.md +32 -32
  77. package/templates/ci/rulebook-review.yml +26 -26
  78. package/templates/cli/AIDER.md +49 -49
  79. package/templates/cli/AMAZON_Q.md +25 -25
  80. package/templates/cli/AUGGIE.md +32 -32
  81. package/templates/cli/CLAUDE.md +117 -117
  82. package/templates/cli/CLINE.md +99 -99
  83. package/templates/cli/CODEBUDDY.md +20 -20
  84. package/templates/cli/CODEIUM.md +20 -20
  85. package/templates/cli/CODEX.md +21 -21
  86. package/templates/cli/CONTINUE.md +34 -34
  87. package/templates/cli/CURSOR_CLI.md +62 -62
  88. package/templates/cli/FACTORY.md +18 -18
  89. package/templates/cli/GEMINI.md +35 -35
  90. package/templates/cli/KILOCODE.md +18 -18
  91. package/templates/cli/OPENCODE.md +18 -18
  92. package/templates/cli/_GENERIC_TEMPLATE.md +29 -29
  93. package/templates/commands/rulebook-decision-create.md +55 -55
  94. package/templates/commands/rulebook-decision-list.md +15 -15
  95. package/templates/commands/rulebook-knowledge-add.md +41 -41
  96. package/templates/commands/rulebook-knowledge-list.md +15 -15
  97. package/templates/commands/rulebook-learn-capture.md +48 -48
  98. package/templates/commands/rulebook-learn-list.md +13 -13
  99. package/templates/commands/rulebook-memory-save.md +48 -48
  100. package/templates/commands/rulebook-memory-search.md +47 -47
  101. package/templates/commands/rulebook-task-apply.md +67 -67
  102. package/templates/commands/rulebook-task-archive.md +94 -94
  103. package/templates/commands/rulebook-task-create.md +93 -93
  104. package/templates/commands/rulebook-task-list.md +42 -42
  105. package/templates/commands/rulebook-task-show.md +52 -52
  106. package/templates/commands/rulebook-task-validate.md +53 -53
  107. package/templates/core/AGENTS_LEAN.md +25 -25
  108. package/templates/core/AGENTS_OVERRIDE.md +16 -16
  109. package/templates/core/AGENT_AUTOMATION.md +296 -296
  110. package/templates/core/DAG.md +304 -304
  111. package/templates/core/DECISIONS.md +38 -38
  112. package/templates/core/DOCUMENTATION_RULES.md +36 -36
  113. package/templates/core/KNOWLEDGE.md +49 -49
  114. package/templates/core/MULTI_AGENT.md +74 -74
  115. package/templates/core/PLANS.md +28 -28
  116. package/templates/core/QUALITY_ENFORCEMENT.md +68 -68
  117. package/templates/core/RALPH.md +471 -471
  118. package/templates/core/RULEBOOK.md +1947 -1947
  119. package/templates/core/TIER1_PROHIBITIONS.md +154 -154
  120. package/templates/core/TOKEN_OPTIMIZATION.md +49 -49
  121. package/templates/frameworks/ANGULAR.md +36 -36
  122. package/templates/frameworks/DJANGO.md +83 -83
  123. package/templates/frameworks/ELECTRON.md +147 -147
  124. package/templates/frameworks/FLASK.md +38 -38
  125. package/templates/frameworks/FLUTTER.md +55 -55
  126. package/templates/frameworks/JQUERY.md +32 -32
  127. package/templates/frameworks/LARAVEL.md +38 -38
  128. package/templates/frameworks/NESTJS.md +43 -43
  129. package/templates/frameworks/NEXTJS.md +127 -127
  130. package/templates/frameworks/NUXT.md +40 -40
  131. package/templates/frameworks/RAILS.md +66 -66
  132. package/templates/frameworks/REACT.md +38 -38
  133. package/templates/frameworks/REACT_NATIVE.md +47 -47
  134. package/templates/frameworks/SPRING.md +39 -39
  135. package/templates/frameworks/SYMFONY.md +36 -36
  136. package/templates/frameworks/VUE.md +36 -36
  137. package/templates/frameworks/ZEND.md +35 -35
  138. package/templates/git/CI_CD_PATTERNS.md +661 -661
  139. package/templates/git/GITHUB_ACTIONS.md +728 -728
  140. package/templates/git/GITLAB_CI.md +730 -730
  141. package/templates/git/GIT_WORKFLOW.md +1192 -1192
  142. package/templates/git/SECRETS_MANAGEMENT.md +585 -585
  143. package/templates/hooks/COMMIT_MSG.md +530 -530
  144. package/templates/hooks/POST_CHECKOUT.md +546 -546
  145. package/templates/hooks/PREPARE_COMMIT_MSG.md +619 -619
  146. package/templates/hooks/PRE_COMMIT.md +414 -414
  147. package/templates/hooks/PRE_PUSH.md +601 -601
  148. package/templates/ides/CONTINUE_RULES.md +16 -16
  149. package/templates/ides/COPILOT.md +37 -37
  150. package/templates/ides/COPILOT_INSTRUCTIONS.md +23 -23
  151. package/templates/ides/CURSOR.md +43 -43
  152. package/templates/ides/GEMINI_RULES.md +17 -17
  153. package/templates/ides/JETBRAINS_AI.md +35 -35
  154. package/templates/ides/REPLIT.md +36 -36
  155. package/templates/ides/TABNINE.md +29 -29
  156. package/templates/ides/VSCODE.md +40 -40
  157. package/templates/ides/WINDSURF.md +36 -36
  158. package/templates/ides/WINDSURF_RULES.md +14 -14
  159. package/templates/ides/ZED.md +32 -32
  160. package/templates/ides/cursor-mdc/go.mdc +24 -24
  161. package/templates/ides/cursor-mdc/python.mdc +24 -24
  162. package/templates/ides/cursor-mdc/quality.mdc +25 -25
  163. package/templates/ides/cursor-mdc/ralph.mdc +39 -39
  164. package/templates/ides/cursor-mdc/rulebook.mdc +38 -38
  165. package/templates/ides/cursor-mdc/rust.mdc +24 -24
  166. package/templates/ides/cursor-mdc/typescript.mdc +25 -25
  167. package/templates/languages/C.md +333 -333
  168. package/templates/languages/CPP.md +743 -743
  169. package/templates/languages/CSHARP.md +417 -417
  170. package/templates/languages/ELIXIR.md +454 -454
  171. package/templates/languages/ERLANG.md +361 -361
  172. package/templates/languages/GO.md +645 -645
  173. package/templates/languages/HASKELL.md +177 -177
  174. package/templates/languages/JAVA.md +607 -607
  175. package/templates/languages/JAVASCRIPT.md +631 -631
  176. package/templates/languages/JULIA.md +97 -97
  177. package/templates/languages/KOTLIN.md +511 -511
  178. package/templates/languages/LISP.md +100 -100
  179. package/templates/languages/LUA.md +74 -74
  180. package/templates/languages/OBJECTIVEC.md +90 -90
  181. package/templates/languages/PHP.md +416 -416
  182. package/templates/languages/PYTHON.md +682 -682
  183. package/templates/languages/RUBY.md +421 -421
  184. package/templates/languages/RUST.md +477 -477
  185. package/templates/languages/SAS.md +73 -73
  186. package/templates/languages/SCALA.md +348 -348
  187. package/templates/languages/SOLIDITY.md +580 -580
  188. package/templates/languages/SQL.md +137 -137
  189. package/templates/languages/SWIFT.md +466 -466
  190. package/templates/languages/TYPESCRIPT.md +591 -591
  191. package/templates/languages/ZIG.md +265 -265
  192. package/templates/modules/ATLASSIAN.md +255 -255
  193. package/templates/modules/CONTEXT7.md +54 -54
  194. package/templates/modules/FIGMA.md +267 -267
  195. package/templates/modules/GITHUB_MCP.md +64 -64
  196. package/templates/modules/GRAFANA.md +328 -328
  197. package/templates/modules/MEMORY.md +126 -126
  198. package/templates/modules/NOTION.md +247 -247
  199. package/templates/modules/PLAYWRIGHT.md +90 -90
  200. package/templates/modules/RULEBOOK_MCP.md +156 -156
  201. package/templates/modules/SERENA.md +337 -337
  202. package/templates/modules/SUPABASE.md +223 -223
  203. package/templates/modules/SYNAP.md +69 -69
  204. package/templates/modules/VECTORIZER.md +63 -63
  205. package/templates/modules/sequential-thinking.md +42 -42
  206. package/templates/ralph/ralph-history.bat +4 -4
  207. package/templates/ralph/ralph-history.sh +5 -5
  208. package/templates/ralph/ralph-init.bat +5 -5
  209. package/templates/ralph/ralph-init.sh +5 -5
  210. package/templates/ralph/ralph-pause.bat +5 -5
  211. package/templates/ralph/ralph-pause.sh +5 -5
  212. package/templates/ralph/ralph-run.bat +5 -5
  213. package/templates/ralph/ralph-run.sh +5 -5
  214. package/templates/ralph/ralph-status.bat +4 -4
  215. package/templates/ralph/ralph-status.sh +5 -5
  216. package/templates/rules/follow-task-sequence.md +36 -36
  217. package/templates/rules/git-safety.md +29 -29
  218. package/templates/rules/incremental-tests.md +29 -29
  219. package/templates/rules/knowledge-base-usage.md +41 -0
  220. package/templates/rules/no-deferred.md +31 -31
  221. package/templates/rules/no-shortcuts.md +30 -30
  222. package/templates/rules/research-first.md +30 -30
  223. package/templates/rules/sequential-editing.md +21 -21
  224. package/templates/rules/session-workflow.md +24 -24
  225. package/templates/rules/task-decomposition.md +32 -32
  226. package/templates/services/AZURE_BLOB.md +184 -184
  227. package/templates/services/CASSANDRA.md +239 -239
  228. package/templates/services/DATADOG.md +26 -26
  229. package/templates/services/DOCKER.md +124 -124
  230. package/templates/services/DOCKER_COMPOSE.md +168 -168
  231. package/templates/services/DYNAMODB.md +308 -308
  232. package/templates/services/ELASTICSEARCH.md +347 -347
  233. package/templates/services/GCS.md +178 -178
  234. package/templates/services/HELM.md +194 -194
  235. package/templates/services/INFLUXDB.md +265 -265
  236. package/templates/services/KAFKA.md +341 -341
  237. package/templates/services/KUBERNETES.md +208 -208
  238. package/templates/services/MARIADB.md +183 -183
  239. package/templates/services/MEMCACHED.md +242 -242
  240. package/templates/services/MINIO.md +201 -201
  241. package/templates/services/MONGODB.md +268 -268
  242. package/templates/services/MYSQL.md +358 -358
  243. package/templates/services/NEO4J.md +247 -247
  244. package/templates/services/OPENTELEMETRY.md +25 -25
  245. package/templates/services/ORACLE.md +290 -290
  246. package/templates/services/PINO.md +24 -24
  247. package/templates/services/POSTGRESQL.md +326 -326
  248. package/templates/services/PROMETHEUS.md +33 -33
  249. package/templates/services/RABBITMQ.md +286 -286
  250. package/templates/services/REDIS.md +292 -292
  251. package/templates/services/S3.md +298 -298
  252. package/templates/services/SENTRY.md +23 -23
  253. package/templates/services/SQLITE.md +294 -294
  254. package/templates/services/SQLSERVER.md +294 -294
  255. package/templates/services/WINSTON.md +30 -30
  256. package/templates/skills/cli/aider/SKILL.md +59 -59
  257. package/templates/skills/cli/amazon-q/SKILL.md +35 -35
  258. package/templates/skills/cli/auggie/SKILL.md +42 -42
  259. package/templates/skills/cli/claude/SKILL.md +42 -42
  260. package/templates/skills/cli/cline/SKILL.md +42 -42
  261. package/templates/skills/cli/codebuddy/SKILL.md +30 -30
  262. package/templates/skills/cli/codeium/SKILL.md +30 -30
  263. package/templates/skills/cli/codex/SKILL.md +31 -31
  264. package/templates/skills/cli/continue/SKILL.md +44 -44
  265. package/templates/skills/cli/cursor-cli/SKILL.md +38 -38
  266. package/templates/skills/cli/factory/SKILL.md +28 -28
  267. package/templates/skills/cli/gemini/SKILL.md +45 -45
  268. package/templates/skills/cli/kilocode/SKILL.md +28 -28
  269. package/templates/skills/cli/opencode/SKILL.md +28 -28
  270. package/templates/skills/core/agent-automation/SKILL.md +194 -194
  271. package/templates/skills/core/dag/SKILL.md +314 -314
  272. package/templates/skills/core/documentation-rules/SKILL.md +46 -46
  273. package/templates/skills/core/quality-enforcement/SKILL.md +78 -78
  274. package/templates/skills/core/rulebook/SKILL.md +176 -176
  275. package/templates/skills/dev/accessibility/SKILL.md +17 -17
  276. package/templates/skills/dev/api-design/SKILL.md +15 -15
  277. package/templates/skills/dev/architect/SKILL.md +17 -17
  278. package/templates/skills/dev/build-fix/SKILL.md +17 -17
  279. package/templates/skills/dev/db-design/SKILL.md +15 -15
  280. package/templates/skills/dev/debug/SKILL.md +16 -16
  281. package/templates/skills/dev/deploy/SKILL.md +17 -17
  282. package/templates/skills/dev/docs/SKILL.md +17 -17
  283. package/templates/skills/dev/migrate/SKILL.md +15 -15
  284. package/templates/skills/dev/perf/SKILL.md +17 -17
  285. package/templates/skills/dev/refactor/SKILL.md +17 -17
  286. package/templates/skills/dev/research/SKILL.md +14 -14
  287. package/templates/skills/dev/review/SKILL.md +18 -18
  288. package/templates/skills/dev/security-audit/SKILL.md +17 -17
  289. package/templates/skills/frameworks/angular/SKILL.md +46 -46
  290. package/templates/skills/frameworks/django/SKILL.md +93 -93
  291. package/templates/skills/frameworks/electron/SKILL.md +157 -157
  292. package/templates/skills/frameworks/flask/SKILL.md +48 -48
  293. package/templates/skills/frameworks/flutter/SKILL.md +65 -65
  294. package/templates/skills/frameworks/jquery/SKILL.md +42 -42
  295. package/templates/skills/frameworks/laravel/SKILL.md +48 -48
  296. package/templates/skills/frameworks/nestjs/SKILL.md +53 -53
  297. package/templates/skills/frameworks/nextjs/SKILL.md +137 -137
  298. package/templates/skills/frameworks/nuxt/SKILL.md +50 -50
  299. package/templates/skills/frameworks/rails/SKILL.md +76 -76
  300. package/templates/skills/frameworks/react/SKILL.md +48 -48
  301. package/templates/skills/frameworks/react-native/SKILL.md +57 -57
  302. package/templates/skills/frameworks/spring/SKILL.md +49 -49
  303. package/templates/skills/frameworks/symfony/SKILL.md +46 -46
  304. package/templates/skills/frameworks/vue/SKILL.md +46 -46
  305. package/templates/skills/frameworks/zend/SKILL.md +45 -45
  306. package/templates/skills/ides/copilot/SKILL.md +47 -47
  307. package/templates/skills/ides/cursor/SKILL.md +53 -53
  308. package/templates/skills/ides/jetbrains-ai/SKILL.md +45 -45
  309. package/templates/skills/ides/replit/SKILL.md +46 -46
  310. package/templates/skills/ides/tabnine/SKILL.md +39 -39
  311. package/templates/skills/ides/vscode/SKILL.md +50 -50
  312. package/templates/skills/ides/windsurf/SKILL.md +46 -46
  313. package/templates/skills/ides/zed/SKILL.md +42 -42
  314. package/templates/skills/languages/c/SKILL.md +343 -343
  315. package/templates/skills/languages/cpp/SKILL.md +753 -753
  316. package/templates/skills/languages/csharp/SKILL.md +427 -427
  317. package/templates/skills/languages/elixir/SKILL.md +464 -464
  318. package/templates/skills/languages/erlang/SKILL.md +371 -371
  319. package/templates/skills/languages/go/SKILL.md +655 -655
  320. package/templates/skills/languages/haskell/SKILL.md +187 -187
  321. package/templates/skills/languages/java/SKILL.md +617 -617
  322. package/templates/skills/languages/javascript/SKILL.md +641 -641
  323. package/templates/skills/languages/julia/SKILL.md +107 -107
  324. package/templates/skills/languages/kotlin/SKILL.md +521 -521
  325. package/templates/skills/languages/lisp/SKILL.md +110 -110
  326. package/templates/skills/languages/lua/SKILL.md +84 -84
  327. package/templates/skills/languages/objectivec/SKILL.md +100 -100
  328. package/templates/skills/languages/php/SKILL.md +426 -426
  329. package/templates/skills/languages/python/SKILL.md +692 -692
  330. package/templates/skills/languages/ruby/SKILL.md +431 -431
  331. package/templates/skills/languages/rust/SKILL.md +487 -487
  332. package/templates/skills/languages/sas/SKILL.md +83 -83
  333. package/templates/skills/languages/scala/SKILL.md +358 -358
  334. package/templates/skills/languages/solidity/SKILL.md +590 -590
  335. package/templates/skills/languages/sql/SKILL.md +147 -147
  336. package/templates/skills/languages/swift/SKILL.md +476 -476
  337. package/templates/skills/languages/typescript/SKILL.md +302 -302
  338. package/templates/skills/languages/zig/SKILL.md +275 -275
  339. package/templates/skills/modules/atlassian/SKILL.md +265 -265
  340. package/templates/skills/modules/context7/SKILL.md +64 -64
  341. package/templates/skills/modules/figma/SKILL.md +277 -277
  342. package/templates/skills/modules/github-mcp/SKILL.md +74 -74
  343. package/templates/skills/modules/grafana/SKILL.md +338 -338
  344. package/templates/skills/modules/memory/SKILL.md +73 -73
  345. package/templates/skills/modules/notion/SKILL.md +257 -257
  346. package/templates/skills/modules/playwright/SKILL.md +100 -100
  347. package/templates/skills/modules/rulebook-mcp/SKILL.md +166 -166
  348. package/templates/skills/modules/serena/SKILL.md +347 -347
  349. package/templates/skills/modules/supabase/SKILL.md +233 -233
  350. package/templates/skills/modules/synap/SKILL.md +79 -79
  351. package/templates/skills/modules/vectorizer/SKILL.md +73 -73
  352. package/templates/skills/services/azure-blob/SKILL.md +194 -194
  353. package/templates/skills/services/cassandra/SKILL.md +249 -249
  354. package/templates/skills/services/dynamodb/SKILL.md +318 -318
  355. package/templates/skills/services/elasticsearch/SKILL.md +357 -357
  356. package/templates/skills/services/gcs/SKILL.md +188 -188
  357. package/templates/skills/services/influxdb/SKILL.md +275 -275
  358. package/templates/skills/services/kafka/SKILL.md +351 -351
  359. package/templates/skills/services/mariadb/SKILL.md +193 -193
  360. package/templates/skills/services/memcached/SKILL.md +252 -252
  361. package/templates/skills/services/minio/SKILL.md +211 -211
  362. package/templates/skills/services/mongodb/SKILL.md +278 -278
  363. package/templates/skills/services/mysql/SKILL.md +368 -368
  364. package/templates/skills/services/neo4j/SKILL.md +257 -257
  365. package/templates/skills/services/oracle/SKILL.md +300 -300
  366. package/templates/skills/services/postgresql/SKILL.md +336 -336
  367. package/templates/skills/services/rabbitmq/SKILL.md +296 -296
  368. package/templates/skills/services/redis/SKILL.md +302 -302
  369. package/templates/skills/services/s3/SKILL.md +308 -308
  370. package/templates/skills/services/sqlite/SKILL.md +304 -304
  371. package/templates/skills/services/sqlserver/SKILL.md +304 -304
  372. package/templates/skills/workflows/ralph/SKILL.md +309 -309
  373. package/templates/skills/workflows/ralph/install.sh +87 -87
  374. package/templates/skills/workflows/ralph/manifest.json +158 -158
@@ -1,1192 +1,1192 @@
1
- <!-- GIT:START -->
2
- # Git Workflow Rules
3
-
4
- **CRITICAL**: Specific rules and patterns for Git version control workflow.
5
-
6
- ## Git Command Allow-List (Quick Reference)
7
-
8
- ### ALLOWED (always safe — no authorization needed)
9
- | Command | Purpose |
10
- |---------|---------|
11
- | `git status` | Check repository state |
12
- | `git diff` | View changes |
13
- | `git log` | View history |
14
- | `git blame` | View line-by-line attribution |
15
- | `git add <files>` | Stage specific files |
16
- | `git commit` | Create commits (after quality checks) |
17
- | `git branch` (list) | List branches |
18
- | `git tag` (list) | List tags |
19
-
20
- ### FORBIDDEN (require explicit user authorization)
21
- | Command | Risk | Why |
22
- |---------|------|-----|
23
- | `git stash` | Loses uncommitted work | Hidden state that gets forgotten |
24
- | `git rebase` | Rewrites history | Breaks shared branch history |
25
- | `git reset --hard` | Destroys changes | Irreversible data loss |
26
- | `git checkout -- .` | Discards all changes | Irreversible data loss |
27
- | `git restore .` | Discards all changes | Irreversible data loss |
28
- | `git revert` | Creates revert commits | May cause unexpected conflicts |
29
- | `git cherry-pick` | Duplicates commits | Can cause merge conflicts |
30
- | `git merge` | Can create conflicts | Requires human judgment |
31
- | `git branch -D` | Deletes branch | Permanent, may lose work |
32
- | `git push --force` | Overwrites remote | NEVER on main/master |
33
- | `git clean -f` | Deletes untracked files | Permanent file deletion |
34
- | `git checkout <branch>` | Switches branch | Breaks concurrent AI sessions |
35
- | `git switch <branch>` | Switches branch | Breaks concurrent AI sessions |
36
-
37
- **Why**: Multiple AI sessions may share the same working tree. Branch switching or destructive operations affect ALL concurrent sessions.
38
-
39
- ---
40
-
41
- ## Git Workflow Overview
42
-
43
- This project follows a strict Git workflow to ensure code quality and proper version control.
44
-
45
- **NEVER commit code without tests passing. NEVER create tags without full quality checks.**
46
-
47
- ## Initial Repository Setup
48
-
49
- ### New Project Initialization
50
-
51
- **⚠️ CRITICAL**: Only run initialization commands if `.git` directory does NOT exist!
52
-
53
- ```bash
54
- # Check if Git repository already exists
55
- if [ -d .git ]; then
56
- echo "❌ Git repository already initialized. Skipping git init."
57
- echo "Current status:"
58
- git status
59
- git remote -v
60
- exit 0
61
- fi
62
-
63
- # If no .git directory exists, initialize:
64
-
65
- # Initialize Git repository
66
- git init
67
-
68
- # Add all files
69
- git add .
70
-
71
- # Initial commit
72
- git commit -m "chore: Initial project setup"
73
-
74
- # Rename default branch to main (GitHub standard)
75
- git branch -M main
76
-
77
- # Add remote (if applicable)
78
- git remote add origin <repository-url>
79
- ```
80
-
81
- **AI Assistant Behavior:**
82
-
83
- ```
84
- BEFORE running any Git initialization commands:
85
-
86
- 1. Check if .git directory exists
87
- 2. If exists:
88
- ✅ Repository already configured
89
- ❌ DO NOT run: git init
90
- ❌ DO NOT run: git branch -M main
91
- ✅ Check status: git status
92
- ✅ Show remotes: git remote -v
93
-
94
- 3. If not exists:
95
- ✅ Safe to initialize
96
- ✅ Run full initialization sequence
97
- ```
98
-
99
- ## AI Assistant Git Checks
100
-
101
- **CRITICAL**: AI assistants MUST perform these checks before Git operations:
102
-
103
- ### Automatic Checks
104
-
105
- ```bash
106
- # 1. Check if Git repository exists
107
- if [ ! -d .git ]; then
108
- echo "No Git repository found."
109
- # Ask user if they want to initialize
110
- fi
111
-
112
- # 2. Check if there are unstaged changes
113
- git status --short
114
-
115
- # 3. Check current branch
116
- CURRENT_BRANCH=$(git branch --show-current)
117
- echo "On branch: $CURRENT_BRANCH"
118
-
119
- # 4. Check if remote exists
120
- git remote -v
121
-
122
- # 5. Check for unpushed commits
123
- git log origin/main..HEAD --oneline 2>/dev/null
124
- ```
125
-
126
- ### Before Git Commands
127
-
128
- **NEVER execute if `.git` directory exists:**
129
- - ❌ `git init` - Repository already initialized
130
- - ❌ `git branch -M main` - Branch may already be configured
131
- - ❌ `git remote add origin` - Remote may already exist (check first with `git remote -v`)
132
- - ❌ `git config user.name/email` - User configuration is personal
133
- - ❌ Reconfiguration commands - Repository is already set up
134
-
135
- **ALWAYS safe to execute:**
136
- - ✅ `git status` - Check repository state
137
- - ✅ `git add` - Stage changes
138
- - ✅ `git commit` - Create commits (after quality checks)
139
- - ✅ `git log` - View history
140
- - ✅ `git diff` - View changes
141
- - ✅ `git branch` - List branches
142
- - ✅ `git tag` - Create tags (after quality checks)
143
-
144
- **Execute with caution (check first):**
145
- - ⚠️ `git push` - Follow push mode configuration
146
- - ⚠️ `git pull` - May cause merge conflicts
147
- - ⚠️ `git merge` - May cause conflicts
148
- - ⚠️ `git rebase` - Can rewrite history
149
- - ⚠️ `git reset --hard` - Destructive, only for rollback
150
- - ⚠️ `git push --force` - NEVER on main/master
151
-
152
- ### Repository Detection
153
-
154
- **AI Assistant MUST check:**
155
-
156
- ```bash
157
- # Before ANY Git operation:
158
-
159
- # 1. Does .git exist?
160
- if [ -d .git ]; then
161
- echo "✅ Git repository exists"
162
-
163
- # 2. Check current state
164
- git status
165
-
166
- # 3. Check branch
167
- BRANCH=$(git branch --show-current)
168
- echo "On branch: $BRANCH"
169
-
170
- # 4. Check remote
171
- REMOTE=$(git remote -v)
172
- if [ -z "$REMOTE" ]; then
173
- echo "⚠️ No remote configured"
174
- else
175
- echo "Remote: $REMOTE"
176
- fi
177
-
178
- # 5. Proceed with normal Git operations
179
- else
180
- echo "⚠️ No Git repository found"
181
- echo "Ask user if they want to initialize Git"
182
- fi
183
- ```
184
-
185
- ## Daily Development Workflow
186
-
187
- ### 1. Before Making Changes
188
-
189
- **CRITICAL**: Always check current state:
190
-
191
- ```bash
192
- # Check current branch and status
193
- git status
194
-
195
- # Ensure you're on the correct branch
196
- git branch
197
-
198
- # Pull latest changes if working with team (use --ff-only for safety)
199
- git pull --ff-only origin main
200
- ```
201
-
202
- **Git Safety**: Use `--ff-only` to prevent unexpected merge commits and maintain linear history.
203
-
204
- ### 2. Making Changes
205
-
206
- **CRITICAL**: Commit after every important implementation:
207
-
208
- **⚠️ IMPORTANT: All commit messages MUST be in English**
209
-
210
- ```bash
211
- # After implementing a feature/fix:
212
-
213
- # 1. Run ALL quality checks FIRST
214
- npm run lint # or equivalent for your language
215
- npm run type-check # TypeScript/typed languages
216
- npm test # ALL tests must pass
217
- npm run build # Ensure build succeeds
218
-
219
- # 2. If ALL checks pass, stage changes
220
- git add .
221
-
222
- # 3. Commit with conventional commit message (ENGLISH ONLY)
223
- git commit -m "feat: Add user authentication
224
-
225
- - Implement login/logout functionality
226
- - Add JWT token management
227
- - Include comprehensive tests (95%+ coverage)
228
- - Update documentation"
229
-
230
- # Alternative for smaller changes (ENGLISH ONLY):
231
- git commit -m "fix: Correct validation logic in user form"
232
-
233
- # For signed commits (recommended for production):
234
- git commit -S -m "feat: Add feature"
235
-
236
- # ❌ NEVER use other languages:
237
- # ❌ git commit -m "feat: Adiciona autenticação de usuário"
238
- # ❌ git commit -m "fix: Corrige lógica de validação"
239
- ```
240
-
241
- ## Advanced Git Safeguards
242
-
243
- ### Safe Push Operations
244
-
245
- ```bash
246
- # NEVER use git push --force on main/master branches
247
- # Instead, use --force-with-lease which prevents overwriting others' work:
248
-
249
- # Force push with safety check (only updates if no one else pushed)
250
- git push --force-with-lease origin feature-branch
251
-
252
- # Regular push is always safest
253
- git push origin main
254
- ```
255
-
256
- ### Commit Signing
257
-
258
- ```bash
259
- # Sign commits with GPG for verified commits
260
- # Set GPG key: git config --global user.signingkey <KEY_ID>
261
- git commit -S -m "feat: Signed commit"
262
-
263
- # Configure to always sign commits
264
- git config --global commit.gpgsign true
265
- ```
266
-
267
- ### Branch Protection (Recommended Settings)
268
-
269
- For GitHub/GitLab repositories, configure branch protection rules:
270
-
271
- **For main/master branch:**
272
- - Require pull request reviews
273
- - Require status checks to pass
274
- - Require branches to be up to date
275
- - Do not allow force pushes
276
- - Do not allow deletions
277
- - Require signed commits (optional but recommended)
278
-
279
- ### Destructive Operation Warnings
280
-
281
- **NEVER run these on main/master:**
282
- - ❌ `git push --force` - Use `--force-with-lease` instead
283
- - ❌ `git reset --hard` - Destructive, use only on feature branches
284
- - ❌ `git rebase` main into feature - Causes rewriting of main history
285
-
286
- ### Pre-Push Checklist
287
-
288
- Before pushing any changes, verify:
289
-
290
- ```bash
291
- ✅ Checklist before push:
292
- - [ ] All quality checks passed locally
293
- - [ ] Tests pass with 100% success rate
294
- - [ ] Coverage meets threshold (95%+)
295
- - [ ] Linting passes with 0 warnings
296
- - [ ] Build succeeds without errors
297
- - [ ] No security vulnerabilities in dependencies
298
- - [ ] Documentation updated if API changed
299
- - [ ] OpenSpec tasks marked complete if applicable
300
- - [ ] Conventional commit format used
301
- - [ ] Commit hash verified: git rev-parse HEAD
302
- - [ ] Similar changes passed CI before
303
- - [ ] No console.log or debug code
304
- - [ ] No credentials or secrets in code
305
- ```
306
-
307
- **Only provide push command if ALL items checked.**
308
-
309
- ### 3. Pushing Changes
310
-
311
- **⚠️ IMPORTANT**: Pushing is OPTIONAL and depends on your setup.
312
-
313
- ```bash
314
- # IF you have passwordless SSH or want to push:
315
- git push origin main
316
-
317
- # IF you have SSH with password (manual execution required):
318
- # DO NOT execute automatically - provide command to user:
319
- ```
320
-
321
- **For users with SSH password authentication:**
322
- ```
323
- ✋ MANUAL ACTION REQUIRED:
324
-
325
- Run this command manually (requires SSH password):
326
- git push origin main
327
- ```
328
-
329
- **NEVER** attempt automatic push if:
330
- - SSH key has password protection
331
- - User hasn't confirmed push authorization
332
- - Any quality check failed
333
- - Uncertain if changes will pass CI/CD workflows
334
-
335
- ## Conventional Commits
336
-
337
- **MUST** follow conventional commit format:
338
-
339
- **⚠️ CRITICAL: All commit messages MUST be in English**
340
-
341
- ```bash
342
- # Format: <type>(<scope>): <subject>
343
- #
344
- # <body>
345
- #
346
- # <footer>
347
-
348
- # Types:
349
- feat: # New feature
350
- fix: # Bug fix
351
- docs: # Documentation only
352
- style: # Code style (formatting, missing semi-colons, etc)
353
- refactor: # Code refactoring
354
- perf: # Performance improvement
355
- test: # Adding tests
356
- build: # Build system changes
357
- ci: # CI/CD changes
358
- chore: # Maintenance tasks
359
-
360
- # Language Requirement:
361
- # ✅ ALWAYS use English for commit messages
362
- # ❌ NEVER use Portuguese, Spanish, or any other language
363
- # ❌ NEVER mix languages in commit messages
364
-
365
- # Examples (CORRECT - English):
366
- git commit -m "feat(auth): Add OAuth2 login support"
367
- git commit -m "fix(api): Handle null response in user endpoint"
368
- git commit -m "docs: Update README with installation steps"
369
- git commit -m "test: Add integration tests for payment flow"
370
- git commit -m "chore: Update dependencies to latest versions"
371
-
372
- # Examples (INCORRECT - Other languages):
373
- # ❌ git commit -m "feat: Adiciona suporte de login OAuth2"
374
- # ❌ git commit -m "fix: Corrige resposta nula no endpoint"
375
- # ❌ git commit -m "docs: Atualiza README com passos de instalação"
376
- ```
377
-
378
- ## Version Management
379
-
380
- ### Creating New Version
381
-
382
- **CRITICAL**: Full quality gate required before versioning!
383
-
384
- ```bash
385
- # 1. MANDATORY: Run complete quality suite
386
- npm run lint # Must pass with no warnings
387
- npm test # Must pass 100%
388
- npm run type-check # Must pass (if applicable)
389
- npm run build # Must succeed
390
- npx codespell # Must pass (if configured)
391
-
392
- # 2. Update version in package.json/Cargo.toml/etc
393
- # Use semantic versioning:
394
- # - MAJOR: Breaking changes (1.0.0 -> 2.0.0)
395
- # - MINOR: New features, backwards compatible (1.0.0 -> 1.1.0)
396
- # - PATCH: Bug fixes (1.0.0 -> 1.0.1)
397
-
398
- # 3. Update CHANGELOG.md
399
- # Document all changes in this version:
400
- ## [1.2.0] - 2024-01-15
401
- ### Added
402
- - New feature X
403
- - New feature Y
404
-
405
- ### Fixed
406
- - Bug in component Z
407
-
408
- ### Changed
409
- - Refactored module A
410
-
411
- # 4. Commit version changes
412
- git add .
413
- git commit -m "chore: Release version 1.2.0
414
-
415
- - Updated version to 1.2.0
416
- - Updated CHANGELOG.md with release notes"
417
-
418
- # 5. Create annotated tag
419
- git tag -a v1.2.0 -m "Release version 1.2.0
420
-
421
- Major changes:
422
- - Feature X
423
- - Feature Y
424
- - Bug fix Z
425
-
426
- All tests passing ✅
427
- Coverage: 95%+ ✅
428
- Linting: Clean ✅
429
- Build: Success ✅"
430
-
431
- # 6. OPTIONAL: Push tag (manual if SSH password)
432
- # Only if you're CERTAIN it will pass CI/CD workflows!
433
- ```
434
-
435
- **For users requiring manual push:**
436
- ```
437
- ✋ MANUAL ACTIONS REQUIRED:
438
-
439
- 1. Verify all quality checks passed locally
440
- 2. Push commits:
441
- git push origin main
442
-
443
- 3. Push tag:
444
- git push origin v1.2.0
445
-
446
- Note: Tag push will trigger CI/CD workflows and may create GitHub release.
447
- Only push if you're confident all checks will pass.
448
- ```
449
-
450
- ## Quality Gate Enforcement
451
-
452
- **CRITICAL**: Pre-commit checks MUST match GitHub Actions workflow commands to prevent CI/CD failures.
453
-
454
- ### Language-Specific Pre-Commit Commands
455
-
456
- **The commands you run locally MUST be identical to those in your GitHub Actions workflows.**
457
-
458
- #### TypeScript/JavaScript Projects
459
-
460
- ```bash
461
- # These commands MUST match .github/workflows/*.yml
462
-
463
- # 1. Type check (matches workflow)
464
- npm run type-check # Must match workflow exactly
465
-
466
- # 2. Lint (matches workflow)
467
- npm run lint # Must match workflow exactly
468
-
469
- # 3. Format check (matches workflow)
470
- npx prettier --check 'src/**/*.ts' 'tests/**/*.ts' # Must match workflow
471
-
472
- # 4. Tests (matches workflow)
473
- npm test # Must match workflow exactly
474
-
475
- # 5. Build (matches workflow)
476
- npm run build # Must match workflow exactly
477
-
478
- # If ANY fails: ❌ DO NOT COMMIT - Fix first!
479
- ```
480
-
481
- #### Rust Projects
482
-
483
- ```bash
484
- # These commands MUST match .github/workflows/*.yml
485
-
486
- # 1. Format check (matches workflow)
487
- cargo fmt --all -- --check
488
-
489
- # 2. Clippy (matches workflow)
490
- cargo clippy --all-targets --all-features -- -D warnings
491
-
492
- # 3. Tests (matches workflow)
493
- cargo test --all-features
494
-
495
- # 4. Build (matches workflow)
496
- cargo build --release
497
-
498
- # If ANY fails: ❌ DO NOT COMMIT - Fix first!
499
- ```
500
-
501
- #### Python Projects
502
-
503
- ```bash
504
- # These commands MUST match .github/workflows/*.yml
505
-
506
- # 1. Format check (matches workflow)
507
- black --check .
508
-
509
- # 2. Lint (matches workflow)
510
- ruff check .
511
-
512
- # 3. Type check (matches workflow)
513
- mypy .
514
-
515
- # 4. Tests (matches workflow)
516
- pytest
517
-
518
- # If ANY fails: ❌ DO NOT COMMIT - Fix first!
519
- ```
520
-
521
- ### Before ANY Commit
522
-
523
- **MANDATORY CHECKS**:
524
-
525
- ```bash
526
- # Checklist - ALL must pass:
527
- ☐ Code formatted
528
- ☐ Linter passes (no warnings)
529
- ☐ Type check passes
530
- ☐ ALL tests pass (100%)
531
- ☐ Coverage meets threshold (95%+)
532
- ☐ Build succeeds
533
- ☐ No console errors/warnings
534
-
535
- # Run quality check script:
536
- npm run quality-check # or equivalent
537
-
538
- # If ANY check fails:
539
- # ❌ DO NOT COMMIT
540
- # ❌ FIX THE ISSUES FIRST
541
- ```
542
-
543
- ### Before Tag Creation
544
-
545
- **MANDATORY CHECKS** (even stricter):
546
-
547
- ```bash
548
- # Extended checklist - ALL must pass:
549
- ☐ All pre-commit checks passed
550
- ☐ Codespell passes (no typos)
551
- ☐ Security audit clean
552
- ☐ Dependencies up to date
553
- ☐ Documentation updated
554
- ☐ CHANGELOG.md updated
555
- ☐ Version bumped correctly
556
- ☐ All workflows would pass
557
-
558
- # Run comprehensive check:
559
- npm run lint
560
- npm test
561
- npm run type-check
562
- npm run build
563
- npx codespell
564
- npm audit
565
-
566
- # Only create tag if everything is green!
567
- ```
568
-
569
- ## Error Recovery & Rollback
570
-
571
- ### When Implementation Is Failing
572
-
573
- If the AI is making repeated mistakes and user is frustrated:
574
-
575
- ```bash
576
- # 1. Identify last stable commit
577
- git log --oneline -10
578
-
579
- # 2. Create backup branch of current work
580
- git branch backup-failed-attempt
581
-
582
- # 3. Hard reset to last stable version
583
- git reset --hard <last-stable-commit-hash>
584
-
585
- # 4. Verify stability
586
- npm test
587
- npm run build
588
-
589
- # 5. Reimplement from scratch using DIFFERENT approach
590
- # ⚠️ DO NOT repeat the same techniques that failed before
591
- # ⚠️ Review AGENTS.md for alternative patterns
592
- # ⚠️ Consider different architecture/design
593
-
594
- # 6. After successful reimplementation
595
- git branch -D backup-failed-attempt # Delete backup if no longer needed
596
- ```
597
-
598
- ### Undo Last Commit (Not Pushed)
599
-
600
- ```bash
601
- # Keep changes, undo commit
602
- git reset --soft HEAD~1
603
-
604
- # Discard changes completely
605
- git reset --hard HEAD~1
606
- ```
607
-
608
- ### Revert Pushed Commit
609
-
610
- ```bash
611
- # Create revert commit
612
- git revert <commit-hash>
613
-
614
- # Then push (manual if SSH password)
615
- ```
616
-
617
- ## Branch Strategy
618
-
619
- ### Feature Branches
620
-
621
- ```bash
622
- # Create feature branch
623
- git checkout -b feature/user-authentication
624
-
625
- # Work on feature...
626
- # Commit regularly with quality checks
627
-
628
- # When feature complete and tested:
629
- git checkout main
630
- git merge feature/user-authentication
631
-
632
- # Delete feature branch
633
- git branch -d feature/user-authentication
634
- ```
635
-
636
- ### Hotfix Workflow
637
-
638
- ```bash
639
- # Critical bug in production
640
- git checkout -b hotfix/critical-security-fix
641
-
642
- # Fix the bug
643
- # MUST include tests
644
- # MUST pass all quality checks
645
-
646
- git commit -m "fix: Critical security vulnerability in auth
647
-
648
- - Patch authentication bypass
649
- - Add regression tests
650
- - Update security documentation"
651
-
652
- # Merge to main
653
- git checkout main
654
- git merge hotfix/critical-security-fix
655
-
656
- # Tag immediately if production fix
657
- git tag -a v1.2.1 -m "Hotfix: Security patch"
658
-
659
- # Manual push if required
660
- ```
661
-
662
- ## CRITICAL RESTRICTIONS - HUMAN AUTHORIZATION REQUIRED
663
-
664
- **⚠️ IMPERATIVE RULES - THESE ARE NON-NEGOTIABLE ⚠️**
665
-
666
- ### Destructive Git Operations
667
-
668
- **ABSOLUTELY FORBIDDEN without explicit human authorization:**
669
-
670
- ```
671
- ❌ NEVER execute: git checkout
672
- ✋ ALWAYS ask user: "Do you want to checkout [branch/commit]? [Y/n]"
673
- ✅ Only execute after explicit user confirmation
674
-
675
- ❌ NEVER execute: git reset
676
- ✋ ALWAYS ask user: "Do you want to reset to [commit]? This may lose changes. [Y/n]"
677
- ✅ Only execute after explicit user confirmation
678
- ⚠️ Explain consequences before executing
679
- ```
680
-
681
- **Rationale**: These commands can cause data loss. Human oversight is mandatory.
682
-
683
- ### Merge Conflict Resolution
684
-
685
- **When merge conflicts occur:**
686
-
687
- ```
688
- ❌ NEVER attempt to resolve conflicts by editing files automatically
689
- ❌ NEVER commit merged files without human review
690
- ✅ ALWAYS stop and request human assistance
691
- ✅ ALWAYS provide conflict locations and context
692
- ✅ ALWAYS wait for human to resolve manually
693
-
694
- Message to user:
695
- "⚠️ Merge conflict detected in the following files:
696
- - [list of conflicted files]
697
-
698
- Please resolve these conflicts manually. I cannot auto-resolve merge conflicts.
699
-
700
- To resolve:
701
- 1. Open the conflicted files
702
- 2. Look for conflict markers (<<<<<<<, =======, >>>>>>>)
703
- 3. Choose the correct version or merge manually
704
- 4. Remove conflict markers
705
- 5. Run: git add <resolved-files>
706
- 6. Run: git commit
707
-
708
- Let me know when you're done, and I can help with the next steps."
709
- ```
710
-
711
- **Rationale**: Merge conflicts require human judgment about which code to keep.
712
-
713
- ### Commit Frequency Management
714
-
715
- **⚠️ IMPORTANT: Reduce excessive commits**
716
-
717
- ```
718
- ❌ DO NOT commit after every small change
719
- ❌ DO NOT create multiple commits for the same logical feature
720
- ✅ COMMIT only when:
721
- - A complete feature is implemented and tested
722
- - A significant bug fix is completed
723
- - A major refactoring is done
724
- - Before creating a version tag
725
- - User explicitly requests a commit
726
-
727
- ✅ GROUP related changes into meaningful commits
728
- ✅ USE conventional commit messages that describe the full scope
729
-
730
- Example of GOOD commit frequency:
731
- - Implement entire authentication system → 1 commit
732
- - Add login, logout, and session management → 1 commit
733
- - Complete feature with tests and docs → 1 commit
734
-
735
- Example of BAD commit frequency (AVOID):
736
- - Add login function → commit
737
- - Add logout function → commit
738
- - Add session check → commit
739
- - Fix typo → commit
740
- - Update comment → commit
741
- ```
742
-
743
- **Rationale**: Too many commits pollute git history and make it harder to track meaningful changes.
744
-
745
- ### Feature Branch Strategy
746
-
747
- **BEFORE starting ANY new task or feature:**
748
-
749
- ```
750
- ✋ ALWAYS ask user FIRST:
751
- "Should I create a separate branch for this feature/task? [Y/n]
752
-
753
- Options:
754
- 1. Create feature branch: git checkout -b feature/[name]
755
- 2. Work directly on current branch
756
- 3. Create hotfix branch: git checkout -b hotfix/[name]
757
-
758
- What would you prefer?"
759
-
760
- ✅ Wait for user decision
761
- ✅ Respect user's branching strategy
762
- ❌ NEVER assume to work on main without asking
763
- ❌ NEVER create branches without permission
764
-
765
- If user says YES to branch:
766
- → Create branch with descriptive name
767
- → Work on that branch
768
- → Ask before merging back to main
769
-
770
- If user says NO to branch:
771
- → Proceed on current branch
772
- → Be extra careful with commits
773
- ```
774
-
775
- **Rationale**: Branching strategy varies by team and project. Always confirm with the human first.
776
-
777
- ## Critical AI Assistant Rules
778
-
779
- ### Repository Initialization
780
-
781
- **BEFORE any `git init` or setup commands:**
782
-
783
- ```
784
- 1. Check for .git directory existence
785
- 2. If .git exists:
786
- - ❌ STOP - Repository already configured
787
- - ❌ DO NOT run git init
788
- - ❌ DO NOT run git config
789
- - ❌ DO NOT run git branch -M
790
- - ❌ DO NOT reconfigure anything
791
- - ✅ Use existing repository as-is
792
-
793
- 3. If .git does NOT exist:
794
- - ✅ Ask user if they want Git initialization
795
- - ✅ Run initialization sequence if approved
796
- ```
797
-
798
- ### Push Command Behavior
799
-
800
- **Based on configured push mode:**
801
-
802
- ```
803
- Manual Mode (DEFAULT):
804
- ❌ NEVER execute: git push
805
- ✅ ALWAYS provide: "Run manually: git push origin main"
806
-
807
- Prompt Mode:
808
- ⚠️ ALWAYS ask first: "Ready to push. Proceed? [Y/n]"
809
- ✅ Execute only if user confirms
810
-
811
- Auto Mode:
812
- ⚠️ Check quality first
813
- ⚠️ Only if 100% confident
814
- ✅ Execute if all checks passed
815
- ```
816
-
817
- ### Quality Gate Enforcement
818
-
819
- **MANDATORY checks before commit:**
820
-
821
- ```bash
822
- # Run in this exact order:
823
- 1. npm run lint # or language equivalent
824
- 2. npm run type-check # if applicable
825
- 3. npm test # ALL tests must pass
826
- 4. npm run build # must succeed
827
-
828
- # If ANY fails:
829
- ❌ STOP - DO NOT commit
830
- ❌ Fix issues first
831
- ❌ Re-run all checks
832
-
833
- # If ALL pass:
834
- ✅ Safe to commit
835
- ✅ Proceed with git add and commit
836
- ```
837
-
838
- **MANDATORY checks before tag:**
839
-
840
- ```bash
841
- # Extended checks for version tags:
842
- 1. All commit checks above +
843
- 2. npx codespell # no typos
844
- 3. npm audit # no vulnerabilities
845
- 4. CHANGELOG.md updated
846
- 5. Version bumped correctly
847
- 6. Documentation current
848
-
849
- # If ANY fails:
850
- ❌ STOP - DO NOT create tag
851
- ❌ Fix issues
852
- ❌ Re-verify everything
853
-
854
- # Only create tag if 100% green!
855
- ```
856
-
857
- ## Best Practices
858
-
859
- ### DO's ✅
860
-
861
- - **ALWAYS** check if .git exists before init commands
862
- - **ALWAYS** run tests before commit
863
- - **ALWAYS** use conventional commit messages
864
- - **ALWAYS** write commit messages in English (never in Portuguese, Spanish, or other languages)
865
- - **ALWAYS** update CHANGELOG for versions
866
- - **ALWAYS** ask before executing `git checkout`
867
- - **ALWAYS** ask before executing `git reset`
868
- - **ALWAYS** ask user if a feature branch should be created before starting tasks
869
- - **ALWAYS** request human assistance when merge conflicts occur
870
- - **COMMIT** only when complete features/fixes are done (not for every small change)
871
- - **TAG** releases with semantic versions
872
- - **VERIFY** quality gates before tagging
873
- - **DOCUMENT** breaking changes clearly
874
- - **REVERT** when implementation is failing repeatedly
875
- - **ASK** user before automatic push
876
- - **PROVIDE** manual commands for SSH password users
877
- - **CHECK** repository state before operations
878
- - **RESPECT** existing Git configuration
879
- - **GROUP** related changes into meaningful commits
880
-
881
- ### DON'Ts ❌
882
-
883
- - **NEVER** run `git init` if .git exists
884
- - **NEVER** run `git config` (user-specific)
885
- - **NEVER** run `git checkout` without explicit user authorization
886
- - **NEVER** run `git reset` without explicit user authorization
887
- - **NEVER** auto-resolve merge conflicts by editing files
888
- - **NEVER** commit merged files without human review
889
- - **NEVER** create excessive commits for small changes
890
- - **NEVER** assume branching strategy - always ask user first
891
- - **NEVER** reconfigure existing repository
892
- - **NEVER** commit without passing tests
893
- - **NEVER** commit with linting errors
894
- - **NEVER** commit with build failures
895
- - **NEVER** write commit messages in languages other than English
896
- - **NEVER** mix languages in commit messages
897
- - **NEVER** create tag without quality checks
898
- - **NEVER** push automatically with SSH password
899
- - **NEVER** push if uncertain about CI/CD success
900
- - **NEVER** commit console.log/debug code
901
- - **NEVER** commit credentials or secrets
902
- - **NEVER** force push to main/master
903
- - **NEVER** rewrite published history
904
- - **NEVER** skip hooks (--no-verify)
905
- - **NEVER** assume repository configuration
906
-
907
- ## SSH Configuration
908
-
909
- ### For Users with SSH Password
910
-
911
- If your SSH key has password protection:
912
-
913
- **Configuration in AGENTS.md or project settings:**
914
-
915
- ```yaml
916
- git_workflow:
917
- auto_push: false
918
- push_mode: "manual"
919
- reason: "SSH key has password protection"
920
- ```
921
-
922
- **AI Assistant Behavior:**
923
- - ✅ Provide push commands in chat
924
- - ✅ Wait for user manual execution
925
- - ❌ Never attempt automatic push
926
- - ❌ Never execute git push commands
927
-
928
- ### For Users with Passwordless SSH
929
-
930
- ```yaml
931
- git_workflow:
932
- auto_push: true # or prompt each time
933
- push_mode: "auto"
934
- ```
935
-
936
- ## Git Hooks
937
-
938
- ### Pre-commit Hook
939
-
940
- Create `.git/hooks/pre-commit`:
941
-
942
- ```bash
943
- #!/bin/sh
944
-
945
- echo "Running pre-commit checks..."
946
-
947
- # Run linter
948
- npm run lint
949
- if [ $? -ne 0 ]; then
950
- echo "❌ Linting failed. Commit aborted."
951
- exit 1
952
- fi
953
-
954
- # Run tests
955
- npm test
956
- if [ $? -ne 0 ]; then
957
- echo "❌ Tests failed. Commit aborted."
958
- exit 1
959
- fi
960
-
961
- # Run type check (if applicable)
962
- if command -v tsc &> /dev/null; then
963
- npm run type-check
964
- if [ $? -ne 0 ]; then
965
- echo "❌ Type check failed. Commit aborted."
966
- exit 1
967
- fi
968
- fi
969
-
970
- echo "✅ All pre-commit checks passed!"
971
- exit 0
972
- ```
973
-
974
- ### Pre-push Hook
975
-
976
- Create `.git/hooks/pre-push`:
977
-
978
- ```bash
979
- #!/bin/sh
980
-
981
- echo "Running pre-push checks..."
982
-
983
- # Run full test suite
984
- npm test
985
- if [ $? -ne 0 ]; then
986
- echo "❌ Tests failed. Push aborted."
987
- exit 1
988
- fi
989
-
990
- # Run build
991
- npm run build
992
- if [ $? -ne 0 ]; then
993
- echo "❌ Build failed. Push aborted."
994
- exit 1
995
- fi
996
-
997
- echo "✅ All pre-push checks passed!"
998
- exit 0
999
- ```
1000
-
1001
- Make hooks executable:
1002
- ```bash
1003
- chmod +x .git/hooks/pre-commit
1004
- chmod +x .git/hooks/pre-push
1005
- ```
1006
-
1007
- ## CI/CD Integration
1008
-
1009
- ### Before Providing Push Commands
1010
-
1011
- **CRITICAL**: Only suggest push if confident about CI/CD success:
1012
-
1013
- ```
1014
- ✅ Provide push command if:
1015
- - All local tests passed
1016
- - All linting passed
1017
- - Build succeeded
1018
- - Coverage meets threshold
1019
- - No warnings or errors
1020
- - Code follows AGENTS.md standards
1021
- - Similar changes passed CI/CD before
1022
-
1023
- ❌ DO NOT provide push command if:
1024
- - ANY quality check failed
1025
- - Uncertain about CI/CD requirements
1026
- - Making experimental changes
1027
- - First time working with this codebase
1028
- - User seems uncertain
1029
-
1030
- Instead say:
1031
- "I recommend running the full CI/CD pipeline locally first to ensure
1032
- the changes will pass. Once confirmed, you can push manually."
1033
- ```
1034
-
1035
- ## GitHub MCP Server Integration
1036
-
1037
- **If GitHub MCP Server is available**, use it for automated workflow monitoring.
1038
-
1039
- ### Workflow Validation After Push
1040
-
1041
- ```
1042
- After every git push (manual or auto):
1043
-
1044
- 1. Wait 5-10 seconds for workflows to trigger
1045
-
1046
- 2. Check workflow status via GitHub MCP:
1047
- - List workflow runs for latest commit
1048
- - Check status of each workflow
1049
-
1050
- 3. If workflows are RUNNING:
1051
- ⏳ Report: "CI/CD workflows in progress..."
1052
- ✅ Continue with other tasks
1053
- ✅ Check again in next user interaction
1054
-
1055
- 4. If workflows COMPLETED:
1056
- - All passed: ✅ Report success
1057
- - Some failed: ❌ Fetch errors and fix
1058
-
1059
- 5. If workflows FAILED:
1060
- a. Fetch complete error logs via GitHub MCP
1061
- b. Display errors to user
1062
- c. Analyze against AGENTS.md standards
1063
- d. Propose specific fixes
1064
- e. Implement fixes
1065
- f. Run local quality checks
1066
- g. Commit fixes
1067
- h. Provide push command for retry
1068
- ```
1069
-
1070
- ### Next Interaction Check
1071
-
1072
- ```
1073
- On every user message after a push:
1074
-
1075
- if (github_mcp_available && last_push_timestamp) {
1076
- // Check workflow status
1077
- const status = await checkWorkflows();
1078
-
1079
- if (status.running) {
1080
- console.log('⏳ CI/CD still running, will check later');
1081
- } else if (status.failed) {
1082
- console.log('❌ CI/CD failures detected!');
1083
- await analyzeAndFixErrors(status.errors);
1084
- } else {
1085
- console.log('✅ All CI/CD workflows passed!');
1086
- }
1087
- }
1088
- ```
1089
-
1090
- ### Error Analysis Flow
1091
-
1092
- ```
1093
- When workflow fails:
1094
-
1095
- 1. Fetch error via GitHub MCP:
1096
- - Workflow name
1097
- - Job name
1098
- - Failed step
1099
- - Error output
1100
- - Full logs
1101
-
1102
- 2. Categorize error:
1103
- - Test failure → Fix test or implementation
1104
- - Lint error → Format/fix code style
1105
- - Build error → Fix compilation issues
1106
- - Type error → Fix type definitions
1107
- - Coverage error → Add more tests
1108
-
1109
- 3. Fix following AGENTS.md:
1110
- - Apply correct pattern from AGENTS.md
1111
- - Add tests if needed
1112
- - Verify locally before committing
1113
-
1114
- 4. Commit fix:
1115
- git commit -m "fix: Resolve CI/CD failure - [specific issue]"
1116
-
1117
- 5. Provide push command:
1118
- "Ready to retry. Run: git push origin main"
1119
-
1120
- 6. After next push:
1121
- - Monitor again
1122
- - Verify fix worked
1123
- ```
1124
-
1125
- ### CI/CD Confidence Check
1126
-
1127
- **Before suggesting push:**
1128
-
1129
- ```
1130
- Assess confidence in CI/CD success:
1131
-
1132
- HIGH confidence (safe to push):
1133
- ✅ All local checks passed
1134
- ✅ Similar changes passed CI before
1135
- ✅ No experimental changes
1136
- ✅ Follows AGENTS.md exactly
1137
- ✅ Comprehensive tests
1138
- ✅ No unusual patterns
1139
-
1140
- MEDIUM confidence (verify first):
1141
- ⚠️ First time with this pattern
1142
- ⚠️ Modified build configuration
1143
- ⚠️ Changed dependencies
1144
- ⚠️ Cross-platform concerns
1145
- → Suggest: "Let's verify locally first"
1146
-
1147
- LOW confidence (don't push yet):
1148
- ❌ Experimental implementation
1149
- ❌ Skipped some tests
1150
- ❌ Uncertain about compatibility
1151
- ❌ Modified CI/CD files
1152
- → Say: "Let's run additional checks first"
1153
- ```
1154
-
1155
- ## Troubleshooting
1156
-
1157
- ### Merge Conflicts
1158
-
1159
- ```bash
1160
- # View conflicts
1161
- git status
1162
-
1163
- # Edit conflicted files (marked with <<<<<<<, =======, >>>>>>>)
1164
-
1165
- # After resolving:
1166
- git add <resolved-files>
1167
- git commit -m "fix: Resolve merge conflicts"
1168
- ```
1169
-
1170
- ### Accidental Commit
1171
-
1172
- ```bash
1173
- # Undo last commit, keep changes
1174
- git reset --soft HEAD~1
1175
-
1176
- # Make corrections
1177
- # Re-commit properly
1178
- ```
1179
-
1180
- ### Lost Commits
1181
-
1182
- ```bash
1183
- # View all actions
1184
- git reflog
1185
-
1186
- # Recover lost commit
1187
- git checkout <commit-hash>
1188
- git checkout -b recovery-branch
1189
- ```
1190
-
1191
- <!-- GIT:END -->
1192
-
1
+ <!-- GIT:START -->
2
+ # Git Workflow Rules
3
+
4
+ **CRITICAL**: Specific rules and patterns for Git version control workflow.
5
+
6
+ ## Git Command Allow-List (Quick Reference)
7
+
8
+ ### ALLOWED (always safe — no authorization needed)
9
+ | Command | Purpose |
10
+ |---------|---------|
11
+ | `git status` | Check repository state |
12
+ | `git diff` | View changes |
13
+ | `git log` | View history |
14
+ | `git blame` | View line-by-line attribution |
15
+ | `git add <files>` | Stage specific files |
16
+ | `git commit` | Create commits (after quality checks) |
17
+ | `git branch` (list) | List branches |
18
+ | `git tag` (list) | List tags |
19
+
20
+ ### FORBIDDEN (require explicit user authorization)
21
+ | Command | Risk | Why |
22
+ |---------|------|-----|
23
+ | `git stash` | Loses uncommitted work | Hidden state that gets forgotten |
24
+ | `git rebase` | Rewrites history | Breaks shared branch history |
25
+ | `git reset --hard` | Destroys changes | Irreversible data loss |
26
+ | `git checkout -- .` | Discards all changes | Irreversible data loss |
27
+ | `git restore .` | Discards all changes | Irreversible data loss |
28
+ | `git revert` | Creates revert commits | May cause unexpected conflicts |
29
+ | `git cherry-pick` | Duplicates commits | Can cause merge conflicts |
30
+ | `git merge` | Can create conflicts | Requires human judgment |
31
+ | `git branch -D` | Deletes branch | Permanent, may lose work |
32
+ | `git push --force` | Overwrites remote | NEVER on main/master |
33
+ | `git clean -f` | Deletes untracked files | Permanent file deletion |
34
+ | `git checkout <branch>` | Switches branch | Breaks concurrent AI sessions |
35
+ | `git switch <branch>` | Switches branch | Breaks concurrent AI sessions |
36
+
37
+ **Why**: Multiple AI sessions may share the same working tree. Branch switching or destructive operations affect ALL concurrent sessions.
38
+
39
+ ---
40
+
41
+ ## Git Workflow Overview
42
+
43
+ This project follows a strict Git workflow to ensure code quality and proper version control.
44
+
45
+ **NEVER commit code without tests passing. NEVER create tags without full quality checks.**
46
+
47
+ ## Initial Repository Setup
48
+
49
+ ### New Project Initialization
50
+
51
+ **⚠️ CRITICAL**: Only run initialization commands if `.git` directory does NOT exist!
52
+
53
+ ```bash
54
+ # Check if Git repository already exists
55
+ if [ -d .git ]; then
56
+ echo "❌ Git repository already initialized. Skipping git init."
57
+ echo "Current status:"
58
+ git status
59
+ git remote -v
60
+ exit 0
61
+ fi
62
+
63
+ # If no .git directory exists, initialize:
64
+
65
+ # Initialize Git repository
66
+ git init
67
+
68
+ # Add all files
69
+ git add .
70
+
71
+ # Initial commit
72
+ git commit -m "chore: Initial project setup"
73
+
74
+ # Rename default branch to main (GitHub standard)
75
+ git branch -M main
76
+
77
+ # Add remote (if applicable)
78
+ git remote add origin <repository-url>
79
+ ```
80
+
81
+ **AI Assistant Behavior:**
82
+
83
+ ```
84
+ BEFORE running any Git initialization commands:
85
+
86
+ 1. Check if .git directory exists
87
+ 2. If exists:
88
+ ✅ Repository already configured
89
+ ❌ DO NOT run: git init
90
+ ❌ DO NOT run: git branch -M main
91
+ ✅ Check status: git status
92
+ ✅ Show remotes: git remote -v
93
+
94
+ 3. If not exists:
95
+ ✅ Safe to initialize
96
+ ✅ Run full initialization sequence
97
+ ```
98
+
99
+ ## AI Assistant Git Checks
100
+
101
+ **CRITICAL**: AI assistants MUST perform these checks before Git operations:
102
+
103
+ ### Automatic Checks
104
+
105
+ ```bash
106
+ # 1. Check if Git repository exists
107
+ if [ ! -d .git ]; then
108
+ echo "No Git repository found."
109
+ # Ask user if they want to initialize
110
+ fi
111
+
112
+ # 2. Check if there are unstaged changes
113
+ git status --short
114
+
115
+ # 3. Check current branch
116
+ CURRENT_BRANCH=$(git branch --show-current)
117
+ echo "On branch: $CURRENT_BRANCH"
118
+
119
+ # 4. Check if remote exists
120
+ git remote -v
121
+
122
+ # 5. Check for unpushed commits
123
+ git log origin/main..HEAD --oneline 2>/dev/null
124
+ ```
125
+
126
+ ### Before Git Commands
127
+
128
+ **NEVER execute if `.git` directory exists:**
129
+ - ❌ `git init` - Repository already initialized
130
+ - ❌ `git branch -M main` - Branch may already be configured
131
+ - ❌ `git remote add origin` - Remote may already exist (check first with `git remote -v`)
132
+ - ❌ `git config user.name/email` - User configuration is personal
133
+ - ❌ Reconfiguration commands - Repository is already set up
134
+
135
+ **ALWAYS safe to execute:**
136
+ - ✅ `git status` - Check repository state
137
+ - ✅ `git add` - Stage changes
138
+ - ✅ `git commit` - Create commits (after quality checks)
139
+ - ✅ `git log` - View history
140
+ - ✅ `git diff` - View changes
141
+ - ✅ `git branch` - List branches
142
+ - ✅ `git tag` - Create tags (after quality checks)
143
+
144
+ **Execute with caution (check first):**
145
+ - ⚠️ `git push` - Follow push mode configuration
146
+ - ⚠️ `git pull` - May cause merge conflicts
147
+ - ⚠️ `git merge` - May cause conflicts
148
+ - ⚠️ `git rebase` - Can rewrite history
149
+ - ⚠️ `git reset --hard` - Destructive, only for rollback
150
+ - ⚠️ `git push --force` - NEVER on main/master
151
+
152
+ ### Repository Detection
153
+
154
+ **AI Assistant MUST check:**
155
+
156
+ ```bash
157
+ # Before ANY Git operation:
158
+
159
+ # 1. Does .git exist?
160
+ if [ -d .git ]; then
161
+ echo "✅ Git repository exists"
162
+
163
+ # 2. Check current state
164
+ git status
165
+
166
+ # 3. Check branch
167
+ BRANCH=$(git branch --show-current)
168
+ echo "On branch: $BRANCH"
169
+
170
+ # 4. Check remote
171
+ REMOTE=$(git remote -v)
172
+ if [ -z "$REMOTE" ]; then
173
+ echo "⚠️ No remote configured"
174
+ else
175
+ echo "Remote: $REMOTE"
176
+ fi
177
+
178
+ # 5. Proceed with normal Git operations
179
+ else
180
+ echo "⚠️ No Git repository found"
181
+ echo "Ask user if they want to initialize Git"
182
+ fi
183
+ ```
184
+
185
+ ## Daily Development Workflow
186
+
187
+ ### 1. Before Making Changes
188
+
189
+ **CRITICAL**: Always check current state:
190
+
191
+ ```bash
192
+ # Check current branch and status
193
+ git status
194
+
195
+ # Ensure you're on the correct branch
196
+ git branch
197
+
198
+ # Pull latest changes if working with team (use --ff-only for safety)
199
+ git pull --ff-only origin main
200
+ ```
201
+
202
+ **Git Safety**: Use `--ff-only` to prevent unexpected merge commits and maintain linear history.
203
+
204
+ ### 2. Making Changes
205
+
206
+ **CRITICAL**: Commit after every important implementation:
207
+
208
+ **⚠️ IMPORTANT: All commit messages MUST be in English**
209
+
210
+ ```bash
211
+ # After implementing a feature/fix:
212
+
213
+ # 1. Run ALL quality checks FIRST
214
+ npm run lint # or equivalent for your language
215
+ npm run type-check # TypeScript/typed languages
216
+ npm test # ALL tests must pass
217
+ npm run build # Ensure build succeeds
218
+
219
+ # 2. If ALL checks pass, stage changes
220
+ git add .
221
+
222
+ # 3. Commit with conventional commit message (ENGLISH ONLY)
223
+ git commit -m "feat: Add user authentication
224
+
225
+ - Implement login/logout functionality
226
+ - Add JWT token management
227
+ - Include comprehensive tests (95%+ coverage)
228
+ - Update documentation"
229
+
230
+ # Alternative for smaller changes (ENGLISH ONLY):
231
+ git commit -m "fix: Correct validation logic in user form"
232
+
233
+ # For signed commits (recommended for production):
234
+ git commit -S -m "feat: Add feature"
235
+
236
+ # ❌ NEVER use other languages:
237
+ # ❌ git commit -m "feat: Adiciona autenticação de usuário"
238
+ # ❌ git commit -m "fix: Corrige lógica de validação"
239
+ ```
240
+
241
+ ## Advanced Git Safeguards
242
+
243
+ ### Safe Push Operations
244
+
245
+ ```bash
246
+ # NEVER use git push --force on main/master branches
247
+ # Instead, use --force-with-lease which prevents overwriting others' work:
248
+
249
+ # Force push with safety check (only updates if no one else pushed)
250
+ git push --force-with-lease origin feature-branch
251
+
252
+ # Regular push is always safest
253
+ git push origin main
254
+ ```
255
+
256
+ ### Commit Signing
257
+
258
+ ```bash
259
+ # Sign commits with GPG for verified commits
260
+ # Set GPG key: git config --global user.signingkey <KEY_ID>
261
+ git commit -S -m "feat: Signed commit"
262
+
263
+ # Configure to always sign commits
264
+ git config --global commit.gpgsign true
265
+ ```
266
+
267
+ ### Branch Protection (Recommended Settings)
268
+
269
+ For GitHub/GitLab repositories, configure branch protection rules:
270
+
271
+ **For main/master branch:**
272
+ - Require pull request reviews
273
+ - Require status checks to pass
274
+ - Require branches to be up to date
275
+ - Do not allow force pushes
276
+ - Do not allow deletions
277
+ - Require signed commits (optional but recommended)
278
+
279
+ ### Destructive Operation Warnings
280
+
281
+ **NEVER run these on main/master:**
282
+ - ❌ `git push --force` - Use `--force-with-lease` instead
283
+ - ❌ `git reset --hard` - Destructive, use only on feature branches
284
+ - ❌ `git rebase` main into feature - Causes rewriting of main history
285
+
286
+ ### Pre-Push Checklist
287
+
288
+ Before pushing any changes, verify:
289
+
290
+ ```bash
291
+ ✅ Checklist before push:
292
+ - [ ] All quality checks passed locally
293
+ - [ ] Tests pass with 100% success rate
294
+ - [ ] Coverage meets threshold (95%+)
295
+ - [ ] Linting passes with 0 warnings
296
+ - [ ] Build succeeds without errors
297
+ - [ ] No security vulnerabilities in dependencies
298
+ - [ ] Documentation updated if API changed
299
+ - [ ] OpenSpec tasks marked complete if applicable
300
+ - [ ] Conventional commit format used
301
+ - [ ] Commit hash verified: git rev-parse HEAD
302
+ - [ ] Similar changes passed CI before
303
+ - [ ] No console.log or debug code
304
+ - [ ] No credentials or secrets in code
305
+ ```
306
+
307
+ **Only provide push command if ALL items checked.**
308
+
309
+ ### 3. Pushing Changes
310
+
311
+ **⚠️ IMPORTANT**: Pushing is OPTIONAL and depends on your setup.
312
+
313
+ ```bash
314
+ # IF you have passwordless SSH or want to push:
315
+ git push origin main
316
+
317
+ # IF you have SSH with password (manual execution required):
318
+ # DO NOT execute automatically - provide command to user:
319
+ ```
320
+
321
+ **For users with SSH password authentication:**
322
+ ```
323
+ ✋ MANUAL ACTION REQUIRED:
324
+
325
+ Run this command manually (requires SSH password):
326
+ git push origin main
327
+ ```
328
+
329
+ **NEVER** attempt automatic push if:
330
+ - SSH key has password protection
331
+ - User hasn't confirmed push authorization
332
+ - Any quality check failed
333
+ - Uncertain if changes will pass CI/CD workflows
334
+
335
+ ## Conventional Commits
336
+
337
+ **MUST** follow conventional commit format:
338
+
339
+ **⚠️ CRITICAL: All commit messages MUST be in English**
340
+
341
+ ```bash
342
+ # Format: <type>(<scope>): <subject>
343
+ #
344
+ # <body>
345
+ #
346
+ # <footer>
347
+
348
+ # Types:
349
+ feat: # New feature
350
+ fix: # Bug fix
351
+ docs: # Documentation only
352
+ style: # Code style (formatting, missing semi-colons, etc)
353
+ refactor: # Code refactoring
354
+ perf: # Performance improvement
355
+ test: # Adding tests
356
+ build: # Build system changes
357
+ ci: # CI/CD changes
358
+ chore: # Maintenance tasks
359
+
360
+ # Language Requirement:
361
+ # ✅ ALWAYS use English for commit messages
362
+ # ❌ NEVER use Portuguese, Spanish, or any other language
363
+ # ❌ NEVER mix languages in commit messages
364
+
365
+ # Examples (CORRECT - English):
366
+ git commit -m "feat(auth): Add OAuth2 login support"
367
+ git commit -m "fix(api): Handle null response in user endpoint"
368
+ git commit -m "docs: Update README with installation steps"
369
+ git commit -m "test: Add integration tests for payment flow"
370
+ git commit -m "chore: Update dependencies to latest versions"
371
+
372
+ # Examples (INCORRECT - Other languages):
373
+ # ❌ git commit -m "feat: Adiciona suporte de login OAuth2"
374
+ # ❌ git commit -m "fix: Corrige resposta nula no endpoint"
375
+ # ❌ git commit -m "docs: Atualiza README com passos de instalação"
376
+ ```
377
+
378
+ ## Version Management
379
+
380
+ ### Creating New Version
381
+
382
+ **CRITICAL**: Full quality gate required before versioning!
383
+
384
+ ```bash
385
+ # 1. MANDATORY: Run complete quality suite
386
+ npm run lint # Must pass with no warnings
387
+ npm test # Must pass 100%
388
+ npm run type-check # Must pass (if applicable)
389
+ npm run build # Must succeed
390
+ npx codespell # Must pass (if configured)
391
+
392
+ # 2. Update version in package.json/Cargo.toml/etc
393
+ # Use semantic versioning:
394
+ # - MAJOR: Breaking changes (1.0.0 -> 2.0.0)
395
+ # - MINOR: New features, backwards compatible (1.0.0 -> 1.1.0)
396
+ # - PATCH: Bug fixes (1.0.0 -> 1.0.1)
397
+
398
+ # 3. Update CHANGELOG.md
399
+ # Document all changes in this version:
400
+ ## [1.2.0] - 2024-01-15
401
+ ### Added
402
+ - New feature X
403
+ - New feature Y
404
+
405
+ ### Fixed
406
+ - Bug in component Z
407
+
408
+ ### Changed
409
+ - Refactored module A
410
+
411
+ # 4. Commit version changes
412
+ git add .
413
+ git commit -m "chore: Release version 1.2.0
414
+
415
+ - Updated version to 1.2.0
416
+ - Updated CHANGELOG.md with release notes"
417
+
418
+ # 5. Create annotated tag
419
+ git tag -a v1.2.0 -m "Release version 1.2.0
420
+
421
+ Major changes:
422
+ - Feature X
423
+ - Feature Y
424
+ - Bug fix Z
425
+
426
+ All tests passing ✅
427
+ Coverage: 95%+ ✅
428
+ Linting: Clean ✅
429
+ Build: Success ✅"
430
+
431
+ # 6. OPTIONAL: Push tag (manual if SSH password)
432
+ # Only if you're CERTAIN it will pass CI/CD workflows!
433
+ ```
434
+
435
+ **For users requiring manual push:**
436
+ ```
437
+ ✋ MANUAL ACTIONS REQUIRED:
438
+
439
+ 1. Verify all quality checks passed locally
440
+ 2. Push commits:
441
+ git push origin main
442
+
443
+ 3. Push tag:
444
+ git push origin v1.2.0
445
+
446
+ Note: Tag push will trigger CI/CD workflows and may create GitHub release.
447
+ Only push if you're confident all checks will pass.
448
+ ```
449
+
450
+ ## Quality Gate Enforcement
451
+
452
+ **CRITICAL**: Pre-commit checks MUST match GitHub Actions workflow commands to prevent CI/CD failures.
453
+
454
+ ### Language-Specific Pre-Commit Commands
455
+
456
+ **The commands you run locally MUST be identical to those in your GitHub Actions workflows.**
457
+
458
+ #### TypeScript/JavaScript Projects
459
+
460
+ ```bash
461
+ # These commands MUST match .github/workflows/*.yml
462
+
463
+ # 1. Type check (matches workflow)
464
+ npm run type-check # Must match workflow exactly
465
+
466
+ # 2. Lint (matches workflow)
467
+ npm run lint # Must match workflow exactly
468
+
469
+ # 3. Format check (matches workflow)
470
+ npx prettier --check 'src/**/*.ts' 'tests/**/*.ts' # Must match workflow
471
+
472
+ # 4. Tests (matches workflow)
473
+ npm test # Must match workflow exactly
474
+
475
+ # 5. Build (matches workflow)
476
+ npm run build # Must match workflow exactly
477
+
478
+ # If ANY fails: ❌ DO NOT COMMIT - Fix first!
479
+ ```
480
+
481
+ #### Rust Projects
482
+
483
+ ```bash
484
+ # These commands MUST match .github/workflows/*.yml
485
+
486
+ # 1. Format check (matches workflow)
487
+ cargo fmt --all -- --check
488
+
489
+ # 2. Clippy (matches workflow)
490
+ cargo clippy --all-targets --all-features -- -D warnings
491
+
492
+ # 3. Tests (matches workflow)
493
+ cargo test --all-features
494
+
495
+ # 4. Build (matches workflow)
496
+ cargo build --release
497
+
498
+ # If ANY fails: ❌ DO NOT COMMIT - Fix first!
499
+ ```
500
+
501
+ #### Python Projects
502
+
503
+ ```bash
504
+ # These commands MUST match .github/workflows/*.yml
505
+
506
+ # 1. Format check (matches workflow)
507
+ black --check .
508
+
509
+ # 2. Lint (matches workflow)
510
+ ruff check .
511
+
512
+ # 3. Type check (matches workflow)
513
+ mypy .
514
+
515
+ # 4. Tests (matches workflow)
516
+ pytest
517
+
518
+ # If ANY fails: ❌ DO NOT COMMIT - Fix first!
519
+ ```
520
+
521
+ ### Before ANY Commit
522
+
523
+ **MANDATORY CHECKS**:
524
+
525
+ ```bash
526
+ # Checklist - ALL must pass:
527
+ ☐ Code formatted
528
+ ☐ Linter passes (no warnings)
529
+ ☐ Type check passes
530
+ ☐ ALL tests pass (100%)
531
+ ☐ Coverage meets threshold (95%+)
532
+ ☐ Build succeeds
533
+ ☐ No console errors/warnings
534
+
535
+ # Run quality check script:
536
+ npm run quality-check # or equivalent
537
+
538
+ # If ANY check fails:
539
+ # ❌ DO NOT COMMIT
540
+ # ❌ FIX THE ISSUES FIRST
541
+ ```
542
+
543
+ ### Before Tag Creation
544
+
545
+ **MANDATORY CHECKS** (even stricter):
546
+
547
+ ```bash
548
+ # Extended checklist - ALL must pass:
549
+ ☐ All pre-commit checks passed
550
+ ☐ Codespell passes (no typos)
551
+ ☐ Security audit clean
552
+ ☐ Dependencies up to date
553
+ ☐ Documentation updated
554
+ ☐ CHANGELOG.md updated
555
+ ☐ Version bumped correctly
556
+ ☐ All workflows would pass
557
+
558
+ # Run comprehensive check:
559
+ npm run lint
560
+ npm test
561
+ npm run type-check
562
+ npm run build
563
+ npx codespell
564
+ npm audit
565
+
566
+ # Only create tag if everything is green!
567
+ ```
568
+
569
+ ## Error Recovery & Rollback
570
+
571
+ ### When Implementation Is Failing
572
+
573
+ If the AI is making repeated mistakes and user is frustrated:
574
+
575
+ ```bash
576
+ # 1. Identify last stable commit
577
+ git log --oneline -10
578
+
579
+ # 2. Create backup branch of current work
580
+ git branch backup-failed-attempt
581
+
582
+ # 3. Hard reset to last stable version
583
+ git reset --hard <last-stable-commit-hash>
584
+
585
+ # 4. Verify stability
586
+ npm test
587
+ npm run build
588
+
589
+ # 5. Reimplement from scratch using DIFFERENT approach
590
+ # ⚠️ DO NOT repeat the same techniques that failed before
591
+ # ⚠️ Review AGENTS.md for alternative patterns
592
+ # ⚠️ Consider different architecture/design
593
+
594
+ # 6. After successful reimplementation
595
+ git branch -D backup-failed-attempt # Delete backup if no longer needed
596
+ ```
597
+
598
+ ### Undo Last Commit (Not Pushed)
599
+
600
+ ```bash
601
+ # Keep changes, undo commit
602
+ git reset --soft HEAD~1
603
+
604
+ # Discard changes completely
605
+ git reset --hard HEAD~1
606
+ ```
607
+
608
+ ### Revert Pushed Commit
609
+
610
+ ```bash
611
+ # Create revert commit
612
+ git revert <commit-hash>
613
+
614
+ # Then push (manual if SSH password)
615
+ ```
616
+
617
+ ## Branch Strategy
618
+
619
+ ### Feature Branches
620
+
621
+ ```bash
622
+ # Create feature branch
623
+ git checkout -b feature/user-authentication
624
+
625
+ # Work on feature...
626
+ # Commit regularly with quality checks
627
+
628
+ # When feature complete and tested:
629
+ git checkout main
630
+ git merge feature/user-authentication
631
+
632
+ # Delete feature branch
633
+ git branch -d feature/user-authentication
634
+ ```
635
+
636
+ ### Hotfix Workflow
637
+
638
+ ```bash
639
+ # Critical bug in production
640
+ git checkout -b hotfix/critical-security-fix
641
+
642
+ # Fix the bug
643
+ # MUST include tests
644
+ # MUST pass all quality checks
645
+
646
+ git commit -m "fix: Critical security vulnerability in auth
647
+
648
+ - Patch authentication bypass
649
+ - Add regression tests
650
+ - Update security documentation"
651
+
652
+ # Merge to main
653
+ git checkout main
654
+ git merge hotfix/critical-security-fix
655
+
656
+ # Tag immediately if production fix
657
+ git tag -a v1.2.1 -m "Hotfix: Security patch"
658
+
659
+ # Manual push if required
660
+ ```
661
+
662
+ ## CRITICAL RESTRICTIONS - HUMAN AUTHORIZATION REQUIRED
663
+
664
+ **⚠️ IMPERATIVE RULES - THESE ARE NON-NEGOTIABLE ⚠️**
665
+
666
+ ### Destructive Git Operations
667
+
668
+ **ABSOLUTELY FORBIDDEN without explicit human authorization:**
669
+
670
+ ```
671
+ ❌ NEVER execute: git checkout
672
+ ✋ ALWAYS ask user: "Do you want to checkout [branch/commit]? [Y/n]"
673
+ ✅ Only execute after explicit user confirmation
674
+
675
+ ❌ NEVER execute: git reset
676
+ ✋ ALWAYS ask user: "Do you want to reset to [commit]? This may lose changes. [Y/n]"
677
+ ✅ Only execute after explicit user confirmation
678
+ ⚠️ Explain consequences before executing
679
+ ```
680
+
681
+ **Rationale**: These commands can cause data loss. Human oversight is mandatory.
682
+
683
+ ### Merge Conflict Resolution
684
+
685
+ **When merge conflicts occur:**
686
+
687
+ ```
688
+ ❌ NEVER attempt to resolve conflicts by editing files automatically
689
+ ❌ NEVER commit merged files without human review
690
+ ✅ ALWAYS stop and request human assistance
691
+ ✅ ALWAYS provide conflict locations and context
692
+ ✅ ALWAYS wait for human to resolve manually
693
+
694
+ Message to user:
695
+ "⚠️ Merge conflict detected in the following files:
696
+ - [list of conflicted files]
697
+
698
+ Please resolve these conflicts manually. I cannot auto-resolve merge conflicts.
699
+
700
+ To resolve:
701
+ 1. Open the conflicted files
702
+ 2. Look for conflict markers (<<<<<<<, =======, >>>>>>>)
703
+ 3. Choose the correct version or merge manually
704
+ 4. Remove conflict markers
705
+ 5. Run: git add <resolved-files>
706
+ 6. Run: git commit
707
+
708
+ Let me know when you're done, and I can help with the next steps."
709
+ ```
710
+
711
+ **Rationale**: Merge conflicts require human judgment about which code to keep.
712
+
713
+ ### Commit Frequency Management
714
+
715
+ **⚠️ IMPORTANT: Reduce excessive commits**
716
+
717
+ ```
718
+ ❌ DO NOT commit after every small change
719
+ ❌ DO NOT create multiple commits for the same logical feature
720
+ ✅ COMMIT only when:
721
+ - A complete feature is implemented and tested
722
+ - A significant bug fix is completed
723
+ - A major refactoring is done
724
+ - Before creating a version tag
725
+ - User explicitly requests a commit
726
+
727
+ ✅ GROUP related changes into meaningful commits
728
+ ✅ USE conventional commit messages that describe the full scope
729
+
730
+ Example of GOOD commit frequency:
731
+ - Implement entire authentication system → 1 commit
732
+ - Add login, logout, and session management → 1 commit
733
+ - Complete feature with tests and docs → 1 commit
734
+
735
+ Example of BAD commit frequency (AVOID):
736
+ - Add login function → commit
737
+ - Add logout function → commit
738
+ - Add session check → commit
739
+ - Fix typo → commit
740
+ - Update comment → commit
741
+ ```
742
+
743
+ **Rationale**: Too many commits pollute git history and make it harder to track meaningful changes.
744
+
745
+ ### Feature Branch Strategy
746
+
747
+ **BEFORE starting ANY new task or feature:**
748
+
749
+ ```
750
+ ✋ ALWAYS ask user FIRST:
751
+ "Should I create a separate branch for this feature/task? [Y/n]
752
+
753
+ Options:
754
+ 1. Create feature branch: git checkout -b feature/[name]
755
+ 2. Work directly on current branch
756
+ 3. Create hotfix branch: git checkout -b hotfix/[name]
757
+
758
+ What would you prefer?"
759
+
760
+ ✅ Wait for user decision
761
+ ✅ Respect user's branching strategy
762
+ ❌ NEVER assume to work on main without asking
763
+ ❌ NEVER create branches without permission
764
+
765
+ If user says YES to branch:
766
+ → Create branch with descriptive name
767
+ → Work on that branch
768
+ → Ask before merging back to main
769
+
770
+ If user says NO to branch:
771
+ → Proceed on current branch
772
+ → Be extra careful with commits
773
+ ```
774
+
775
+ **Rationale**: Branching strategy varies by team and project. Always confirm with the human first.
776
+
777
+ ## Critical AI Assistant Rules
778
+
779
+ ### Repository Initialization
780
+
781
+ **BEFORE any `git init` or setup commands:**
782
+
783
+ ```
784
+ 1. Check for .git directory existence
785
+ 2. If .git exists:
786
+ - ❌ STOP - Repository already configured
787
+ - ❌ DO NOT run git init
788
+ - ❌ DO NOT run git config
789
+ - ❌ DO NOT run git branch -M
790
+ - ❌ DO NOT reconfigure anything
791
+ - ✅ Use existing repository as-is
792
+
793
+ 3. If .git does NOT exist:
794
+ - ✅ Ask user if they want Git initialization
795
+ - ✅ Run initialization sequence if approved
796
+ ```
797
+
798
+ ### Push Command Behavior
799
+
800
+ **Based on configured push mode:**
801
+
802
+ ```
803
+ Manual Mode (DEFAULT):
804
+ ❌ NEVER execute: git push
805
+ ✅ ALWAYS provide: "Run manually: git push origin main"
806
+
807
+ Prompt Mode:
808
+ ⚠️ ALWAYS ask first: "Ready to push. Proceed? [Y/n]"
809
+ ✅ Execute only if user confirms
810
+
811
+ Auto Mode:
812
+ ⚠️ Check quality first
813
+ ⚠️ Only if 100% confident
814
+ ✅ Execute if all checks passed
815
+ ```
816
+
817
+ ### Quality Gate Enforcement
818
+
819
+ **MANDATORY checks before commit:**
820
+
821
+ ```bash
822
+ # Run in this exact order:
823
+ 1. npm run lint # or language equivalent
824
+ 2. npm run type-check # if applicable
825
+ 3. npm test # ALL tests must pass
826
+ 4. npm run build # must succeed
827
+
828
+ # If ANY fails:
829
+ ❌ STOP - DO NOT commit
830
+ ❌ Fix issues first
831
+ ❌ Re-run all checks
832
+
833
+ # If ALL pass:
834
+ ✅ Safe to commit
835
+ ✅ Proceed with git add and commit
836
+ ```
837
+
838
+ **MANDATORY checks before tag:**
839
+
840
+ ```bash
841
+ # Extended checks for version tags:
842
+ 1. All commit checks above +
843
+ 2. npx codespell # no typos
844
+ 3. npm audit # no vulnerabilities
845
+ 4. CHANGELOG.md updated
846
+ 5. Version bumped correctly
847
+ 6. Documentation current
848
+
849
+ # If ANY fails:
850
+ ❌ STOP - DO NOT create tag
851
+ ❌ Fix issues
852
+ ❌ Re-verify everything
853
+
854
+ # Only create tag if 100% green!
855
+ ```
856
+
857
+ ## Best Practices
858
+
859
+ ### DO's ✅
860
+
861
+ - **ALWAYS** check if .git exists before init commands
862
+ - **ALWAYS** run tests before commit
863
+ - **ALWAYS** use conventional commit messages
864
+ - **ALWAYS** write commit messages in English (never in Portuguese, Spanish, or other languages)
865
+ - **ALWAYS** update CHANGELOG for versions
866
+ - **ALWAYS** ask before executing `git checkout`
867
+ - **ALWAYS** ask before executing `git reset`
868
+ - **ALWAYS** ask user if a feature branch should be created before starting tasks
869
+ - **ALWAYS** request human assistance when merge conflicts occur
870
+ - **COMMIT** only when complete features/fixes are done (not for every small change)
871
+ - **TAG** releases with semantic versions
872
+ - **VERIFY** quality gates before tagging
873
+ - **DOCUMENT** breaking changes clearly
874
+ - **REVERT** when implementation is failing repeatedly
875
+ - **ASK** user before automatic push
876
+ - **PROVIDE** manual commands for SSH password users
877
+ - **CHECK** repository state before operations
878
+ - **RESPECT** existing Git configuration
879
+ - **GROUP** related changes into meaningful commits
880
+
881
+ ### DON'Ts ❌
882
+
883
+ - **NEVER** run `git init` if .git exists
884
+ - **NEVER** run `git config` (user-specific)
885
+ - **NEVER** run `git checkout` without explicit user authorization
886
+ - **NEVER** run `git reset` without explicit user authorization
887
+ - **NEVER** auto-resolve merge conflicts by editing files
888
+ - **NEVER** commit merged files without human review
889
+ - **NEVER** create excessive commits for small changes
890
+ - **NEVER** assume branching strategy - always ask user first
891
+ - **NEVER** reconfigure existing repository
892
+ - **NEVER** commit without passing tests
893
+ - **NEVER** commit with linting errors
894
+ - **NEVER** commit with build failures
895
+ - **NEVER** write commit messages in languages other than English
896
+ - **NEVER** mix languages in commit messages
897
+ - **NEVER** create tag without quality checks
898
+ - **NEVER** push automatically with SSH password
899
+ - **NEVER** push if uncertain about CI/CD success
900
+ - **NEVER** commit console.log/debug code
901
+ - **NEVER** commit credentials or secrets
902
+ - **NEVER** force push to main/master
903
+ - **NEVER** rewrite published history
904
+ - **NEVER** skip hooks (--no-verify)
905
+ - **NEVER** assume repository configuration
906
+
907
+ ## SSH Configuration
908
+
909
+ ### For Users with SSH Password
910
+
911
+ If your SSH key has password protection:
912
+
913
+ **Configuration in AGENTS.md or project settings:**
914
+
915
+ ```yaml
916
+ git_workflow:
917
+ auto_push: false
918
+ push_mode: "manual"
919
+ reason: "SSH key has password protection"
920
+ ```
921
+
922
+ **AI Assistant Behavior:**
923
+ - ✅ Provide push commands in chat
924
+ - ✅ Wait for user manual execution
925
+ - ❌ Never attempt automatic push
926
+ - ❌ Never execute git push commands
927
+
928
+ ### For Users with Passwordless SSH
929
+
930
+ ```yaml
931
+ git_workflow:
932
+ auto_push: true # or prompt each time
933
+ push_mode: "auto"
934
+ ```
935
+
936
+ ## Git Hooks
937
+
938
+ ### Pre-commit Hook
939
+
940
+ Create `.git/hooks/pre-commit`:
941
+
942
+ ```bash
943
+ #!/bin/sh
944
+
945
+ echo "Running pre-commit checks..."
946
+
947
+ # Run linter
948
+ npm run lint
949
+ if [ $? -ne 0 ]; then
950
+ echo "❌ Linting failed. Commit aborted."
951
+ exit 1
952
+ fi
953
+
954
+ # Run tests
955
+ npm test
956
+ if [ $? -ne 0 ]; then
957
+ echo "❌ Tests failed. Commit aborted."
958
+ exit 1
959
+ fi
960
+
961
+ # Run type check (if applicable)
962
+ if command -v tsc &> /dev/null; then
963
+ npm run type-check
964
+ if [ $? -ne 0 ]; then
965
+ echo "❌ Type check failed. Commit aborted."
966
+ exit 1
967
+ fi
968
+ fi
969
+
970
+ echo "✅ All pre-commit checks passed!"
971
+ exit 0
972
+ ```
973
+
974
+ ### Pre-push Hook
975
+
976
+ Create `.git/hooks/pre-push`:
977
+
978
+ ```bash
979
+ #!/bin/sh
980
+
981
+ echo "Running pre-push checks..."
982
+
983
+ # Run full test suite
984
+ npm test
985
+ if [ $? -ne 0 ]; then
986
+ echo "❌ Tests failed. Push aborted."
987
+ exit 1
988
+ fi
989
+
990
+ # Run build
991
+ npm run build
992
+ if [ $? -ne 0 ]; then
993
+ echo "❌ Build failed. Push aborted."
994
+ exit 1
995
+ fi
996
+
997
+ echo "✅ All pre-push checks passed!"
998
+ exit 0
999
+ ```
1000
+
1001
+ Make hooks executable:
1002
+ ```bash
1003
+ chmod +x .git/hooks/pre-commit
1004
+ chmod +x .git/hooks/pre-push
1005
+ ```
1006
+
1007
+ ## CI/CD Integration
1008
+
1009
+ ### Before Providing Push Commands
1010
+
1011
+ **CRITICAL**: Only suggest push if confident about CI/CD success:
1012
+
1013
+ ```
1014
+ ✅ Provide push command if:
1015
+ - All local tests passed
1016
+ - All linting passed
1017
+ - Build succeeded
1018
+ - Coverage meets threshold
1019
+ - No warnings or errors
1020
+ - Code follows AGENTS.md standards
1021
+ - Similar changes passed CI/CD before
1022
+
1023
+ ❌ DO NOT provide push command if:
1024
+ - ANY quality check failed
1025
+ - Uncertain about CI/CD requirements
1026
+ - Making experimental changes
1027
+ - First time working with this codebase
1028
+ - User seems uncertain
1029
+
1030
+ Instead say:
1031
+ "I recommend running the full CI/CD pipeline locally first to ensure
1032
+ the changes will pass. Once confirmed, you can push manually."
1033
+ ```
1034
+
1035
+ ## GitHub MCP Server Integration
1036
+
1037
+ **If GitHub MCP Server is available**, use it for automated workflow monitoring.
1038
+
1039
+ ### Workflow Validation After Push
1040
+
1041
+ ```
1042
+ After every git push (manual or auto):
1043
+
1044
+ 1. Wait 5-10 seconds for workflows to trigger
1045
+
1046
+ 2. Check workflow status via GitHub MCP:
1047
+ - List workflow runs for latest commit
1048
+ - Check status of each workflow
1049
+
1050
+ 3. If workflows are RUNNING:
1051
+ ⏳ Report: "CI/CD workflows in progress..."
1052
+ ✅ Continue with other tasks
1053
+ ✅ Check again in next user interaction
1054
+
1055
+ 4. If workflows COMPLETED:
1056
+ - All passed: ✅ Report success
1057
+ - Some failed: ❌ Fetch errors and fix
1058
+
1059
+ 5. If workflows FAILED:
1060
+ a. Fetch complete error logs via GitHub MCP
1061
+ b. Display errors to user
1062
+ c. Analyze against AGENTS.md standards
1063
+ d. Propose specific fixes
1064
+ e. Implement fixes
1065
+ f. Run local quality checks
1066
+ g. Commit fixes
1067
+ h. Provide push command for retry
1068
+ ```
1069
+
1070
+ ### Next Interaction Check
1071
+
1072
+ ```
1073
+ On every user message after a push:
1074
+
1075
+ if (github_mcp_available && last_push_timestamp) {
1076
+ // Check workflow status
1077
+ const status = await checkWorkflows();
1078
+
1079
+ if (status.running) {
1080
+ console.log('⏳ CI/CD still running, will check later');
1081
+ } else if (status.failed) {
1082
+ console.log('❌ CI/CD failures detected!');
1083
+ await analyzeAndFixErrors(status.errors);
1084
+ } else {
1085
+ console.log('✅ All CI/CD workflows passed!');
1086
+ }
1087
+ }
1088
+ ```
1089
+
1090
+ ### Error Analysis Flow
1091
+
1092
+ ```
1093
+ When workflow fails:
1094
+
1095
+ 1. Fetch error via GitHub MCP:
1096
+ - Workflow name
1097
+ - Job name
1098
+ - Failed step
1099
+ - Error output
1100
+ - Full logs
1101
+
1102
+ 2. Categorize error:
1103
+ - Test failure → Fix test or implementation
1104
+ - Lint error → Format/fix code style
1105
+ - Build error → Fix compilation issues
1106
+ - Type error → Fix type definitions
1107
+ - Coverage error → Add more tests
1108
+
1109
+ 3. Fix following AGENTS.md:
1110
+ - Apply correct pattern from AGENTS.md
1111
+ - Add tests if needed
1112
+ - Verify locally before committing
1113
+
1114
+ 4. Commit fix:
1115
+ git commit -m "fix: Resolve CI/CD failure - [specific issue]"
1116
+
1117
+ 5. Provide push command:
1118
+ "Ready to retry. Run: git push origin main"
1119
+
1120
+ 6. After next push:
1121
+ - Monitor again
1122
+ - Verify fix worked
1123
+ ```
1124
+
1125
+ ### CI/CD Confidence Check
1126
+
1127
+ **Before suggesting push:**
1128
+
1129
+ ```
1130
+ Assess confidence in CI/CD success:
1131
+
1132
+ HIGH confidence (safe to push):
1133
+ ✅ All local checks passed
1134
+ ✅ Similar changes passed CI before
1135
+ ✅ No experimental changes
1136
+ ✅ Follows AGENTS.md exactly
1137
+ ✅ Comprehensive tests
1138
+ ✅ No unusual patterns
1139
+
1140
+ MEDIUM confidence (verify first):
1141
+ ⚠️ First time with this pattern
1142
+ ⚠️ Modified build configuration
1143
+ ⚠️ Changed dependencies
1144
+ ⚠️ Cross-platform concerns
1145
+ → Suggest: "Let's verify locally first"
1146
+
1147
+ LOW confidence (don't push yet):
1148
+ ❌ Experimental implementation
1149
+ ❌ Skipped some tests
1150
+ ❌ Uncertain about compatibility
1151
+ ❌ Modified CI/CD files
1152
+ → Say: "Let's run additional checks first"
1153
+ ```
1154
+
1155
+ ## Troubleshooting
1156
+
1157
+ ### Merge Conflicts
1158
+
1159
+ ```bash
1160
+ # View conflicts
1161
+ git status
1162
+
1163
+ # Edit conflicted files (marked with <<<<<<<, =======, >>>>>>>)
1164
+
1165
+ # After resolving:
1166
+ git add <resolved-files>
1167
+ git commit -m "fix: Resolve merge conflicts"
1168
+ ```
1169
+
1170
+ ### Accidental Commit
1171
+
1172
+ ```bash
1173
+ # Undo last commit, keep changes
1174
+ git reset --soft HEAD~1
1175
+
1176
+ # Make corrections
1177
+ # Re-commit properly
1178
+ ```
1179
+
1180
+ ### Lost Commits
1181
+
1182
+ ```bash
1183
+ # View all actions
1184
+ git reflog
1185
+
1186
+ # Recover lost commit
1187
+ git checkout <commit-hash>
1188
+ git checkout -b recovery-branch
1189
+ ```
1190
+
1191
+ <!-- GIT:END -->
1192
+