@mrciphersmith/keryx 0.4.28 → 0.4.30

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 (132) hide show
  1. package/dist/cli.js +4916 -3655
  2. package/dist/core.js +91 -28
  3. package/dist/keryx-general-worker-entry.js +413 -240
  4. package/package.json +1 -1
  5. package/src/gdskills/bundled/install-manifest.json +3 -0
  6. package/src/gdskills/bundled/rules/core/api-contracts.mdc +21 -136
  7. package/src/gdskills/bundled/rules/core/async-patterns.mdc +18 -171
  8. package/src/gdskills/bundled/rules/core/clean-architecture.mdc +40 -150
  9. package/src/gdskills/bundled/rules/core/cli-interface-design.mdc +63 -194
  10. package/src/gdskills/bundled/rules/core/code-style-patterns.mdc +36 -48
  11. package/src/gdskills/bundled/rules/core/concurrency-patterns.mdc +32 -0
  12. package/src/gdskills/bundled/rules/core/database-patterns.mdc +26 -148
  13. package/src/gdskills/bundled/rules/core/error-handling.mdc +57 -109
  14. package/src/gdskills/bundled/rules/core/frontend-assistant.mdc +14 -29
  15. package/src/gdskills/bundled/rules/core/layout-rendering.mdc +51 -0
  16. package/src/gdskills/bundled/rules/core/mobx-store-template.mdc +69 -511
  17. package/src/gdskills/bundled/rules/core/nestjs-dto.mdc +18 -36
  18. package/src/gdskills/bundled/rules/core/playwright-testing.mdc +35 -308
  19. package/src/gdskills/bundled/rules/core/security-baseline.mdc +18 -140
  20. package/src/gdskills/bundled/rules/core/skill-authoring.mdc +190 -0
  21. package/src/gdskills/bundled/rules/core/skills-storage-workflow.mdc +5 -0
  22. package/src/gdskills/bundled/rules/core/solid-principles.mdc +70 -121
  23. package/src/gdskills/bundled/rules/core/storybook-guidelines.mdc +20 -22
  24. package/src/gdskills/bundled/rules/core/tdd-workflow.mdc +37 -74
  25. package/src/gdskills/bundled/rules/core/ui-anti-slop.mdc +48 -37
  26. package/src/gdskills/bundled/skills/orchestration/task-implementer/SKILL.md +2 -2
  27. package/src/gdskills/bundled/skills/quality/deprecation-path/SKILL.md +1 -1
  28. package/src/gdskills/bundled/skills/quality/tests-creator/SKILL.md +1 -1
  29. package/src/gdskills/bundled/skills/review/review-architecture/SKILL.md +25 -61
  30. package/src/gdskills/bundled/skills/review/review-backend/SKILL.md +15 -69
  31. package/src/gdskills/bundled/skills/review/review-clean-code/SKILL.md +84 -418
  32. package/src/gdskills/bundled/skills/review/review-core-boundaries/SKILL.md +2 -2
  33. package/src/gdskills/bundled/skills/review/review-degradation/SKILL.md +1 -1
  34. package/src/gdskills/bundled/skills/review/review-flow-graph/SKILL.md +1 -1
  35. package/src/gdskills/bundled/skills/review/review-frontend/SKILL.md +17 -311
  36. package/src/gdskills/bundled/skills/review/review-frontend-conventions/SKILL.md +8 -22
  37. package/src/gdskills/bundled/skills/review/review-highload/SKILL.md +84 -228
  38. package/src/gdskills/bundled/skills/review/review-layout/SKILL.md +22 -28
  39. package/src/gdskills/bundled/skills/review/review-logic/SKILL.md +9 -10
  40. package/src/gdskills/bundled/skills/review/review-performance/SKILL.md +16 -38
  41. package/src/gdskills/bundled/skills/review/review-premise/SKILL.md +1 -1
  42. package/src/gdskills/bundled/skills/review/review-regression/SKILL.md +1 -1
  43. package/src/gdskills/bundled/skills/review/review-security-code/SKILL.md +8 -8
  44. package/src/gdskills/bundled/skills/review/review-style/SKILL.md +49 -88
  45. package/src/gdskills/bundled/skills/review/review-testing-practices/SKILL.md +22 -40
  46. package/src/gdskills/bundled/skills/review/review-ui-ux/SKILL.md +42 -82
  47. package/src/gdskills/bundled/stacks/angular/rules/coding-style.mdc +15 -57
  48. package/src/gdskills/bundled/stacks/angular/rules/patterns.mdc +16 -60
  49. package/src/gdskills/bundled/stacks/angular/rules/security.mdc +11 -49
  50. package/src/gdskills/bundled/stacks/angular/rules/testing.mdc +13 -52
  51. package/src/gdskills/bundled/stacks/c-cpp/rules/coding-style.mdc +33 -57
  52. package/src/gdskills/bundled/stacks/c-cpp/rules/patterns.mdc +35 -62
  53. package/src/gdskills/bundled/stacks/c-cpp/rules/security.mdc +35 -62
  54. package/src/gdskills/bundled/stacks/c-cpp/rules/testing.mdc +34 -54
  55. package/src/gdskills/bundled/stacks/ci-github-gitlab/rules/patterns.mdc +27 -56
  56. package/src/gdskills/bundled/stacks/ci-github-gitlab/rules/security.mdc +51 -119
  57. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/coding-style.mdc +42 -74
  58. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/patterns.mdc +45 -83
  59. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/security.mdc +34 -59
  60. package/src/gdskills/bundled/stacks/csharp-dotnet/rules/testing.mdc +33 -62
  61. package/src/gdskills/bundled/stacks/django/rules/coding-style.mdc +15 -56
  62. package/src/gdskills/bundled/stacks/django/rules/patterns.mdc +16 -68
  63. package/src/gdskills/bundled/stacks/django/rules/security.mdc +13 -71
  64. package/src/gdskills/bundled/stacks/django/rules/testing.mdc +16 -62
  65. package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/coding-style.mdc +30 -53
  66. package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/patterns.mdc +20 -56
  67. package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/security.mdc +52 -122
  68. package/src/gdskills/bundled/stacks/docker-k8s-terraform/rules/testing.mdc +23 -42
  69. package/src/gdskills/bundled/stacks/fastapi/rules/coding-style.mdc +13 -47
  70. package/src/gdskills/bundled/stacks/fastapi/rules/patterns.mdc +18 -81
  71. package/src/gdskills/bundled/stacks/fastapi/rules/security.mdc +13 -75
  72. package/src/gdskills/bundled/stacks/fastapi/rules/testing.mdc +14 -58
  73. package/src/gdskills/bundled/stacks/flutter-dart/rules/coding-style.mdc +36 -74
  74. package/src/gdskills/bundled/stacks/flutter-dart/rules/patterns.mdc +30 -66
  75. package/src/gdskills/bundled/stacks/flutter-dart/rules/security.mdc +33 -67
  76. package/src/gdskills/bundled/stacks/flutter-dart/rules/testing.mdc +41 -73
  77. package/src/gdskills/bundled/stacks/go/rules/coding-style.mdc +36 -57
  78. package/src/gdskills/bundled/stacks/go/rules/patterns.mdc +27 -42
  79. package/src/gdskills/bundled/stacks/go/rules/security.mdc +26 -43
  80. package/src/gdskills/bundled/stacks/go/rules/testing.mdc +23 -41
  81. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/coding-style.mdc +21 -40
  82. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/patterns.mdc +26 -43
  83. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/security.mdc +25 -37
  84. package/src/gdskills/bundled/stacks/java-kotlin-spring/rules/testing.mdc +34 -50
  85. package/src/gdskills/bundled/stacks/kotlin-android/rules/coding-style.mdc +28 -65
  86. package/src/gdskills/bundled/stacks/kotlin-android/rules/patterns.mdc +34 -78
  87. package/src/gdskills/bundled/stacks/kotlin-android/rules/security.mdc +35 -68
  88. package/src/gdskills/bundled/stacks/kotlin-android/rules/testing.mdc +34 -68
  89. package/src/gdskills/bundled/stacks/mobx/rules/coding-style.mdc +18 -64
  90. package/src/gdskills/bundled/stacks/mobx/rules/patterns.mdc +13 -66
  91. package/src/gdskills/bundled/stacks/mobx/rules/security.mdc +8 -35
  92. package/src/gdskills/bundled/stacks/mobx/rules/testing.mdc +10 -39
  93. package/src/gdskills/bundled/stacks/nestjs/rules/coding-style.mdc +32 -45
  94. package/src/gdskills/bundled/stacks/nestjs/rules/patterns.mdc +40 -60
  95. package/src/gdskills/bundled/stacks/nestjs/rules/security.mdc +30 -50
  96. package/src/gdskills/bundled/stacks/nestjs/rules/testing.mdc +27 -47
  97. package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/coding-style.mdc +14 -48
  98. package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/patterns.mdc +15 -67
  99. package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/security.mdc +12 -50
  100. package/src/gdskills/bundled/stacks/nextjs-nuxt/rules/testing.mdc +11 -43
  101. package/src/gdskills/bundled/stacks/php-laravel/rules/coding-style.mdc +17 -58
  102. package/src/gdskills/bundled/stacks/php-laravel/rules/patterns.mdc +15 -56
  103. package/src/gdskills/bundled/stacks/php-laravel/rules/security.mdc +13 -50
  104. package/src/gdskills/bundled/stacks/php-laravel/rules/testing.mdc +14 -55
  105. package/src/gdskills/bundled/stacks/python/rules/coding-style.mdc +13 -41
  106. package/src/gdskills/bundled/stacks/python/rules/patterns.mdc +20 -61
  107. package/src/gdskills/bundled/stacks/python/rules/security.mdc +15 -57
  108. package/src/gdskills/bundled/stacks/python/rules/testing.mdc +16 -50
  109. package/src/gdskills/bundled/stacks/react/rules/coding-style.mdc +14 -40
  110. package/src/gdskills/bundled/stacks/react/rules/patterns.mdc +15 -55
  111. package/src/gdskills/bundled/stacks/react/rules/security.mdc +13 -49
  112. package/src/gdskills/bundled/stacks/react/rules/testing.mdc +10 -37
  113. package/src/gdskills/bundled/stacks/ruby-rails/rules/coding-style.mdc +15 -48
  114. package/src/gdskills/bundled/stacks/ruby-rails/rules/patterns.mdc +18 -67
  115. package/src/gdskills/bundled/stacks/ruby-rails/rules/security.mdc +11 -60
  116. package/src/gdskills/bundled/stacks/ruby-rails/rules/testing.mdc +14 -65
  117. package/src/gdskills/bundled/stacks/rust/rules/coding-style.mdc +39 -65
  118. package/src/gdskills/bundled/stacks/rust/rules/patterns.mdc +33 -60
  119. package/src/gdskills/bundled/stacks/rust/rules/security.mdc +35 -57
  120. package/src/gdskills/bundled/stacks/rust/rules/testing.mdc +29 -52
  121. package/src/gdskills/bundled/stacks/sql-db/rules/coding-style.mdc +12 -48
  122. package/src/gdskills/bundled/stacks/sql-db/rules/patterns.mdc +22 -113
  123. package/src/gdskills/bundled/stacks/sql-db/rules/security.mdc +11 -56
  124. package/src/gdskills/bundled/stacks/sql-db/rules/testing.mdc +14 -59
  125. package/src/gdskills/bundled/stacks/swift-ios/rules/coding-style.mdc +29 -65
  126. package/src/gdskills/bundled/stacks/swift-ios/rules/patterns.mdc +41 -88
  127. package/src/gdskills/bundled/stacks/swift-ios/rules/security.mdc +28 -53
  128. package/src/gdskills/bundled/stacks/swift-ios/rules/testing.mdc +32 -65
  129. package/src/gdskills/bundled/stacks/vue/rules/coding-style.mdc +17 -52
  130. package/src/gdskills/bundled/stacks/vue/rules/patterns.mdc +17 -63
  131. package/src/gdskills/bundled/stacks/vue/rules/security.mdc +11 -41
  132. package/src/gdskills/bundled/stacks/vue/rules/testing.mdc +16 -48
