@hivehub/rulebook 2.1.0 → 3.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 (187) hide show
  1. package/README.md +779 -661
  2. package/dist/cli/commands.d.ts +22 -0
  3. package/dist/cli/commands.d.ts.map +1 -1
  4. package/dist/cli/commands.js +291 -8
  5. package/dist/cli/commands.js.map +1 -1
  6. package/dist/core/claude-mcp.d.ts +32 -0
  7. package/dist/core/claude-mcp.d.ts.map +1 -0
  8. package/dist/core/claude-mcp.js +92 -0
  9. package/dist/core/claude-mcp.js.map +1 -0
  10. package/dist/core/config-manager.d.ts.map +1 -1
  11. package/dist/core/config-manager.js +27 -6
  12. package/dist/core/config-manager.js.map +1 -1
  13. package/dist/core/generator.d.ts.map +1 -1
  14. package/dist/core/generator.js +98 -49
  15. package/dist/core/generator.js.map +1 -1
  16. package/dist/core/migrator.d.ts +13 -0
  17. package/dist/core/migrator.d.ts.map +1 -1
  18. package/dist/core/migrator.js +76 -9
  19. package/dist/core/migrator.js.map +1 -1
  20. package/dist/core/openspec-migrator.d.ts +1 -1
  21. package/dist/core/openspec-migrator.d.ts.map +1 -1
  22. package/dist/core/openspec-migrator.js +14 -7
  23. package/dist/core/openspec-migrator.js.map +1 -1
  24. package/dist/core/workflow-generator.js +297 -261
  25. package/dist/core/workflow-generator.js.map +1 -1
  26. package/dist/index.js +40 -1
  27. package/dist/index.js.map +1 -1
  28. package/dist/mcp/rulebook-server.d.ts.map +1 -1
  29. package/dist/mcp/rulebook-server.js +255 -74
  30. package/dist/mcp/rulebook-server.js.map +1 -1
  31. package/dist/memory/hnsw-index.d.ts +63 -0
  32. package/dist/memory/hnsw-index.d.ts.map +1 -0
  33. package/dist/memory/hnsw-index.js +421 -0
  34. package/dist/memory/hnsw-index.js.map +1 -0
  35. package/dist/memory/memory-cache.d.ts +33 -0
  36. package/dist/memory/memory-cache.d.ts.map +1 -0
  37. package/dist/memory/memory-cache.js +85 -0
  38. package/dist/memory/memory-cache.js.map +1 -0
  39. package/dist/memory/memory-hooks.d.ts +42 -0
  40. package/dist/memory/memory-hooks.d.ts.map +1 -0
  41. package/dist/memory/memory-hooks.js +193 -0
  42. package/dist/memory/memory-hooks.js.map +1 -0
  43. package/dist/memory/memory-manager.d.ts +55 -0
  44. package/dist/memory/memory-manager.d.ts.map +1 -0
  45. package/dist/memory/memory-manager.js +209 -0
  46. package/dist/memory/memory-manager.js.map +1 -0
  47. package/dist/memory/memory-search.d.ts +42 -0
  48. package/dist/memory/memory-search.d.ts.map +1 -0
  49. package/dist/memory/memory-search.js +166 -0
  50. package/dist/memory/memory-search.js.map +1 -0
  51. package/dist/memory/memory-store.d.ts +59 -0
  52. package/dist/memory/memory-store.d.ts.map +1 -0
  53. package/dist/memory/memory-store.js +394 -0
  54. package/dist/memory/memory-store.js.map +1 -0
  55. package/dist/memory/memory-types.d.ts +69 -0
  56. package/dist/memory/memory-types.d.ts.map +1 -0
  57. package/dist/memory/memory-types.js +7 -0
  58. package/dist/memory/memory-types.js.map +1 -0
  59. package/dist/memory/memory-vectorizer.d.ts +29 -0
  60. package/dist/memory/memory-vectorizer.d.ts.map +1 -0
  61. package/dist/memory/memory-vectorizer.js +104 -0
  62. package/dist/memory/memory-vectorizer.js.map +1 -0
  63. package/dist/types.d.ts +7 -0
  64. package/dist/types.d.ts.map +1 -1
  65. package/package.json +107 -106
  66. package/templates/commands/rulebook-memory-save.md +48 -0
  67. package/templates/commands/rulebook-memory-search.md +47 -0
  68. package/templates/commands/rulebook-task-apply.md +2 -2
  69. package/templates/commands/rulebook-task-archive.md +2 -2
  70. package/templates/commands/rulebook-task-create.md +2 -2
  71. package/templates/commands/rulebook-task-list.md +2 -2
  72. package/templates/commands/rulebook-task-show.md +2 -2
  73. package/templates/commands/rulebook-task-validate.md +2 -2
  74. package/templates/git/CI_CD_PATTERNS.md +4 -4
  75. package/templates/git/GITHUB_ACTIONS.md +3 -3
  76. package/templates/git/GITLAB_CI.md +4 -4
  77. package/templates/git/SECRETS_MANAGEMENT.md +4 -4
  78. package/templates/hooks/COMMIT_MSG.md +4 -4
  79. package/templates/hooks/POST_CHECKOUT.md +3 -3
  80. package/templates/hooks/PREPARE_COMMIT_MSG.md +3 -3
  81. package/templates/hooks/PRE_COMMIT.md +4 -4
  82. package/templates/hooks/PRE_PUSH.md +4 -4
  83. package/templates/modules/MEMORY.md +63 -0
  84. package/templates/skills/cli/aider/SKILL.md +59 -0
  85. package/templates/skills/cli/amazon-q/SKILL.md +35 -0
  86. package/templates/skills/cli/auggie/SKILL.md +42 -0
  87. package/templates/skills/cli/claude/SKILL.md +42 -0
  88. package/templates/skills/cli/claude-code/SKILL.md +146 -0
  89. package/templates/skills/cli/cline/SKILL.md +42 -0
  90. package/templates/skills/cli/codebuddy/SKILL.md +30 -0
  91. package/templates/skills/cli/codeium/SKILL.md +30 -0
  92. package/templates/skills/cli/codex/SKILL.md +31 -0
  93. package/templates/skills/cli/continue/SKILL.md +44 -0
  94. package/templates/skills/cli/cursor-cli/SKILL.md +38 -0
  95. package/templates/skills/cli/factory/SKILL.md +28 -0
  96. package/templates/skills/cli/gemini/SKILL.md +45 -0
  97. package/templates/skills/cli/kilocode/SKILL.md +28 -0
  98. package/templates/skills/cli/opencode/SKILL.md +28 -0
  99. package/templates/skills/core/agent-automation/SKILL.md +194 -0
  100. package/templates/skills/core/dag/SKILL.md +314 -0
  101. package/templates/skills/core/documentation-rules/SKILL.md +47 -0
  102. package/templates/skills/core/quality-enforcement/SKILL.md +78 -0
  103. package/templates/skills/frameworks/angular/SKILL.md +46 -0
  104. package/templates/skills/frameworks/django/SKILL.md +93 -0
  105. package/templates/skills/frameworks/electron/SKILL.md +157 -0
  106. package/templates/skills/frameworks/flask/SKILL.md +48 -0
  107. package/templates/skills/frameworks/flutter/SKILL.md +65 -0
  108. package/templates/skills/frameworks/jquery/SKILL.md +42 -0
  109. package/templates/skills/frameworks/laravel/SKILL.md +48 -0
  110. package/templates/skills/frameworks/nestjs/SKILL.md +53 -0
  111. package/templates/skills/frameworks/nextjs/SKILL.md +137 -0
  112. package/templates/skills/frameworks/nuxt/SKILL.md +50 -0
  113. package/templates/skills/frameworks/rails/SKILL.md +76 -0
  114. package/templates/skills/frameworks/react/SKILL.md +48 -0
  115. package/templates/skills/frameworks/react-native/SKILL.md +57 -0
  116. package/templates/skills/frameworks/spring/SKILL.md +49 -0
  117. package/templates/skills/frameworks/symfony/SKILL.md +46 -0
  118. package/templates/skills/frameworks/vue/SKILL.md +46 -0
  119. package/templates/skills/frameworks/zend/SKILL.md +45 -0
  120. package/templates/skills/ides/copilot/SKILL.md +47 -0
  121. package/templates/skills/ides/cursor/SKILL.md +53 -0
  122. package/templates/skills/ides/jetbrains-ai/SKILL.md +45 -0
  123. package/templates/skills/ides/replit/SKILL.md +46 -0
  124. package/templates/skills/ides/tabnine/SKILL.md +39 -0
  125. package/templates/skills/ides/vscode/SKILL.md +50 -0
  126. package/templates/skills/ides/windsurf/SKILL.md +46 -0
  127. package/templates/skills/ides/zed/SKILL.md +42 -0
  128. package/templates/skills/languages/ada/SKILL.md +68 -0
  129. package/templates/skills/languages/c/SKILL.md +343 -0
  130. package/templates/skills/languages/cpp/SKILL.md +753 -0
  131. package/templates/skills/languages/csharp/SKILL.md +427 -0
  132. package/templates/skills/languages/dart/SKILL.md +342 -0
  133. package/templates/skills/languages/elixir/SKILL.md +464 -0
  134. package/templates/skills/languages/erlang/SKILL.md +371 -0
  135. package/templates/skills/languages/go/SKILL.md +655 -0
  136. package/templates/skills/languages/haskell/SKILL.md +187 -0
  137. package/templates/skills/languages/java/SKILL.md +617 -0
  138. package/templates/skills/languages/javascript/SKILL.md +641 -0
  139. package/templates/skills/languages/julia/SKILL.md +107 -0
  140. package/templates/skills/languages/kotlin/SKILL.md +521 -0
  141. package/templates/skills/languages/lisp/SKILL.md +110 -0
  142. package/templates/skills/languages/lua/SKILL.md +84 -0
  143. package/templates/skills/languages/objectivec/SKILL.md +100 -0
  144. package/templates/skills/languages/php/SKILL.md +426 -0
  145. package/templates/skills/languages/python/SKILL.md +692 -0
  146. package/templates/skills/languages/r/SKILL.md +360 -0
  147. package/templates/skills/languages/ruby/SKILL.md +431 -0
  148. package/templates/skills/languages/rust/SKILL.md +487 -0
  149. package/templates/skills/languages/sas/SKILL.md +83 -0
  150. package/templates/skills/languages/scala/SKILL.md +358 -0
  151. package/templates/skills/languages/solidity/SKILL.md +590 -0
  152. package/templates/skills/languages/sql/SKILL.md +147 -0
  153. package/templates/skills/languages/swift/SKILL.md +476 -0
  154. package/templates/skills/languages/zig/SKILL.md +275 -0
  155. package/templates/skills/modules/atlassian/SKILL.md +265 -0
  156. package/templates/skills/modules/context7/SKILL.md +64 -0
  157. package/templates/skills/modules/figma/SKILL.md +277 -0
  158. package/templates/skills/modules/github-mcp/SKILL.md +74 -0
  159. package/templates/skills/modules/grafana/SKILL.md +338 -0
  160. package/templates/skills/modules/memory/SKILL.md +73 -0
  161. package/templates/skills/modules/notion/SKILL.md +257 -0
  162. package/templates/skills/modules/playwright/SKILL.md +100 -0
  163. package/templates/skills/modules/rulebook-mcp/SKILL.md +166 -0
  164. package/templates/skills/modules/serena/SKILL.md +347 -0
  165. package/templates/skills/modules/supabase/SKILL.md +233 -0
  166. package/templates/skills/modules/synap/SKILL.md +79 -0
  167. package/templates/skills/modules/vectorizer/SKILL.md +73 -0
  168. package/templates/skills/services/azure-blob/SKILL.md +194 -0
  169. package/templates/skills/services/cassandra/SKILL.md +249 -0
  170. package/templates/skills/services/dynamodb/SKILL.md +318 -0
  171. package/templates/skills/services/elasticsearch/SKILL.md +357 -0
  172. package/templates/skills/services/gcs/SKILL.md +188 -0
  173. package/templates/skills/services/influxdb/SKILL.md +275 -0
  174. package/templates/skills/services/kafka/SKILL.md +351 -0
  175. package/templates/skills/services/mariadb/SKILL.md +193 -0
  176. package/templates/skills/services/memcached/SKILL.md +252 -0
  177. package/templates/skills/services/minio/SKILL.md +211 -0
  178. package/templates/skills/services/mongodb/SKILL.md +278 -0
  179. package/templates/skills/services/mysql/SKILL.md +368 -0
  180. package/templates/skills/services/neo4j/SKILL.md +257 -0
  181. package/templates/skills/services/oracle/SKILL.md +300 -0
  182. package/templates/skills/services/postgresql/SKILL.md +336 -0
  183. package/templates/skills/services/rabbitmq/SKILL.md +296 -0
  184. package/templates/skills/services/redis/SKILL.md +302 -0
  185. package/templates/skills/services/s3/SKILL.md +308 -0
  186. package/templates/skills/services/sqlite/SKILL.md +304 -0
  187. package/templates/skills/services/sqlserver/SKILL.md +304 -0
