@punks/cli 2.6.1 → 3.0.0-beta.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 (102) hide show
  1. package/AGENTS.md +1 -1
  2. package/README.md +42 -24
  3. package/dist/BASELINE_CHANGELOG.md +57 -0
  4. package/dist/CHANGELOG.md +80 -0
  5. package/dist/data/scripts/harness-projection/adapters/claude.d.mts +3 -0
  6. package/dist/data/scripts/harness-projection/adapters/claude.mjs +124 -0
  7. package/dist/data/scripts/harness-projection/adapters/codex.d.mts +3 -0
  8. package/dist/data/scripts/harness-projection/adapters/codex.mjs +137 -0
  9. package/dist/data/scripts/harness-projection/adapters/cursor.d.mts +5 -0
  10. package/dist/data/scripts/harness-projection/adapters/cursor.mjs +106 -0
  11. package/dist/data/scripts/harness-projection/adapters/opencode.d.mts +5 -0
  12. package/dist/data/scripts/harness-projection/adapters/opencode.mjs +100 -0
  13. package/dist/data/scripts/harness-projection/apply.d.mts +12 -0
  14. package/dist/data/scripts/harness-projection/apply.mjs +96 -0
  15. package/dist/data/scripts/harness-projection/core.d.mts +8 -0
  16. package/dist/data/scripts/harness-projection/core.mjs +239 -0
  17. package/dist/data/scripts/harness-projection/test-fixtures/application-context-plan.json +27 -0
  18. package/dist/data/scripts/harness-projection/test-fixtures/claude/actions.json +109 -0
  19. package/dist/data/scripts/harness-projection/test-fixtures/claude/context-plan.json +150 -0
  20. package/dist/data/scripts/harness-projection/test-fixtures/claude/matrix.json +23 -0
  21. package/dist/data/scripts/harness-projection/test-fixtures/claude/traces.json +15 -0
  22. package/dist/data/scripts/harness-projection/test-fixtures/codex/actions.json +124 -0
  23. package/dist/data/scripts/harness-projection/test-fixtures/codex/context-plan.json +150 -0
  24. package/dist/data/scripts/harness-projection/test-fixtures/codex/matrix.json +23 -0
  25. package/dist/data/scripts/harness-projection/test-fixtures/codex/traces.json +15 -0
  26. package/dist/data/scripts/harness-projection/test-fixtures/cursor/compiler-input.json +93 -0
  27. package/dist/data/scripts/harness-projection/test-fixtures/cursor/context-plan.json +108 -0
  28. package/dist/data/scripts/harness-projection/test-fixtures/cursor/matrix.json +19 -0
  29. package/dist/data/scripts/harness-projection/test-fixtures/cursor/projection.json +54 -0
  30. package/dist/data/scripts/harness-projection/test-fixtures/mixed-context-plan.json +35 -0
  31. package/dist/data/scripts/harness-projection/test-fixtures/opencode/compiler-input.json +93 -0
  32. package/dist/data/scripts/harness-projection/test-fixtures/opencode/context-plan.json +108 -0
  33. package/dist/data/scripts/harness-projection/test-fixtures/opencode/matrix.json +19 -0
  34. package/dist/data/scripts/harness-projection/test-fixtures/opencode/projection.json +51 -0
  35. package/dist/data/scripts/sync-subagents.mjs +1113 -33
  36. package/dist/data/subagents/manifest.mjs +5 -6
  37. package/dist/index.js +1373 -62672
  38. package/dist/skills/agnostic/docs/docs-onboarding/SKILL.md +1 -1
  39. package/dist/skills/agnostic/docs/docs-onboarding/references/artifact-contract.md +2 -2
  40. package/dist/skills/agnostic/planning/create-plan/SKILL.md +11 -10
  41. package/dist/skills/agnostic/planning/create-plan/references/grill-ambiguity.md +10 -31
  42. package/dist/skills/agnostic/planning/create-plan/references/plan-schema.md +2 -2
  43. package/dist/skills/agnostic/planning/create-spec/SKILL.md +3 -5
  44. package/dist/skills/agnostic/planning/create-spec/assets/SPEC-TEMPLATE.md +1 -0
  45. package/dist/skills/agnostic/planning/create-spec/references/backlog-sync.md +2 -2
  46. package/dist/skills/agnostic/planning/create-spec/references/grill-phase.md +4 -9
  47. package/dist/skills/agnostic/planning/create-spec/references/spec-quality-bar.md +1 -0
  48. package/dist/skills/agnostic/planning/implement-spec/references/lifecycle.md +1 -1
  49. package/dist/skills/agnostic/requirements/grilling/LICENSE +21 -0
  50. package/dist/skills/agnostic/requirements/grilling/SKILL.md +6 -30
  51. package/dist/skills/agnostic/requirements/grilling/UPSTREAM.md +16 -0
  52. package/dist/skills/agnostic/requirements/requirements-grill/SKILL.md +3 -5
  53. package/dist/skills/agnostic/requirements/requirements-grill/references/artifact-output.md +40 -16
  54. package/dist/skills/agnostic/requirements/requirements-grill/references/grilling-flow.md +3 -16
  55. package/dist/skills/agnostic/requirements/write-backlog/REFERENCE.md +21 -15
  56. package/dist/skills/agnostic/requirements/write-backlog/SKILL.md +14 -14
  57. package/dist/skills/agnostic/requirements/write-backlog/assets/concepts/backlog-model.md +28 -9
  58. package/dist/skills/agnostic/requirements/write-backlog/assets/providers/azure-devops-create-payload.md +45 -5
  59. package/dist/skills/agnostic/requirements/write-backlog/assets/providers/github-projects-create-payload.md +48 -28
  60. package/dist/skills/agnostic/requirements/write-backlog/assets/providers/linear-create-payload.md +22 -6
  61. package/dist/skills/agnostic/requirements/write-backlog/assets/providers/monday-create-payload.md +47 -22
  62. package/dist/skills/frameworks/effect/effect/LICENSE +21 -0
  63. package/dist/skills/frameworks/effect/effect/SKILL.md +100 -0
  64. package/dist/skills/frameworks/effect/effect/UPSTREAM.md +11 -0
  65. package/dist/skills/frameworks/effect/effect/references/CACHING.md +76 -0
  66. package/dist/skills/frameworks/effect/effect/references/CONFIG.md +67 -0
  67. package/dist/skills/frameworks/effect/effect/references/HTTP_CLIENTS.md +101 -0
  68. package/dist/skills/frameworks/effect/{effect-authoring/references/otel-patterns.md → effect/references/OBSERVABILITY.md} +4 -29
  69. package/dist/skills/frameworks/effect/effect/references/SCHEDULING.md +135 -0
  70. package/dist/skills/frameworks/effect/effect/references/SCHEMA.md +130 -0
  71. package/dist/skills/frameworks/effect/effect/references/SERVICES_LAYERS.md +168 -0
  72. package/dist/skills/frameworks/effect/effect/references/STREAMS.md +135 -0
  73. package/dist/skills/frameworks/effect/effect/references/TESTING.md +118 -0
  74. package/dist/skills/frameworks/effect/effect-backend-structure/SKILL.md +7 -8
  75. package/dist/skills/frameworks/effect/effect-recoverable-actions/SKILL.md +1 -1
  76. package/dist/skills/frameworks/nestjs/nestjs-best-practices/.gitignore +29 -0
  77. package/dist/skills/misc/secrets-cli/SKILL.md +54 -0
  78. package/dist/skills/misc/secrets-cli/references/command-reference.md +107 -0
  79. package/dist/skills/misc/secrets-cli/references/safety-and-errors.md +54 -0
  80. package/dist/skills/misc/secrets-cli/references/workflows.md +106 -0
  81. package/dist/skills/phases/design-phase/phases/grill.md +1 -1
  82. package/dist/skills/phases/requirements-phase/SKILL.md +2 -4
  83. package/dist/skills/phases/review-phase/REFERENCE.md +13 -5
  84. package/dist/skills/phases/review-phase/SKILL.md +3 -2
  85. package/package.json +1 -1
  86. package/dist/skills/agnostic/planning/create-spec/references/handoff.md +0 -47
  87. package/dist/skills/frameworks/effect/effect-authoring/SKILL.md +0 -116
  88. package/dist/skills/frameworks/effect/effect-authoring/references/branded-types.md +0 -98
  89. package/dist/skills/frameworks/effect/effect-authoring/references/effect-primitives.md +0 -144
  90. package/dist/skills/frameworks/effect/effect-authoring/references/error-patterns.md +0 -156
  91. package/dist/skills/frameworks/effect/effect-authoring/references/test-patterns.md +0 -146
  92. package/dist/skills/frameworks/effect/effect-best-practices/SKILL.md +0 -517
  93. package/dist/skills/frameworks/effect/effect-best-practices/references/anti-patterns.md +0 -392
  94. package/dist/skills/frameworks/effect/effect-best-practices/references/effect-atom-patterns.md +0 -653
  95. package/dist/skills/frameworks/effect/effect-best-practices/references/error-patterns.md +0 -464
  96. package/dist/skills/frameworks/effect/effect-best-practices/references/language-server.md +0 -287
  97. package/dist/skills/frameworks/effect/effect-best-practices/references/layer-patterns.md +0 -495
  98. package/dist/skills/frameworks/effect/effect-best-practices/references/observability-patterns.md +0 -342
  99. package/dist/skills/frameworks/effect/effect-best-practices/references/rpc-cluster-patterns.md +0 -418
  100. package/dist/skills/frameworks/effect/effect-best-practices/references/schema-patterns.md +0 -353
  101. package/dist/skills/frameworks/effect/effect-best-practices/references/service-patterns.md +0 -299
  102. /package/dist/skills/frameworks/effect/{effect-authoring/references/effect-atom-patterns.md → effect/references/EFFECT_ATOM.md} +0 -0