@@ -7,67 +7,50 @@ metadata:
7
7
 
8
8
  # Go security
9
9
 
10
- Narrows `core-common-rules`' stack-agnostic security rules to Go-specific,
11
- OWASP-relevant risks and the safe standard-library API to use instead.
12
- Applies only to `*.go` files.
10
+ Narrows `core-common-rules`' stack-agnostic security rules to Go-specific
11
+ risks (OWASP) and the safe standard-library API. Applies only to `*.go`
12
+ files.
13
13
 
14
14
  ## Command and shell execution
15
15
 
16
- - Build an argument list for `os/exec.Command(name, args...)`; never
17
- interpolate untrusted input into a shell string passed to
18
- `exec.Command("sh", "-c", cmd)` — that reintroduces shell injection that
19
- `exec.Command`'s arg-list form avoids by construction.
20
- - When a shell really is required (globbing, pipelines), validate/allowlist
21
- every piece of untrusted input that reaches the string before it is
22
- built, and say so in the change.
16
+ - Use `os/exec.Command(name, args...)`; never interpolate untrusted input
17
+ into `exec.Command("sh", "-c", cmd)`.
18
+ - When a shell is required (globbing, pipelines), allowlist every piece of
19
+ untrusted input that reaches the string, and say so in the change.
23
20
 
