xtrm-tools 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (447) hide show
  1. package/CHANGELOG.md +496 -0
  2. package/README.md +762 -0
  3. package/cli/dist/index.cjs +55245 -0
  4. package/cli/dist/index.cjs.map +1 -0
  5. package/cli/dist/index.d.cts +2 -0
  6. package/cli/package.json +43 -0
  7. package/config/.env.example +40 -0
  8. package/config/hooks.json +36 -0
  9. package/config/mcp_servers.json +46 -0
  10. package/config/mcp_servers_optional.json +53 -0
  11. package/config/settings.json +70 -0
  12. package/hooks/README.md +156 -0
  13. package/hooks/__pycache__/agent_context.cpython-314.pyc +0 -0
  14. package/hooks/agent_context.py +105 -0
  15. package/hooks/gitnexus/gitnexus-hook.cjs +133 -0
  16. package/hooks/serena-workflow-reminder.py +74 -0
  17. package/hooks/skill-discovery.py +90 -0
  18. package/hooks/skill-suggestion.py +112 -0
  19. package/hooks/test_agent_context.py +112 -0
  20. package/hooks/type-safety-enforcement.py +107 -0
  21. package/package.json +48 -0
  22. package/project-skills/main-guard/.claude/hooks/main-guard.cjs +188 -0
  23. package/project-skills/main-guard/.claude/settings.json +16 -0
  24. package/project-skills/main-guard/.claude/skills/using-main-guard/SKILL.md +135 -0
  25. package/project-skills/main-guard/README.md +163 -0
  26. package/project-skills/py-quality-gate/.claude/hooks/quality-check.py +311 -0
  27. package/project-skills/py-quality-gate/.claude/settings.json +16 -0
  28. package/project-skills/py-quality-gate/.claude/skills/using-py-quality-gate/SKILL.md +112 -0
  29. package/project-skills/py-quality-gate/README.md +147 -0
  30. package/project-skills/service-skills-set/.claude/git-hooks/__pycache__/doc_reminder.cpython-314.pyc +0 -0
  31. package/project-skills/service-skills-set/.claude/git-hooks/__pycache__/skill_staleness.cpython-314.pyc +0 -0
  32. package/project-skills/service-skills-set/.claude/git-hooks/doc_reminder.py +67 -0
  33. package/project-skills/service-skills-set/.claude/git-hooks/skill_staleness.py +194 -0
  34. package/project-skills/service-skills-set/.claude/service-registry.json +4 -0
  35. package/project-skills/service-skills-set/.claude/settings.json +37 -0
  36. package/project-skills/service-skills-set/.claude/skills/creating-service-skills/SKILL.md +433 -0
  37. package/project-skills/service-skills-set/.claude/skills/creating-service-skills/references/script_quality_standards.md +412 -0
  38. package/project-skills/service-skills-set/.claude/skills/creating-service-skills/references/service_skill_system_guide.md +264 -0
  39. package/project-skills/service-skills-set/.claude/skills/creating-service-skills/scripts/bootstrap.py +308 -0
  40. package/project-skills/service-skills-set/.claude/skills/creating-service-skills/scripts/deep_dive.py +304 -0
  41. package/project-skills/service-skills-set/.claude/skills/creating-service-skills/scripts/scaffolder.py +482 -0
  42. package/project-skills/service-skills-set/.claude/skills/scoping-service-skills/SKILL.md +231 -0
  43. package/project-skills/service-skills-set/.claude/skills/scoping-service-skills/scripts/scope.py +74 -0
  44. package/project-skills/service-skills-set/.claude/skills/updating-service-skills/SKILL.md +136 -0
  45. package/project-skills/service-skills-set/.claude/skills/updating-service-skills/scripts/__pycache__/drift_detector.cpython-314.pyc +0 -0
  46. package/project-skills/service-skills-set/.claude/skills/updating-service-skills/scripts/drift_detector.py +222 -0
  47. package/project-skills/service-skills-set/.claude/skills/using-service-skills/SKILL.md +108 -0
  48. package/project-skills/service-skills-set/.claude/skills/using-service-skills/scripts/__pycache__/cataloger.cpython-314.pyc +0 -0
  49. package/project-skills/service-skills-set/.claude/skills/using-service-skills/scripts/__pycache__/skill_activator.cpython-314.pyc +0 -0
  50. package/project-skills/service-skills-set/.claude/skills/using-service-skills/scripts/cataloger.py +74 -0
  51. package/project-skills/service-skills-set/.claude/skills/using-service-skills/scripts/skill_activator.py +152 -0
  52. package/project-skills/service-skills-set/README.md +93 -0
  53. package/project-skills/service-skills-set/__pycache__/install-service-skills.cpython-314.pyc +0 -0
  54. package/project-skills/service-skills-set/install-service-skills.py +163 -0
  55. package/project-skills/service-skills-set/service-skills-readme.md +236 -0
  56. package/project-skills/tdd-guard/.claude/settings.json +38 -0
  57. package/project-skills/tdd-guard/.claude/skills/using-tdd-guard/SKILL.md +74 -0
  58. package/project-skills/tdd-guard/CLAUDE.md +98 -0
  59. package/project-skills/tdd-guard/CONTRIBUTING.md +38 -0
  60. package/project-skills/tdd-guard/DEVELOPMENT.md +127 -0
  61. package/project-skills/tdd-guard/LICENSE +21 -0
  62. package/project-skills/tdd-guard/README.md +396 -0
  63. package/project-skills/tdd-guard/docs/adr/001-claude-session-subdirectory.md +52 -0
  64. package/project-skills/tdd-guard/docs/adr/002-secure-claude-binary-path.md +56 -0
  65. package/project-skills/tdd-guard/docs/adr/003-remove-configurable-data-directory.md +56 -0
  66. package/project-skills/tdd-guard/docs/adr/004-monorepo-architecture.md +64 -0
  67. package/project-skills/tdd-guard/docs/adr/005-claude-project-dir-support.md +55 -0
  68. package/project-skills/tdd-guard/docs/adr/006-phpunit-separate-repository.md +93 -0
  69. package/project-skills/tdd-guard/docs/adr/007-golangci-lint-path-support.md +83 -0
  70. package/project-skills/tdd-guard/docs/adr/008-storybook-reporter-design.md +182 -0
  71. package/project-skills/tdd-guard/docs/assets/tdd-guard-demo-screenshot.gif +0 -0
  72. package/project-skills/tdd-guard/docs/config-migration.md +143 -0
  73. package/project-skills/tdd-guard/docs/configuration.md +137 -0
  74. package/project-skills/tdd-guard/docs/custom-instructions.md +43 -0
  75. package/project-skills/tdd-guard/docs/enforcement.md +46 -0
  76. package/project-skills/tdd-guard/docs/ignore-patterns.md +81 -0
  77. package/project-skills/tdd-guard/docs/linting.md +109 -0
  78. package/project-skills/tdd-guard/docs/quick-commands.md +52 -0
  79. package/project-skills/tdd-guard/docs/session-management.md +75 -0
  80. package/project-skills/tdd-guard/docs/storybook-vitest-addon.md +120 -0
  81. package/project-skills/tdd-guard/docs/validation-model.md +63 -0
  82. package/project-skills/tdd-guard/eslint.config.mjs +140 -0
  83. package/project-skills/tdd-guard/package-lock.json +16937 -0
  84. package/project-skills/tdd-guard/package.json +102 -0
  85. package/project-skills/tdd-guard/reporters/go/README.md +67 -0
  86. package/project-skills/tdd-guard/reporters/go/cmd/tdd-guard-go/main.go +127 -0
  87. package/project-skills/tdd-guard/reporters/go/cmd/tdd-guard-go/main_test.go +280 -0
  88. package/project-skills/tdd-guard/reporters/go/go.mod +3 -0
  89. package/project-skills/tdd-guard/reporters/go/go.sum +0 -0
  90. package/project-skills/tdd-guard/reporters/go/internal/formatter/formatter.go +126 -0
  91. package/project-skills/tdd-guard/reporters/go/internal/formatter/formatter_test.go +264 -0
  92. package/project-skills/tdd-guard/reporters/go/internal/io/tee_reader.go +26 -0
  93. package/project-skills/tdd-guard/reporters/go/internal/io/tee_reader_test.go +37 -0
  94. package/project-skills/tdd-guard/reporters/go/internal/parser/mixed_reader.go +94 -0
  95. package/project-skills/tdd-guard/reporters/go/internal/parser/mixed_reader_test.go +198 -0
  96. package/project-skills/tdd-guard/reporters/go/internal/parser/parser.go +245 -0
  97. package/project-skills/tdd-guard/reporters/go/internal/parser/parser_test.go +547 -0
  98. package/project-skills/tdd-guard/reporters/go/internal/storage/storage.go +35 -0
  99. package/project-skills/tdd-guard/reporters/go/internal/storage/storage_test.go +113 -0
  100. package/project-skills/tdd-guard/reporters/go/internal/transformer/transformer.go +103 -0
  101. package/project-skills/tdd-guard/reporters/go/internal/transformer/transformer_test.go +303 -0
  102. package/project-skills/tdd-guard/reporters/jest/README.md +102 -0
  103. package/project-skills/tdd-guard/reporters/jest/package.json +38 -0
  104. package/project-skills/tdd-guard/reporters/phpunit/.php-cs-fixer.php +28 -0
  105. package/project-skills/tdd-guard/reporters/phpunit/README.md +97 -0
  106. package/project-skills/tdd-guard/reporters/phpunit/SYNC_README.md +29 -0
  107. package/project-skills/tdd-guard/reporters/phpunit/composer.json +55 -0
  108. package/project-skills/tdd-guard/reporters/phpunit/phpunit.xml.dist +19 -0
  109. package/project-skills/tdd-guard/reporters/phpunit/psalm.xml +44 -0
  110. package/project-skills/tdd-guard/reporters/phpunit/src/Event/ErroredTestSubscriber.php +28 -0
  111. package/project-skills/tdd-guard/reporters/phpunit/src/Event/FailedTestSubscriber.php +28 -0
  112. package/project-skills/tdd-guard/reporters/phpunit/src/Event/IncompleteTestSubscriber.php +28 -0
  113. package/project-skills/tdd-guard/reporters/phpunit/src/Event/PassedTestSubscriber.php +27 -0
  114. package/project-skills/tdd-guard/reporters/phpunit/src/Event/SkippedTestSubscriber.php +28 -0
  115. package/project-skills/tdd-guard/reporters/phpunit/src/Event/TestRunnerFinishedSubscriber.php +24 -0
  116. package/project-skills/tdd-guard/reporters/phpunit/src/PathValidator.php +88 -0
  117. package/project-skills/tdd-guard/reporters/phpunit/src/Storage.php +26 -0
  118. package/project-skills/tdd-guard/reporters/phpunit/src/TddGuardExtension.php +33 -0
  119. package/project-skills/tdd-guard/reporters/phpunit/src/TddGuardListener.php +158 -0
  120. package/project-skills/tdd-guard/reporters/phpunit/src/TddGuardSubscriber.php +35 -0
  121. package/project-skills/tdd-guard/reporters/phpunit/src/TestResultCollector.php +105 -0
  122. package/project-skills/tdd-guard/reporters/phpunit/tests/PathValidatorTest.php +74 -0
  123. package/project-skills/tdd-guard/reporters/phpunit/tests/TddGuardExtensionFailedTest.php +241 -0
  124. package/project-skills/tdd-guard/reporters/phpunit/tests/TddGuardExtensionTest.php +84 -0
  125. package/project-skills/tdd-guard/reporters/phpunit/tests/TddGuardStorageLocationTest.php +71 -0
  126. package/project-skills/tdd-guard/reporters/pytest/README.md +77 -0
  127. package/project-skills/tdd-guard/reporters/pytest/pyproject.toml +43 -0
  128. package/project-skills/tdd-guard/reporters/pytest/pytest.ini.example +7 -0
  129. package/project-skills/tdd-guard/reporters/pytest/tdd_guard_pytest/__init__.py +1 -0
  130. package/project-skills/tdd-guard/reporters/pytest/tdd_guard_pytest/pytest_reporter.py +134 -0
  131. package/project-skills/tdd-guard/reporters/pytest/tests/__init__.py +1 -0
  132. package/project-skills/tdd-guard/reporters/pytest/tests/conftest.py +3 -0
  133. package/project-skills/tdd-guard/reporters/pytest/tests/helpers.py +293 -0
  134. package/project-skills/tdd-guard/reporters/pytest/tests/test_config_option.py +38 -0
  135. package/project-skills/tdd-guard/reporters/pytest/tests/test_path_validation.py +59 -0
  136. package/project-skills/tdd-guard/reporters/pytest/tests/test_plugin_config.py +32 -0
  137. package/project-skills/tdd-guard/reporters/pytest/tests/test_project_root.py +296 -0
  138. package/project-skills/tdd-guard/reporters/pytest/tests/test_pytest_reporter.py +137 -0
  139. package/project-skills/tdd-guard/reporters/rspec/Gemfile +3 -0
  140. package/project-skills/tdd-guard/reporters/rust/Cargo.lock +458 -0
  141. package/project-skills/tdd-guard/reporters/rust/Cargo.toml +33 -0
  142. package/project-skills/tdd-guard/reporters/rust/Makefile.example +95 -0
  143. package/project-skills/tdd-guard/reporters/rust/README.md +88 -0
  144. package/project-skills/tdd-guard/reporters/rust/src/error_parser.rs +309 -0
  145. package/project-skills/tdd-guard/reporters/rust/src/main.rs +464 -0
  146. package/project-skills/tdd-guard/reporters/rust/src/parser.rs +225 -0
  147. package/project-skills/tdd-guard/reporters/rust/src/transformer.rs +409 -0
  148. package/project-skills/tdd-guard/reporters/storybook/README.md +108 -0
  149. package/project-skills/tdd-guard/reporters/storybook/package-lock.json +9482 -0
  150. package/project-skills/tdd-guard/reporters/storybook/package.json +43 -0
  151. package/project-skills/tdd-guard/reporters/storybook/src/StorybookReporter.test-data.ts +22 -0
  152. package/project-skills/tdd-guard/reporters/storybook/src/StorybookReporter.test.ts +190 -0
  153. package/project-skills/tdd-guard/reporters/storybook/src/StorybookReporter.ts +88 -0
  154. package/project-skills/tdd-guard/reporters/storybook/src/index.ts +12 -0
  155. package/project-skills/tdd-guard/reporters/storybook/src/types.ts +37 -0
  156. package/project-skills/tdd-guard/reporters/storybook/tsconfig.json +11 -0
  157. package/project-skills/tdd-guard/reporters/test/artifacts/go/failing/go.mod +3 -0
  158. package/project-skills/tdd-guard/reporters/test/artifacts/go/failing/single_failing_test.go +13 -0
  159. package/project-skills/tdd-guard/reporters/test/artifacts/go/import/go.mod +3 -0
  160. package/project-skills/tdd-guard/reporters/test/artifacts/go/import/single_import_error_test.go +17 -0
  161. package/project-skills/tdd-guard/reporters/test/artifacts/go/passing/go.mod +3 -0
  162. package/project-skills/tdd-guard/reporters/test/artifacts/go/passing/single_passing_test.go +13 -0
  163. package/project-skills/tdd-guard/reporters/test/artifacts/jest/single-failing.test.js +5 -0
  164. package/project-skills/tdd-guard/reporters/test/artifacts/jest/single-import-error.test.js +8 -0
  165. package/project-skills/tdd-guard/reporters/test/artifacts/jest/single-passing.test.js +5 -0
  166. package/project-skills/tdd-guard/reporters/test/artifacts/phpunit/SingleFailingTest.php +11 -0
  167. package/project-skills/tdd-guard/reporters/test/artifacts/phpunit/SingleImportErrorTest.php +14 -0
  168. package/project-skills/tdd-guard/reporters/test/artifacts/phpunit/SinglePassingTest.php +11 -0
  169. package/project-skills/tdd-guard/reporters/test/artifacts/pytest/test_single_failing.py +3 -0
  170. package/project-skills/tdd-guard/reporters/test/artifacts/pytest/test_single_import_error.py +6 -0
  171. package/project-skills/tdd-guard/reporters/test/artifacts/pytest/test_single_passing.py +3 -0
  172. package/project-skills/tdd-guard/reporters/test/artifacts/rust/failing/Cargo.lock +7 -0
  173. package/project-skills/tdd-guard/reporters/test/artifacts/rust/failing/Cargo.toml +4 -0
  174. package/project-skills/tdd-guard/reporters/test/artifacts/rust/failing/src/lib.rs +14 -0
  175. package/project-skills/tdd-guard/reporters/test/artifacts/rust/import/Cargo.lock +7 -0
  176. package/project-skills/tdd-guard/reporters/test/artifacts/rust/import/Cargo.toml +4 -0
  177. package/project-skills/tdd-guard/reporters/test/artifacts/rust/import/src/lib.rs +13 -0
  178. package/project-skills/tdd-guard/reporters/test/artifacts/rust/passing/Cargo.lock +7 -0
  179. package/project-skills/tdd-guard/reporters/test/artifacts/rust/passing/Cargo.toml +4 -0
  180. package/project-skills/tdd-guard/reporters/test/artifacts/rust/passing/src/lib.rs +14 -0
  181. package/project-skills/tdd-guard/reporters/test/artifacts/storybook/Calculator.js +4 -0
  182. package/project-skills/tdd-guard/reporters/test/artifacts/storybook/single-failing.stories.js +15 -0
  183. package/project-skills/tdd-guard/reporters/test/artifacts/storybook/single-import-error.stories.js +14 -0
  184. package/project-skills/tdd-guard/reporters/test/artifacts/storybook/single-passing.stories.js +15 -0
  185. package/project-skills/tdd-guard/reporters/test/artifacts/vitest/single-failing.test.js +7 -0
  186. package/project-skills/tdd-guard/reporters/test/artifacts/vitest/single-import-error.test.js +9 -0
  187. package/project-skills/tdd-guard/reporters/test/artifacts/vitest/single-passing.test.js +7 -0
  188. package/project-skills/tdd-guard/reporters/test/factories/go.ts +59 -0
  189. package/project-skills/tdd-guard/reporters/test/factories/helpers.ts +48 -0
  190. package/project-skills/tdd-guard/reporters/test/factories/index.ts +7 -0
  191. package/project-skills/tdd-guard/reporters/test/factories/jest.ts +51 -0
  192. package/project-skills/tdd-guard/reporters/test/factories/phpunit.ts +63 -0
  193. package/project-skills/tdd-guard/reporters/test/factories/pytest.ts +41 -0
  194. package/project-skills/tdd-guard/reporters/test/factories/rust.ts +158 -0
  195. package/project-skills/tdd-guard/reporters/test/factories/storybook.ts +198 -0
  196. package/project-skills/tdd-guard/reporters/test/factories/vitest.ts +51 -0
  197. package/project-skills/tdd-guard/reporters/test/reporters.integration.test.ts +735 -0
  198. package/project-skills/tdd-guard/reporters/test/types.ts +28 -0
  199. package/project-skills/tdd-guard/reporters/vitest/README.md +64 -0
  200. package/project-skills/tdd-guard/reporters/vitest/package.json +35 -0
  201. package/project-skills/tdd-guard/src/cli/buildContext.test.ts +200 -0
  202. package/project-skills/tdd-guard/src/cli/buildContext.ts +48 -0
  203. package/project-skills/tdd-guard/src/cli/tdd-guard.test.ts +159 -0
  204. package/project-skills/tdd-guard/src/cli/tdd-guard.ts +48 -0
  205. package/project-skills/tdd-guard/src/config/Config.test.ts +538 -0
  206. package/project-skills/tdd-guard/src/config/Config.ts +172 -0
  207. package/project-skills/tdd-guard/src/contracts/schemas/guardSchemas.test.ts +58 -0
  208. package/project-skills/tdd-guard/src/contracts/schemas/guardSchemas.ts +8 -0
  209. package/project-skills/tdd-guard/src/contracts/schemas/lintSchemas.test.ts +347 -0
  210. package/project-skills/tdd-guard/src/contracts/schemas/lintSchemas.ts +61 -0
  211. package/project-skills/tdd-guard/src/contracts/schemas/pytestSchemas.test.ts +24 -0
  212. package/project-skills/tdd-guard/src/contracts/schemas/pytestSchemas.ts +7 -0
  213. package/project-skills/tdd-guard/src/contracts/schemas/reporterSchemas.test.ts +377 -0
  214. package/project-skills/tdd-guard/src/contracts/schemas/reporterSchemas.ts +75 -0
  215. package/project-skills/tdd-guard/src/contracts/schemas/toolSchemas.test.ts +563 -0
  216. package/project-skills/tdd-guard/src/contracts/schemas/toolSchemas.ts +140 -0
  217. package/project-skills/tdd-guard/src/contracts/types/ClientType.ts +1 -0
  218. package/project-skills/tdd-guard/src/contracts/types/ConfigOptions.ts +12 -0
  219. package/project-skills/tdd-guard/src/contracts/types/Context.ts +16 -0
  220. package/project-skills/tdd-guard/src/contracts/types/ModelClient.ts +3 -0
  221. package/project-skills/tdd-guard/src/contracts/types/ValidationResult.ts +6 -0
  222. package/project-skills/tdd-guard/src/guard/GuardManager.test.ts +336 -0
  223. package/project-skills/tdd-guard/src/guard/GuardManager.ts +83 -0
  224. package/project-skills/tdd-guard/src/hooks/HookEvents.test.ts +107 -0
  225. package/project-skills/tdd-guard/src/hooks/HookEvents.ts +39 -0
  226. package/project-skills/tdd-guard/src/hooks/fileTypeDetection.ts +16 -0
  227. package/project-skills/tdd-guard/src/hooks/postToolLint.test.ts +327 -0
  228. package/project-skills/tdd-guard/src/hooks/postToolLint.ts +165 -0
  229. package/project-skills/tdd-guard/src/hooks/processHookData.test.ts +465 -0
  230. package/project-skills/tdd-guard/src/hooks/processHookData.ts +203 -0
  231. package/project-skills/tdd-guard/src/hooks/sessionHandler.test.ts +136 -0
  232. package/project-skills/tdd-guard/src/hooks/sessionHandler.ts +31 -0
  233. package/project-skills/tdd-guard/src/hooks/userPromptHandler.test.ts +131 -0
  234. package/project-skills/tdd-guard/src/hooks/userPromptHandler.ts +55 -0
  235. package/project-skills/tdd-guard/src/index.ts +19 -0
  236. package/project-skills/tdd-guard/src/linters/Linter.ts +5 -0
  237. package/project-skills/tdd-guard/src/linters/eslint/ESLint.test.ts +183 -0
  238. package/project-skills/tdd-guard/src/linters/eslint/ESLint.ts +82 -0
  239. package/project-skills/tdd-guard/src/linters/golangci/GolangciLint.test.ts +170 -0
  240. package/project-skills/tdd-guard/src/linters/golangci/GolangciLint.ts +148 -0
  241. package/project-skills/tdd-guard/src/processors/index.ts +1 -0
  242. package/project-skills/tdd-guard/src/processors/lintProcessor.ts +77 -0
  243. package/project-skills/tdd-guard/src/processors/testResults/TestResultsProcessor.test.ts +303 -0
  244. package/project-skills/tdd-guard/src/processors/testResults/TestResultsProcessor.ts +255 -0
  245. package/project-skills/tdd-guard/src/providers/LinterProvider.test.ts +43 -0
  246. package/project-skills/tdd-guard/src/providers/LinterProvider.ts +20 -0
  247. package/project-skills/tdd-guard/src/providers/ModelClientProvider.test.ts +68 -0
  248. package/project-skills/tdd-guard/src/providers/ModelClientProvider.ts +22 -0
  249. package/project-skills/tdd-guard/src/storage/FileStorage.test.ts +76 -0
  250. package/project-skills/tdd-guard/src/storage/FileStorage.ts +108 -0
  251. package/project-skills/tdd-guard/src/storage/MemoryStorage.ts +57 -0
  252. package/project-skills/tdd-guard/src/storage/Storage.test.ts +227 -0
  253. package/project-skills/tdd-guard/src/storage/Storage.ts +17 -0
  254. package/project-skills/tdd-guard/src/validation/context/context.test.ts +364 -0
  255. package/project-skills/tdd-guard/src/validation/context/context.ts +155 -0
  256. package/project-skills/tdd-guard/src/validation/models/AnthropicApi.test.ts +171 -0
  257. package/project-skills/tdd-guard/src/validation/models/AnthropicApi.ts +49 -0
  258. package/project-skills/tdd-guard/src/validation/models/ClaudeAgentSdk.test.ts +167 -0
  259. package/project-skills/tdd-guard/src/validation/models/ClaudeAgentSdk.ts +54 -0
  260. package/project-skills/tdd-guard/src/validation/models/ClaudeCli.test.ts +239 -0
  261. package/project-skills/tdd-guard/src/validation/models/ClaudeCli.ts +57 -0
  262. package/project-skills/tdd-guard/src/validation/prompts/file-types.ts +52 -0
  263. package/project-skills/tdd-guard/src/validation/prompts/operations/edit.ts +58 -0
  264. package/project-skills/tdd-guard/src/validation/prompts/operations/multi-edit.ts +54 -0
  265. package/project-skills/tdd-guard/src/validation/prompts/operations/write.ts +54 -0
  266. package/project-skills/tdd-guard/src/validation/prompts/response.ts +40 -0
  267. package/project-skills/tdd-guard/src/validation/prompts/rules.ts +51 -0
  268. package/project-skills/tdd-guard/src/validation/prompts/system-prompt.ts +10 -0
  269. package/project-skills/tdd-guard/src/validation/prompts/tools/lint-results.ts +15 -0
  270. package/project-skills/tdd-guard/src/validation/prompts/tools/test-output.ts +14 -0
  271. package/project-skills/tdd-guard/src/validation/prompts/tools/todos.ts +9 -0
  272. package/project-skills/tdd-guard/src/validation/validator.test.ts +268 -0
  273. package/project-skills/tdd-guard/src/validation/validator.ts +159 -0
  274. package/project-skills/tdd-guard/test/artifacts/go/.golangci.yml +6 -0
  275. package/project-skills/tdd-guard/test/artifacts/go/with-issues/file-with-issues.go +12 -0
  276. package/project-skills/tdd-guard/test/artifacts/go/with-issues/go.mod +3 -0
  277. package/project-skills/tdd-guard/test/artifacts/go/without-issues/file-without-issues.go +7 -0
  278. package/project-skills/tdd-guard/test/artifacts/go/without-issues/go.mod +3 -0
  279. package/project-skills/tdd-guard/test/artifacts/javascript/eslint.config.js +20 -0
  280. package/project-skills/tdd-guard/test/artifacts/javascript/file-with-issues.js +12 -0
  281. package/project-skills/tdd-guard/test/artifacts/javascript/file-without-issues.js +10 -0
  282. package/project-skills/tdd-guard/test/hooks/fileTypeDetection.test.ts +26 -0
  283. package/project-skills/tdd-guard/test/hooks/processHookData.fileType.test.ts +46 -0
  284. package/project-skills/tdd-guard/test/hooks/processHookData.python.test.ts +68 -0
  285. package/project-skills/tdd-guard/test/integration/test-context.test.ts +66 -0
  286. package/project-skills/tdd-guard/test/integration/validator.core.test.ts +96 -0
  287. package/project-skills/tdd-guard/test/integration/validator.scenarios.test.ts +497 -0
  288. package/project-skills/tdd-guard/test/utils/assertions.ts +29 -0
  289. package/project-skills/tdd-guard/test/utils/factories/contextFactory.ts +30 -0
  290. package/project-skills/tdd-guard/test/utils/factories/editFactory.ts +82 -0
  291. package/project-skills/tdd-guard/test/utils/factories/helpers.test.ts +46 -0
  292. package/project-skills/tdd-guard/test/utils/factories/helpers.ts +46 -0
  293. package/project-skills/tdd-guard/test/utils/factories/lintFactory.ts +352 -0
  294. package/project-skills/tdd-guard/test/utils/factories/modelClientProviderFactory.ts +21 -0
  295. package/project-skills/tdd-guard/test/utils/factories/multiEditFactory.ts +79 -0
  296. package/project-skills/tdd-guard/test/utils/factories/operations.ts +57 -0
  297. package/project-skills/tdd-guard/test/utils/factories/reporterFactory.ts +55 -0
  298. package/project-skills/tdd-guard/test/utils/factories/scenarios/index.ts +22 -0
  299. package/project-skills/tdd-guard/test/utils/factories/scenarios/languages/python.ts +745 -0
  300. package/project-skills/tdd-guard/test/utils/factories/scenarios/languages/typescript.ts +767 -0
  301. package/project-skills/tdd-guard/test/utils/factories/scenarios/types.ts +77 -0
  302. package/project-skills/tdd-guard/test/utils/factories/scenarios/utils.ts +15 -0
  303. package/project-skills/tdd-guard/test/utils/factories/sessionStartFactory.ts +36 -0
  304. package/project-skills/tdd-guard/test/utils/factories/testDefaults.ts +90 -0
  305. package/project-skills/tdd-guard/test/utils/factories/testResultsFactory.ts +234 -0
  306. package/project-skills/tdd-guard/test/utils/factories/todoFactory.ts +99 -0
  307. package/project-skills/tdd-guard/test/utils/factories/userPromptSubmitFactory.ts +39 -0
  308. package/project-skills/tdd-guard/test/utils/factories/writeFactory.ts +70 -0
  309. package/project-skills/tdd-guard/test/utils/index.ts +131 -0
  310. package/project-skills/tdd-guard/tsconfig.build.json +16 -0
  311. package/project-skills/tdd-guard/tsconfig.eslint.json +17 -0
  312. package/project-skills/tdd-guard/tsconfig.json +32 -0
  313. package/project-skills/tdd-guard/tsconfig.node.json +10 -0
  314. package/project-skills/tdd-guard/vitest.config.ts +85 -0
  315. package/project-skills/ts-quality-gate/.claude/hooks/hook-config.json +66 -0
  316. package/project-skills/ts-quality-gate/.claude/hooks/quality-check.cjs +1251 -0
  317. package/project-skills/ts-quality-gate/.claude/settings.json +16 -0
  318. package/project-skills/ts-quality-gate/.claude/skills/using-ts-quality-gate/SKILL.md +81 -0
  319. package/project-skills/ts-quality-gate/README.md +115 -0
  320. package/skills/README.txt +31 -0
  321. package/skills/clean-code/SKILL.md +201 -0
  322. package/skills/delegating/SKILL.md +196 -0
  323. package/skills/delegating/config.yaml +210 -0
  324. package/skills/delegating/references/orchestration-protocols.md +41 -0
  325. package/skills/docker-expert/SKILL.md +409 -0
  326. package/skills/documenting/CHANGELOG.md +23 -0
  327. package/skills/documenting/README.md +148 -0
  328. package/skills/documenting/SKILL.md +113 -0
  329. package/skills/documenting/examples/example_pattern.md +70 -0
  330. package/skills/documenting/examples/example_reference.md +70 -0
  331. package/skills/documenting/examples/example_ssot_analytics.md +64 -0
  332. package/skills/documenting/examples/example_workflow.md +141 -0
  333. package/skills/documenting/references/changelog-format.md +97 -0
  334. package/skills/documenting/references/metadata-schema.md +136 -0
  335. package/skills/documenting/references/taxonomy.md +81 -0
  336. package/skills/documenting/references/versioning-rules.md +78 -0
  337. package/skills/documenting/scripts/__pycache__/drift_detector.cpython-314.pyc +0 -0
  338. package/skills/documenting/scripts/__pycache__/orchestrator.cpython-314.pyc +0 -0
  339. package/skills/documenting/scripts/__pycache__/validate_metadata.cpython-314.pyc +0 -0
  340. package/skills/documenting/scripts/bump_version.sh +60 -0
  341. package/skills/documenting/scripts/changelog/__init__.py +0 -0
  342. package/skills/documenting/scripts/changelog/__pycache__/__init__.cpython-314.pyc +0 -0
  343. package/skills/documenting/scripts/changelog/__pycache__/add_entry.cpython-314.pyc +0 -0
  344. package/skills/documenting/scripts/changelog/__pycache__/bump_release.cpython-314.pyc +0 -0
  345. package/skills/documenting/scripts/changelog/__pycache__/validate_changelog.cpython-314.pyc +0 -0
  346. package/skills/documenting/scripts/changelog/add_entry.py +216 -0
  347. package/skills/documenting/scripts/changelog/bump_release.py +117 -0
  348. package/skills/documenting/scripts/changelog/init_changelog.py +54 -0
  349. package/skills/documenting/scripts/changelog/validate_changelog.py +128 -0
  350. package/skills/documenting/scripts/drift_detector.py +266 -0
  351. package/skills/documenting/scripts/generate_template.py +311 -0
  352. package/skills/documenting/scripts/list_by_category.sh +84 -0
  353. package/skills/documenting/scripts/orchestrator.py +255 -0
  354. package/skills/documenting/scripts/validate_metadata.py +242 -0
  355. package/skills/documenting/templates/CHANGELOG.md.template +13 -0
  356. package/skills/documenting/tests/__pycache__/test_changelog.cpython-314-pytest-9.0.2.pyc +0 -0
  357. package/skills/documenting/tests/__pycache__/test_drift_detector.cpython-314-pytest-9.0.2.pyc +0 -0
  358. package/skills/documenting/tests/__pycache__/test_orchestrator.cpython-314-pytest-9.0.2.pyc +0 -0
  359. package/skills/documenting/tests/__pycache__/test_validate_metadata.cpython-314-pytest-9.0.2.pyc +0 -0
  360. package/skills/documenting/tests/integration_test.sh +70 -0
  361. package/skills/documenting/tests/test_changelog.py +201 -0
  362. package/skills/documenting/tests/test_drift_detector.py +80 -0
  363. package/skills/documenting/tests/test_orchestrator.py +52 -0
  364. package/skills/documenting/tests/test_validate_metadata.py +64 -0
  365. package/skills/find-skills/SKILL.md +133 -0
  366. package/skills/gitnexus-debugging/SKILL.md +85 -0
  367. package/skills/gitnexus-exploring/SKILL.md +75 -0
  368. package/skills/gitnexus-impact-analysis/SKILL.md +94 -0
  369. package/skills/gitnexus-refactoring/SKILL.md +113 -0
  370. package/skills/hook-development/SKILL.md +797 -0
  371. package/skills/hook-development/examples/load-context.sh +55 -0
  372. package/skills/hook-development/examples/quality-check.js +1168 -0
  373. package/skills/hook-development/examples/validate-bash.sh +43 -0
  374. package/skills/hook-development/examples/validate-write.sh +38 -0
  375. package/skills/hook-development/references/advanced.md +527 -0
  376. package/skills/hook-development/references/migration.md +369 -0
  377. package/skills/hook-development/references/patterns.md +412 -0
  378. package/skills/hook-development/scripts/README.md +164 -0
  379. package/skills/hook-development/scripts/hook-linter.sh +153 -0
  380. package/skills/hook-development/scripts/test-hook.sh +252 -0
  381. package/skills/hook-development/scripts/validate-hook-schema.sh +159 -0
  382. package/skills/obsidian-cli/SKILL.md +106 -0
  383. package/skills/orchestrating-agents/SKILL.md +135 -0
  384. package/skills/orchestrating-agents/config.yaml +45 -0
  385. package/skills/orchestrating-agents/references/agent-context-integration.md +37 -0
  386. package/skills/orchestrating-agents/references/examples.md +45 -0
  387. package/skills/orchestrating-agents/references/handover-protocol.md +31 -0
  388. package/skills/orchestrating-agents/references/workflows.md +42 -0
  389. package/skills/orchestrating-agents/scripts/detect_neighbors.py +23 -0
  390. package/skills/prompt-improving/README.md +162 -0
  391. package/skills/prompt-improving/SKILL.md +74 -0
  392. package/skills/prompt-improving/references/analysis_commands.md +24 -0
  393. package/skills/prompt-improving/references/chain_of_thought.md +24 -0
  394. package/skills/prompt-improving/references/mcp_definitions.md +20 -0
  395. package/skills/prompt-improving/references/multishot.md +23 -0
  396. package/skills/prompt-improving/references/xml_core.md +60 -0
  397. package/skills/python-testing/SKILL.md +815 -0
  398. package/skills/senior-backend/SKILL.md +209 -0
  399. package/skills/senior-backend/references/api_design_patterns.md +103 -0
  400. package/skills/senior-backend/references/backend_security_practices.md +103 -0
  401. package/skills/senior-backend/references/database_optimization_guide.md +103 -0
  402. package/skills/senior-backend/scripts/api_load_tester.py +114 -0
  403. package/skills/senior-backend/scripts/api_scaffolder.py +114 -0
  404. package/skills/senior-backend/scripts/database_migration_tool.py +114 -0
  405. package/skills/senior-data-scientist/SKILL.md +226 -0
  406. package/skills/senior-data-scientist/references/experiment_design_frameworks.md +80 -0
  407. package/skills/senior-data-scientist/references/feature_engineering_patterns.md +80 -0
  408. package/skills/senior-data-scientist/references/statistical_methods_advanced.md +80 -0
  409. package/skills/senior-data-scientist/scripts/experiment_designer.py +100 -0
  410. package/skills/senior-data-scientist/scripts/feature_engineering_pipeline.py +100 -0
  411. package/skills/senior-data-scientist/scripts/model_evaluation_suite.py +100 -0
  412. package/skills/senior-devops/SKILL.md +209 -0
  413. package/skills/senior-devops/references/cicd_pipeline_guide.md +103 -0
  414. package/skills/senior-devops/references/deployment_strategies.md +103 -0
  415. package/skills/senior-devops/references/infrastructure_as_code.md +103 -0
  416. package/skills/senior-devops/scripts/deployment_manager.py +114 -0
  417. package/skills/senior-devops/scripts/pipeline_generator.py +114 -0
  418. package/skills/senior-devops/scripts/terraform_scaffolder.py +114 -0
  419. package/skills/senior-security/SKILL.md +209 -0
  420. package/skills/senior-security/references/cryptography_implementation.md +103 -0
  421. package/skills/senior-security/references/penetration_testing_guide.md +103 -0
  422. package/skills/senior-security/references/security_architecture_patterns.md +103 -0
  423. package/skills/senior-security/scripts/pentest_automator.py +114 -0
  424. package/skills/senior-security/scripts/security_auditor.py +114 -0
  425. package/skills/senior-security/scripts/threat_modeler.py +114 -0
  426. package/skills/skill-creator/LICENSE.txt +202 -0
  427. package/skills/skill-creator/SKILL.md +479 -0
  428. package/skills/skill-creator/agents/analyzer.md +274 -0
  429. package/skills/skill-creator/agents/comparator.md +202 -0
  430. package/skills/skill-creator/agents/grader.md +223 -0
  431. package/skills/skill-creator/assets/eval_review.html +146 -0
  432. package/skills/skill-creator/eval-viewer/generate_review.py +471 -0
  433. package/skills/skill-creator/eval-viewer/viewer.html +1325 -0
  434. package/skills/skill-creator/references/schemas.md +430 -0
  435. package/skills/skill-creator/scripts/__init__.py +0 -0
  436. package/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
  437. package/skills/skill-creator/scripts/generate_report.py +326 -0
  438. package/skills/skill-creator/scripts/improve_description.py +248 -0
  439. package/skills/skill-creator/scripts/package_skill.py +136 -0
  440. package/skills/skill-creator/scripts/quick_validate.py +103 -0
  441. package/skills/skill-creator/scripts/run_eval.py +310 -0
  442. package/skills/skill-creator/scripts/run_loop.py +332 -0
  443. package/skills/skill-creator/scripts/utils.py +47 -0
  444. package/skills/using-TDD/SKILL.md +410 -0
  445. package/skills/using-serena-lsp/README.md +8 -0
  446. package/skills/using-serena-lsp/REFERENCE.md +194 -0
  447. package/skills/using-serena-lsp/SKILL.md +82 -0
