hatch3r 1.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 (132) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +437 -0
  3. package/agents/hatch3r-a11y-auditor.md +126 -0
  4. package/agents/hatch3r-architect.md +160 -0
  5. package/agents/hatch3r-ci-watcher.md +123 -0
  6. package/agents/hatch3r-context-rules.md +97 -0
  7. package/agents/hatch3r-dependency-auditor.md +164 -0
  8. package/agents/hatch3r-devops.md +138 -0
  9. package/agents/hatch3r-docs-writer.md +97 -0
  10. package/agents/hatch3r-implementer.md +162 -0
  11. package/agents/hatch3r-learnings-loader.md +108 -0
  12. package/agents/hatch3r-lint-fixer.md +104 -0
  13. package/agents/hatch3r-perf-profiler.md +123 -0
  14. package/agents/hatch3r-researcher.md +642 -0
  15. package/agents/hatch3r-reviewer.md +81 -0
  16. package/agents/hatch3r-security-auditor.md +119 -0
  17. package/agents/hatch3r-test-writer.md +134 -0
  18. package/commands/hatch3r-agent-customize.md +146 -0
  19. package/commands/hatch3r-api-spec.md +49 -0
  20. package/commands/hatch3r-benchmark.md +50 -0
  21. package/commands/hatch3r-board-fill.md +504 -0
  22. package/commands/hatch3r-board-init.md +315 -0
  23. package/commands/hatch3r-board-pickup.md +672 -0
  24. package/commands/hatch3r-board-refresh.md +198 -0
  25. package/commands/hatch3r-board-shared.md +369 -0
  26. package/commands/hatch3r-bug-plan.md +410 -0
  27. package/commands/hatch3r-codebase-map.md +1182 -0
  28. package/commands/hatch3r-command-customize.md +94 -0
  29. package/commands/hatch3r-context-health.md +112 -0
  30. package/commands/hatch3r-cost-tracking.md +139 -0
  31. package/commands/hatch3r-dep-audit.md +171 -0
  32. package/commands/hatch3r-feature-plan.md +379 -0
  33. package/commands/hatch3r-healthcheck.md +307 -0
  34. package/commands/hatch3r-hooks.md +282 -0
  35. package/commands/hatch3r-learn.md +217 -0
  36. package/commands/hatch3r-migration-plan.md +51 -0
  37. package/commands/hatch3r-onboard.md +56 -0
  38. package/commands/hatch3r-project-spec.md +1153 -0
  39. package/commands/hatch3r-recipe.md +179 -0
  40. package/commands/hatch3r-refactor-plan.md +426 -0
  41. package/commands/hatch3r-release.md +328 -0
  42. package/commands/hatch3r-roadmap.md +556 -0
  43. package/commands/hatch3r-rule-customize.md +114 -0
  44. package/commands/hatch3r-security-audit.md +370 -0
  45. package/commands/hatch3r-skill-customize.md +93 -0
  46. package/commands/hatch3r-workflow.md +377 -0
  47. package/dist/cli/hooks-ZOTFDEA3.js +59 -0
  48. package/dist/cli/index.d.ts +2 -0
  49. package/dist/cli/index.js +3584 -0
  50. package/github-agents/hatch3r-docs-agent.md +46 -0
  51. package/github-agents/hatch3r-lint-agent.md +41 -0
  52. package/github-agents/hatch3r-security-agent.md +54 -0
  53. package/github-agents/hatch3r-test-agent.md +66 -0
  54. package/hooks/hatch3r-ci-failure.md +10 -0
  55. package/hooks/hatch3r-file-save.md +11 -0
  56. package/hooks/hatch3r-post-merge.md +10 -0
  57. package/hooks/hatch3r-pre-commit.md +11 -0
  58. package/hooks/hatch3r-pre-push.md +10 -0
  59. package/hooks/hatch3r-session-start.md +10 -0
  60. package/mcp/mcp.json +62 -0
  61. package/package.json +84 -0
  62. package/prompts/hatch3r-bug-triage.md +155 -0
  63. package/prompts/hatch3r-code-review.md +131 -0
  64. package/prompts/hatch3r-pr-description.md +173 -0
  65. package/rules/hatch3r-accessibility-standards.md +77 -0
  66. package/rules/hatch3r-accessibility-standards.mdc +75 -0
  67. package/rules/hatch3r-agent-orchestration.md +160 -0
  68. package/rules/hatch3r-api-design.md +176 -0
  69. package/rules/hatch3r-api-design.mdc +176 -0
  70. package/rules/hatch3r-browser-verification.md +73 -0
  71. package/rules/hatch3r-browser-verification.mdc +73 -0
  72. package/rules/hatch3r-ci-cd.md +70 -0
  73. package/rules/hatch3r-ci-cd.mdc +68 -0
  74. package/rules/hatch3r-code-standards.md +102 -0
  75. package/rules/hatch3r-code-standards.mdc +100 -0
  76. package/rules/hatch3r-component-conventions.md +102 -0
  77. package/rules/hatch3r-component-conventions.mdc +102 -0
  78. package/rules/hatch3r-data-classification.md +85 -0
  79. package/rules/hatch3r-data-classification.mdc +83 -0
  80. package/rules/hatch3r-dependency-management.md +17 -0
  81. package/rules/hatch3r-dependency-management.mdc +15 -0
  82. package/rules/hatch3r-error-handling.md +17 -0
  83. package/rules/hatch3r-error-handling.mdc +15 -0
  84. package/rules/hatch3r-feature-flags.md +112 -0
  85. package/rules/hatch3r-feature-flags.mdc +112 -0
  86. package/rules/hatch3r-git-conventions.md +47 -0
  87. package/rules/hatch3r-git-conventions.mdc +45 -0
  88. package/rules/hatch3r-i18n.md +90 -0
  89. package/rules/hatch3r-i18n.mdc +90 -0
  90. package/rules/hatch3r-learning-consult.md +29 -0
  91. package/rules/hatch3r-learning-consult.mdc +27 -0
  92. package/rules/hatch3r-migrations.md +17 -0
  93. package/rules/hatch3r-migrations.mdc +15 -0
  94. package/rules/hatch3r-observability.md +165 -0
  95. package/rules/hatch3r-observability.mdc +165 -0
  96. package/rules/hatch3r-performance-budgets.md +109 -0
  97. package/rules/hatch3r-performance-budgets.mdc +109 -0
  98. package/rules/hatch3r-secrets-management.md +76 -0
  99. package/rules/hatch3r-secrets-management.mdc +74 -0
  100. package/rules/hatch3r-security-patterns.md +211 -0
  101. package/rules/hatch3r-security-patterns.mdc +211 -0
  102. package/rules/hatch3r-testing.md +89 -0
  103. package/rules/hatch3r-testing.mdc +87 -0
  104. package/rules/hatch3r-theming.md +51 -0
  105. package/rules/hatch3r-theming.mdc +51 -0
  106. package/rules/hatch3r-tooling-hierarchy.md +92 -0
  107. package/rules/hatch3r-tooling-hierarchy.mdc +79 -0
  108. package/skills/hatch3r-a11y-audit/SKILL.md +131 -0
  109. package/skills/hatch3r-agent-customize/SKILL.md +75 -0
  110. package/skills/hatch3r-api-spec/SKILL.md +66 -0
  111. package/skills/hatch3r-architecture-review/SKILL.md +96 -0
  112. package/skills/hatch3r-bug-fix/SKILL.md +129 -0
  113. package/skills/hatch3r-ci-pipeline/SKILL.md +76 -0
  114. package/skills/hatch3r-command-customize/SKILL.md +67 -0
  115. package/skills/hatch3r-context-health/SKILL.md +76 -0
  116. package/skills/hatch3r-cost-tracking/SKILL.md +65 -0
  117. package/skills/hatch3r-dep-audit/SKILL.md +82 -0
  118. package/skills/hatch3r-feature/SKILL.md +129 -0
  119. package/skills/hatch3r-gh-agentic-workflows/SKILL.md +150 -0
  120. package/skills/hatch3r-incident-response/SKILL.md +86 -0
  121. package/skills/hatch3r-issue-workflow/SKILL.md +139 -0
  122. package/skills/hatch3r-logical-refactor/SKILL.md +73 -0
  123. package/skills/hatch3r-migration/SKILL.md +76 -0
  124. package/skills/hatch3r-perf-audit/SKILL.md +114 -0
  125. package/skills/hatch3r-pr-creation/SKILL.md +85 -0
  126. package/skills/hatch3r-qa-validation/SKILL.md +86 -0
  127. package/skills/hatch3r-recipe/SKILL.md +67 -0
  128. package/skills/hatch3r-refactor/SKILL.md +86 -0
  129. package/skills/hatch3r-release/SKILL.md +93 -0
  130. package/skills/hatch3r-rule-customize/SKILL.md +70 -0
  131. package/skills/hatch3r-skill-customize/SKILL.md +67 -0
  132. package/skills/hatch3r-visual-refactor/SKILL.md +89 -0