24
21
  ## Templating and output encoding
25
22
 
26
- - Use `html/template` for any output rendered into HTML/JS/CSS/URL
27
- context — it contextually auto-escapes. `text/template` performs no
28
- escaping and is an XSS vector the moment its output reaches a browser;
29
- reserve `text/template` for genuinely non-HTML output (config files,
30
- emails in plain text).
23
+ - `html/template` for any HTML/JS/CSS/URL output; `text/template` only for
24
+ non-HTML output (config files, plain-text email).
31
25
 
32
26
  ## SQL and data access
33
27
 
34
- - Use `database/sql` placeholders (`?` or `$1` depending on driver), never
35
- `fmt.Sprintf`/string concatenation to build a query with any
36
- user-influenced value — placeholders are the injection defense, not an
37
- input-validation substitute for it.
38
- - An ORM/query builder's raw-SQL escape hatch carries the same rule: pass
39
- parameters through its placeholder API, not through interpolated
40
- strings.
28
+ - `database/sql` placeholders (`?` or `$1`), never `fmt.Sprintf` or
29
+ concatenation with a user-influenced value.
30
+ - The same for an ORM/query builder's raw-SQL escape hatch: use its
31
+ placeholder API.
41
32
 
42
33
  ## Randomness and secrets
43
34
 
44
- - Use `crypto/rand` for anything security-sensitive — tokens, session
45
- IDs, keys, nonces. `math/rand`/`math/rand/v2` is deterministic given a
46
- seed and unsuitable for secrets even though its API looks similar.
47
- - Never hard-code a credential, API key, or signing secret in source;
48
- load it from environment/secret storage the project already uses.
35
+ - `crypto/rand` for tokens, session IDs, keys, nonces; never
36
+ `math/rand`/`math/rand/v2`.
37
+ - No hard-coded credential, API key, or signing secret; load from the
38
+ environment/secret storage the project already uses.
49
39
 
50
40
  ## Filesystem and path handling
51
41
 
52
- - `filepath.Clean` normalizes a path but does not contain it — a cleaned
53
- path can still climb outside an intended root via `..` before cleaning,
54
- or via a symlink. For serving/opening files under a fixed root from an
55
- untrusted relative path, prefer `os.Root` (Go 1.24+) or
56
- `filepath.IsLocal` to confirm containment before opening, rather than
57
- `filepath.Clean` alone.
42
+ - `filepath.Clean` alone does not contain a path. For opening files under a
43
+ fixed root from an untrusted relative path, use `os.Root` (Go 1.24+) or
44
+ `filepath.IsLocal`.
58
45
 