@@ -0,0 +1,54 @@
1
+ # Safety, Selectors, and Errors
2
+
3
+ ## Selector and Inference Rules
4
+
5
+ - Project selectors accept ID or slug.
6
+ - When project is omitted, inference uses `--project` override first, then the default Git remote repository name, then the current directory basename.
7
+ - Environment selectors accept ID or slug within the selected project.
8
+ - File IDs work without `--env` and are sent directly.
9
+ - File names and paths require `--env`. Within that environment, resolution prefers exact ID, then exact path, then a unique exact name.
10
+ - Ambiguous file names fail. Use an exact path or file ID.
11
+ - Never rely on project inference when the Git remote or working directory does not unambiguously match the target project.
12
+
13
+ ## Stdin and Redaction
14
+
15
+ - Prefer `--stdin` so values do not enter shell history or process arguments.
16
+ - Single-value stdin removes one terminal `\n` or `\r\n`; other bytes remain part of the value.
17
+ - Bulk stdin is newline-delimited `KEY=value`. Every line must contain a non-empty key before the first `=`.
18
+ - Do not combine positional values with `--stdin`.
19
+ - Lists, mutation summaries, bulk reads, and pull plans show key names, not values.
20
+ - `values get` prints the raw value. Redirect or capture it; never reproduce it in agent messages, logs, screenshots, diffs, or handoffs.
21
+ - Do not inspect pulled dotenv contents unless the user explicitly requires it and the output can remain secret-safe.
22
+
23
+ ## Pull and Overwrite Safety
24
+
25
+ Pulls write every returned payload to its configured path relative to the current directory. Existing files are overwritten; missing parent directories are created. There is no merge.
26
+
27
+ Interactive terminals show a plan and default to Yes. `n`, Right, or Tab can decline; Ctrl-C interrupts. Non-interactive execution auto-approves. Do not run a pull non-interactively until paths and overwrite impact are known.
28
+
29
+ A cancelled pull writes nothing. A write failure can occur after earlier files in a multi-file pull were written, so verify every planned path after failure.
30
+
31
+ ## Errors and Exit Codes
32
+
33
+ - `0`: command completed successfully. Empty list or no changed keys can still be successful; inspect the message against the requested outcome.
34
+ - `1`: invalid syntax/input, missing selector, expired authentication/backend failure, forbidden access, conflict, validation failure, rate limit, unavailable backend, or other command failure.
35
+ - `130`: interactive pull interrupted with Ctrl-C.
36
+
37
+ A locally missing login currently prints `Authentication required` without necessarily returning a nonzero code because no RPC is attempted. A declined pull also exits successfully without writing. Treat both as incomplete regardless of exit code.
38
+
39
+ Common recovery:
40
+
41
+ - `Authentication required` or expired/unauthorized: run `secrets login`, then `secrets whoami`.
42
+ - `Project not found`: pass the correct project ID/slug with `--project`; check inference.
43
+ - `Environment not found`: list environments in the selected project and retry with ID/slug.
44
+ - `File not found`: supply `--env` for name/path selection, or use the file ID.
45
+ - `Multiple files have that name`: use exact path or file ID.
46
+ - `No account exists for that email`: the target user must sign in once, then membership addition can be retried.
47
+ - `Forbidden`: confirm identity, role, project membership, and target scope; do not retry unchanged.
48
+ - `conflicts with current backend state`: relist the scope before retrying.
49
+ - `Too many requests`: wait, then retry once.
50
+ - backend unavailable: preserve inputs and retry later.
51
+ - missing or conflicting value source: provide exactly one positional value source or `--stdin`.
52
+ - invalid bulk input: use one `KEY=value` per argument or line.
53
+
54
+ Never paste secret-bearing command arguments or backend payloads into an error report. Report the command shape with placeholders, safe error text, and exit code.
@@ -0,0 +1,106 @@
1
+ # Workflows
2
+
3
+ ## Install or Check Version
4
+
5
+ ```bash
6
+ node --version
7
+ npm install --global @punks/secrets
8
+ secrets --version
9
+ secrets --help
10
+ ```
11
+
12
+ Use `npx @punks/secrets --help` for a one-off run. Use `@punks/secrets@next` only when an explicit prerelease-testing policy requires it. Do not assume the local CLI matches this manual; inspect leaf help when syntax is in doubt.
13
+
14
+ ## Authenticate
15
+
16
+ ```bash
17
+ secrets login
18
+ secrets whoami
19
+ ```
20
+
21
+ Complete browser approval and check that the browser code matches the terminal code. `login` reports the existing identity instead of switching accounts when the stored session is still valid. To switch:
22
+
23
+ ```bash
24
+ secrets logout
25
+ secrets login
26
+ secrets whoami
27
+ ```
28
+
29
+ ## Create a Project and Membership
30
+
31
+ ```bash
32
+ secrets projects create "Payments API" --slug payments
33
+ secrets projects list
34
+ secrets projects users add teammate@example.com --project payments
35
+ secrets projects users list payments
36
+ ```
37
+
38
+ Membership prerequisite: the target email must complete sign-in once before an admin can add it. If addition says no account exists, ask that person to run `secrets login`, then retry. There is no role option.
39
+
40
+ ## Create an Environment and File
41
+
42
+ ```bash
43
+ secrets envs create Production --project payments
44
+ secrets envs list payments
45
+ secrets files create .env.production --env production --project payments
46
+ secrets files list production --project payments
47
+ ```
48
+
49
+ The file path is both the configured pull destination and, by default, the display-name source.
50
+
51
+ ## Set and Inspect Values
52
+
53
+ Prefer stdin for all sensitive values:
54
+
55
+ ```bash
56
+ printf '%s' "$API_TOKEN" | secrets values put .env.production API_TOKEN --stdin --env production --project payments
57
+ secrets values list .env.production --env production --project payments
58
+ ```
59
+
60
+ Set several values without exposing them as arguments:
61
+
62
+ ```bash
63
+ secrets values bulk-upsert .env.production --stdin --env production --project payments < values.env
64
+ secrets values list .env.production --env production --project payments
65
+ ```
66
+
67
+ Use `get` only when the destination requires the raw value. Redirect it directly; do not let the agent quote or summarize it:
68
+
69
+ ```bash
70
+ secrets values get FILE_ID API_TOKEN > /secure/destination
71
+ ```
72
+
73
+ ## Pull One File or an Environment
74
+
75
+ ```bash
76
+ secrets files pull .env.production --env production --project payments
77
+ secrets envs pull production --project payments
78
+ ```
79
+
80
+ Before approval, inspect every planned path and key name. Pull writes relative to the current directory, creates missing parent directories, renders dotenv content, and overwrites existing target files. Interactive pulls ask for approval; non-interactive pulls proceed automatically. Verify expected paths after completion without printing contents.
81
+
82
+ ## Update Names, Slugs, or Paths
83
+
84
+ ```bash
85
+ secrets projects update payments --name "Payments Platform"
86
+ secrets envs update production --slug prod --project payments
87
+ secrets files update .env.production --env prod --path .env --project payments
88
+ ```
89
+
90
+ After changing a slug or path, use the new selector for later commands. List the parent scope to confirm the change.
91
+
92
+ ## Destructive Cleanup
93
+
94
+ Destructive commands do not prompt. List and verify each target first. For complete cleanup, work leaf-to-root so no active child is hidden by a parent deletion:
95
+
96
+ ```bash
97
+ secrets values list FILE --env ENVIRONMENT --project PROJECT
98
+ secrets values bulk-delete FILE KEY... --env ENVIRONMENT --project PROJECT
99
+ secrets files delete FILE --env ENVIRONMENT --project PROJECT
100
+ secrets envs delete ENVIRONMENT --project PROJECT
101
+ secrets projects users list PROJECT
102
+ secrets projects users remove USER_ID_OR_EMAIL --project PROJECT
103
+ secrets projects delete PROJECT
104
+ ```
105
+
106
+ Remove the operating identity last if it must be removed at all. Project, environment, and file deletes are recoverable backend deletions, but the CLI has no restore command. Value deletion updates the stored file payload and removes the key from later pulls while backend version history remains the recovery boundary. Do not promise restoration from the CLI.
@@ -34,4 +34,4 @@ Default to one branch per user-visible page or flow. Use section-level branches
34
34
  - Rejected or superseded constraints.