@@ -0,0 +1,110 @@
1
+ ---
2
+ name: "Lisp"
3
+ description: "Execute these commands after EVERY implementation (see AGENT_AUTOMATION module for full workflow)."
4
+ version: "1.0.0"
5
+ category: "languages"
6
+ author: "Rulebook"
7
+ tags: ["languages", "language"]
8
+ dependencies: []
9
+ conflicts: []
10
+ ---
11
+ <!-- LISP:START -->
12
+ # Common Lisp Project Rules
13
+
14
+ ## Agent Automation Commands
15
+
16
+ **CRITICAL**: Execute these commands after EVERY implementation (see AGENT_AUTOMATION module for full workflow).
17
+
18
+ ```bash
19
+ # Complete quality check sequence:
20
+ sbcl --eval '(ql:quickload :sblint)' --eval '(sblint:run-lint "src/")' # Linting
21
+ sbcl --load tests/run-tests.lisp # All tests
22
+ sbcl --eval '(asdf:make :your-system)' # Build with ASDF
23
+ ```
24
+
25
+ ## Common Lisp Configuration
26
+
27
+ **CRITICAL**: Use SBCL 2.3+ or CCL with ASDF3 and modern tooling.
28
+
29
+ - **Implementation**: SBCL 2.3+ (recommended) or CCL
30
+ - **Build System**: ASDF3
31
+ - **Testing**: FiveAM or Prove
32
+ - **Linter**: sblint
33
+
34
+ ### System Definition (your-system.asd)
35
+
36
+ ```lisp
37
+ (defsystem "your-system"
38
+ :description "Your system description"
39
+ :version "0.1.0"
40
+ :author "Your Name <you@example.com>"
41
+ :license "MIT"
42
+ :depends-on (:alexandria
43
+ :cl-ppcre
44
+ :str)
45
+ :components ((:module "src"
46
+ :components
47
+ ((:file "package")
48
+ (:file "main" :depends-on ("package")))))
49
+ :in-order-to ((test-op (test-op "your-system/tests"))))
50
+
51
+ (defsystem "your-system/tests"
52
+ :depends-on ("your-system"
53
+ "fiveam")
54
+ :components ((:module "tests"
55
+ :components
56
+ ((:file "package")
57
+ (:file "main-tests" :depends-on ("package")))))
58
+ :perform (test-op (o c) (symbol-call :fiveam :run! :your-system-tests)))
59
+ ```
60
+
61
+ ## Code Quality Standards
62
+
63
+ ### Mandatory Quality Checks
64
+
65
+ **IMPORTANT**: These commands MUST match your GitHub Actions workflows!
66
+
67
+ ```bash
68
+ # Pre-Commit Checklist (MUST match .github/workflows/*.yml)
69
+
70
+ # 1. Lint (matches workflow)
71
+ sblint your-system.asd
72
+
73
+ # 2. Load system (check for errors - matches workflow)
74
+ sbcl --non-interactive --load your-system.asd \
75
+ --eval '(ql:quickload :your-system)' \
76
+ --eval '(quit)'
77
+
78
+ # 3. Run tests (matches workflow)
79
+ sbcl --non-interactive \
80
+ --eval '(ql:quickload :your-system/tests)' \
81
+ --eval '(asdf:test-system :your-system)' \
82
+ --eval '(quit)'
83
+
84
+ # If ANY fails: ❌ DO NOT COMMIT - Fix first!
85
+ ```
86
+
87
+ ### Testing Example (FiveAM)
88
+
89
+ ```lisp
90
+ (in-package :your-system/tests)
91
+
92
+ (def-suite your-system-tests
93
+ :description "Main test suite")
94
+
95
+ (in-suite your-system-tests)
96
+
97
+ (test process-data-test
98
+ "Test data processing"
99
+ (is (equal '(2 4 6) (process-data '(1 2 3))))
100
+ (is (null (process-data '())))
101
+ (signals error (process-data nil)))
102
+
103
+ (test validate-input-test
104
+ "Test input validation"
105
+ (is-true (validate-input "test"))
106
+ (is-false (validate-input "")))
107
+ ```
108
+
109
+ <!-- LISP:END -->
110
+
@@ -0,0 +1,84 @@
1
+ ---
2
+ name: "Lua"
3
+ description: "Execute these commands after EVERY implementation (see AGENT_AUTOMATION module for full workflow)."
4
+ version: "1.0.0"
5
+ category: "languages"
6
+ author: "Rulebook"
7
+ tags: ["languages", "language"]
8
+ dependencies: []
9
+ conflicts: []
10
+ ---
11
+ <!-- LUA:START -->
12
+ # Lua Project Rules
13
+
14
+ ## Agent Automation Commands
15
+
16
+ **CRITICAL**: Execute these commands after EVERY implementation (see AGENT_AUTOMATION module for full workflow).
17
+
18
+ ```bash
19
+ # Complete quality check sequence:
20
+ stylua --check . # Format check
21
+ luacheck . # Linting
22
+ busted # All tests (100% pass)
23
+
24
+ # No standard security audit for Lua
25
+ ```
26
+
27
+ ## Lua Configuration
28
+
29
+ **CRITICAL**: Use Lua 5.4 or LuaJIT with linting.
30
+
31
+ - **Version**: Lua 5.4 or LuaJIT 2.1+
32
+ - **Linter**: luacheck
33
+ - **Formatter**: StyLua
34
+ - **Testing**: busted or luaunit
35
+
36
+ ## Code Quality Standards
37
+
38
+ ### Mandatory Quality Checks
39
+
40
+ **IMPORTANT**: These commands MUST match your GitHub Actions workflows!
41
+
42
+ ```bash
43
+ # Pre-Commit Checklist (MUST match .github/workflows/*.yml)
44
+
45
+ # 1. Format check (matches workflow)
46
+ stylua --check src/ tests/
47
+
48
+ # 2. Lint (matches workflow)
49
+ luacheck src/ tests/ --std luajit --no-unused-args
50
+
51
+ # 3. Run tests (matches workflow)
52
+ busted tests/
53
+
54
+ # If ANY fails: ❌ DO NOT COMMIT - Fix first!
55
+ ```
56
+
57
+ **Why This Matters:**
58
+ - Example: Using `stylua` (writes) locally but `stylua --check` in CI = failure
59
+
60
+ ### Testing Example (busted)
61
+
62
+ ```lua
63
+ describe("DataProcessor", function()
64
+ local processor
65
+
66
+ before_each(function()
67
+ processor = require("data_processor").new()
68
+ end)
69
+
70
+ it("processes valid input", function()
71
+ local result = processor:process({1, 2, 3})
72
+ assert.are.same({2, 4, 6}, result)
73
+ end)
74
+
75
+ it("handles empty input", function()
76
+ assert.has_no.errors(function()
77
+ processor:process({})
78
+ end)
79
+ end)
80
+ end)
81
+ ```
82
+
83
+ <!-- LUA:END -->
84
+
@@ -0,0 +1,100 @@
1
+ ---
2
+ name: "Objective-C"
3
+ description: "Execute these commands after EVERY implementation (see AGENT_AUTOMATION module for full workflow)."
4
+ version: "1.0.0"
5
+ category: "languages"
6
+ author: "Rulebook"
7
+ tags: ["languages", "language"]
8
+ dependencies: []
9
+ conflicts: []
10
+ ---
11
+ <!-- OBJECTIVEC:START -->
12
+ # Objective-C Project Rules
13
+
14
+ ## Agent Automation Commands
15
+
16
+ **CRITICAL**: Execute these commands after EVERY implementation (see AGENT_AUTOMATION module for full workflow).
17
+
18
+ ```bash
19
+ # Complete quality check sequence:
20
+ xcodebuild clean build # Build verification
21
+ xcodebuild test -scheme YourScheme # All tests
22
+ # clang static analyzer runs automatically in Xcode builds
23
+
24
+ # Security audit:
25
+ # Use Xcode's built-in analyzer or third-party tools
26
+ ```
27
+
28
+ ## Objective-C Configuration
29
+
30
+ **CRITICAL**: Use Modern Objective-C with ARC and strict warnings.
31
+
32
+ - **Version**: Xcode 15+
33
+ - **ARC**: Automatic Reference Counting required
34
+ - **Formatter**: clang-format
35
+ - **Testing**: XCTest
36
+ - **Analyzer**: clang static analyzer
37
+
38
+ ## Code Quality Standards
39
+
40
+ ### Mandatory Quality Checks
41
+
42
+ **IMPORTANT**: These commands MUST match your GitHub Actions workflows!
43
+
44
+ ```bash
45
+ # Pre-Commit Checklist (MUST match .github/workflows/*.yml)
46
+
47
+ # 1. Format check (matches workflow)
48
+ clang-format --dry-run --Werror **/*.{h,m}
49
+
50
+ # 2. Static analysis (matches workflow)
51
+ xcodebuild analyze -scheme YourScheme -sdk iphonesimulator
52
+
53
+ # 3. Build (matches workflow)
54
+ xcodebuild build -scheme YourScheme -sdk iphonesimulator \
55
+ ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
56
+
57
+ # 4. Run tests (matches workflow)
58
+ xcodebuild test -scheme YourScheme -sdk iphonesimulator \
59
+ -destination 'platform=iOS Simulator,name=iPhone 15'
60
+
61
+ # If ANY fails: ❌ DO NOT COMMIT - Fix first!
62
+ ```
63
+
64
+ **Why This Matters:**
65
+ - Example: Using `clang-format -i` locally but `--dry-run` in CI = failure
66
+
67
+ ### Testing Example (XCTest)
68
+
69
+ ```objective-c
70
+ @import XCTest;
71
+ #import "DataProcessor.h"
72
+
73
+ @interface DataProcessorTests : XCTestCase
74
+ @property (nonatomic, strong) DataProcessor *processor;
75
+ @end
76
+
77
+ @implementation DataProcessorTests
78
+
79
+ - (void)setUp {
80
+ [super setUp];
81
+ self.processor = [[DataProcessor alloc] initWithThreshold:0.5];
82
+ }
83
+
84
+ - (void)testProcessValidInput {
85
+ NSArray *input = @[@1, @2, @3];
86
+ NSArray *result = [self.processor process:input];
87
+
88
+ XCTAssertNotNil(result);
89
+ XCTAssertGreaterThan(result.count, 0);
90
+ }
91
+
92
+ - (void)testProcessHandlesNil {
93
+ XCTAssertThrows([self.processor process:nil]);
94
+ }
95
+
96
+ @end
97
+ ```
98
+
99
+ <!-- OBJECTIVEC:END -->
100
+
@@ -0,0 +1,426 @@
1
+ ---
2
+ name: "PHP"
3
+ description: "Execute these commands after EVERY implementation (see AGENT_AUTOMATION module for full workflow)."
4
+ version: "1.0.0"
5
+ category: "languages"
6
+ author: "Rulebook"
7
+ tags: ["languages", "language"]
8
+ dependencies: []
9
+ conflicts: []
10
+ ---
11
+ <!-- PHP:START -->
12
+ # PHP Project Rules
13
+
14
+ ## Agent Automation Commands
15
+
16
+ **CRITICAL**: Execute these commands after EVERY implementation (see AGENT_AUTOMATION module for full workflow).
17
+
18
+ ```bash
19
+ # Complete quality check sequence:
20
+ ./vendor/bin/pint --test # Format check (Laravel Pint)
21
+ # OR: ./vendor/bin/php-cs-fixer fix --dry-run
22
+ ./vendor/bin/phpstan analyze # Static analysis
23
+ ./vendor/bin/phpunit # All tests (100% pass)
24
+ ./vendor/bin/phpunit --coverage-text # Coverage (95%+ required)
25
+
26
+ # Security audit:
27
+ composer audit # Vulnerability scan
28
+ composer outdated # Check outdated deps
29
+ ```
30
+
31
+ ## PHP Configuration
32
+
33
+ **CRITICAL**: Use PHP 8.2+ with strict types enabled.
34
+
35
+ - **Version**: PHP 8.2+
36
+ - **Strict Types**: Enabled
37
+ - **Type Hints**: Required for all functions
38
+ - **Error Reporting**: E_ALL | E_STRICT
39
+
40
+ ### composer.json Requirements
41
+
42
+ ```json
43
+ {
44
+ "name": "your-vendor/your-package",
45
+ "description": "A short description of your package",
46
+ "type": "library",
47
+ "license": "MIT",
48
+ "authors": [
49
+ {
50
+ "name": "Your Name",
51
+ "email": "your.email@example.com"
52
+ }
53
+ ],
54
+ "require": {
55
+ "php": "^8.2"
56
+ },
57
+ "require-dev": {
58
+ "phpunit/phpunit": "^11.0",
59
+ "phpstan/phpstan": "^1.10",
60
+ "squizlabs/php_codesniffer": "^3.8",
61
+ "friendsofphp/php-cs-fixer": "^3.48"
62
+ },
63
+ "autoload": {
64
+ "psr-4": {
65
+ "YourVendor\\YourPackage\\": "src/"
66
+ }
67
+ },
68
+ "autoload-dev": {
69
+ "psr-4": {
70
+ "YourVendor\\YourPackage\\Tests\\": "tests/"
71
+ }
72
+ },
73
+ "scripts": {
74
+ "test": "phpunit",
75
+ "cs-fix": "php-cs-fixer fix",
76
+ "cs-check": "php-cs-fixer fix --dry-run --diff",
77
+ "stan": "phpstan analyse",
78
+ "phpcs": "phpcs src tests"
79
+ },
80
+ "minimum-stability": "stable",
81
+ "prefer-stable": true
82
+ }
83
+ ```
84
+
85
+ ## Code Quality Standards
86
+
87
+ ### Mandatory Quality Checks
88
+
89
+ **CRITICAL**: After implementing ANY feature, you MUST run these commands in order.
90
+
91
+ **IMPORTANT**: These commands MUST match your GitHub Actions workflows to prevent CI/CD failures!
92
+
93
+ ```bash
94
+ # Pre-Commit Checklist (MUST match .github/workflows/*.yml)
95
+
96
+ # 1. Format check (matches workflow - use check, not fix!)
97
+ composer cs-check
98
+
99
+ # 2. Static analysis (MUST pass with no errors - matches workflow)
100
+ composer stan
101
+
102
+ # 3. Code style check (matches workflow)
103
+ composer phpcs
104
+
105
+ # 4. Run all tests (MUST pass 100% - matches workflow)
106
+ composer test
107
+
108
+ # 5. Check coverage (MUST meet threshold)
109
+ ./vendor/bin/phpunit --coverage-text
110
+
111
+ # If ANY fails: ❌ DO NOT COMMIT - Fix first!
112
+ ```
113
+
114
+ **If ANY of these fail, you MUST fix the issues before committing.**
115
+
116
+ **Why This Matters:**
117
+ - CI/CD failures happen when local commands differ from workflows
118
+ - Example: Using `cs-fix` locally but `cs-check` in CI = failure
119
+ - Example: Missing static analysis locally = CI PHPStan failures
120
+
121
+ ### Code Style
122
+
123
+ Use PHP-CS-Fixer with PSR-12 standard. Configuration in `.php-cs-fixer.php`:
124
+
125
+ ```php
126
+ <?php
127
+
128
+ declare(strict_types=1);
129
+
130
+ $finder = PhpCsFixer\Finder::create()
131
+ ->in(__DIR__ . '/src')
132
+ ->in(__DIR__ . '/tests');
133
+
134
+ return (new PhpCsFixer\Config())
135
+ ->setRules([
136
+ '@PSR12' => true,
137
+ '@PHP82Migration' => true,
138
+ 'strict_param' => true,
139
+ 'array_syntax' => ['syntax' => 'short'],
140
+ 'declare_strict_types' => true,
141
+ 'native_function_invocation' => ['include' => ['@all']],
142
+ 'no_unused_imports' => true,
143
+ 'ordered_imports' => ['sort_algorithm' => 'alpha'],
144
+ 'phpdoc_align' => true,
145
+ 'phpdoc_order' => true,
146
+ 'trailing_comma_in_multiline' => ['elements' => ['arrays']],
147
+ ])
148
+ ->setFinder($finder);
149
+ ```
150
+
151
+ ### Static Analysis
152
+
153
+ Use PHPStan at maximum level. Configuration in `phpstan.neon`:
154
+
155
+ ```neon
156
+ parameters:
157
+ level: max
158
+ paths:
159
+ - src
160
+ - tests
161
+ excludePaths:
162
+ - tests/Fixtures/*
163
+ checkMissingIterableValueType: true
164
+ checkGenericClassInNonGenericObjectType: true
165
+ reportUnmatchedIgnoredErrors: true
166
+ ```
167
+
168
+ ### Testing
169
+
170
+ - **Framework**: PHPUnit 11+
171
+ - **Location**: `tests/` directory
172
+ - **Coverage**: XDebug or PCOV
173
+ - **Coverage Threshold**: 95%+
174
+
175
+ Configuration in `phpunit.xml`:
176
+
177
+ ```xml
178
+ <?xml version="1.0" encoding="UTF-8"?>
179
+ <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
180
+ xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
181
+ bootstrap="vendor/autoload.php"
182
+ colors="true"
183
+ failOnRisky="true"
184
+ failOnWarning="true"
185
+ cacheDirectory=".phpunit.cache">
186
+ <testsuites>
187
+ <testsuite name="Unit">
188
+ <directory>tests/Unit</directory>
189
+ </testsuite>
190
+ <testsuite name="Integration">
191
+ <directory>tests/Integration</directory>
192
+ </testsuite>
193
+ </testsuites>
194
+ <source>
195
+ <include>
196
+ <directory>src</directory>
197
+ </include>
198
+ </source>
199
+ <coverage>
200
+ <report>
201
+ <html outputDirectory="coverage"/>
202
+ <text outputFile="php://stdout"/>
203
+ </report>
204
+ </coverage>
205
+ </phpunit>
206
+ ```
207
+
208
+ Example test:
209
+
210
+ ```php
211
+ <?php
212
+
213
+ declare(strict_types=1);
214
+
215
+ namespace YourVendor\YourPackage\Tests;
216
+
217
+ use PHPUnit\Framework\TestCase;
218
+ use YourVendor\YourPackage\MyClass;
219
+
220
+ final class MyClassTest extends TestCase
221
+ {
222
+ public function testProcessValidInput(): void
223
+ {
224
+ $myClass = new MyClass();
225
+ $result = $myClass->process('hello');
226
+
227
+ $this->assertSame('HELLO', $result);
228
+ }
229
+
230
+ public function testProcessEmptyInputThrowsException(): void
231
+ {
232
+ $this->expectException(\InvalidArgumentException::class);
233
+ $this->expectExceptionMessage('Input cannot be empty');
234
+
235
+ $myClass = new MyClass();
236
+ $myClass->process('');
237
+ }
238
+ }
239
+ ```
240
+
241
+ ### Type Declarations
242
+
243
+ - Use strict types in all files
244
+ - Type hint all parameters and return types
245
+ - Use union types and nullable types appropriately
246
+
247
+ Example:
248
+
249
+ ```php
250
+ <?php
251
+
252
+ declare(strict_types=1);
253
+
254
+ namespace YourVendor\YourPackage;
255
+
256
+ use InvalidArgumentException;
257
+
258
+ final class DataProcessor
259
+ {
260
+ /**
261
+ * Process the input data and return the result.
262
+ *
263
+ * @param string $input The input to process
264
+ * @return string The processed output
265
+ * @throws InvalidArgumentException If input is empty
266
+ */
267
+ public function process(string $input): string
268
+ {
269
+ if ($input === '') {
270
+ throw new InvalidArgumentException('Input cannot be empty');
271
+ }
272
+
273
+ return strtoupper($input);
274
+ }
275
+
276
+ /**
277
+ * Find a value in the data.
278
+ *
279
+ * @param array<string, mixed> $data
280
+ * @param string $key
281
+ * @return mixed|null
282
+ */
283
+ public function findValue(array $data, string $key): mixed
284
+ {
285
+ return $data[$key] ?? null;
286
+ }
287
+
288
+ /**
289
+ * Process multiple items.
290
+ *
291
+ * @param list<string> $items
292
+ * @return list<string>
293
+ */
294
+ public function processMany(array $items): array
295
+ {
296
+ return array_map(
297
+ fn (string $item): string => $this->process($item),
298
+ $items
299
+ );
300
+ }
301
+ }
302
+ ```
303
+
304
+ ## Documentation
305
+
306
+ - Use PHPDoc blocks for all public methods
307
+ - Include `@param`, `@return`, `@throws` tags
308
+ - Use generics annotations for arrays
309
+
310
+ Example:
311
+
312
+ ```php
313
+ <?php
314
+
315
+ declare(strict_types=1);
316
+
317
+ namespace YourVendor\YourPackage;
318
+
319
+ /**
320
+ * Service for managing user data.
321
+ *
322
+ * This class provides methods for creating, updating, and retrieving user information.
323
+ */
324
+ final class UserService
325
+ {
326
+ /**
327
+ * Find a user by ID.
328
+ *
329
+ * @param positive-int $userId The user ID
330
+ * @return array{id: int, name: string, email: string}|null User data or null if not found
331
+ */
332
+ public function findById(int $userId): ?array
333
+ {
334
+ // Implementation
335
+ }
336
+
337
+ /**
338
+ * Get all users.
339
+ *
340
+ * @return list<array{id: int, name: string, email: string}>
341
+ */
342
+ public function getAll(): array
343
+ {
344
+ // Implementation
345
+ }
346
+ }
347
+ ```
348
+
349
+ ## Project Structure
350
+
351
+ ```
352
+ project/
353
+ ├── composer.json # Composer configuration
354
+ ├── phpunit.xml # PHPUnit configuration
355
+ ├── phpstan.neon # PHPStan configuration
356
+ ├── .php-cs-fixer.php # PHP-CS-Fixer configuration
357
+ ├── README.md # Project overview (allowed in root)
358
+ ├── CHANGELOG.md # Version history (allowed in root)
359
+ ├── LICENSE # Project license (allowed in root)
360
+ ├── src/
361
+ │ └── YourClass.php
362
+ ├── tests/
363
+ │ ├── Unit/
364
+ │ └── Integration/
365
+ └── docs/ # Project documentation
366
+ ```
367
+
368
+ ## CI/CD Requirements
369
+
370
+ Must include GitHub Actions workflows for:
371
+
372
+ 1. **Testing** (`php-test.yml`):
373
+ - Test on ubuntu-latest, windows-latest
374
+ - Test on PHP 8.2, 8.3
375
+ - Upload coverage reports
376
+
377
+ 2. **Linting** (`php-lint.yml`):
378
+ - PHPStan: `composer stan`
379
+ - PHP-CS-Fixer: `composer cs-check`
380
+ - PHPCS: `composer phpcs`
381
+
382
+ ## Package Publication
383
+
384
+ ### Publishing to Packagist
385
+
386
+ **Prerequisites:**
387
+ 1. Create account at https://packagist.org
388
+ 2. Submit your package (automatic sync with GitHub)
389
+ 3. Configure webhook in GitHub for auto-updates
390
+
391
+ **Publishing Workflow:**
392
+
393
+ 1. Update version in composer.json (optional, uses git tags)
394
+ 2. Update CHANGELOG.md
395
+ 3. Run quality checks:
396
+ ```bash
397
+ composer cs-fix
398
+ composer stan
399
+ composer test
400
+ ```
401
+
402
+ 4. Create git tag: `git tag v1.0.0 && git push --tags`
403
+ 5. Packagist automatically updates from GitHub
404
+ 6. Package available at: `https://packagist.org/packages/your-vendor/your-package`
405
+
406
+ **Publishing Checklist:**
407
+
408
+ - ✅ All tests passing
409
+ - ✅ PHPStan at max level passes
410
+ - ✅ Code style conforms to PSR-12
411
+ - ✅ CHANGELOG.md updated
412
+ - ✅ README.md up to date
413
+ - ✅ LICENSE file present
414
+ - ✅ composer.json metadata complete
415
+ - ✅ GitHub repository public
416
+ - ✅ Webhook configured on Packagist
417
+
418
+ **Semantic Versioning:**
419
+
420
+ Packagist uses git tags for versions:
421
+ - Tag format: `v1.0.0`
422
+ - Follows [SemVer](https://semver.org/)
423
+ - Composer constraints: `^1.0`, `~1.0`, `1.0.*`
424
+
425
+ <!-- PHP:END -->
426
+