59
46
  ## TLS and network
60
47
 
61
- - Never set `InsecureSkipVerify: true` on a `tls.Config` outside of a
62
- short-lived local test, and never ship it that way — it disables
63
- certificate validation entirely, including hostname checks.
64
- - Configure `http.Server` with explicit `ReadHeaderTimeout` (and
65
- typically `ReadTimeout`/`WriteTimeout`/`IdleTimeout`); a server with no
66
- timeouts is vulnerable to slow-client resource exhaustion (Slowloris).
48
+ - Never `InsecureSkipVerify: true` outside a short-lived local test, never
49
+ shipped.
50
+ - `http.Server` with explicit `ReadHeaderTimeout` (and typically
51
+ `ReadTimeout`/`WriteTimeout`/`IdleTimeout`).
67
52
 
68
53
  ## Dependency hygiene
69
54
 
70
- - Run `govulncheck ./...` when introducing or updating dependencies, or
71
- when asked to check a module for known vulnerabilities — it correlates
72
- the Go vulnerability database against actually-reachable code paths,
73
- not just declared dependency versions.
55
+ - Run `govulncheck ./...` when introducing or updating dependencies, or when
56
+ asked to check a module for known vulnerabilities.
@@ -13,56 +13,38 @@ Narrows `core-common-rules`' stack-agnostic testing rules to the standard
13
13
 
14
14
  ## Layout and naming
15
15
 
16
- - Tests live beside the code they cover as `<file>_test.go` in the same
17
- package (or `<pkg>_test` for a black-box test that only exercises the
18
- exported API) — no separate `tests/` tree.
19
- - Table-driven tests with `t.Run(tc.name, func(t *testing.T) { ... })`
20
- subtests are the default shape for anything with more than one case;
21
- name each case descriptively, not `case1`/`case2`.
22
- - `testdata/` holds golden files and fixtures a test reads; Go's tooling
23
- already excludes it from builds — do not invent another fixture
24
- directory convention.
16
+ - Tests live beside the code as `<file>_test.go` in the same package (or
17
+ `<pkg>_test` for black-box tests of the exported API); no separate `tests/`
18
+ tree.
19
+ - Table-driven tests with `t.Run(tc.name, ...)` for more than one case; name
20
+ cases descriptively, not `case1`/`case2`.
21
+ - `testdata/` for golden files and fixtures; no other fixture directory
22
+ convention.
25
23
 
26
24
  ## Test helpers and lifecycle
27
25
 
28
- - Mark a helper function `t.Helper()` as its first line so failures report
29
- the caller's line, not the helper's.
30
- - Use `t.Cleanup(func() { ... })` for teardown instead of a manual
31
- `defer` chain scattered across a subtest — it composes correctly with
32
- `t.Run` and parallel subtests.
33
- - Use `t.Context()` (Go 1.24+) for a context that is canceled when the
34
- test completes, instead of hand-rolling `context.WithCancel` plus a
35
- `defer cancel()` in every test.
36
- - Call `t.Parallel()` deliberately, only when the subtest's fixtures are
37
- genuinely independent — a parallel subtest sharing mutable fixture
38
- state races silently.
26
+ - `t.Helper()` as the first line of a helper.
27
+ - `t.Cleanup` for teardown instead of a scattered `defer` chain.
28
+ - `t.Context()` (Go 1.24+) instead of hand-rolled `context.WithCancel`.
29
+ - `t.Parallel()` only when the subtest's fixtures are independent.
39
30
 
40
31
  ## Assertions and determinism
41
32
 
42
- - Plain `if got != want { t.Errorf(...) }` (or the project's already-
43
- configured assertion library) — do not introduce a new assertion
44
- library into a project that has not adopted one.
45
- - Never synchronize with `time.Sleep` to wait for a goroutine/async result
46
- — use a channel, `sync.WaitGroup`, `context` deadline, or a polling
47
- helper with a timeout so the test is deterministic and not flaky under
48
- load.
49
- - `httptest.NewServer`/`httptest.NewRecorder` for HTTP handler tests
50
- instead of binding a real port.
33
+ - Plain `if got != want { t.Errorf(...) }` or the project's configured
34
+ assertion library; do not add a new one.
35
+ - Never `time.Sleep` to wait for async results; use a channel,
36
+ `sync.WaitGroup`, `context` deadline, or a polling helper with a timeout.
37
+ - `httptest.NewServer`/`httptest.NewRecorder` for HTTP handler tests.
51
38
 
52
39
  ## Fuzzing and benchmarks
53
40
 
54
- - `func FuzzX(f *testing.F)` with `f.Add(...)` seed corpus entries for
55
- parsers, decoders, or anything that touches untrusted input formats;
56
- run locally with `go test -fuzz=FuzzX` before relying on it in CI.
57
- - Benchmarks use `for b.Loop() { ... }` (Go 1.24+) rather than the older
58
- `for i := 0; i < b.N; i++`; `b.Loop()` resets the timer automatically
59
- and keeps loop-body values alive against dead-code elimination, so
60
- results are not accidentally optimized away.
41
+ - `func FuzzX(f *testing.F)` with `f.Add(...)` seeds for parsers, decoders,
42
+ and untrusted input formats; run `go test -fuzz=FuzzX` locally before
43
+ relying on it in CI.
44
+ - Benchmarks use `for b.Loop() { ... }` (Go 1.24+), not
45
+ `for i := 0; i < b.N; i++`.
61
46
 