35
35
  - Open conflicts or parked scope.
36
36
  - Artifact intent per scope unit.
37
- - Phase handoff with next route: prototype.
37
+ - After `$requirements-grill` completes, phase handoff with next route: prototype.
@@ -34,13 +34,11 @@ Normally do not create or update a formal agent goal. This phase is an interview
34
34
 
35
35
  2. Route to `requirements-grill` while decisions are open.
36
36
  - Let `requirements-grill` own HITL interviewing.
37
- - Ask one question at a time with a recommended answer and why.
38
37
  - Turn ambiguity into named branches, branch percentages, accepted decisions, rejected/superseded decisions, glossary entries, axioms, and parked scope.
39
- - Do not write backlog while major branches remain open unless the user explicitly parks them.
40
38
 
41
39
  3. Decide backlog readiness.
42
- - Backlog-ready means active branches are closed enough for module/epic/story shaping, and unresolved branches are either non-blocking, explicitly parked, or recorded as follow-up scope.
43
- - If not ready, continue grilling or report the exact blocker branches.
40
+ - After `$requirements-grill` completes, backlog-ready means active requirements are shaped enough for module/epic/story work and any non-blocking or follow-up scope is recorded.
41
+ - If not ready, report the exact backlog-shaping blockers.
44
42
  - If ready, hand off to `write-backlog`.