@@ -0,0 +1,412 @@
1
+ # Script Quality Standards for Service Skills
2
+
3
+ > Distilled from the mercury-market-data implementation (Feb 2026).
4
+ > Updated with lessons from the processing-papers implementation (Feb 2026).
5
+ > Apply these standards to every script generated in Phase 2 of the service-skill-builder workflow.
6
+
7
+ ---
8
+
9
+ ## Mandatory DB Connection Pattern
10
+
11
+ **Every script that touches the database MUST use this exact pattern.** No exceptions.
12
+
13
+ ```python
14
+ #!/usr/bin/env python3
15
+ import sys
16
+ from pathlib import Path
17
+ from dotenv import load_dotenv
18
+
19
+ # Resolve project root (depth depends on script location within .claude/skills/)
20
+ project_root = Path(__file__).resolve().parent.parent.parent.parent.parent
21
+ env_file = project_root / ".env"
22
+ if env_file.exists():
23
+ load_dotenv(str(env_file))
24
+
25
+ sys.path.insert(0, str(project_root))
26
+ from shared.db_pool_manager import execute_db_query
27
+ ```
28
+
29
+ **Why:** System `python3` may lack `dotenv` and project deps. Always test with `venv/bin/python3`.
30
+ **Never:** Raw `psycopg2`, hardcoded DSN strings, or skipping the `load_dotenv` call.
31
+
32
+ ---
33
+
34
+ ## Schema Verification Before Writing Any SQL
35
+
36
+ Run these queries against the live DB **before** writing any script SQL. Paste the results
37
+ into the delegation prompt so the agent never guesses column or table names.
38
+
39
+ ```sql
40
+ -- Step 1: Confirm which tables actually exist
41
+ SELECT tablename FROM pg_tables WHERE schemaname = 'public' ORDER BY tablename;
42
+
43
+ -- Step 2: For each output table — get exact column names and types
44
+ SELECT column_name, data_type, is_nullable
45
+ FROM information_schema.columns
46
+ WHERE table_name = '<your_table>'
47
+ ORDER BY ordinal_position;
48
+ ```
49
+
50
+ **Critical rule:** If a table has no timestamp column, use `COUNT(*)` for freshness checks —
51
+ never guess a column name. Verify with `information_schema.columns` first.
52
+
53
+ ---
54
+
55
+ ## Makefile Standard
56
+
57
+ Every `scripts/` directory MUST contain a `Makefile` with these standard targets.
58
+ This is auto-generated by the scaffolder in Phase 1 and should be updated in Phase 2
59
+ to add any service-specific targets.
60
+
61
+ ```makefile
62
+ # Skill diagnostic scripts for <service-id>
63
+ # Usage: make <target> (from this directory)
64
+ # Override python: make health PYTHON=../../venv/bin/python3
65
+
66
+ PYTHON := python3
67
+
68
+ .PHONY: health health-json data data-json logs errors db help
69
+
70
+ help:
71
+ @echo "Available targets:"
72
+ @echo " health - Run health probe (human readable)"
73
+ @echo " health-json - Run health probe (JSON output)"
74
+ @echo " data - Show latest DB records"
75
+ @echo " data-json - Show latest DB records (JSON, limit 5)"
76
+ @echo " logs - Tail and analyze recent logs"
77
+ @echo " errors - Show errors/criticals only"
78
+ @echo " db - Run DB helper example queries"
79
+
80
+ health:
81
+ $(PYTHON) health_probe.py
82
+
83
+ health-json:
84
+ $(PYTHON) health_probe.py --json
85
+
86
+ data:
87
+ $(PYTHON) data_explorer.py
88
+
89
+ data-json:
90
+ $(PYTHON) data_explorer.py --json --limit 5
91
+
92
+ logs:
93
+ $(PYTHON) log_hunter.py --tail 50
94
+
95
+ errors:
96
+ $(PYTHON) log_hunter.py --errors-only --tail 50
97
+
98
+ db:
99
+ $(PYTHON) db_helper.py
100
+ ```
101
+
102
+ ---
103
+
104
+ ## Design Principles
105
+
106
+ ### 1. Service-Specific, Not Generic
107
+
108
+ The single most important rule. Generic scripts provide zero value.
109
+
110
+ **Wrong (generic stub output):**
111
+ ```python
112
+ error_patterns = [
113
+ r"(ERROR|CRITICAL|FATAL|EXCEPTION)",
114
+ r"ConnectionError",
115
+ r"SyntaxError",
116
+ r"ImportError",
117
+ ]
118
+ ```
119
+
120
+ **Right (service-specific, sourced from actual codebase):**
121
+ ```python
122
+ PATTERNS = [
123
+ # From yfinance source: actual exception class names
124
+ ("Rate limit", r"YFRateLimitError|429.*yahoo|Too Many Requests", "error"),
125
+ ("Missing data", r"YFPricesMissingError|no timezone found|Period.*invalid", "warning"),
126
+ # From DB layer: actual psycopg2 messages
127
+ ("DB connect", r"could not connect|password authentication failed", "critical"),
128
+ ("DB write", r"relation.*does not exist|column.*does not exist", "error"),
129
+ ]
130
+ ```
131
+
132
+ **How to find real patterns:** Read the service's entry point script, exception handlers, and log statements. Search for `logger.error`, `raise`, `except` blocks, and error message strings.
133
+
134
+ ---
135
+
136
+ ### 2. Port Awareness: Host vs. Container
137
+
138
+ Scripts in `skills/` run on the host machine, not inside Docker. Port mappings matter.
139
+
140
+ | Context | Use This Port |
141
+ |---------|--------------|
142
+ | Host scripts (`skills/*.py`) | External mapped port (e.g., `5433` for TimescaleDB `5433:5432`) |
143
+ | Docker service env vars | Internal port (`5432`) |
144
+ | `docker exec` commands | N/A — resolves via container DNS |
145
+
146
+ **Always use env vars with correct defaults:**
147
+ ```python
148
+ DB_HOST = os.getenv("DB_HOST", "localhost")
149
+ DB_PORT = int(os.getenv("DB_PORT", "5433")) # External mapped port
150
+ ```
151
+
152
+ ---
153
+
154
+ ### 3. Read-Before-Write Discipline
155
+
156
+ When a stub file already exists and you are replacing it, **always read it first**. Write tools fail with "File has not been read yet" otherwise. New files (no existing content) can be created directly.
157
+
158
+ ---
159
+
160
+ ### 4. Dual Output Mode
161
+
162
+ Every script must support both human-readable (default) and machine-readable (`--json`) output.
163
+
164
+ ```python
165
+ parser.add_argument("--json", action="store_true", help="Output as JSON")
166
+
167
+ if args.json:
168
+ print(json.dumps(result, indent=2, default=str))
169
+ return
170
+ # ... human-readable output below
171
+ ```
172
+
173
+ ---
174
+
175
+ ### 5. Actionable Remediation in Output
176
+
177
+ When a health probe or log hunter detects a critical problem, it must print the exact fix command — not a generic "check the logs."
178
+
179
+ ```python
180
+ if by_sev["critical"]:
181
+ print(f"\n ⚠ Critical issues detected.")
182
+ if any("OAuth expired" in h["labels"] for h in by_sev["critical"]):
183
+ print(f" Fix: docker exec -it {CONTAINER} python scripts/auth.py --refresh")
184
+ if any("DB connect" in h["labels"] for h in by_sev["critical"]):
185
+ print(f" Fix: docker compose restart timescaledb && docker compose restart {CONTAINER}")
186
+ ```
187
+
188
+ ---
189
+
190
+ ## health_probe.py Standards
191
+
192
+ ### Structure
193
+
194
+ ```python
195
+ CONTAINER = "service-name" # Exact Docker container name
196
+
197
+ def check_container() -> dict:
198
+ """docker inspect for status. Always present."""
199
+ ...
200
+
201
+ def check_<domain>() -> dict:
202
+ """Service-specific check (DB freshness, file presence, HTTP endpoint, etc.)"""
203
+ ...
204
+
205
+ def main():
206
+ # 1. Collect all checks
207
+ # 2. --json: dump report dict
208
+ # 3. Human: print formatted table
209
+ # 4. Print fix commands on failure
210
+ ```
211
+
212
+ ### For DB-writing services: Freshness Table
213
+
214
+ ```python
215
+ # Define per-table stale thresholds based on service update frequency
216
+ FRESHNESS_CHECKS = [
217
+ # (table_name, timestamp_col, stale_threshold_minutes)
218
+ ("candles_5m", "timestamp", 30), # 5m feed → stale if >30m old
219
+ ("outright_snapshots", "snapshot_ts", 10), # continuous → stale if >10m old
220
+ ("volatility_snapshots","snapshot_ts", 1500), # daily job → stale if >25h old
221
+ ]
222
+ ```
223
+
224
+ Stale threshold logic: `update_interval × 3` is a reasonable default, but adjust for business criticality.
225
+
226
+ ### For HTTP API services: Endpoint Probing
227
+
228
+ Do not ping generic ports. Probe the actual API routes the service exposes:
229
+
230
+ ```python
231
+ HEALTH_ENDPOINTS = [
232
+ ("FastAPI health", "http://localhost:8000/api/system/health", 3),
233
+ ("Background server", "http://localhost:5002/health", 2),
234
+ ]
235
+ # Optional smoke tests against real data endpoints
236
+ SMOKE_ENDPOINTS = [
237
+ ("Market snapshot", "http://localhost:8000/api/market/snapshot"),
238
+ ("Volatility data", "http://localhost:8000/api/analytics/volatility"),
239
+ ]
240
+ ```
241
+
242
+ ### For one-shot services (migrations, backfills): Exit Code
243
+
244
+ ```python
245
+ # docker inspect returns status="exited" and exit_code="0" on success
246
+ result = subprocess.run(
247
+ ["docker", "inspect", "--format",
248
+ "{{.State.Status}} {{.State.ExitCode}} {{.State.FinishedAt}}",
249
+ CONTAINER],
250
+ capture_output=True, text=True
251
+ )
252
+ ```
253
+
254
+ A one-shot service is healthy if `exit_code == "0"` and expected tables/schemas exist in the DB.
255
+
256
+ ### For file watcher services: Mount + State File
257
+
258
+ ```python
259
+ def check_scid_mount() -> dict:
260
+ result = subprocess.run(
261
+ ["docker", "exec", CONTAINER, "ls", "/data/scid"],
262
+ capture_output=True, text=True, timeout=10
263
+ )
264
+ files = [f for f in result.stdout.splitlines() if f.endswith(".scid")]
265
+ return {"accessible": result.returncode == 0, "file_count": len(files)}
266
+
267
+ def check_state_file() -> dict:
268
+ result = subprocess.run(
269
+ ["docker", "exec", CONTAINER, "cat", "/app/state/watcher_state.json"],
270
+ capture_output=True, text=True
271
+ )
272
+ if result.returncode != 0:
273
+ return {"present": False}
274
+ return {"present": True, "state": json.loads(result.stdout)}
275
+ ```
276
+
277
+ ---
278
+
279
+ ## log_hunter.py Standards
280
+
281
+ ### Pattern Structure
282
+
283
+ ```python
284
+ PATTERNS = [
285
+ # (label, regex_pattern, severity)
286
+ ("OAuth expired", r"invalid_grant|token.*expired", "critical"),
287
+ ("PDF parse", r"PdfReadError|pdf.*format.*changed", "error"),
288
+ ("No data", r"No new.*report|0 reports.*found", "warning"),
289
+ ("Report saved", r"report.*ingested|saved.*DB", "info"),
290
+ ]
291
+ ```
292
+
293
+ **Severity levels:**
294
+ - `critical`: Service needs restart or manual intervention to recover
295
+ - `error`: Functionality is impaired, data may be incomplete
296
+ - `warning`: Degraded state, worth monitoring
297
+ - `info`: Normal operation confirmation
298
+
299
+ ### Severity Ordering
300
+
301
+ Always use `sev_order` so that the highest severity "wins" when a line matches multiple patterns:
302
+
303
+ ```python
304
+ sev_order = {"critical": 0, "error": 1, "warning": 2, "info": 3}
305
+ if matched_severity is None or sev_order[severity] < sev_order[matched_severity]:
306
+ matched_severity = severity
307
+ ```
308
+
309
+ ### Required CLI Flags
310
+
311
+ ```python
312
+ parser.add_argument("--tail", type=int, default=200)
313
+ parser.add_argument("--since", type=str, default=None) # Docker --since (e.g. "1h", "2026-01-01")
314
+ parser.add_argument("--errors-only", action="store_true") # Skip info entries
315
+ parser.add_argument("--json", action="store_true")
316
+ ```
317
+
318
+ ### Pattern Design Rules
319
+
320
+ 1. Test patterns against the **actual log format** of the service, not hypothetical messages.
321
+ 2. Use `re.IGNORECASE` — log levels and messages vary in capitalization.
322
+ 3. Prefer specific class names (`YFPricesMissingError`) over generic keywords (`Error`).
323
+ 4. For Rust services, add: `r"thread '.*' panicked|panicked at '"` as a critical pattern.
324
+ 5. Always include at least 2 `info` patterns for normal operation confirmation — so the absence of info lines itself becomes a signal.
325
+
326
+ ### Anti-patterns to avoid
327
+
328
+ | Anti-pattern | Why It Fails |
329
+ |---|---|
330
+ | `r"ERROR"` | Matches comment text, variable names, and dozens of false positives |
331
+ | `r"Exception"` | Too broad — every Python `try/except` emits this |
332
+ | `r"ConnectionError"` | Only catches one subclass; misses `OperationalError`, `InterfaceError`, etc. |
333
+ | Single `error_patterns` list without severity | Provides no triage — everything looks equally bad |
334
+
335
+ ---
336
+
337
+ ## Specialist Script Standards
338
+
339
+ ### data_explorer.py (for DB-writing services)
340
+
341
+ Purpose: Let an agent query the service's output tables interactively without writing SQL.
342
+
343
+ ```python
344
+ # Always support:
345
+ parser.add_argument("--symbol", help="Filter to a specific symbol")
346
+ parser.add_argument("--history", action="store_true", help="Show time series, not just latest")
347
+ parser.add_argument("--limit", type=int, default=20)
348
+ parser.add_argument("--json", action="store_true")
349
+ ```
350
+
351
+ Use `DISTINCT ON (symbol) ... ORDER BY symbol, timestamp DESC` for "latest per symbol" queries. Use parameterized queries: `WHERE symbol = %s`.
352
+
353
+ ### endpoint_tester.py (for HTTP API services)
354
+
355
+ Test every real route in the API, not just `/health`. Measure response time and size:
356
+
357
+ ```python
358
+ ENDPOINTS = [
359
+ # (label, method, path, expected_status, timeout_s)
360
+ ("Health check", "GET", "/api/system/health", 200, 3),
361
+ ("Market overview", "GET", "/api/market/overview", 200, 5),
362
+ ("Symbol detail", "GET", "/api/market/ES=F", 200, 5),
363
+ # ... all actual routes
364
+ ]
365
+ ```
366
+
367
+ Report slow endpoints (>2s) separately from failed ones.
368
+
369
+ ### state_inspector.py (for stateful file watchers)
370
+
371
+ Read the state file via `docker exec` and compute lag between current file size and processed byte offset:
372
+
373
+ ```python
374
+ scid_size = get_file_size_in_container(container, filepath)
375
+ lag_bytes = scid_size - state["byte_offset"]
376
+ lag_flag = " ⚠" if lag_bytes > 1_000_000 else ""
377
+ ```
378
+
379
+ ### coverage_checker.py (for one-shot backfill services)
380
+
381
+ Report per-entity (spread, symbol, etc.) row counts, date ranges, and gaps:
382
+
383
+ ```sql
384
+ SELECT entity_id, COUNT(*) AS rows,
385
+ MIN(ts) AS earliest, MAX(ts) AS latest
386
+ FROM output_table
387
+ GROUP BY entity_id ORDER BY entity_id;
388
+ ```
389
+
390
+ Also detect missing entities against a known expected list, and find time-series gaps using `LAG()`.
391
+
392
+ ---
393
+
394
+ ## Common Pitfalls
395
+
396
+ | Pitfall | Prevention |
397
+ |---------|-----------|
398
+ | Script uses port 5432 from host | Default to 5433 (external mapped port); document the discrepancy |
399
+ | Script uses HTTP port scanning instead of real routes | Read docker-compose to find actual port mappings; check the service's API routes |
400
+ | OAuth token path is wrong | `docker exec container ls /expected/path` to verify before hardcoding |
401
+ | **DB table name is guessed** | Run `SELECT tablename FROM pg_tables WHERE schemaname='public'` first; include output in delegation prompt |
402
+ | **DB column name is guessed** | Run `SELECT column_name, data_type FROM information_schema.columns WHERE table_name='X'` per table; include in delegation prompt |
403
+ | **Assumed timestamp column on every table** | Check `information_schema.columns` — if no timestamp exists, use `COUNT(*)` for freshness; never guess |
404
+ | `try` block with no matching `except` | Every DB call needs a complete `try/except`; bare `try` blocks crash silently |
405
+ | Function renamed but call sites not updated | After any rename, grep the scripts dir for the old name before finishing |
406
+ | Delegation with no `-y` flag (Qwen) | Qwen requires `-y` for non-interactive file writes; without it, research happens but no files are written |
407
+ | Using `ccs gemini` instead of `gemini -p` | Gemini: `gemini -p "..."` · Qwen: `qwen -y "..."` · GLM: `env -u CLAUDECODE ccs glm -p "..."` |
408
+ | Scripts tested with system python3 | Always test with `venv/bin/python3`; system python may lack dotenv and other deps |
409
+ | Log patterns too broad | Read the actual `logger.error()` calls in the source code |
410
+ | Missing `--since` flag | Log hunters without `--since` can't be used for incremental monitoring |
411
+ | `health_probe.py` doesn't print fix commands | Always add actionable remediation text after detecting critical states |
412
+ | No `scripts/Makefile` | Every skill must have a Makefile with standard targets; scaffolder generates it in Phase 1 |
@@ -0,0 +1,264 @@
1
+ # Service Skill System: Architecture & Operations Guide
2
+
3
+ > Distilled from real-world Docker microservices projects.
4
+ > This guide is project-agnostic — adapt all examples to your stack.
5
+
6
+ ---
7
+
8
+ ## 1. System Overview
9
+
10
+ The **Service Skill System** transforms an AI agent from a generic assistant into a service-aware operator. Each Docker service in your project gets a dedicated **skill package**: a structured combination of operational documentation and executable diagnostic scripts.
11
+
12
+ ### What a Skill Provides
13
+
14
+ | Layer | Contents | Purpose |
15
+ |-------|----------|---------|
16
+ | `SKILL.md` | Operational manual | How the service works, how to debug it |
17
+ | `scripts/health_probe.py` | Container + data freshness checks | Is the service healthy right now? |
18
+ | `scripts/log_hunter.py` | Pattern-based log analysis | What is the service logging and why? |
19
+ | `scripts/<specialist>.py` | Service-specific inspector | What state does this service hold? |
20
+
21
+ Without scripts, a skill is documentation only. Without documentation, scripts have no context. Both are required.
22
+
23
+ ---
24
+
25
+ ## 2. System Architecture
26
+
27
+ ### Three Components
28
+
29
+ **A. The Builder (`service-skill-builder`)**
30
+ The meta-skill that generates other skills.
31
+ - **Input**: `docker-compose*.yml`, Dockerfiles, entry-point source code
32
+ - **Engine**: `scripts/main.py` (Phase 1 skeleton generator)
33
+ - **Output**: `SKILL.md`, `REFINEMENT_BRIEF.md`, stub scripts → then replaced in Phase 2
34
+
35
+ **B. The Health Checker (`scripts/skill_health_check.py`)**
36
+ Detects drift between skills and the live codebase.
37
+ - Compares service modification timestamps vs. skill generation timestamps
38
+ - Identifies services with no skill (coverage gaps)
39
+ - Reports stale skills needing a re-dive
40
+
41
+ **C. The Generated Skills**
42
+ Individual packages per service (e.g., `.claude/skills/my-service/`).
43
+
44
+ ---
45
+
46
+ ## 3. Mandatory Two-Phase Workflow
47
+
48
+ **Phase 1 and Phase 2 are both required. The skeleton alone is never sufficient.**
49
+
50
+ ### Phase 1: Automated Skeleton
51
+
52
+ Run the generator against your project root:
53
+
54
+ ```bash
55
+ # Discover all Docker services
56
+ python3 .claude/skills/service-skill-builder/scripts/main.py --scan
57
+
58
+ # Generate skeleton for one service
59
+ python3 .claude/skills/service-skill-builder/scripts/main.py <service-name>
60
+ ```
61
+
62
+ The skeleton provides:
63
+ - Structural facts: port mappings, env var names, image names, volumes
64
+ - `REFINEMENT_BRIEF.md` listing every open question
65
+ - Generic stub scripts (placeholder only — **must be replaced**)
66
+
67
+ **The skeleton cannot tell you:**
68
+ - What the service actually writes to the database (column names, stale thresholds)
69
+ - What real error messages look like in the logs
70
+ - What "healthy" vs. "degraded" vs. "failed" looks like
71
+ - What exact commands fix common failures
72
+
73
+ ### Phase 2: Agentic Deep Dive
74
+
75
+ Read the source code. Answer every question in `REFINEMENT_BRIEF.md` using `Grep`, `Glob`, `Read`, and Serena LSP tools. Do not guess. Do not leave placeholders.
76
+
77
+ **Mandatory investigation areas:**
78
+
79
+ #### Container & Runtime
80
+ - What is the exact entry point? (Dockerfile CMD + docker-compose `command:`)
81
+ - Is this a long-running daemon, a cron job, or a one-shot? → determines health strategy
82
+ - Which env vars cause a crash if missing? Which are optional?
83
+ - What volumes does it read from? Write to?
84
+ - What is the restart policy and why?
85
+
86
+ #### Data Layer
87
+ - Which tables does it write? Which does it only read?
88
+ - What is the timestamp column for each output table (`created_at`, `snapshot_ts`, `asof_ts`, etc.)?
89
+ - What is a realistic "stale" threshold in minutes per table? (Rule of thumb: update_interval × 3)
90
+ - Does it use Redis, S3, local files, or other external state?
91
+ - Are queries parameterized? (Check `%s`, `%(name)s`, `?` patterns — never f-strings in SQL)
92
+
93
+ #### Failure Modes
94
+ Build this table with ≥5 rows from code comments, exception handlers, and READMEs:
95
+
96
+ | Symptom | Likely Cause | Resolution |
97
+ |---------|-------------|------------|
98
+ | (what you see in logs or alerts) | (root cause) | (exact docker/shell command to fix) |
99
+
100
+ #### Log Patterns
101
+ Search for `logger.error`, `logger.warning`, `raise`, `except`, and `panic!` in the source:
102
+ - What appears in logs during normal healthy operation? (→ `info` patterns)
103
+ - What appears during recoverable errors? (→ `warning` / `error` patterns)
104
+ - What appears during critical failures requiring restart? (→ `critical` patterns)
105
+ - For Rust services: what does a panic look like? (`thread '.*' panicked`)
106
+
107
+ ---
108
+
109
+ ## 4. Service Type Classification
110
+
111
+ Classify before writing scripts. The service type determines which scripts to write beyond the baseline `health_probe.py` and `log_hunter.py`.
112
+
113
+ | Service Type | Health Probe Strategy | Specialist Script |
114
+ |---|---|---|
115
+ | **Continuous DB writer** | Table freshness (age of most recent row per table) | `data_explorer.py` |
116
+ | **HTTP API server** | HTTP probe against real routes (not just port scan) | `endpoint_tester.py` |
117
+ | **One-shot / migration** | Container exit code + expected tables/schemas present | `coverage_checker.py` |
118
+ | **File watcher** | Mount path accessible + state file present + DB recency | `state_inspector.py` |
119
+ | **Email / API poller** | Container running + auth token file present | service-specific |
120
+ | **Scheduled backup** | Recent backup files in staging dir + daemon running | service-specific |
121
+ | **MCP stdio server** | Data source freshness in DB (no HTTP to probe) | service-specific |
122
+
123
+ ---
124
+
125
+ ## 5. Directory Structure
126
+
127
+ ```
128
+ .claude/skills/
129
+ ├── service-skill-builder/ # Meta-skill (system core)
130
+ │ ├── SKILL.md
131
+ │ ├── references/
132
+ │ │ ├── service_skill_system_guide.md # This file
133
+ │ │ └── script_quality_standards.md # Script design rules
134
+ │ └── scripts/
135
+ │ ├── main.py # Phase 1 skeleton generator
136
+ │ ├── skill_health_check.py # Drift detection
137
+ │ ├── discovery.py # Docker Compose parser
138
+ │ ├── analysis.py # AST/regex code analyzer
139
+ │ ├── devops_audit.py # CI/CD/observability audit
140
+ │ └── generator.py # Skill file generation logic
141
+
142
+ ├── my-service-a/ # Generated skill (long-running daemon)
143
+ │ ├── SKILL.md
144
+ │ └── scripts/
145
+ │ ├── health_probe.py # Container + DB freshness checks
146
+ │ ├── log_hunter.py # Pattern-matched log analysis
147
+ │ └── data_explorer.py # Query output tables interactively
148
+
149
+ ├── my-service-b/ # Generated skill (HTTP API)
150
+ │ ├── SKILL.md
151
+ │ └── scripts/
152
+ │ ├── health_probe.py
153
+ │ ├── log_hunter.py
154
+ │ └── endpoint_tester.py # Probe all real API routes
155
+
156
+ └── my-service-c/ # Generated skill (file watcher)
157
+ ├── SKILL.md
158
+ └── scripts/
159
+ ├── health_probe.py
160
+ ├── log_hunter.py
161
+ └── state_inspector.py # Read state file, compute lag
162
+ ```
163
+
164
+ Agent mirrors — always sync after creating or updating skills:
165
+
166
+ ```bash
167
+ for d in .claude/skills/my-*/; do
168
+ svc=$(basename "$d")
169
+ cp -r "$d" ".agent/skills/$svc/"
170
+ cp -r "$d" ".gemini/skills/$svc/"
171
+ done
172
+ ```
173
+
174
+ ---
175
+
176
+ ## 6. Skill Lifecycle
177
+
178
+ ### When to Generate a Skill
179
+ - A new Docker service is added to the project
180
+ - An existing service is significantly refactored
181
+
182
+ ### When to Update a Skill
183
+ - The service's database schema changes
184
+ - New error conditions are added to the code
185
+ - The entry point or restart policy changes
186
+ - The health check script's stale thresholds no longer reflect reality
187
+
188
+ ### Detecting Drift
189
+
190
+ ```bash
191
+ # Check all skills for staleness
192
+ python3 .claude/skills/service-skill-builder/scripts/skill_health_check.py --all
193
+ ```
194
+
195
+ Output example:
196
+ ```
197
+ my-service-a: HEALTHY
198
+ my-service-b: STALE (service code modified 2026-01-15, skill generated 2025-11-01)
199
+ my-service-c: MISSING (no skill exists)
200
+ ```
201
+
202
+ A skill is **STALE** when the service's source code or docker-compose definition has been modified more recently than the skill was generated. This is a signal to re-run Phase 2 for the affected service.
203
+
204
+ ---
205
+
206
+ ## 7. Quality Gates
207
+
208
+ A skill is **complete** (not draft) when all of the following are true:
209
+
210
+ - [ ] No `[PENDING RESEARCH]` markers remain in SKILL.md
211
+ - [ ] All stub scripts have been replaced with service-specific implementations
212
+ - [ ] `health_probe.py` queries actual output tables with correct stale thresholds
213
+ - [ ] `log_hunter.py` patterns are sourced from the real codebase (not invented)
214
+ - [ ] At least one specialist script exists if the service has unique inspectable state
215
+ - [ ] The Troubleshooting table has ≥5 rows based on real failure modes
216
+ - [ ] All CLI commands in SKILL.md are verified against the actual docker-compose config
217
+ - [ ] Scripts have been synced to `.agent/skills/` and `.gemini/skills/` mirrors
218
+
219
+ ---
220
+
221
+ ## 8. Best Practices
222
+
223
+ ### One Service, One Skill
224
+ Keep skills granular. A skill for `my-api` should not also document `my-worker`. Tightly coupled services (e.g., Redis master/replica) may share a skill if they are always operated together.
225
+
226
+ ### Read Source, Not Docs
227
+ Internal README files go stale. The entry point script, exception handlers, and log statements are the ground truth. Always grep the source code for actual error messages before writing log patterns.
228
+
229
+ ### Port Awareness
230
+ Scripts in `skills/` run on the **host machine**, not inside Docker. Always use the external mapped port:
231
+
232
+ ```python
233
+ # ✅ Host script (external mapped port)
234
+ DB_PORT = int(os.getenv("DB_PORT", "5433"))
235
+
236
+ # ❌ Wrong for a host script (container-internal port)
237
+ DB_PORT = int(os.getenv("DB_PORT", "5432"))
238
+ ```
239
+
240
+ ### Executable Knowledge
241
+ Prefer putting logic into `scripts/` (executed without reading into context) over text-only descriptions in SKILL.md. An agent that can run `health_probe.py` learns the truth about service health in one step. An agent reading stale prose may act on incorrect assumptions.
242
+
243
+ ### Actionable Remediation
244
+ Every critical failure detected by a script must print the exact command to fix it — not "check the logs." For example:
245
+
246
+ ```python
247
+ if not token_present:
248
+ print(f" Fix: docker exec -it {CONTAINER} python scripts/auth.py --refresh")
249
+ ```
250
+
251
+ ---
252
+
253
+ ## 9. Anti-Patterns
254
+
255
+ | Anti-pattern | Why It Fails |
256
+ |---|---|
257
+ | Skip Phase 2 because Phase 1 looks complete | Skeleton has correct port numbers but wrong table names, wrong log patterns, wrong stale thresholds |
258
+ | Copy log patterns from another service's skill | Different services emit different errors; shared patterns produce false positives and miss real failures |
259
+ | Use port 5432 in host scripts | Container-internal port is unreachable from host; scripts silently hang |
260
+ | Write `health_probe.py` without fix commands | Agent sees a failure but has no recovery path |
261
+ | Leave `[PENDING RESEARCH]` markers | The skill is unusable — an agent acting on incomplete info may apply wrong fixes |
262
+ | Forget to sync to `.agent/` and `.gemini/` | Other agent runtimes use stale or missing skills |
263
+ | Use `r"ERROR"` as a log pattern | Matches variable names, comments, thousands of false positives |
264
+ | Hardcode table names without verifying | `SELECT tablename FROM pg_tables WHERE schemaname='public'` first |