62
47
  ## Race detection and coverage
63
48
 
64
- - Run `go test -race ./...` for any change touching goroutines, shared
65
- state, or channels — the race detector catches data races unit
66
- assertions cannot see.
67
- - New behavior gets a new test in the same change; a bug fix gets a
68
- regression test that fails before the fix and passes after.
49
+ - `go test -race ./...` for any change touching goroutines, shared state, or
50
+ channels.
@@ -9,59 +9,40 @@ metadata:
9
9
 
10
10
  Narrows `core-common-rules`' stack-agnostic style rules to current Spring
11
11
  Boot 3.x idiom, for both Java and Kotlin sources. Applies only to
12
- `*.java`/`*.kt`/`*.kts` files — everything not Spring/Java/Kotlin-specific
13
- still comes from the common rules this file `extends`.
12
+ `*.java`/`*.kt`/`*.kts` files.
14
13
 
15
14
  ## Dependency injection
16
15
 
17
- - Prefer constructor injection over field injection: a Java `@Service`
18
- declares its dependencies as `private final` fields set in the
19
- constructor (no `@Autowired` needed on the constructor once there is
20
- only one), or a Kotlin class declares them as constructor `val`
21
- properties. Field-level `@Autowired` is discouraged — it hides the
22
- dependency graph, prevents the field from being `final`/`val`, and
23
- makes the class impossible to construct without the Spring container in
24
- a plain unit test.
25
- - A class with more than 4-5 constructor dependencies is a signal the
26
- class has too many responsibilities, not a reason to fall back to field
27
- injection to make the constructor shorter.
16
+ - Constructor injection over field injection: a Java `@Service` declares
17
+ `private final` fields set in the constructor (no `@Autowired` on a sole
18
+ constructor); a Kotlin class declares constructor `val` properties.
19
+ Field-level `@Autowired` is discouraged.
20
+ - Overrides the `solid-principles.mdc` "Constructor dependencies" row
21
+ for Java/Kotlin: more than 4 is the threshold, a signal of too many
22
+ responsibilities, never a reason to fall back to field injection.
28
23
 
29
24
  ## Layered architecture
30
25
 
31
- - Keep the controller/service/repository layers distinct: a
32
- `@RestController` parses/validates the request and delegates to a
33
- `@Service`; business logic and transaction boundaries live in the
34
- service layer; a `@Repository`/Spring Data interface is the only layer
35
- that talks to persistence. Do not put query logic in a controller or
36
- HTTP concerns in a service.
37
- - Expose a request/response DTO at the API boundary, never a JPA `@Entity`
38
- directly — an entity carries lazy associations and persistence-specific
39
- fields that leak internal structure and can trigger
40
- `LazyInitializationException` when serialized outside a transaction.
26
+ - Controller/service/repository layers stay distinct: a `@RestController`
27
+ parses/validates the request and delegates to a `@Service`; business logic
28
+ and transaction boundaries live in the service; a `@Repository`/Spring Data
29
+ interface is the only layer that talks to persistence.
30
+ - Expose a request/response DTO at the API boundary, never a JPA `@Entity`.
41
31
 
42
32
  ## Naming and structure
43
33
 
44
- - Java: standard `PascalCase` for types, `camelCase` for members/methods,
45
- packages lowercase with no underscores.
46
- - Kotlin: `PascalCase` for classes, `camelCase` for functions/properties;
47
- prefer a `data class` for a DTO/value-holder instead of a plain class
48
- with manually written `equals`/`hashCode`/`toString`.
49
- - Kotlin null-safety: model an optional field as a nullable type (`String?`)
50
- and handle it with `?.`/`?:`/`requireNotNull`, not `!!` — a `!!` on
51
- anything that can plausibly be null at runtime (a request field, a
52
- lookup result) reintroduces the NPE the type system exists to prevent.
34
+ - Kotlin: a `data class` for a DTO/value-holder, not a plain class with
35
+ hand-written `equals`/`hashCode`/`toString`.
36
+ - Kotlin null-safety: an optional field is a nullable type (`String?`)
37
+ handled with `?.`/`?:`/`requireNotNull`, not `!!`.
53
38
 
54
39
  ## Bean Validation and DTOs
55
40
 
56
- - Annotate request DTO fields with `jakarta.validation` constraints
57
- (`@NotNull`, `@NotBlank`, `@Size`, `@Email`, etc.) and mark the
58
- controller parameter `@Valid`/`@Validated` — validation belongs on the
59
- DTO at the boundary, not re-implemented as manual `if` checks inside
60
- the service.
41
+ - `jakarta.validation` constraints (`@NotNull`, `@NotBlank`, `@Size`,
42
+ `@Email`) on request DTO fields and `@Valid`/`@Validated` on the controller
43
+ parameter, not manual `if` checks in the service.
61
44
 
62
45
  ## Formatting
63
46
 
64
47
  - Follow the project's configured formatter (`spotless`, `ktlint`,