45
43
 
46
44
  4. Run `write-backlog` only after readiness.
@@ -78,13 +78,21 @@ owner must recover with public-result RED and GREEN evidence.
78
78
  ## Requirements Grill Wrapper Review
79
79
 
80
80
  When reviewed spec, plan, phase, or wrapper claims to use
81
- `requirements-grill` or design-phase grill, review that wrapper against
82
- the `requirements-grill` inner flow, not just its outer handoff.
81
+ `requirements-grill` or design-phase grill, review shared interview behavior
82
+ against `$grilling` and durable behavior against the `requirements-grill`
83
+ inner flow, not just its outer handoff.
83
84
 
84
85
  Check:
85
86
 
86
87
  - Serious grill sessions pair `references/grilling-flow.md` with
87
88
  `references/artifact-output.md`.
89
+ - Before each round is yielded, it is persisted with stable question ids,
90
+ prerequisites, and the current frontier, with a stable mapping between live
91
+ questions and the routed log/status artifacts.
92
+ - Each response set is processed answer by answer; partially answered rounds
93
+ preserve omitted questions as unanswered and carry them forward.
94
+ - Status is updated after each response set, and branch percentages agree with
95
+ the unanswered-question and shared-understanding confirmation fields.
88
96
  - Routed grill log/status artifacts are created or updated when grilling