@@ -0,0 +1,176 @@
1
+ ---
2
+ description: API endpoint and contract design patterns for the project
3
+ alwaysApply: true
4
+ ---
5
+ # API Design
6
+
7
+ - Use consistent request/response schemas. Document in spec files.
8
+ - All endpoints versioned (URL prefix or header). Backward-compatible changes only.
9
+ - Additive changes only: add fields, never rename or remove without migration.
10
+ - Error responses follow standard shape: `{ code, message, details? }`.
11
+ - Idempotency keys for mutation endpoints. Reject duplicate requests.
12
+ - Request validation at the boundary: validate and sanitize before processing.
13
+ - List endpoints return envelopes: `{ data, pagination }`. Never raw arrays.
14
+ - Rate limiting enforced server-side. Return 429 with `Retry-After` when exceeded.
15
+ - API contracts documented in project specs. Update on schema changes.
16
+
17
+ ## Authentication & Authorization
18
+
19
+ - Validate JWT signature, expiration (`exp`), audience (`aud`), and issuer (`iss`) on every request.
20
+ - Enforce algorithm in server config (`RS256` for asymmetric, `HS256` for symmetric). Reject `alg: none`.
21
+ - Access tokens short-lived (15–60 min). Use opaque refresh tokens with rotation and revocation.
22
+ - OAuth 2.0 with PKCE for SPAs and mobile clients. Never use implicit flow.
23
+ - API keys identify applications, not users. Scope keys to specific services and rotate on schedule.
24
+ - Authorization middleware checks permissions before handler execution. Fail closed on missing claims.
25
+ - Apply principle of least privilege: scope tokens to the minimum required permissions.
26
+ - Store tokens in `HttpOnly`, `Secure`, `SameSite=Strict` cookies when possible. Avoid `localStorage`.
27
+
28
+ ## CORS Policy
29
+
30
+ - Allowlist specific origins explicitly. Never use `Access-Control-Allow-Origin: *` in production.
31
+ - Set `Access-Control-Allow-Credentials: true` only for origins that require cookie-based auth.
32
+ - Cache preflight responses with `Access-Control-Max-Age` (e.g., 7200 seconds) to reduce OPTIONS overhead.
33
+ - Restrict `Access-Control-Allow-Methods` to the methods the endpoint actually supports.
34
+ - Restrict `Access-Control-Allow-Headers` to required headers. Do not reflect the request's headers verbatim.
35
+ - Reject requests from origins not on the allowlist at the gateway level before reaching application code.
36
+
37
+ ## Security Headers
38
+
39
+ - `Strict-Transport-Security`: `max-age=63072000; includeSubDomains; preload`. Enforce HTTPS everywhere.
40
+ - `Content-Security-Policy`: Use nonce-based script directives. Avoid `unsafe-inline` and `unsafe-eval`.
41
+ - `X-Content-Type-Options: nosniff`. Prevent MIME-type sniffing.
42
+ - `X-Frame-Options: DENY` (or `SAMEORIGIN` if iframing is required within the same domain).
43
+ - `Referrer-Policy: strict-origin-when-cross-origin`. Minimize referrer leakage.
44
+ - `Permissions-Policy`: Disable unused browser features (`camera=(), microphone=(), geolocation=()`).
45
+ - Return security headers from a centralized middleware so every response includes them consistently.
46
+
47
+ ## Pagination Standards
48
+
49
+ - Default to cursor-based pagination for ordered data with high write frequency or deep traversal.
50
+ - Use offset-based pagination only for small, stable datasets where total count is cheap.
51
+ - Enforce a maximum page size server-side (e.g., 100 items). Ignore client requests exceeding the limit.
52
+ - Return `nextCursor` (or `null`) in the envelope. Clients must not construct cursors—they are opaque.
53
+ - Total count is optional: provide it only when the query cost is bounded. Use `hasMore` boolean otherwise.
54
+ - Reject deep offset pagination beyond a threshold (e.g., offset > 10000) to protect database performance.
55
+ - Include pagination metadata in the envelope: `{ data, pagination: { nextCursor, hasMore, pageSize } }`.
56
+
57
+ ## Request Security
58
+
59
+ - Enforce TLS 1.2+ (prefer 1.3). Terminate TLS at the edge or load balancer; reject plaintext HTTP.
60
+ - Set request body size limits per endpoint (e.g., 1 MB default, higher for file uploads with explicit cap).
61
+ - Validate `Content-Type` header matches expected media type. Reject mismatched content types with 415.
62
+ - File uploads: validate MIME type by inspecting magic bytes, not just the extension or header. Restrict to an allowlist.
63
+ - SSRF prevention: validate and restrict outbound URLs to an allowlist. Block private/internal IP ranges (`10.x`, `172.16–31.x`, `169.254.x`, `127.x`, `::1`). Resolve DNS before checking.
64
+ - Sanitize user input that appears in outbound requests (headers, URLs, body). Parameterize—never interpolate.
65
+ - Apply request throttling per client identity, not just per IP, to handle shared proxies.
66
+
67
+ ## Webhook Security
68
+
69
+ - Sign payloads with HMAC-SHA256 using a per-provider shared secret. Include the signature in a header (e.g., `X-Webhook-Signature: v1=<hex>`).
70
+ - Include a timestamp header (e.g., `X-Webhook-Timestamp`). Reject payloads older than 5 minutes.
71
+ - Verify the signature over the raw request body bytes using constant-time comparison.
72
+ - Idempotency: track delivery IDs to prevent processing duplicate webhook events.
73
+ - Delivery retries: use exponential backoff (e.g., 1s, 5s, 30s, 5m, 30m) with a maximum retry count.
74
+ - Rotate webhook secrets periodically. Support dual-secret verification during rotation windows.
75
+ - Log signature verification failures and alert on anomalous patterns (spike in failures, unknown sources).
76
+ - Process webhook payloads asynchronously: acknowledge with 200 immediately, then enqueue for processing.
77
+
78
+ ## OpenAPI 3.1
79
+
80
+ - Use OpenAPI 3.1 for all REST API documentation. 3.1 aligns fully with JSON Schema (draft 2020-12), eliminating the type mismatches present in 3.0.
81
+ - **JSON Schema alignment:** Use standard JSON Schema keywords directly — `$ref` alongside other keywords, `type` as an array (`"type": ["string", "null"]`), `const`, `prefixItems`, `contentMediaType`. No more `nullable: true` (use `type: ["string", "null"]` instead).
82
+ - **Webhooks support:** Define webhooks as top-level objects alongside `paths`. Each webhook specifies the callback URL pattern, payload schema, and expected response.
83
+ - **`$id` and `$anchor`:** Use JSON Schema `$id` for reusable schema identification and `$anchor` for in-document references. This replaces the need for custom `x-` extension workarounds.
84
+ - Validate OpenAPI specs in CI using `@redocly/cli lint` or `spectral`. Block merges on validation failures.
85
+ - Generate TypeScript types from OpenAPI specs using `openapi-typescript` for compile-time contract enforcement between client and server.
86
+ - Version OpenAPI spec files alongside the code they describe. Every API change must include a corresponding spec update in the same PR.
87
+
88
+ ## GraphQL API Design
89
+
90
+ ### Schema Design
91
+
92
+ - **Schema-first:** Define the schema (SDL) before implementing resolvers. The schema is the contract — it drives both client and server code generation.
93
+ - **Naming:** Types in `PascalCase`, fields and arguments in `camelCase`, enum values in `SCREAMING_SNAKE_CASE`.
94
+ - **Nullability:** Fields are nullable by default in GraphQL. Use `!` (non-null) deliberately — only for fields that will always have a value. Over-using `!` makes error handling brittle.
95
+ - **Input types:** Use dedicated `input` types for mutations. Never reuse output types as mutation inputs.
96
+ - **Descriptions:** Every type, field, and argument must have a description in the SDL. These are the API documentation.
97
+
98
+ ### Pagination
99
+
100
+ - Implement the Relay Connection specification for paginated lists: `Connection` → `Edge` → `Node` pattern with `pageInfo` (hasNextPage, hasPreviousPage, startCursor, endCursor).
101
+ - Support `first`/`after` (forward) and `last`/`before` (backward) pagination arguments.
102
+ - Enforce a maximum page size server-side (e.g., 100). Reject requests exceeding the limit.
103
+
104
+ ### Error Handling
105
+
106
+ - Use the standard GraphQL `errors` array for operation-level errors. Include `extensions.code` for machine-readable error classification (e.g., `UNAUTHENTICATED`, `FORBIDDEN`, `VALIDATION_ERROR`).
107
+ - For field-level expected errors (e.g., a mutation that can fail), use union return types: `type CreateUserResult = User | ValidationError | ConflictError`. This makes error states explicit in the schema.
108
+ - Never expose internal error details (stack traces, SQL errors) in production error messages.
109
+
110
+ ### N+1 Prevention
111
+
112
+ - Use DataLoader (or equivalent batching library) for every resolver that fetches data from a data source. DataLoader batches and deduplicates requests within a single GraphQL operation.
113
+ - Create one DataLoader instance per request (not globally). Global loaders leak data between requests.
114
+ - Monitor resolver execution with tracing (OpenTelemetry) to identify N+1 patterns that escape DataLoader coverage.
115
+
116
+ ### Security
117
+
118
+ - Enforce query depth limits (e.g., max depth 10) and query complexity limits to prevent resource exhaustion from deeply nested or expensive queries.
119
+ - Disable introspection in production. Enable only in development and staging.
120
+ - Apply field-level authorization in resolvers. Schema visibility is not security — every resolver must verify permissions.
121
+
122
+ ## gRPC API Design
123
+
124
+ ### Protobuf Schema Design
125
+
126
+ - Use Protocol Buffers (proto3) for service and message definitions. Store `.proto` files in a shared `proto/` directory, versioned alongside code.
127
+ - **Naming:** Services in `PascalCase`, RPCs in `PascalCase`, messages in `PascalCase`, fields in `snake_case`, enums in `SCREAMING_SNAKE_CASE` with a `_UNSPECIFIED` zero value.
128
+ - **Field numbers:** Never reuse field numbers — they are the wire format identity. Reserve removed field numbers with `reserved`.
129
+ - **Backward compatibility:** Only add fields (never remove or rename). Use `optional` for new fields that older clients may not send. This is the same additive-only principle as REST.
130
+
131
+ ### Streaming Patterns
132
+
133
+ | Pattern | Use Case | Example |
134
+ |---------|----------|---------|
135
+ | Unary | Simple request-response | `GetUser(GetUserRequest) returns (User)` |
136
+ | Server streaming | Server pushes multiple responses | `WatchEvents(WatchRequest) returns (stream Event)` |
137
+ | Client streaming | Client sends multiple messages | `UploadChunks(stream Chunk) returns (UploadResult)` |
138
+ | Bidirectional streaming | Both sides stream | `Chat(stream Message) returns (stream Message)` |
139
+
140
+ - Default to unary RPCs. Use streaming only when the use case requires it (real-time feeds, large uploads, bidirectional communication).
141
+ - Implement proper stream lifecycle: handle cancellation, set deadlines, and clean up resources on stream termination.
142
+
143
+ ### Error Codes
144
+
145
+ - Use standard gRPC status codes (`google.rpc.Code`). Map domain errors to the most specific status code:
146
+
147
+ | Status Code | When to Use |
148
+ |-------------|-------------|
149
+ | `OK` | Success |
150
+ | `INVALID_ARGUMENT` | Client sent bad input |
151
+ | `NOT_FOUND` | Requested resource does not exist |
152
+ | `ALREADY_EXISTS` | Create conflict |
153
+ | `PERMISSION_DENIED` | Authenticated but not authorized |
154
+ | `UNAUTHENTICATED` | Missing or invalid credentials |
155
+ | `RESOURCE_EXHAUSTED` | Rate limit exceeded, quota depleted |
156
+ | `INTERNAL` | Unexpected server error |
157
+ | `UNAVAILABLE` | Transient failure, client should retry |
158
+ | `DEADLINE_EXCEEDED` | Operation timed out |
159
+
160
+ - Include structured error details using `google.rpc.Status` with `details` field for machine-readable error metadata (e.g., field violations, retry info).
161
+
162
+ ## Rate Limit Headers
163
+
164
+ Follow the IETF draft standard (`draft-ietf-httpapi-ratelimit-headers`) for rate limit response headers:
165
+
166
+ | Header | Description | Example |
167
+ |--------|-------------|---------|
168
+ | `RateLimit-Limit` | Maximum number of requests allowed in the current window | `100` |
169
+ | `RateLimit-Remaining` | Number of requests remaining in the current window | `42` |
170
+ | `RateLimit-Reset` | Seconds until the rate limit window resets | `30` |
171
+ | `Retry-After` | Seconds to wait before retrying (on 429 responses) | `30` |
172
+
173
+ - Return these headers on every API response (not just 429). This lets clients implement proactive throttling.
174
+ - When the rate limit is exceeded, return HTTP `429 Too Many Requests` with `Retry-After` header.
175
+ - Document rate limits per endpoint tier in the API specification (e.g., auth endpoints: 100/min, read endpoints: 1000/min, write endpoints: 500/min).
176
+ - Apply rate limiting by authenticated identity (API key, user token) as the primary key. Fall back to IP-based limiting for unauthenticated endpoints.
@@ -0,0 +1,176 @@
1
+ ---
2
+ description: API endpoint and contract design patterns for the project
3
+ alwaysApply: true
4
+ ---
5
+ # API Design
6
+
7
+ - Use consistent request/response schemas. Document in spec files.
8
+ - All endpoints versioned (URL prefix or header). Backward-compatible changes only.
9
+ - Additive changes only: add fields, never rename or remove without migration.
10
+ - Error responses follow standard shape: `{ code, message, details? }`.
11
+ - Idempotency keys for mutation endpoints. Reject duplicate requests.
12
+ - Request validation at the boundary: validate and sanitize before processing.
13
+ - List endpoints return envelopes: `{ data, pagination }`. Never raw arrays.
14
+ - Rate limiting enforced server-side. Return 429 with `Retry-After` when exceeded.
15
+ - API contracts documented in project specs. Update on schema changes.
16
+
17
+ ## Authentication & Authorization
18
+
19
+ - Validate JWT signature, expiration (`exp`), audience (`aud`), and issuer (`iss`) on every request.
20
+ - Enforce algorithm in server config (`RS256` for asymmetric, `HS256` for symmetric). Reject `alg: none`.
21
+ - Access tokens short-lived (15–60 min). Use opaque refresh tokens with rotation and revocation.
22
+ - OAuth 2.0 with PKCE for SPAs and mobile clients. Never use implicit flow.
23
+ - API keys identify applications, not users. Scope keys to specific services and rotate on schedule.
24
+ - Authorization middleware checks permissions before handler execution. Fail closed on missing claims.
25
+ - Apply principle of least privilege: scope tokens to the minimum required permissions.
26
+ - Store tokens in `HttpOnly`, `Secure`, `SameSite=Strict` cookies when possible. Avoid `localStorage`.
27
+
28
+ ## CORS Policy
29
+
30
+ - Allowlist specific origins explicitly. Never use `Access-Control-Allow-Origin: *` in production.
31
+ - Set `Access-Control-Allow-Credentials: true` only for origins that require cookie-based auth.
32
+ - Cache preflight responses with `Access-Control-Max-Age` (e.g., 7200 seconds) to reduce OPTIONS overhead.
33
+ - Restrict `Access-Control-Allow-Methods` to the methods the endpoint actually supports.
34
+ - Restrict `Access-Control-Allow-Headers` to required headers. Do not reflect the request's headers verbatim.
35
+ - Reject requests from origins not on the allowlist at the gateway level before reaching application code.
36
+
37
+ ## Security Headers
38
+
39
+ - `Strict-Transport-Security`: `max-age=63072000; includeSubDomains; preload`. Enforce HTTPS everywhere.
40
+ - `Content-Security-Policy`: Use nonce-based script directives. Avoid `unsafe-inline` and `unsafe-eval`.
41
+ - `X-Content-Type-Options: nosniff`. Prevent MIME-type sniffing.
42
+ - `X-Frame-Options: DENY` (or `SAMEORIGIN` if iframing is required within the same domain).
43
+ - `Referrer-Policy: strict-origin-when-cross-origin`. Minimize referrer leakage.
44
+ - `Permissions-Policy`: Disable unused browser features (`camera=(), microphone=(), geolocation=()`).
45
+ - Return security headers from a centralized middleware so every response includes them consistently.
46
+
47
+ ## Pagination Standards
48
+
49
+ - Default to cursor-based pagination for ordered data with high write frequency or deep traversal.
50
+ - Use offset-based pagination only for small, stable datasets where total count is cheap.
51
+ - Enforce a maximum page size server-side (e.g., 100 items). Ignore client requests exceeding the limit.
52
+ - Return `nextCursor` (or `null`) in the envelope. Clients must not construct cursors—they are opaque.
53
+ - Total count is optional: provide it only when the query cost is bounded. Use `hasMore` boolean otherwise.
54
+ - Reject deep offset pagination beyond a threshold (e.g., offset > 10000) to protect database performance.
55
+ - Include pagination metadata in the envelope: `{ data, pagination: { nextCursor, hasMore, pageSize } }`.
56
+
57
+ ## Request Security
58
+
59
+ - Enforce TLS 1.2+ (prefer 1.3). Terminate TLS at the edge or load balancer; reject plaintext HTTP.
60
+ - Set request body size limits per endpoint (e.g., 1 MB default, higher for file uploads with explicit cap).
61
+ - Validate `Content-Type` header matches expected media type. Reject mismatched content types with 415.
62
+ - File uploads: validate MIME type by inspecting magic bytes, not just the extension or header. Restrict to an allowlist.
63
+ - SSRF prevention: validate and restrict outbound URLs to an allowlist. Block private/internal IP ranges (`10.x`, `172.16–31.x`, `169.254.x`, `127.x`, `::1`). Resolve DNS before checking.
64
+ - Sanitize user input that appears in outbound requests (headers, URLs, body). Parameterize—never interpolate.
65
+ - Apply request throttling per client identity, not just per IP, to handle shared proxies.
66
+
67
+ ## Webhook Security
68
+
69
+ - Sign payloads with HMAC-SHA256 using a per-provider shared secret. Include the signature in a header (e.g., `X-Webhook-Signature: v1=<hex>`).
70
+ - Include a timestamp header (e.g., `X-Webhook-Timestamp`). Reject payloads older than 5 minutes.
71
+ - Verify the signature over the raw request body bytes using constant-time comparison.
72
+ - Idempotency: track delivery IDs to prevent processing duplicate webhook events.
73
+ - Delivery retries: use exponential backoff (e.g., 1s, 5s, 30s, 5m, 30m) with a maximum retry count.
74
+ - Rotate webhook secrets periodically. Support dual-secret verification during rotation windows.
75
+ - Log signature verification failures and alert on anomalous patterns (spike in failures, unknown sources).
76
+ - Process webhook payloads asynchronously: acknowledge with 200 immediately, then enqueue for processing.
77
+
78
+ ## OpenAPI 3.1
79
+
80
+ - Use OpenAPI 3.1 for all REST API documentation. 3.1 aligns fully with JSON Schema (draft 2020-12), eliminating the type mismatches present in 3.0.
81
+ - **JSON Schema alignment:** Use standard JSON Schema keywords directly — `$ref` alongside other keywords, `type` as an array (`"type": ["string", "null"]`), `const`, `prefixItems`, `contentMediaType`. No more `nullable: true` (use `type: ["string", "null"]` instead).
82
+ - **Webhooks support:** Define webhooks as top-level objects alongside `paths`. Each webhook specifies the callback URL pattern, payload schema, and expected response.
83
+ - **`$id` and `$anchor`:** Use JSON Schema `$id` for reusable schema identification and `$anchor` for in-document references. This replaces the need for custom `x-` extension workarounds.
84
+ - Validate OpenAPI specs in CI using `@redocly/cli lint` or `spectral`. Block merges on validation failures.
85
+ - Generate TypeScript types from OpenAPI specs using `openapi-typescript` for compile-time contract enforcement between client and server.
86
+ - Version OpenAPI spec files alongside the code they describe. Every API change must include a corresponding spec update in the same PR.
87
+
88
+ ## GraphQL API Design
89
+
90
+ ### Schema Design
91
+
92
+ - **Schema-first:** Define the schema (SDL) before implementing resolvers. The schema is the contract — it drives both client and server code generation.
93
+ - **Naming:** Types in `PascalCase`, fields and arguments in `camelCase`, enum values in `SCREAMING_SNAKE_CASE`.
94
+ - **Nullability:** Fields are nullable by default in GraphQL. Use `!` (non-null) deliberately — only for fields that will always have a value. Over-using `!` makes error handling brittle.
95
+ - **Input types:** Use dedicated `input` types for mutations. Never reuse output types as mutation inputs.
96
+ - **Descriptions:** Every type, field, and argument must have a description in the SDL. These are the API documentation.
97
+
98
+ ### Pagination
99
+
100
+ - Implement the Relay Connection specification for paginated lists: `Connection` → `Edge` → `Node` pattern with `pageInfo` (hasNextPage, hasPreviousPage, startCursor, endCursor).
101
+ - Support `first`/`after` (forward) and `last`/`before` (backward) pagination arguments.
102
+ - Enforce a maximum page size server-side (e.g., 100). Reject requests exceeding the limit.
103
+
104
+ ### Error Handling
105
+
106
+ - Use the standard GraphQL `errors` array for operation-level errors. Include `extensions.code` for machine-readable error classification (e.g., `UNAUTHENTICATED`, `FORBIDDEN`, `VALIDATION_ERROR`).
107
+ - For field-level expected errors (e.g., a mutation that can fail), use union return types: `type CreateUserResult = User | ValidationError | ConflictError`. This makes error states explicit in the schema.
108
+ - Never expose internal error details (stack traces, SQL errors) in production error messages.
109
+
110
+ ### N+1 Prevention
111
+
112
+ - Use DataLoader (or equivalent batching library) for every resolver that fetches data from a data source. DataLoader batches and deduplicates requests within a single GraphQL operation.
113
+ - Create one DataLoader instance per request (not globally). Global loaders leak data between requests.
114
+ - Monitor resolver execution with tracing (OpenTelemetry) to identify N+1 patterns that escape DataLoader coverage.
115
+
116
+ ### Security
117
+
118
+ - Enforce query depth limits (e.g., max depth 10) and query complexity limits to prevent resource exhaustion from deeply nested or expensive queries.
119
+ - Disable introspection in production. Enable only in development and staging.
120
+ - Apply field-level authorization in resolvers. Schema visibility is not security — every resolver must verify permissions.
121
+
122
+ ## gRPC API Design
123
+
124
+ ### Protobuf Schema Design
125
+
126
+ - Use Protocol Buffers (proto3) for service and message definitions. Store `.proto` files in a shared `proto/` directory, versioned alongside code.
127
+ - **Naming:** Services in `PascalCase`, RPCs in `PascalCase`, messages in `PascalCase`, fields in `snake_case`, enums in `SCREAMING_SNAKE_CASE` with a `_UNSPECIFIED` zero value.
128
+ - **Field numbers:** Never reuse field numbers — they are the wire format identity. Reserve removed field numbers with `reserved`.
129
+ - **Backward compatibility:** Only add fields (never remove or rename). Use `optional` for new fields that older clients may not send. This is the same additive-only principle as REST.
130
+
131
+ ### Streaming Patterns
132
+
133
+ | Pattern | Use Case | Example |
134
+ |---------|----------|---------|
135
+ | Unary | Simple request-response | `GetUser(GetUserRequest) returns (User)` |
136
+ | Server streaming | Server pushes multiple responses | `WatchEvents(WatchRequest) returns (stream Event)` |
137
+ | Client streaming | Client sends multiple messages | `UploadChunks(stream Chunk) returns (UploadResult)` |
138
+ | Bidirectional streaming | Both sides stream | `Chat(stream Message) returns (stream Message)` |
139
+
140
+ - Default to unary RPCs. Use streaming only when the use case requires it (real-time feeds, large uploads, bidirectional communication).
141
+ - Implement proper stream lifecycle: handle cancellation, set deadlines, and clean up resources on stream termination.
142
+
143
+ ### Error Codes
144
+
145
+ - Use standard gRPC status codes (`google.rpc.Code`). Map domain errors to the most specific status code:
146
+
147
+ | Status Code | When to Use |
148
+ |-------------|-------------|
149
+ | `OK` | Success |
150
+ | `INVALID_ARGUMENT` | Client sent bad input |
151
+ | `NOT_FOUND` | Requested resource does not exist |
152
+ | `ALREADY_EXISTS` | Create conflict |
153
+ | `PERMISSION_DENIED` | Authenticated but not authorized |
154
+ | `UNAUTHENTICATED` | Missing or invalid credentials |
155
+ | `RESOURCE_EXHAUSTED` | Rate limit exceeded, quota depleted |
156
+ | `INTERNAL` | Unexpected server error |
157
+ | `UNAVAILABLE` | Transient failure, client should retry |
158
+ | `DEADLINE_EXCEEDED` | Operation timed out |
159
+
160
+ - Include structured error details using `google.rpc.Status` with `details` field for machine-readable error metadata (e.g., field violations, retry info).
161
+
162
+ ## Rate Limit Headers
163
+
164
+ Follow the IETF draft standard (`draft-ietf-httpapi-ratelimit-headers`) for rate limit response headers:
165
+
166
+ | Header | Description | Example |
167
+ |--------|-------------|---------|
168
+ | `RateLimit-Limit` | Maximum number of requests allowed in the current window | `100` |
169
+ | `RateLimit-Remaining` | Number of requests remaining in the current window | `42` |
170
+ | `RateLimit-Reset` | Seconds until the rate limit window resets | `30` |
171
+ | `Retry-After` | Seconds to wait before retrying (on 429 responses) | `30` |
172
+
173
+ - Return these headers on every API response (not just 429). This lets clients implement proactive throttling.
174
+ - When the rate limit is exceeded, return HTTP `429 Too Many Requests` with `Retry-After` header.
175
+ - Document rate limits per endpoint tier in the API specification (e.g., auth endpoints: 100/min, read endpoints: 1000/min, write endpoints: 500/min).
176
+ - Apply rate limiting by authenticated identity (API key, user token) as the primary key. Fall back to IP-based limiting for unauthenticated endpoints.
@@ -0,0 +1,73 @@
1
+ ---
2
+ description: Browser-based verification for UI and user-facing changes
3
+ alwaysApply: false
4
+ ---
5
+ # Browser Verification
6
+
7
+ ## When Required
8
+
9
+ Browser verification is required when changes touch user-facing surfaces:
10
+
11
+ - UI component changes (new components, modified templates, style changes)
12
+ - User-facing features with visual or interactive elements
13
+ - Bug fixes for visually observable symptoms
14
+ - Visual refactors (layout, styling, animation changes)
15
+ - Accessibility audits and fixes
16
+ - Frontend performance profiling
17
+
18
+ ## When NOT Required
19
+
20
+ Skip browser verification for:
21
+
22
+ - Pure backend/API changes with no UI impact
23
+ - Configuration, environment, or infrastructure changes
24
+ - Documentation-only changes
25
+ - Data model or schema changes without corresponding UI
26
+ - CI/CD pipeline changes
27
+ - Code refactors that do not alter rendered output
28
+
29
+ ## Verification Protocol
30
+
31
+ ### 1. Ensure Dev Server is Running
32
+
33
+ - Check if the project's dev server is already running (check terminal output or process list).
34
+ - If not running, start it in the background using the project's dev command (e.g., `npm run dev`).
35
+ - Wait for the server to be ready before proceeding.
36
+ - Do NOT stop shared dev servers when done — other processes may depend on them.
37
+
38
+ ### 2. Navigate and Verify
39
+
40
+ - Open the browser and navigate to the page or surface affected by the change.
41
+ - Visually confirm the implementation matches acceptance criteria.
42
+ - Interact with the changed elements: click buttons, fill forms, trigger state changes.
43
+ - Check the browser console for errors or warnings introduced by the change.
44
+ - If the change is responsive, test at multiple viewport sizes.
45
+
46
+ ### 3. Capture Evidence
47
+
48
+ - Take screenshots of the affected surfaces showing the change works correctly.
49
+ - For before/after changes (visual refactors, bug fixes), capture both states when possible.
50
+ - Note any browser console errors or warnings in the verification summary.
51
+ - Include screenshots in the PR description or attach to the issue.
52
+
53
+ ### 4. Accessibility Spot-Check (if UI)
54
+
55
+ - Tab through new interactive elements to verify keyboard accessibility.
56
+ - Check that focus indicators are visible.
57
+ - Verify color contrast is sufficient on new or changed text.
58
+
59
+ ### 5. Visual Regression Testing
60
+
61
+ - **Screenshot comparison**: Use Playwright screenshot assertions (`expect(page).toHaveScreenshot()`) for page-level regression. For component-level visual regression, use Chromatic, Percy, or Playwright component screenshots. Compare against approved baselines on every PR.
62
+ - **Baseline management**: Store baseline images in version control (for Playwright) or in a cloud service (Chromatic/Percy). Review and approve visual diffs as part of the PR review workflow — treat unapproved visual changes as blocking.
63
+ - **What to capture**: Key pages and critical user flows at multiple viewport sizes: mobile (375px), tablet (768px), desktop (1440px). Capture dark and light theme variants. Capture empty, loading, and error states for data-driven pages.
64
+ - **Thresholds**: Configure a pixel-level variance threshold of 0.1–0.5% to tolerate anti-aliasing and font rendering differences across environments. Flag structural changes (layout shifts, missing elements, new elements) as hard failures regardless of threshold.
65
+ - **CI integration**: Run visual regression tests in the PR pipeline alongside unit and integration tests. Block merge on unapproved visual changes. Generate visual diff reports (side-by-side, overlay, or slider) and link them in the PR for reviewer access.
66
+
67
+ ## Tools
68
+
69
+ Use the browser automation MCP available in your environment:
70
+
71
+ - **Cursor:** `cursor-ide-browser` MCP (browser_navigate, browser_snapshot, browser_click, browser_type, browser_screenshot, browser_tabs)
72
+ - **Playwright MCP:** `@anthropic/mcp-playwright` for headless or headed browser automation
73
+ - **Fallback:** If no browser MCP is available, document that browser verification was skipped and why.
@@ -0,0 +1,73 @@
1
+ ---
2
+ description: Browser-based verification for UI and user-facing changes
3
+ alwaysApply: false
4
+ ---
5
+ # Browser Verification
6
+
7
+ ## When Required
8
+
9
+ Browser verification is required when changes touch user-facing surfaces:
10
+
11
+ - UI component changes (new components, modified templates, style changes)
12
+ - User-facing features with visual or interactive elements
13
+ - Bug fixes for visually observable symptoms
14
+ - Visual refactors (layout, styling, animation changes)
15
+ - Accessibility audits and fixes
16
+ - Frontend performance profiling
17
+
18
+ ## When NOT Required
19
+
20
+ Skip browser verification for:
21
+
22
+ - Pure backend/API changes with no UI impact
23
+ - Configuration, environment, or infrastructure changes
24
+ - Documentation-only changes
25
+ - Data model or schema changes without corresponding UI
26
+ - CI/CD pipeline changes
27
+ - Code refactors that do not alter rendered output
28
+
29
+ ## Verification Protocol
30
+
31
+ ### 1. Ensure Dev Server is Running
32
+
33
+ - Check if the project's dev server is already running (check terminal output or process list).
34
+ - If not running, start it in the background using the project's dev command (e.g., `npm run dev`).
35
+ - Wait for the server to be ready before proceeding.
36
+ - Do NOT stop shared dev servers when done — other processes may depend on them.
37
+
38
+ ### 2. Navigate and Verify
39
+
40
+ - Open the browser and navigate to the page or surface affected by the change.
41
+ - Visually confirm the implementation matches acceptance criteria.
42
+ - Interact with the changed elements: click buttons, fill forms, trigger state changes.
43
+ - Check the browser console for errors or warnings introduced by the change.
44
+ - If the change is responsive, test at multiple viewport sizes.
45
+
46
+ ### 3. Capture Evidence
47
+
48
+ - Take screenshots of the affected surfaces showing the change works correctly.
49
+ - For before/after changes (visual refactors, bug fixes), capture both states when possible.
50
+ - Note any browser console errors or warnings in the verification summary.
51
+ - Include screenshots in the PR description or attach to the issue.
52
+
53
+ ### 4. Accessibility Spot-Check (if UI)
54
+
55
+ - Tab through new interactive elements to verify keyboard accessibility.
56
+ - Check that focus indicators are visible.
57
+ - Verify color contrast is sufficient on new or changed text.
58
+
59
+ ### 5. Visual Regression Testing
60
+
61
+ - **Screenshot comparison**: Use Playwright screenshot assertions (`expect(page).toHaveScreenshot()`) for page-level regression. For component-level visual regression, use Chromatic, Percy, or Playwright component screenshots. Compare against approved baselines on every PR.
62
+ - **Baseline management**: Store baseline images in version control (for Playwright) or in a cloud service (Chromatic/Percy). Review and approve visual diffs as part of the PR review workflow — treat unapproved visual changes as blocking.
63
+ - **What to capture**: Key pages and critical user flows at multiple viewport sizes: mobile (375px), tablet (768px), desktop (1440px). Capture dark and light theme variants. Capture empty, loading, and error states for data-driven pages.
64
+ - **Thresholds**: Configure a pixel-level variance threshold of 0.1–0.5% to tolerate anti-aliasing and font rendering differences across environments. Flag structural changes (layout shifts, missing elements, new elements) as hard failures regardless of threshold.
65
+ - **CI integration**: Run visual regression tests in the PR pipeline alongside unit and integration tests. Block merge on unapproved visual changes. Generate visual diff reports (side-by-side, overlay, or slider) and link them in the PR for reviewer access.
66
+
67
+ ## Tools
68
+
69
+ Use the browser automation MCP available in your environment:
70
+
71
+ - **Cursor:** `cursor-ide-browser` MCP (browser_navigate, browser_snapshot, browser_click, browser_type, browser_screenshot, browser_tabs)
72
+ - **Playwright MCP:** `@anthropic/mcp-playwright` for headless or headed browser automation
73
+ - **Fallback:** If no browser MCP is available, document that browser verification was skipped and why.
@@ -0,0 +1,70 @@
1
+ ---
2
+ id: hatch3r-ci-cd
3
+ type: rule
4
+ description: CI/CD pipeline standards covering stage gates, deployment strategies, and rollback procedures
5
+ scope: always
6
+ ---
7
+ # CI/CD Standards
8
+
9
+ ## Pipeline Design
10
+
11
+ - Every pipeline must have these ordered stages: install, lint, typecheck, test, build, deploy.
12
+ - Stages within the same tier run in parallel. Cross-tier stages are sequential.
13
+ - Fail fast: a failing stage must abort all downstream stages immediately.
14
+ - Pipeline configuration lives in version control alongside the application code.
15
+ - Use matrix builds for multi-platform or multi-version testing.
16
+
17
+ ## Stage Gates
18
+
19
+ - **Lint gate:** Zero warnings policy. New warnings block the pipeline.
20
+ - **Type gate:** Strict mode with no suppressions. Type errors are build failures.
21
+ - **Test gate:** All tests pass. Coverage must not decrease from the base branch.
22
+ - **Security gate:** Dependency vulnerability scan with no critical/high findings.
23
+ - **Build gate:** Artifact must be reproducible — same commit produces identical output.
24
+
25
+ ## Artifact Management
26
+
27
+ - Build artifacts once per commit. Promote the same artifact across environments.
28
+ - Tag artifacts with: git SHA, branch name, build timestamp, pipeline run ID.
29
+ - Retention policy: production artifacts 90 days, staging 30 days, PR artifacts 7 days.
30
+ - Store build metadata (dependencies, test results, coverage) alongside the artifact.
31
+ - Never deploy an artifact that hasn't passed all stage gates.
32
+
33
+ ## Deployment Strategies
34
+
35
+ - **Staging:** Auto-deploy on merge to the default branch. No manual approval needed.
36
+ - **Production:** Require explicit approval from at least one team member.
37
+ - Use progressive deployment (canary or blue-green) for production services.
38
+ - Set automatic rollback triggers: error rate > 1%, latency p99 > 2x baseline, health check failures.
39
+ - Database migrations run before application deployment. They must be backward-compatible.
40
+
41
+ ## Environment Promotion
42
+
43
+ - Environments: `development` → `staging` → `production`.
44
+ - Each promotion uses the exact same artifact — no rebuilds between environments.
45
+ - Environment-specific configuration is injected at deploy time, not build time.
46
+ - Feature flags control feature availability per environment, not code branches.
47
+ - Staging must mirror production infrastructure as closely as possible.
48
+
49
+ ## Rollback Procedures
50
+
51
+ - Every deployment must support instant rollback to the previous version.
52
+ - Rollback is a deployment of the previous artifact, not a code revert.
53
+ - Database rollback scripts (`down` migrations) must be tested before every deployment.
54
+ - Rollback decision criteria: automated monitoring triggers OR manual team decision within 30 minutes.
55
+ - Post-rollback: create an incident ticket, run root cause analysis, fix forward.
56
+
57
+ ## Branch Protection
58
+
59
+ - The default branch requires: passing CI, at least one approval, no force pushes.
60
+ - Feature branches auto-delete after merge.
61
+ - Release branches (if used) follow the same protection as the default branch.
62
+ - Direct commits to the default branch are forbidden — all changes go through PRs.
63
+
64
+ ## Secrets Management in CI
65
+
66
+ - Never store secrets in pipeline configuration files.
67
+ - Use the CI platform's secret storage (GitHub Secrets, GitLab CI Variables, etc.).
68
+ - Rotate CI secrets on a regular schedule (at least quarterly).
69
+ - Audit secret access logs for unauthorized usage.
70
+ - Use OIDC-based authentication for cloud provider access instead of long-lived credentials.
@@ -0,0 +1,68 @@
1
+ ---
2
+ description: CI/CD pipeline standards covering stage gates, deployment strategies, and rollback procedures
3
+ alwaysApply: true
4
+ ---
5
+ # CI/CD Standards
6
+
7
+ ## Pipeline Design
8
+
9
+ - Every pipeline must have these ordered stages: install, lint, typecheck, test, build, deploy.
10
+ - Stages within the same tier run in parallel. Cross-tier stages are sequential.
11
+ - Fail fast: a failing stage must abort all downstream stages immediately.
12
+ - Pipeline configuration lives in version control alongside the application code.
13
+ - Use matrix builds for multi-platform or multi-version testing.
14
+
15
+ ## Stage Gates
16
+
17
+ - **Lint gate:** Zero warnings policy. New warnings block the pipeline.
18
+ - **Type gate:** Strict mode with no suppressions. Type errors are build failures.
19
+ - **Test gate:** All tests pass. Coverage must not decrease from the base branch.
20
+ - **Security gate:** Dependency vulnerability scan with no critical/high findings.
21
+ - **Build gate:** Artifact must be reproducible — same commit produces identical output.
22
+
23
+ ## Artifact Management
24
+
25
+ - Build artifacts once per commit. Promote the same artifact across environments.
26
+ - Tag artifacts with: git SHA, branch name, build timestamp, pipeline run ID.
27
+ - Retention policy: production artifacts 90 days, staging 30 days, PR artifacts 7 days.
28
+ - Store build metadata (dependencies, test results, coverage) alongside the artifact.
29
+ - Never deploy an artifact that hasn't passed all stage gates.
30
+
31
+ ## Deployment Strategies
32
+
33
+ - **Staging:** Auto-deploy on merge to the default branch. No manual approval needed.
34
+ - **Production:** Require explicit approval from at least one team member.
35
+ - Use progressive deployment (canary or blue-green) for production services.
36
+ - Set automatic rollback triggers: error rate > 1%, latency p99 > 2x baseline, health check failures.
37
+ - Database migrations run before application deployment. They must be backward-compatible.
38
+
39
+ ## Environment Promotion
40
+
41
+ - Environments: `development` → `staging` → `production`.
42
+ - Each promotion uses the exact same artifact — no rebuilds between environments.
43
+ - Environment-specific configuration is injected at deploy time, not build time.
44
+ - Feature flags control feature availability per environment, not code branches.
45
+ - Staging must mirror production infrastructure as closely as possible.
46
+
47
+ ## Rollback Procedures
48
+
49
+ - Every deployment must support instant rollback to the previous version.
50
+ - Rollback is a deployment of the previous artifact, not a code revert.
51
+ - Database rollback scripts (`down` migrations) must be tested before every deployment.
52
+ - Rollback decision criteria: automated monitoring triggers OR manual team decision within 30 minutes.
53
+ - Post-rollback: create an incident ticket, run root cause analysis, fix forward.
54
+
55
+ ## Branch Protection
56
+
57
+ - The default branch requires: passing CI, at least one approval, no force pushes.
58
+ - Feature branches auto-delete after merge.
59
+ - Release branches (if used) follow the same protection as the default branch.
60
+ - Direct commits to the default branch are forbidden — all changes go through PRs.
61
+
62
+ ## Secrets Management in CI
63
+
64
+ - Never store secrets in pipeline configuration files.
65
+ - Use the CI platform's secret storage (GitHub Secrets, GitLab CI Variables, etc.).
66
+ - Rotate CI secrets on a regular schedule (at least quarterly).
67
+ - Audit secret access logs for unauthorized usage.
68
+ - Use OIDC-based authentication for cloud provider access instead of long-lived credentials.