65
- google-java-format, or whatever `build.gradle(.kts)`/`pom.xml` already
66
- wires up) rather than hand-formatting around it; do not introduce a
67
- second formatter into a project that has already standardized on one.
48
+ google-java-format); do not add a second one.
@@ -8,58 +8,41 @@ metadata:
8
8
  # Java/Kotlin + Spring patterns
9
9
 
10
10
  Narrows `core-common-rules`' stack-agnostic design guidance to idiomatic
11
- Spring Boot 3.x design and its common anti-patterns, for both Java and
12
- Kotlin. Applies only to `*.java`/`*.kt`/`*.kts` files.
11
+ Spring Boot 3.x design, for both Java and Kotlin. Applies only to
12
+ `*.java`/`*.kt`/`*.kts` files.
13
13
 
14
14
  ## Transaction boundaries and the self-invocation pitfall
15
15
 
16
- - `@Transactional` is placed on the outermost service method that defines
17
- the unit of work, not scattered on every repository call.
18
- - Spring's declarative transactions are proxy-based (AOP): a call from
19
- one method to another `@Transactional` method **on the same class**,
20
- through `this`, bypasses the proxy entirely — the annotation is
21
- silently ignored, no new transaction starts and no rollback happens on
22
- that inner call. Split the self-invoking method out into a separate
23
- bean the caller depends on (constructor-injected), so the call crosses
24
- a real proxy boundary, instead of calling `this.otherTransactionalMethod()`.
25
- - Keep a `@Transactional` method free of unrelated I/O (HTTP calls,
26
- file access) that would hold the transaction/connection open longer
27
- than necessary.
16
+ - `@Transactional` on the outermost service method that defines the unit of
17
+ work, not on every repository call.
18
+ - A call to another `@Transactional` method on the same class through `this`
19
+ bypasses the proxy and the annotation is ignored. Move the method to a
20
+ separate constructor-injected bean.
21
+ - No unrelated I/O (HTTP calls, file access) inside a `@Transactional`
22
+ method.
28
23
 
29
24
  ## Spring Data JPA query patterns
30
25
 
31
- - Watch for N+1: iterating a collection and accessing a lazy association
32
- per item issues one query per item. Fix with `@EntityGraph` on the
33
- repository method, a JPQL `JOIN FETCH`, or a projection that selects
34
- only the fields actually needed — do not switch every association to
35
- `FetchType.EAGER` as a blanket fix, which just moves the N+1 into every
36
- unrelated query that loads the entity.
37
- - Prefer a derived query method or `@Query` with named parameters over
38
- building JPQL/native SQL by string concatenation.
39
- - Use a projection (an interface or DTO) for a read path that only needs
40
- a subset of an entity's fields, instead of loading the full entity
41
- graph and mapping it down in the service layer.
26
+ - N+1 on lazy associations: fix with `@EntityGraph`, JPQL `JOIN FETCH`, or a
27
+ projection; no blanket `FetchType.EAGER`.
28
+ - A derived query method or `@Query` with named parameters over
29
+ string-concatenated JPQL/native SQL.
30
+ - A projection (interface or DTO) for a read path needing a subset of an
31
+ entity's fields.
42
32
 
43
33
  ## Dependency injection and bean design
44
34
 
45
- - Define an interface at the consumer boundary (the package/module that
46
- calls through it) when a component genuinely has more than one
47
- implementation or needs to be mocked across module boundaries; do not
48
- add an interface with a single Spring-managed implementation "for
49
- testability" when constructor injection with a concrete class already
50
- gives a test the same seam via a test double.
51
- - Favor constructor injection producing an immutable, fully-initialized
52
- bean over setter injection or field injection, which both allow a bean
53
- to exist in a partially-configured state.
35
+ - An interface at the consumer boundary only when a component has more than
36
+ one implementation or must be mocked across module boundaries; none for a
37
+ single Spring-managed implementation "for testability".
38
+ - Constructor injection producing an immutable, fully-initialized bean over
39
+ setter or field injection.
54
40
 
55
41
  ## Anti-patterns to flag
56
42
 
57
- - A "god service" that accumulates unrelated business logic across
58
- multiple domains — split by bounded responsibility, mirroring the
59
- controller/service/repository layering above.
60
- - Catching a broad `Exception`/`RuntimeException` in a service method
61
- only to log and swallow it, instead of letting it propagate to a
62
- `@ControllerAdvice`/`@ExceptionHandler` that maps it to the right HTTP
63
- response.
64
- - A `@RestController` method containing business/query logic directly
65
- instead of delegating to a service — controllers should stay thin.
43
+ - A "god service" accumulating unrelated business logic across domains.
44
+ - Catching a broad `Exception`/`RuntimeException` in a service only to log
45
+ and swallow it, instead of propagating to a `@ControllerAdvice`/
46
+ `@ExceptionHandler`.
47
+ - A `@RestController` method containing business/query logic instead of
48
+ delegating to a service.
@@ -8,62 +8,50 @@ metadata:
8
8
  # Java/Kotlin + Spring security
9
9
 
10
10
  Narrows `core-common-rules`' stack-agnostic security rules to Spring Boot
11
- 3.x-specific, OWASP-relevant risks. Broadly scoped to all Java/Kotlin
12
- sources for data-access and secrets guidance below, with extra emphasis
13
- on controller/security-config files for the HTTP-facing rules.
11
+ 3.x-specific risks (OWASP). Broadly scoped to all Java/Kotlin sources for
12
+ data-access and secrets guidance, with extra emphasis on controller and
13
+ security-config files for the HTTP-facing rules.
14
14
 