89
97
  decisions, branches, parked scope, percentages, glossary, axioms, or
90
98
  ambiguities change.
@@ -93,9 +101,9 @@ Check:
93
101
  - Added or renamed wiki grill artifacts update routed metadata/bookkeeping:
94
102
  `content/docs/project/grilling/meta.json`, section index when missing,
95
103
  and wiki `log.md` when the repo maintains one.
96
- - Downstream handoff evidence exists as applicable: wiki synthesis,
97
- backlog/user stories, spec, or phase handoff carrying closed decisions
98
- and parked/open branches.
104
+ - After `$grilling` completes, downstream handoff evidence exists as
105
+ applicable: wiki synthesis, backlog/user stories, spec, or phase handoff
106
+ carrying accepted decisions and recorded scope state.
99
107
 
100
108
  Missing inner-flow or durable-artifact evidence is a review finding when
101
109
  the wrapper promised grill behavior.
@@ -27,8 +27,9 @@ Load [REFERENCE.md](REFERENCE.md) before running review tools. Start with
27
27
  - Apply relevant `AGENTS.md` guidance and scoped skills for reviewed paths.
28
28
  - Use `review` as the review-flow wrapper; keep axes separate.
29
29
  - Use `autoreview` as the core structured review runtime.
30
- - If target claims `requirements-grill` or design-phase grill, inspect
31
- `requirements-grill` inner flow and durable-artifact evidence.
30
+ - If target claims `requirements-grill` or design-phase grill, inspect shared
31
+ interview behavior against `$grilling` and durable-artifact evidence against
32
+ the `requirements-grill` inner flow.
32
33
 
33
34
  ## Steps
34
35
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@punks/cli",
3
- "version": "2.6.1",
3
+ "version": "3.0.0-beta.0",
4
4
  "description": "Harness Intelligence scaffolding CLI",
