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