15
15
  ## Spring Security configuration
16
16
 
17
- - Configure security with a `SecurityFilterChain` `@Bean` returned from a
18
- `@Configuration` class (`http.build()` on an `HttpSecurity` you have
19
- customized) — this is the current Spring Boot 3.x idiom. Do not extend
20
- `WebSecurityConfigurerAdapter`; it was removed in Spring Security 6 /
21
- Spring Boot 3 and any code still referencing it is targeting an old
22
- major version.
23
- - Scope authorization rules explicitly (`authorizeHttpRequests` with
24
- path/role matchers) rather than leaving a catch-all `permitAll()` that
25
- was only meant for one endpoint during development.
17
+ - A `SecurityFilterChain` `@Bean` from a `@Configuration` class
18
+ (`http.build()`); never extend `WebSecurityConfigurerAdapter` (removed in
19
+ Spring Security 6 / Spring Boot 3).
20
+ - Scope authorization explicitly (`authorizeHttpRequests` with path/role
21
+ matchers); no catch-all `permitAll()` left from one development endpoint.
26
22
 
27
23
  ## CSRF
28
24
 
29
25
  - A stateless, token-authenticated API (bearer JWT/OAuth2, no session
30
- cookie) legitimately disables CSRF protection (`csrf(AbstractHttpConfigurer::disable)`)
31
- because CSRF exploits ambient cookie auth, which does not apply here —
32
- state this reasoning explicitly when disabling it.
26
+ cookie) may disable CSRF (`csrf(AbstractHttpConfigurer::disable)`); state
27
+ the reason when disabling it.
33
28
  - A session-cookie-authenticated endpoint (browser form login, `JSESSIONID`)
34
- must keep CSRF protection enabled; disabling it there reopens the exact
35
- attack the stateless-API exception does not apply to.
29
+ keeps CSRF protection enabled.
36
30
 
37
31
  ## SQL and data access
38
32
 
39
- - Use Spring Data JPA derived queries or parameterized `@Query`
40
- (JPQL/native, with named or positional bind parameters), never
41
- string-concatenated or `String.format`-built SQL/JPQL with any
42
- user-influenced value — parameterization is the injection defense, not
43
- an input-validation substitute for it.
44
- - The same applies to `JdbcTemplate`/`NamedParameterJdbcTemplate`: use its
45
- parameter-binding API, never interpolate a value into the SQL string.
33
+ - Spring Data JPA derived queries or parameterized `@Query` (named or
34
+ positional bind parameters); never string-concatenated or
35
+ `String.format`-built SQL/JPQL with a user-influenced value.
36
+ - `JdbcTemplate`/`NamedParameterJdbcTemplate` through its parameter-binding
37
+ API, never interpolation into the SQL string.
46
38
 
47
39
  ## Input validation as the DTO boundary defense
48
40
 
49
41
  - Validate untrusted input at the DTO boundary with `jakarta.validation`
50
- annotations plus `@Valid`/`@Validated` on the controller method — this
51
- is the primary injection/malformed-input defense point for request
52
- data, on top of (not instead of) parameterized queries downstream.
42
+ annotations plus `@Valid`/`@Validated` on the controller method, in
43
+ addition to parameterized queries downstream.
53
44
 
54
45
  ## Secrets and configuration
55
46
 
56
- - Never hard-code a credential, API key, or signing secret in source or
57
- in `application.yml`/`application.properties` committed to the repo —
58
- load it from environment variables, a config server, or the secret
59
- store the project already uses (Spring's externalized configuration
60
- supports both cleanly).
61
- - Do not log a request/response body that may carry credentials, tokens,
62
- or PII at `INFO`/`DEBUG` level without redaction.
47
+ - No hard-coded credential, API key, or signing secret in source or in
48
+ committed `application.yml`/`application.properties`; use environment
49
+ variables, a config server, or the project's secret store.
50
+ - Do not log a request/response body that may carry credentials, tokens, or
51
+ PII at `INFO`/`DEBUG` without redaction.
63
52
 
64
53
  ## Dependency hygiene
65
54
 
66
55
  - Run the project's configured dependency-vulnerability check (OWASP
67
- Dependency-Check plugin, `./gradlew dependencyCheckAnalyze`, or
68
- whatever the build already wires up) when introducing or bumping a
69
- dependency, rather than skipping it because "it's just a minor bump."
56
+ Dependency-Check plugin, `./gradlew dependencyCheckAnalyze`) when
57
+ introducing or bumping a dependency, including a minor bump.
@@ -13,68 +13,52 @@ Spring Boot Test conventions, for both Java and Kotlin. Applies only to
13
13
 
14
14
  ## Layout and naming
15
15
 
16
- - Tests live under `src/test/java` or `src/test/kotlin`, mirroring the
17
- package of the class under test, named `<Type>Test` (unit) or
18
- `<Type>IT`/`<Type>IntegrationTest` (integration) — match whichever
19
- convention the project already uses.
20
- - Prefer a plain, dependency-free unit test (construct the class
21
- directly, pass mocks/fakes to the constructor) for logic that does not
22
- need the Spring container; reserve `@SpringBootTest` for genuine
23
- integration coverage — a full context load per test class is slow and
24
- is not a substitute for testing a service's logic in isolation.
16
+ - Tests under `src/test/java` or `src/test/kotlin`, mirroring the package of
17
+ the class under test, named `<Type>Test` (unit) or
18
+ `<Type>IT`/`<Type>IntegrationTest` (integration); match the project's
19
+ convention.
20
+ - A plain unit test (construct the class directly, pass mocks/fakes to the
21
+ constructor) for logic that does not need the Spring container;
22
+ `@SpringBootTest` only for genuine integration coverage.
25
23
 