5
5
  "bin": {
6
6
  "hi": "dist/index.js",
@@ -1,47 +0,0 @@
1
- # Handoff
2
-
3
- Use this reference after the spec and wiki bookkeeping are complete.
4
-
5
- ## Complexity assessment
6
-
7
- Classify the change before recommending the next step.
8
-
9
- ### Trivial / straightforward
10
-
11
- - small and well-scoped
12
- - clear acceptance criteria
13
- - few unknowns
14
- - low architectural risk
15
- - limited surface area
16
-
17
- Recommendation:
18
-
19
- - suggest direct implementation
20
-
21
- ### Non-trivial
22
-
23
- - multiple moving parts
24
- - unclear dependencies
25
- - architectural choices still matter
26
- - risk of breaking existing behavior
27
- - open questions remain about the approach
28
-
29
- Recommendation:
30
-
31
- - suggest `create-plan`
32
-
33
- ## User-facing closeout
34
-
35
- Tell the user:
36
-
37
- - where the spec was created
38
- - that wiki index and log were updated
39
- - that the spec is ready for review
40
- - the suggested next step
41
-
42
- Then ask them to reply with:
43
-
44
- - `[P]` to create an implementation plan
45
- - `[I]` to implement directly
46
-
47
- Then stop and wait. Do not proceed until the user approves the spec and picks a next step.
@@ -1,116 +0,0 @@
1
- ---
2
- name: effect-authoring
3
- description: >-
4
- Use when asked to plan, write, build, fix, refactor, or review Effect-TS
5
- code. Apply before editing so the first implementation follows repo
6
- conventions for Effect primitives, branded IDs, observability, error design,
7
- `@effect/vitest`, and Effect-Atom, especially in `packages/api`.
8
- ---
9
-
10
- # Effect-TS Authoring Guide
11
-
12
- Use this skill before edits. Optimize for correct code on first pass, not a scorecard after the fact.
13
-
14
- ## Workflow
15
-
16
- ### Step 1: Classify the Task Before Writing
17
-
18
- Sort the requested change into the smallest relevant set:
19
-
20
- - **Backend Effect code**: Effect services, procedures, repositories, layers, schemas, domain actions
21
- - **Test code**: `.test.ts` files, test layers, failure-path coverage
22
- - **UI / Effect-Atom code**: `.tsx` files using Effect-Atom, RPC, HttpApi clients
23
-
24
- Skip config/docs unless they change the implementation contract.
25
-
26
- ### Step 2: Load Only the References Needed for the Task
27
-
28
- Read the minimum reference set before editing:
29
-
30
- - **Backend Effect code**: `references/effect-primitives.md`, `references/branded-types.md`, `references/otel-patterns.md`, `references/error-patterns.md`
31
- - **Test code**: `references/test-patterns.md`
32
- - **UI / Effect-Atom code**: `references/effect-atom-patterns.md`
33
-
34
- If uncertain about Effect library behavior, run `opensrc path effect` or `opensrc path Effect-TS/effect` to resolve the local checkout path, then inspect there instead of guessing.
35
-
36
- ### Step 3: Build a Pre-Write Checklist
37
-
38
- Turn the loaded references into a short implementation checklist for the exact files/functions being changed.
39
-
40
- For backend Effect work, check for these constraints up front:
41
-
42
- - Make dependencies visible as Effect requirements or `Effect.Service` dependencies; do not hide them behind concrete imports
43
- - Provide implementations with `Layer`s; avoid call-site `Effect.provide` except at runner/test boundaries
44
- - Use Effect primitives over native patterns where the repo expects them: `Array`, `Match`, `Option`, `Schema`, `Effect.forEach`, `Layer`
45
- - Avoid `try/catch`, `async/await`, `console.log`, ad-hoc validation, and plain `Error` classes in Effect code
46
- - Carry branded IDs through boundaries; do not fall back to raw `string` / `number`
47
- - Use named `Effect.fn("Service.method")` wrappers for named effectful functions
48
- - Annotate spans with essential IDs and business context only
49
- - Prefer `Schema.TaggedError` and `catchTag` with rich context over generic failures
50
-
51
- For test work, check for these constraints up front:
52
-
53
- - Use `@effect/vitest`, not plain `vitest`
54
- - Prefer `it.layer(...)` and `it.scoped(...)`
55
- - Replace Effect services with test layers, not `vi.mock`
56
- - Test failures with `Effect.either` / tagged errors, not `try/catch`
57
-
58
- For UI work, check for these constraints up front:
59
-
60
- - Prefer Effect-Atom typesafe clients for first-party Effect backends
61
- - Avoid `useEffect` + `fetch` state machines when an atom/query should own the data flow
62
-
63
- ### Step 4: Inspect Local Patterns Before Editing
64
-
65
- Read adjacent modules before writing:
66
-
67
- - existing tagged error names
68
- - local branded type definitions
69
- - layer composition style
70
- - service/action boundaries
71
- - trace naming conventions
72
- - nearby test harness patterns
73
-
74
- Prefer repo-local patterns over generic examples from the references.
75
-
76
- ### Step 5: Write the Code Against the Checklist
77
-
78
- Implement directly against the pre-write checklist. Treat the references as authoring constraints, not post-hoc review criteria.
79
-
80
- If a reference conflicts with established local conventions, follow the local convention and call out the mismatch briefly in the final response.
81
-
82
- Do not start with a review-style `git diff` workflow when the task is code generation or refactoring. Start from the requested change and the target files.
83
-
84
- ### Step 6: Validate Immediately After Editing
85
-
86
- Run the narrowest useful validation for the touched area:
87
-
88
- - targeted tests
89
- - relevant typecheck
90
- - lint if the changed surface is lint-sensitive
91
- - any repo-specific command that proves the new behavior
92
-
93
- If validation fails, fix the code before moving on.
94
-
95
- ### Step 7: Switch to Review Mode Only When Needed
96
-
97
- Use review-style findings only when:
98
-
99
- - the user explicitly asks for a review, audit, or score
100
- - the task is read-only
101
- - a final spot-check is needed after implementation
102
-
103
- In review mode, use the same references, but report findings instead of treating them as a pre-write checklist.
104
-
105
- Do not default to spawning review subagents during authoring. That adds latency and pushes correctness to the end of the workflow.
106
-
107
- ## Reference Files
108
-
109
- Load on demand:
110
-
111
- - `references/effect-primitives.md` — Effect Array, Match, Option, Schema, `Effect.forEach`, Layer
112
- - `references/branded-types.md` — branded IDs and boundary consistency
113
- - `references/otel-patterns.md` — `Effect.fn`, span annotations, structured logging
114
- - `references/error-patterns.md` — `Schema.TaggedError`, `catchTag`, error context
115
- - `references/test-patterns.md` — `@effect/vitest`, `it.layer`, failure-path testing
116
- - `references/effect-atom-patterns.md` — Effect-Atom queries, mutations, client patterns
@@ -1,98 +0,0 @@
1
- # Branded Types Checklist
2
-
3
- ## Core Rule
4
-
5
- All entity IDs MUST use branded types via `Schema.brand()`. Never use plain `string` or `number` for IDs. This prevents mixing up IDs of different entity types at compile time.
6
-
7
- ## How to Define Branded Types
8
-
9
- ```typescript
10
- import { Schema } from "effect"
11
-
12
- // Integer IDs
13
- export const UserId = Schema.Int.pipe(Schema.brand("@myorg/schema/UserId"))
14
- export type UserId = Schema.Schema.Type<typeof UserId>
15
-
16
- // String IDs
17
- export const ApiKey = Schema.String.pipe(Schema.brand("@myorg/schema/ApiKey"))
18
- export type ApiKey = Schema.Schema.Type<typeof ApiKey>
19
-
20
- // FromString variants (for URL params that arrive as strings)
21
- export const UserIdFromString = Schema.NumberFromString.pipe(
22
- Schema.brand("@myorg/schema/UserId")
23
- )
24
- ```
25
-
26
- Define branded types for every entity ID in your domain (e.g., `UserId`, `OrganizationId`, `ProjectId`, `OrderId`, `ProductId`, etc.) and colocate them in a shared branded types module.
27
-
28
- ## Checklist
29
-
30
- ### 1. Function Parameters Use Branded Types Directly
31
-
32
- ```typescript
33
- // GOOD
34
- const findById = (userId: UserId, organizationId: OrganizationId) => ...
35
-
36
- // BAD
37
- const findById = (userId: number, organizationId: number) => ...
38
- ```
39
-
40
- ### 2. No `as` Casting for IDs
41
-
42
- ```typescript
43
- // GOOD
44
- import { Schema } from "effect"
45
- const id = Schema.decodeSync(UserId)(rawValue)
46
- // or use the branded constructor
47
- const id = UserId.make(rawValue)
48
-
49
- // BAD
50
- const id = rawValue as UserId
51
- const id = someNumber as unknown as UserId
52
- ```
53
-
54
- ### 3. *FromString Variants for URL/Route Params
55
-
56
- URL params arrive as strings. Use `*FromString` schemas to decode them.
57
-
58
- ```typescript
59
- // GOOD
60
- const params = Schema.Struct({
61
- userId: UserIdFromString,
62
- projectId: ProjectIdFromString,
63
- })
64
-
65
- // BAD
66
- const userId = parseInt(req.params.userId) as UserId
67
- ```
68
-
69
- ### 4. Database Schema Alignment
70
-
71
- When a database column uses a branded type, all code accessing that column must use the same branded type throughout. Check that:
72
- - Repository method params match column types
73
- - Service method params propagate branded types (not plain numbers)
74
- - API handler params decode to branded types before passing to services
75
-
76
- ### 5. No Plain string/number in Domain Types
77
-
78
- ```typescript
79
- // GOOD
80
- interface OrderConfig {
81
- orderId: OrderId
82
- userId: UserId
83
- }
84
-
85
- // BAD
86
- interface OrderConfig {
87
- orderId: number
88
- userId: number
89
- }
90
- ```
91
-
92
- ## Where to Check
93
-
94
- - Function signatures (params and return types)
95
- - Interface/type definitions containing IDs
96
- - Schema definitions for API input/output
97
- - Database query `.where()` clauses
98
- - Variable declarations storing IDs
@@ -1,144 +0,0 @@
1
- # Effect Primitives Checklist
2
-
3
- ## 1. Effect Array/HashMap Over Native
4
-
5
- Use `Array` from `effect` for functional array operations in Effect code. Use `HashMap` for key-value lookups instead of plain objects or `Map`.
6
-
7
- ```typescript
8
- // GOOD
9
- import { Array, HashMap } from "effect"
10
- const ids = Array.map(items, (item) => item.id)
11
- const lookup = HashMap.fromIterable(items.map((i) => [i.id, i]))
12
-
13
- // BAD
14
- const ids = items.map((item) => item.id) // native .map in Effect service code
15
- ```
16
-
17
- ## 2. Effect.forEach Over For Loops
18
-
19
- Any loop body that performs an Effect must use `Effect.forEach`. Supports `concurrency` option for parallel execution.
20
-
21
- ```typescript
22
- // GOOD
23
- yield* Effect.forEach(users, (user) => sendNotification(user), { concurrency: 5 })
24
-
25
- // BAD
26
- for (const user of users) {
27
- yield* sendNotification(user)
28
- }
29
- ```
30
-
31
- ## 3. Match Over Switch Statements
32
-
33
- All `switch` statements on discriminated unions or string literals should use `Match.value()` or `Match.type<T>()` with `Match.exhaustive`.
34
-
35
- ```typescript
36
- // GOOD
37
- import { Match } from "effect"
38
- const result = Match.value(platform).pipe(
39
- Match.when("IOS", () => "ios" as const),
40
- Match.when("ANDROID", () => "android" as const),
41
- Match.exhaustive
42
- )
43
-
44
- // BAD
45
- switch (platform) {
46
- case "IOS": return "ios"
47
- case "ANDROID": return "android"
48
- }
49
- ```
50
-
51
- ## 4. Option Over Optional Chaining
52
-
53
- In Effect services and domain types, prefer `Option<T>` over `T | null | undefined`. Use `Option.match`, `Option.map`, `Option.getOrElse` instead of `?.` chains.
54
-
55
- ```typescript
56
- // GOOD
57
- import { Option } from "effect"
58
- const name = Option.match(user.displayName, {
59
- onNone: () => "Anonymous",
60
- onSome: (name) => name
61
- })
62
-
63
- // BAD
64
- const name = user?.displayName ?? "Anonymous" // in Effect service code
65
- ```
66
-
67
- Note: `?.` is acceptable in React components and non-Effect utility code. Flag it only in Effect services/repositories/handlers.
68
-
69
- ## 5. Effect Schema Over Zod/Manual Validation
70
-
71
- All runtime validation should use `Schema` from `effect`. No Zod imports. No manual `typeof`/`instanceof` guards for data parsing.
72
-
73
- ```typescript
74
- // GOOD
75
- import { Schema } from "effect"
76
- const UserInput = Schema.Struct({
77
- name: Schema.String,
78
- email: Schema.String.pipe(Schema.pattern(/@/)),
79
- })
80
-
81
- // BAD
82
- import { z } from "zod"
83
- const UserInput = z.object({ name: z.string() })
84
- ```
85
-
86
- ## 6. Layer.provide Not Effect.provide
87
-
88
- Dependencies should be composed via `Layer` in service definitions and layer files, not via `Effect.provide` at call sites. Exception: final runner/test boundaries and infrastructure bindings in entry points.
89
-
90
- Keep requirements visible. If a function needs a repository, client, flag service, clock, config, or runtime binding, that need should appear as an Effect environment requirement or an `Effect.Service` dependency until a layer provides it.
91
-
92
- ```typescript
93
- // GOOD
94
- export class MyService extends Effect.Service<MyService>()("MyService", {
95
- dependencies: [DepA.Default, DepB.Default],
96
- effect: Effect.gen(function* () { ... })
97
- }) {}
98
-
99
- // Also GOOD (Layer.provide chain)
100
- const MainLayer = ServiceA.Default.pipe(
101
- Layer.provideMerge(ServiceB.Default),
102
- Layer.provide(Database)
103
- )
104
-
105
- // BAD (providing at call site)
106
- const result = yield* myEffect.pipe(Effect.provide(someLayer))
107
- ```
108
-
109
- ## 7. No try/catch
110
-
111
- Everything uses Effect error channel. No `try { } catch { }` blocks in Effect code.
112
-
113
- ```typescript
114
- // GOOD
115
- yield* Effect.tryPromise({
116
- try: () => fetch(url),
117
- catch: (e) => new FetchError({ cause: e })
118
- })
119
-
120
- // BAD
121
- try {
122
- const res = await fetch(url)
123
- } catch (e) {
124
- throw new Error("fetch failed")
125
- }
126
- ```
127
-
128
- ## 8. No Promise-Based Code
129
-
130
- Service methods return `Effect`, not `Promise`. No `async/await` in Effect service implementations.
131
-
132
- ```typescript
133
- // GOOD
134
- const fetchUser = Effect.fn("fetchUser")(function* (id: UserId) {
135
- const user = yield* userRepo.findById(id)
136
- return user
137
- })
138
-
139
- // BAD
140
- const fetchUser = async (id: string) => {
141
- const user = await userRepo.findById(id)
142
- return user
143
- }
144
- ```