26
24
  ## Test slices
27
25
 
28
- - Use the narrowest Spring test slice that covers what is being tested:
29
- `@WebMvcTest` for a controller (with `MockMvc`), `@DataJpaTest` for a
30
- repository, `@SpringBootTest` only when the interaction across the
31
- whole wired context is actually what is under test.
32
- - For a repository/integration test that needs a real database, prefer
33
- Testcontainers over an in-memory substitute (H2 standing in for
34
- Postgres/MySQL) when the project already uses Testcontainers — an
35
- in-memory DB can silently pass a query that the real production
36
- database would reject or execute differently.
26
+ - The narrowest Spring test slice: `@WebMvcTest` for a controller (with
27
+ `MockMvc`), `@DataJpaTest` for a repository, `@SpringBootTest` only when
28
+ the interaction across the whole wired context is under test.
29
+ - Testcontainers over an in-memory substitute (H2 standing in for
30
+ Postgres/MySQL) when the project already uses Testcontainers.
37
31
 
38
32
  ## Mocking
39
33
 
40
- - Mock/stub only the collaborators the class under test actually depends
41
- on (Mockito's `@Mock`/`@InjectMocks`, or MockK for Kotlin) — do not
42
- reach for `@MockitoBean`/`@SpringBootTest` just to avoid constructing a
43
- plain dependency by hand when the class was designed for constructor
44
- injection. `@MockitoBean` is the current annotation for mocking a bean
45
- inside a Spring test slice; Spring Boot's own `@MockBean` is deprecated
46
- since Boot 3.4 and removed in 4.x, so only reach for it on a project
47
- still pinned below 3.4.
48
- - Assert on behavior/interactions relevant to the test (`verify(...)`),
49
- not on incidental implementation details that would make the test
50
- brittle to a harmless refactor.
34
+ - Mock/stub only the collaborators the class under test depends on
35
+ (Mockito `@Mock`/`@InjectMocks`, or MockK for Kotlin); no
36
+ `@MockitoBean`/`@SpringBootTest` just to avoid constructing a plain
37
+ dependency by hand. `@MockitoBean` is the annotation for mocking a bean
38
+ inside a Spring test slice; `@MockBean` is deprecated since Boot 3.4 and
39
+ removed in 4.x, so use it only on a project pinned below 3.4.
40
+ - Assert on behavior/interactions relevant to the test (`verify(...)`), not
41
+ incidental implementation details.
51
42
 
52
43
  ## Assertions and determinism
53
44
 
54
- - Use the project's already-configured assertion library (AssertJ,
55
- JUnit's own assertions, or Kotlin's `kotlin.test`) — do not introduce a
56
- second one into a project that has standardized.
57
- - Never synchronize with `Thread.sleep`/`delay` to wait for an async
58
- result — use Awaitility (`await().atMost(...).until(...)`), a
59
- `CompletableFuture`/coroutine join, or a `CountDownLatch`, so the test
60
- is deterministic and not flaky under CI load.
61
- - A test covering validation should assert on the specific constraint
62
- violation/exception type, not just that "some" exception was thrown.
45
+ - The project's configured assertion library (AssertJ, JUnit's own, or
46
+ Kotlin's `kotlin.test`); do not add a second.
47
+ - Never `Thread.sleep`/`delay` to wait for an async result; use Awaitility
48
+ (`await().atMost(...).until(...)`), a `CompletableFuture`/coroutine join,
49
+ or a `CountDownLatch`.
50
+ - A validation test asserts the specific constraint violation/exception type.
63
51
 
64
52
  ## Fixtures and lifecycle
65
53
 
66
- - Prefer a builder or a test-fixture factory method for constructing
67
- entities/DTOs with sensible defaults, overriding only the fields the
68
- test cares about, over duplicating a large constructor call in every
69
- test method.
70
- - Use `@BeforeEach`/`@AfterEach` (or Kotlin's equivalents) for
71
- per-test setup/teardown; reserve `@BeforeAll`/`@AfterAll` for
72
- genuinely expensive, safely-shared setup (a Testcontainers instance).
54
+ - A builder or test-fixture factory method with sensible defaults,
55
+ overriding only the fields the test cares about.
56
+ - `@BeforeEach`/`@AfterEach` for per-test setup/teardown; `@BeforeAll`/
57
+ `@AfterAll` only for expensive, safely-shared setup (a Testcontainers
58
+ instance).
73
59
 
74
60
  ## Coverage expectations
75
61
 
76
- - New behavior gets a new test in the same change; a bug fix gets a
77
- regression test that fails before the fix and passes after.
78
- - Run the project's build-tool test task (`./gradlew test` or `mvn test`)
79
- for any change touching test files, and its integration-test task
80
- separately when one is configured, before reporting done.
62
+ - Run the build-tool test task (`./gradlew test` or `mvn test`) for any
63
+ change touching test files, and the integration-test task separately when
64
+ configured, before reporting done.