aiblueprint-cli 1.4.87 → 1.4.89

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 (55) hide show
  1. package/agents-config/skills/agents-manager/SKILL.md +14 -3
  2. package/agents-config/skills/agents-manager/references/writing-agent-prompts.md +1 -1
  3. package/agents-config/skills/apex/SKILL.md +116 -55
  4. package/agents-config/skills/apex/scripts/setup-templates.sh +154 -0
  5. package/agents-config/skills/apex/scripts/update-progress.sh +80 -0
  6. package/agents-config/skills/apex/steps/step-00-init.md +278 -0
  7. package/agents-config/skills/apex/steps/step-00b-branch.md +126 -0
  8. package/agents-config/skills/apex/steps/step-00b-economy.md +247 -0
  9. package/agents-config/skills/apex/steps/step-00b-interactive.md +170 -0
  10. package/agents-config/skills/apex/steps/step-00b-save.md +125 -0
  11. package/agents-config/skills/apex/steps/step-01-analyze.md +388 -0
  12. package/agents-config/skills/apex/steps/step-02-plan.md +593 -0
  13. package/agents-config/skills/apex/steps/step-02b-tasks.md +301 -0
  14. package/agents-config/skills/apex/steps/step-03-execute-teams.md +296 -0
  15. package/agents-config/skills/apex/steps/step-03-execute.md +240 -0
  16. package/agents-config/skills/apex/steps/step-04-validate.md +272 -0
  17. package/agents-config/skills/apex/steps/step-05-examine.md +400 -0
  18. package/agents-config/skills/apex/steps/step-06-resolve.md +239 -0
  19. package/agents-config/skills/apex/steps/step-07-tests.md +250 -0
  20. package/agents-config/skills/apex/steps/step-08-run-tests.md +314 -0
  21. package/agents-config/skills/apex/steps/step-09-finish.md +223 -0
  22. package/agents-config/skills/apex/steps/step-10-verify.md +296 -0
  23. package/agents-config/skills/apex/templates/00-context.md +55 -0
  24. package/agents-config/skills/apex/templates/01-analyze.md +10 -0
  25. package/agents-config/skills/apex/templates/02-plan.md +10 -0
  26. package/agents-config/skills/apex/templates/03-execute.md +10 -0
  27. package/agents-config/skills/apex/templates/04-validate.md +10 -0
  28. package/agents-config/skills/apex/templates/05-examine.md +10 -0
  29. package/agents-config/skills/apex/templates/06-resolve.md +10 -0
  30. package/agents-config/skills/apex/templates/07-tests.md +10 -0
  31. package/agents-config/skills/apex/templates/08-run-tests.md +10 -0
  32. package/agents-config/skills/apex/templates/09-finish.md +10 -0
  33. package/agents-config/skills/apex/templates/10-verify.md +9 -0
  34. package/agents-config/skills/apex/templates/README.md +195 -0
  35. package/agents-config/skills/apex/templates/step-complete.md +7 -0
  36. package/agents-config/skills/appstore-connect/SKILL.md +3 -9
  37. package/agents-config/skills/environments-manager/SKILL.md +86 -94
  38. package/agents-config/skills/environments-manager/examples/{skills/dev/SKILL.md → claude/commands/dev.md} +1 -2
  39. package/agents-config/skills/environments-manager/examples/{skills/lint/SKILL.md → claude/commands/lint.md} +1 -2
  40. package/agents-config/skills/environments-manager/examples/{skills/test/SKILL.md → claude/commands/test.md} +1 -2
  41. package/agents-config/skills/environments-manager/examples/{skills/typecheck/SKILL.md → claude/commands/typecheck.md} +1 -2
  42. package/agents-config/skills/environments-manager/examples/scripts/worktree-down.sh +5 -12
  43. package/agents-config/skills/environments-manager/examples/scripts/worktree-up.sh +11 -21
  44. package/agents-config/skills/environments-manager/references/claude.md +9 -13
  45. package/agents-config/skills/environments-manager/references/convex.md +120 -0
  46. package/agents-config/skills/environments-manager/references/cursor.md +2 -2
  47. package/agents-config/skills/environments-manager/references/postgresql.md +89 -0
  48. package/agents-config/skills/oneshot/SKILL.md +21 -37
  49. package/agents-config/skills/rules-manager/SKILL.md +15 -2
  50. package/agents-config/skills/skill-manager/SKILL.md +30 -2
  51. package/agents-config/skills/ultrathink/SKILL.md +1 -1
  52. package/agents-config/skills/use-fable/SKILL.md +64 -0
  53. package/package.json +1 -1
  54. package/agents-config/skills/appstore-connect/references/setup.md +0 -156
  55. package/agents-config/skills/appstore-connect/references/testflight.md +0 -212
@@ -0,0 +1,195 @@
1
+ # APEX Template System
2
+
3
+ ## Overview
4
+
5
+ This directory contains template files used to initialize APEX workflow outputs when save mode (`-s`) is enabled. This template system significantly reduces token usage by moving repetitive content out of step files.
6
+
7
+ ## Template Files
8
+
9
+ | Template | Purpose | Created When |
10
+ |----------|---------|--------------|
11
+ | `00-context.md` | Workflow configuration and progress tracking | Always (if save_mode) |
12
+ | `01-analyze.md` | Analysis findings | Always (if save_mode) |
13
+ | `02-plan.md` | Implementation plan | Always (if save_mode) |
14
+ | `03-execute.md` | Implementation log | Always (if save_mode) |
15
+ | `04-validate.md` | Validation results | Always (if save_mode) |
16
+ | `05-examine.md` | Adversarial review findings | Only if examine_mode enabled |
17
+ | `06-resolve.md` | Finding resolution log | Only if examine_mode enabled |
18
+ | `07-tests.md` | Test analysis and creation | Only if test_mode enabled |
19
+ | `08-run-tests.md` | Test runner log | Only if test_mode enabled |
20
+ | `09-finish.md` | PR creation log | Only if pr_mode enabled |
21
+ | `step-complete.md` | Completion marker template | Referenced in steps |
22
+
23
+ ## Template Variables
24
+
25
+ Templates use `{{variable}}` syntax for placeholders:
26
+
27
+ | Variable | Description | Example |
28
+ |----------|-------------|---------|
29
+ | `{{task_id}}` | Kebab-case task identifier | `01-add-auth-middleware` |
30
+ | `{{task_description}}` | Plain text task description | `add authentication middleware` |
31
+ | `{{timestamp}}` | ISO 8601 timestamp | `2026-01-12T10:30:00Z` |
32
+ | `{{auto_mode}}` | Auto mode flag | `true` or `false` |
33
+ | `{{examine_mode}}` | Examine mode flag | `true` or `false` |
34
+ | `{{save_mode}}` | Save mode flag | `true` or `false` |
35
+ | `{{test_mode}}` | Test mode flag | `true` or `false` |
36
+ | `{{economy_mode}}` | Economy mode flag | `true` or `false` |
37
+ | `{{branch_mode}}` | Branch mode flag | `true` or `false` |
38
+ | `{{pr_mode}}` | PR mode flag | `true` or `false` |
39
+ | `{{interactive_mode}}` | Interactive mode flag | `true` or `false` |
40
+ | `{{branch_name}}` | Git branch name | `feature/add-auth` |
41
+ | `{{original_input}}` | Raw user input | `/apex -a -s add auth` |
42
+ | `{{examine_status}}` | Progress status for examine steps | `⏸ Pending` or `⏭ Skip` |
43
+ | `{{test_status}}` | Progress status for test steps | `⏸ Pending` or `⏭ Skip` |
44
+ | `{{pr_status}}` | Progress status for PR step | `⏸ Pending` or `⏭ Skip` |
45
+
46
+ ## Setup Script
47
+
48
+ ### `setup-templates.sh`
49
+
50
+ Initializes all template files in the output directory with variables replaced.
51
+
52
+ **Usage:**
53
+ ```bash
54
+ bash scripts/setup-templates.sh \
55
+ "task_id" \
56
+ "task_description" \
57
+ "auto_mode" \
58
+ "examine_mode" \
59
+ "save_mode" \
60
+ "test_mode" \
61
+ "economy_mode" \
62
+ "branch_mode" \
63
+ "pr_mode" \
64
+ "interactive_mode" \
65
+ "branch_name" \
66
+ "original_input"
67
+ ```
68
+
69
+ **Output:**
70
+ ```
71
+ .claude/output/apex/01-add-auth-middleware/
72
+ ├── 00-context.md # Always created
73
+ ├── 01-analyze.md # Always created
74
+ ├── 02-plan.md # Always created
75
+ ├── 03-execute.md # Always created
76
+ ├── 04-validate.md # Always created
77
+ ├── 05-examine.md # Only if examine_mode
78
+ ├── 06-resolve.md # Only if examine_mode
79
+ ├── 07-tests.md # Only if test_mode
80
+ ├── 08-run-tests.md # Only if test_mode
81
+ └── 09-finish.md # Only if pr_mode
82
+ ```
83
+
84
+ ## Progress Update Script
85
+
86
+ ### `update-progress.sh`
87
+
88
+ Updates the progress table in `00-context.md` without manual markdown editing.
89
+
90
+ **Usage:**
91
+ ```bash
92
+ bash scripts/update-progress.sh <task_id> <step_number> <step_name> <status>
93
+ ```
94
+
95
+ **Examples:**
96
+ ```bash
97
+ # Mark step 01 as in progress
98
+ bash scripts/update-progress.sh "01-add-auth" "01" "analyze" "in_progress"
99
+
100
+ # Mark step 01 as complete
101
+ bash scripts/update-progress.sh "01-add-auth" "01" "analyze" "complete"
102
+
103
+ # Mark step 02 as in progress
104
+ bash scripts/update-progress.sh "01-add-auth" "02" "plan" "in_progress"
105
+ ```
106
+
107
+ **Status Values:**
108
+ - `in_progress` → `⏳ In Progress`
109
+ - `complete` → `✓ Complete`
110
+
111
+ ## Token Savings
112
+
113
+ ### Before Optimization
114
+
115
+ Each step file contained full template content inline:
116
+
117
+ ```markdown
118
+ ### 1. Initialize Save Output (if save_mode)
119
+
120
+ **If `{save_mode}` = true:**
121
+
122
+ Create `{output_dir}/01-analyze.md`:
123
+ ```markdown
124
+ # Step 01: Analyze
125
+
126
+ **Task:** {task_description}
127
+ **Started:** {ISO timestamp}
128
+
129
+ ---
130
+
131
+ ## Context Discovery
132
+ ```
133
+
134
+ Update `00-context.md` progress:
135
+ ```markdown
136
+ | 01-analyze | ⏳ In Progress | {timestamp} |
137
+ ```
138
+ ```
139
+
140
+ **Token cost per step:** ~200 tokens × 9 steps = ~1,800 tokens
141
+
142
+ ### After Optimization
143
+
144
+ Step files now reference templates and scripts:
145
+
146
+ ```markdown
147
+ ### 1. Initialize Save Output (if save_mode)
148
+
149
+ **If `{save_mode}` = true:**
150
+
151
+ The file `{output_dir}/01-analyze.md` has already been created by the setup script.
152
+
153
+ Update progress:
154
+ ```bash
155
+ bash {skill_dir}/scripts/update-progress.sh "{task_id}" "01" "analyze" "in_progress"
156
+ ```
157
+
158
+ Append your findings to `01-analyze.md` as you work.
159
+ ```
160
+
161
+ **Token cost per step:** ~50 tokens × 9 steps = ~450 tokens
162
+
163
+ **Total savings:** ~1,350 tokens per workflow execution (75% reduction)
164
+
165
+ ## How It Works
166
+
167
+ 1. **Initialization (step-00-init.md):**
168
+ - Runs `setup-templates.sh` once at workflow start
169
+ - Creates all template files with variables replaced
170
+ - Output directory is ready with pre-initialized files
171
+
172
+ 2. **Each Step:**
173
+ - Runs `update-progress.sh` to mark step as "in_progress"
174
+ - Appends findings/logs to the pre-created step file
175
+ - Runs `update-progress.sh` again to mark step as "complete"
176
+
177
+ 3. **Benefits:**
178
+ - AI doesn't need to hold template content in context
179
+ - Consistent formatting across all workflows
180
+ - Easy to update templates without editing step files
181
+ - Scripts handle the tedious markdown updates
182
+
183
+ ## Updating Templates
184
+
185
+ To modify template content:
186
+
187
+ 1. Edit the template file in `templates/`
188
+ 2. Changes apply to all future workflows automatically
189
+ 3. No need to update step files
190
+
191
+ ## Maintenance
192
+
193
+ - Templates are stateless (no workflow-specific logic)
194
+ - Scripts are idempotent (safe to run multiple times)
195
+ - Variables use `{{var}}` syntax to avoid conflicts with markdown
@@ -0,0 +1,7 @@
1
+ ---
2
+
3
+ ## Step Complete
4
+
5
+ **Status:** ✓ Complete
6
+ **Next:** {{next_step}}
7
+ **Timestamp:** {{timestamp}}
@@ -1,19 +1,14 @@
1
1
  ---
2
2
  name: appstore-connect
3
- description: Interact with App Store Connect via the asc CLI - apps, builds, TestFlight, beta testers, reviews, sales/analytics, metadata, IAP, signing, submissions. Also builds an Expo/React Native iOS app and ships it to TestFlight via "appstore-connect testflight". Use for "check my app", "App Store Connect", "TestFlight status", "ship to TestFlight", "app review", "my app sales", or "asc".
4
- argument-hint: "[testflight [--expo] [setup]] | <natural-language ASC request>"
3
+ description: Interact with App Store Connect via the asc CLI - apps, builds, TestFlight, beta testers, reviews, sales/analytics, metadata, IAP, signing, submissions. Use for "check my app", "App Store Connect", "TestFlight status", "app review", "my app sales", or "asc".
5
4
  ---
6
5
 
7
6
  # App Store Connect (asc)
8
7
 
9
8
  Read, manage, and ship any of the user's App Store apps through the **`asc`** CLI (App Store Connect CLI by Rork). `asc` covers nearly the entire ASC surface; reach for the raw API only for the rare gap.
10
9
 
11
- <testflight_mode>
12
- **If invoked as `appstore-connect testflight` (or "build and ship to TestFlight"):** this is a full build-and-upload workflow, not a single `asc` call. Read [references/testflight.md](references/testflight.md) and follow it end to end — it takes an Expo / React Native iOS app from local dev to an installable TestFlight build (ASC API-key signing to avoid Apple ID 2FA, `eas build --local` by default, `--expo` for a cloud build, then `asc publish testflight`). Pass `--expo` for a cloud build, or `testflight setup` to stop after credentials are ready. Everything below is the general `asc` surface for everyday read/manage tasks.
13
- </testflight_mode>
14
-
15
10
  <auth>
16
- `asc` is usually already authenticated on this machine (a default keychain profile). Verify before doing real work:
11
+ `asc` is already authenticated on this machine (a default keychain profile). Verify before doing real work:
17
12
 
18
13
  ```bash
19
14
  asc auth status # shows stored credential profiles + which is default
@@ -22,7 +17,7 @@ asc doctor # diagnose auth/config issues
22
17
  ```
23
18
 
24
19
  - Multiple accounts/teams: `asc --profile <name> <command>` selects a profile.
25
- - **Not authenticated / no working credential / a NEW account with no stored key:** read [references/setup.md](references/setup.md) and follow it — a battle-tested workflow to locate the `.p8`, key id, and issuer id, then `asc auth login`. Never print or commit `.p8` keys, key ids, or issuer ids.
20
+ - A NEW account with no stored key: run the `find-asc-credentials` skill (locates the `.p8`, key id, and issuer id, then `asc auth login`). Never print or commit `.p8` keys, key ids, or issuer ids.
26
21
  </auth>
27
22
 
28
23
  <how_to_drive>
@@ -45,7 +40,6 @@ asc docs list # embedded guides; `asc docs <topic>` to read one
45
40
  | List/inspect apps, app id | `asc apps`, `asc status --app <id>` |
46
41
  | Builds (processing, ids) | `asc builds` |
47
42
  | TestFlight: beta groups, testers, distribute a build | `asc testflight` |
48
- | **Build an iOS app + ship to TestFlight (end to end)** | `appstore-connect testflight` → [references/testflight.md](references/testflight.md) |
49
43
  | Versions / release state | `asc versions`, `asc release`, `asc status` |
50
44
  | Metadata, localizations, keywords | `asc metadata`, `asc localizations` |
51
45
  | Screenshots / previews | `asc screenshots`, `asc video-previews` |
@@ -7,11 +7,13 @@ allow_implicit_invocation: true
7
7
 
8
8
  # Environments Manager
9
9
 
10
- Set up per-worktree environments so a fresh worktree is instantly ready to run: env files copied, dependencies installed, isolated database created, and common commands one click away. Supports Claude Code, Cursor, and Codex - the **shared scripts are the same on every IDE**; only the config file that points at them differs.
10
+ Set up per-worktree environments so a fresh worktree is ready to run: env files copied, dependencies installed, optional data services isolated or seeded, generated code refreshed, and common commands exposed through the selected IDE. Supports Claude Code, Cursor, and Codex. The shared scripts are the same on every IDE; only the config file that points at them differs.
11
+
12
+ Keep this skill database-agnostic. The main flow decides what needs to happen; database-specific implementation details live in references and should be loaded only when that backend is relevant.
11
13
 
12
14
  ## Interactive Flow
13
15
 
14
- This skill is interactive. Ask the user the two questions below before writing anything - the right setup depends on the project. Use whichever interactive question mechanism the host harness provides. Do not assume answers.
16
+ This skill is interactive. Ask the user the questions below before writing anything. Use whichever interactive question mechanism the host harness provides. Do not assume answers.
15
17
 
16
18
  ### Step 1: What should happen in a fresh worktree?
17
19
 
@@ -19,24 +21,37 @@ Ask the user what the setup script should do, as a multi-select. The first optio
19
21
 
20
22
  | Option | What it adds to `scripts/worktree-up.sh` |
21
23
  | :--- | :--- |
22
- | Copy ignored env files from the source checkout | `cp` of `.env`, `.env.local`, `.env.development.local` (default - almost always wanted) |
23
- | Install dependencies | `pnpm install` / `bun install` / `npm install` based on lockfile |
24
- | Create an isolated database for this worktree | Build a unique DB name from the worktree dir, rewrite `DATABASE_URL` in `.env`, run `createdb` + import |
25
- | Run codegen (Prisma, Drizzle, generated types) | `pnpm prisma:generate` / `bun run db:generate` / etc. |
24
+ | Copy ignored env files from the source checkout | Copy `.env`, `.env.local`, `.env.development.local` when the source has them and the worktree does not. For Claude Code, prefer `.worktreeinclude` when possible. |
25
+ | Install dependencies | `pnpm install`, `bun install`, `yarn install`, or `npm install` based on lockfile. |
26
+ | Isolate or seed a data backend | Load the backend reference when it exists. Otherwise use researcher agents to discover the project's backend, docs, and current best setup pattern before writing scripts. |
27
+ | Run codegen | Project-specific codegen such as Prisma, Drizzle, Convex, generated types, or SDK generation. |
28
+
29
+ If the user has project-specific steps such as seed data, S3/R2 sync, local services, webhook tunnels, fixture generation, or env cloning, ask one follow-up free-form question to capture them.
30
+
31
+ ### Step 2: Which data backend, if any?
32
+
33
+ Ask which backend needs worktree isolation or seeding. Use the answer to decide which reference to load:
34
+
35
+ | Backend | Action |
36
+ | :--- | :--- |
37
+ | None | Keep setup to env copy, install, codegen, and dev scripts. |
38
+ | PostgreSQL | Load `references/postgresql.md`. |
39
+ | Convex | Load `references/convex.md`. |
40
+ | Other SQL or non-SQL backend | Use researcher agents to inspect the repo, official docs, and current CLI behavior. Then write a narrow project-specific approach instead of adapting PostgreSQL or Convex by analogy. |
26
41
 
27
- If the user has project-specific steps (seed data, S3 sync, etc.), ask a follow-up free-form question to capture them.
42
+ For unknown backends, do not guess commands, reset behavior, file formats, import/export semantics, or production-safety flags. Ask researcher agents to find the official docs and at least one in-repo example or closely matching project pattern. Summarize the discovered approach before editing scripts.
28
43
 
29
- ### Step 2: Which IDEs should be wired up?
44
+ ### Step 3: Which IDEs should be wired up?
30
45
 
31
- Ask a multi-select with options: Claude Code, Cursor, Codex. The user can pick any combination - the shared `scripts/` directory only gets generated once.
46
+ Ask a multi-select with options: Claude Code, Cursor, Codex. The user can pick any combination. Generate the shared `scripts/` directory once.
32
47
 
33
- ### Step 3: Apply each selected IDE
48
+ ### Step 4: Apply each selected IDE
34
49
 
35
- For each selected IDE, read the matching reference file and apply only its linking config. Do not duplicate the script logic - the IDE config just points at `scripts/worktree-up.sh`, `scripts/worktree-down.sh`, and `scripts/dev.sh`.
50
+ For each selected IDE, read the matching reference file and apply only its linking config. Do not duplicate script logic in IDE config; the IDE config points at `scripts/worktree-up.sh`, `scripts/worktree-down.sh`, and `scripts/dev.sh`.
36
51
 
37
- - Claude Code load `references/claude.md`
38
- - Cursor load `references/cursor.md`
39
- - Codex load `references/codex.md`
52
+ - Claude Code -> load `references/claude.md`
53
+ - Cursor -> load `references/cursor.md`
54
+ - Codex -> load `references/codex.md`
40
55
 
41
56
  ## Shared Shape
42
57
 
@@ -50,9 +65,9 @@ scripts/
50
65
  └── (project-specific helpers, all *.sh)
51
66
  ```
52
67
 
53
- Plus one or more IDE config files (see references). The IDE config is thin; all logic lives in `scripts/`.
68
+ Plus one or more IDE config files. The IDE config is thin; all logic lives in `scripts/`.
54
69
 
55
- **Naming convention**: every generated script MUST end in `.sh`. No bare `worktree-up`, no `dev`. IDE configs reference scripts by full filename (`scripts/worktree-up.sh`, not `scripts/worktree-up`). This is enforced in every reference file and example.
70
+ Naming convention: every generated script MUST end in `.sh`. No bare `worktree-up`, no `dev`. IDE configs reference scripts by full filename (`scripts/worktree-up.sh`, not `scripts/worktree-up`). This is enforced in every reference file and example.
56
71
 
57
72
  ## Environment Variable Cascade
58
73
 
@@ -64,29 +79,29 @@ SOURCE_PATH="${CODEX_SOURCE_TREE_PATH:-${ROOT_WORKTREE_PATH:-}}"
64
79
  ```
65
80
 
66
81
  | Platform | Worktree path | Source checkout path | Setup trigger |
67
- | :------- | :----------------------- | :------------------------ | :--- |
68
- | Codex | `$CODEX_WORKTREE_PATH` | `$CODEX_SOURCE_TREE_PATH` | `[setup] script` in TOML, runs once per worktree |
69
- | Cursor | `pwd` inside worktree | `$ROOT_WORKTREE_PATH` | `setup-worktree-unix` in JSON, runs once per worktree |
70
- | Claude | `pwd` inside worktree (the hook wrapper cd's in) | `$CLAUDE_PROJECT_DIR` (source repo, exposed inside the hook); the wrapper re-exports it as `ROOT_WORKTREE_PATH` | `WorktreeCreate` hook, runs once per worktree |
82
+ | :--- | :--- | :--- | :--- |
83
+ | Codex | `$CODEX_WORKTREE_PATH` | `$CODEX_SOURCE_TREE_PATH` | `[setup] script` in TOML, runs once per worktree. |
84
+ | Cursor | `pwd` inside worktree | `$ROOT_WORKTREE_PATH` | `setup-worktree-unix` in JSON, runs once per worktree. |
85
+ | Claude | `pwd` inside worktree after wrapper `cd` | `$CLAUDE_PROJECT_DIR` from the hook, re-exported as `ROOT_WORKTREE_PATH` by the wrapper | `WorktreeCreate` hook, runs once per worktree. |
71
86
 
72
- **Important about Claude Code**: do NOT use `SessionStart` for setup - it fires every session. Use the `WorktreeCreate` hook, which fires once when `claude --worktree` creates the worktree. The Claude wrapper script (`scripts/claude-worktree-create.sh`) is responsible for calling `git worktree add` itself, then handing off to `scripts/worktree-up.sh` inside the new worktree with `ROOT_WORKTREE_PATH` set. See [references/claude.md](references/claude.md).
87
+ Important about Claude Code: do not use `SessionStart` for setup; it fires every session. Use the `WorktreeCreate` hook, which fires once when `claude --worktree` creates the worktree. The Claude wrapper script (`scripts/claude-worktree-create.sh`) is responsible for calling `git worktree add` itself, then handing off to `scripts/worktree-up.sh` inside the new worktree with `ROOT_WORKTREE_PATH` set. See `references/claude.md`.
73
88
 
74
- If no env var yields a source checkout, fall back to a project-specific absolute path (e.g. `$HOME/Developer/saas/<repo>`). Ask the user during Step 1 if you cannot infer it.
89
+ If no env var yields a source checkout, fall back to a project-specific absolute path only when you can infer it confidently. Otherwise ask the user during Step 1.
75
90
 
76
91
  ## `scripts/worktree-up.sh`
77
92
 
78
- Setup must be **idempotent** - reruns are safe. Built from the user's Step 1 selections. Required behavior in order:
93
+ Setup must be idempotent: reruns are safe. Build the script from the user's Step 1 selections and any backend reference loaded in Step 2. Required behavior in order:
79
94
 
80
95
  1. `set -euo pipefail`.
81
96
  2. Resolve `WORKTREE_PATH` and `SOURCE_PATH`.
82
97
  3. `cd "$WORKTREE_PATH"`.
83
- 4. If "Copy env files" selected: copy `.env`, `.env.local`, `.env.development.local` only when the source has them and the worktree does not.
84
- 5. If "Install dependencies" selected: detect from lockfile and run the matching install.
85
- 6. If "Isolated database" selected: build a DB name from `basename "$WORKTREE_PATH" | tr '/' '-'`, rewrite only `DATABASE_URL` (and any related vars) in the copied `.env`, create the DB if missing. Provide a reset escape hatch: `<PROJECT>_RESET_DB=1` drops and recreates.
86
- 7. If "Codegen" selected: run the project's codegen command.
98
+ 4. If env copying was selected, copy `.env`, `.env.local`, `.env.development.local` only when the source has them and the worktree does not.
99
+ 5. If dependency install was selected, detect the lockfile and run the matching install.
100
+ 6. If backend isolation/seeding was selected, apply the backend reference or the researched project-specific approach.
101
+ 7. If codegen was selected, run the project's codegen command.
87
102
  8. Append any free-form project-specific steps from Step 1.
88
103
 
89
- Reference template (adjust based on selections):
104
+ Base template, before backend-specific additions:
90
105
 
91
106
  ```bash
92
107
  #!/usr/bin/env bash
@@ -107,46 +122,28 @@ for f in .env .env.local .env.development.local; do
107
122
  fi
108
123
  done
109
124
 
110
- # Install deps
125
+ # Install deps.
111
126
  if [[ -f pnpm-lock.yaml ]]; then pnpm install
112
127
  elif [[ -f bun.lock || -f bun.lockb ]]; then bun install
113
128
  elif [[ -f yarn.lock ]]; then yarn install
114
129
  elif [[ -f package-lock.json ]]; then npm install
115
130
  fi
116
131
 
117
- # Project-specific DB isolation and codegen go here.
132
+ # Backend isolation/seeding and codegen go here.
118
133
  ```
119
134
 
120
135
  ## `scripts/worktree-down.sh`
121
136
 
122
- Cleanup runs before the IDE destroys the worktree.
137
+ Cleanup runs before the IDE destroys the worktree. Keep cleanup scoped to resources that the setup script created or selected explicitly.
123
138
 
124
139
  1. `set -euo pipefail`.
125
- 2. `cd "$WORKTREE_PATH"`.
126
- 3. Read DB names from the worktree `.env`. **Never guess from branch names.**
127
- 4. `dropdb --if-exists` per DB found, against a maintenance database.
128
- 5. Remove copied env files.
129
- 6. If env files or PostgreSQL tools are missing, print one short message and exit 0.
130
-
131
- ```bash
132
- #!/usr/bin/env bash
133
- set -euo pipefail
134
-
135
- WORKTREE_PATH="${CODEX_WORKTREE_PATH:-${CURSOR_WORKTREE_PATH:-$(pwd)}}"
136
- cd "$WORKTREE_PATH"
137
-
138
- if [[ ! -f .env ]]; then
139
- echo "no .env in worktree, nothing to clean"
140
- exit 0
141
- fi
142
-
143
- db_name=$(grep -E '^DATABASE_URL=' .env | sed -E 's|.*/([^/?]+).*|\1|' | head -n1 || true)
144
- if [[ -n "${db_name:-}" ]] && command -v dropdb >/dev/null 2>&1; then
145
- dropdb --if-exists -d postgres "$db_name" || true
146
- fi
140
+ 2. Resolve `WORKTREE_PATH`.
141
+ 3. `cd "$WORKTREE_PATH"`.
142
+ 4. Run backend-specific cleanup only when the loaded backend reference requires it.
143
+ 5. Remove copied local env files only if that is appropriate for the project.
144
+ 6. If required tools or env files are missing, print one short message and exit 0.
147
145
 
148
- rm -f .env .env.local .env.development.local
149
- ```
146
+ Never guess resource names from branch names. Read names from the worktree's env/config files or from deterministic setup metadata created by `worktree-up.sh`.
150
147
 
151
148
  ## `scripts/dev.sh`
152
149
 
@@ -170,30 +167,32 @@ exec pnpm dev -p "$port" # adjust for the project package manager
170
167
 
171
168
  ## Standard Actions
172
169
 
173
- Every project should expose these four actions through the IDE's own mechanism (see references). Wire them per IDE.
170
+ Every project should expose these four actions through the IDE's own mechanism:
174
171
 
175
- | Action | Command (typical) |
176
- | :--------- | :------------------------------- |
177
- | Dev | `scripts/dev.sh` |
178
- | Typecheck | `pnpm ts` / `bun run typecheck` |
179
- | Unit tests | `pnpm test:ci` / `bun test` |
180
- | Lint | `pnpm lint:ci` / `bun run lint` |
172
+ | Action | Command (typical) |
173
+ | :--- | :--- |
174
+ | Dev | `scripts/dev.sh` |
175
+ | Typecheck | `pnpm ts` / `bun run typecheck` |
176
+ | Unit tests | `pnpm test:ci` / `bun test` |
177
+ | Lint | `pnpm lint:ci` / `bun run lint` |
181
178
 
182
179
  Add `E2E` as an action only if the suite is cheap enough to run interactively.
183
180
 
184
181
  ## Universal Guardrails
185
182
 
186
183
  - Never commit secrets. Copying ignored env files into a local worktree is fine; logging them is not.
187
- - Never drop a database whose name was guessed from a branch. Read it from the worktree `.env`.
188
184
  - Never put fragile multi-line shell programs inside an IDE config file. Keep all logic in `scripts/`; the IDE config just calls those scripts.
189
185
  - Never hardcode a dev port. Pick a free one starting from `${DEV_PORT_START:-3910}`.
190
- - Setup must be idempotent. Provide a reset escape hatch via env var (`<PROJECT>_RESET_DB=1`).
191
- - Print DB names and redacted hosts only.
186
+ - Setup must be idempotent. Provide a reset escape hatch for stateful resources via env var (`<PROJECT>_RESET_<RESOURCE>=1`).
187
+ - Print resource names and redacted hosts only.
192
188
  - The scripts and IDE config must live on the source checkout / main branch, not only the current worktree, or future worktrees will have nothing to copy.
193
- - **Never import data from a production source.** Any setup step that exports a database/deployment and replays it into the new worktree MUST reject any source ref containing `prod`/`production` and require an explicit override env var (`<PROJECT>_ALLOW_PROD_SOURCE=1`). Even a single mistaken `--replace-all` against the wrong source can nuke a teammate's dev environment or, worse, leak prod data into a feature branch. Default the source to `dev` and validate before each export.
189
+ - Never destroy or import from production data by default. Any setup step that exports from a shared source and replays into a worktree must reject production-looking refs unless the user explicitly approved an override env var.
190
+ - Hook wrappers must survive a missing `/dev/tty`, a wrong default Node version, and CLI prompts. See `references/claude.md` -> "Hook Robustness" for the concrete fixes.
191
+
192
+ Use this production-source guard in backend references or project-specific helpers:
194
193
 
195
194
  ```bash
196
- assert_dev_source() {
195
+ assert_non_prod_ref() {
197
196
  case "$1" in
198
197
  prod|prod:*|prod/*|production|production:*|production/*)
199
198
  echo "refusing prod source: $1" >&2; exit 1 ;;
@@ -203,8 +202,6 @@ assert_dev_source() {
203
202
  }
204
203
  ```
205
204
 
206
- - **Hook wrappers must survive a missing `/dev/tty`, a wrong default Node version, and CLI prompts.** See `references/claude.md` → "Hook Robustness" for the five concrete fixes.
207
-
208
205
  ## Verification
209
206
 
210
207
  After generating files:
@@ -214,7 +211,7 @@ bash -n scripts/worktree-up.sh scripts/worktree-down.sh scripts/dev.sh
214
211
  git status --short
215
212
  ```
216
213
 
217
- If Python 3.11+ is available, validate any generated TOML:
214
+ If Python 3.11+ is available, validate generated TOML:
218
215
 
219
216
  ```bash
220
217
  python3 - <<'PY'
@@ -231,41 +228,36 @@ python3 -c "import json; json.load(open('.cursor/worktrees.json'))"
231
228
  python3 -c "import json; json.load(open('.claude/settings.json'))"
232
229
  ```
233
230
 
234
- ## IDE-Specific Linking
235
-
236
- After the shared scripts are written, for each IDE selected in Step 2, load the matching reference file and apply only its linking config:
231
+ ## References
237
232
 
238
- - **Claude Code** → [references/claude.md](references/claude.md) - `.claude/settings.json` worktree hooks + optional project action skills.
239
- - **Cursor** → [references/cursor.md](references/cursor.md) - `.cursor/worktrees.json` setup keys.
240
- - **Codex** → [references/codex.md](references/codex.md) - `.codex/environments/environment.toml` setup, cleanup, and actions.
233
+ Load only the references relevant to the selected backend and IDE:
241
234
 
242
- If multiple IDEs were selected, generate `scripts/` once and then apply each reference in turn.
235
+ - `references/postgresql.md` - PostgreSQL isolation, reset, and cleanup.
236
+ - `references/convex.md` - Convex local/cloud deployments, allowlisted seeding, env cloning, and cleanup.
237
+ - `references/claude.md` - Claude Code WorktreeCreate/WorktreeRemove wiring.
238
+ - `references/cursor.md` - Cursor worktree setup wiring.
239
+ - `references/codex.md` - Codex local environment TOML.
243
240
 
244
241
  ## Examples
245
242
 
246
- Working copies of every file this skill generates live under [examples/](examples/). Use them as the source-of-truth shape when writing into a real project. Adapt the project section (package manager, DB name prefix, codegen step) for the target repo.
243
+ Working examples live under `examples/`. Read the relevant example before writing files into a real project, but do not copy verbatim. The user's selections, backend reference, and project conventions determine which sections survive.
247
244
 
248
245
  ```text
249
246
  examples/
250
247
  ├── scripts/
251
- │ ├── worktree-up.sh # pnpm + Postgres + Prisma reference
252
- │ ├── worktree-down.sh # pnpm + Postgres reference
253
- │ ├── dev.sh # free-port dev server reference
254
- │ ├── claude-worktree-create.sh # Claude WorktreeCreate hook wrapper
255
- └── claude-worktree-remove.sh # Claude WorktreeRemove hook wrapper
248
+ │ ├── worktree-up.sh
249
+ │ ├── worktree-down.sh
250
+ │ ├── dev.sh
251
+ │ ├── convex-selective-seed.sh
252
+ ├── claude-worktree-create.sh
253
+ │ └── claude-worktree-remove.sh
256
254
  ├── claude/
257
- │ ├── .worktreeinclude # native env-file copy list
258
- │ ├── settings.json # WorktreeCreate + WorktreeRemove hooks
259
- ├── skills/ # optional project action skills
260
- │ ├── dev/SKILL.md
261
- │ ├── typecheck/SKILL.md
262
- │ ├── test/SKILL.md
263
- │ └── lint/SKILL.md
255
+ │ ├── .worktreeinclude
256
+ │ ├── settings.json
257
+ │ └── commands/
264
258
  ├── cursor/
265
- │ └── worktrees.json # setup-worktree-unix -> scripts/worktree-up.sh
259
+ │ └── worktrees.json
266
260
  └── codex/
267
261
  └── environments/
268
- └── environment.toml # setup, cleanup, four actions
262
+ └── environment.toml
269
263
  ```
270
-
271
- Read the relevant example before writing the file into the target project. Do not copy verbatim - the user's Step 1 selections determine which sections of `worktree-up.sh` survive.
@@ -1,6 +1,5 @@
1
1
  ---
2
- name: dev
3
- description: Start the dev server on a free port for this project.
2
+ description: Start the dev server on a free port
4
3
  ---
5
4
 
6
5
  Run `scripts/dev.sh` from the project root. Stream output until the dev server is listening, then return the URL.
@@ -1,6 +1,5 @@
1
1
  ---
2
- name: lint
3
- description: Run the linter for this project and report violations.
2
+ description: Run the linter
4
3
  ---
5
4
 
6
5
  Run the project's lint command (`pnpm lint:ci`, `bun run lint`, or equivalent). Report any violations.
@@ -1,6 +1,5 @@
1
1
  ---
2
- name: test
3
- description: Run unit tests for this project and summarize failures.
2
+ description: Run unit tests
4
3
  ---
5
4
 
6
5
  Run the project's unit test command (`pnpm test:ci`, `bun test`, or equivalent). Report failures with file:line references.
@@ -1,6 +1,5 @@
1
1
  ---
2
- name: typecheck
3
- description: Typecheck this project and report errors with file references.
2
+ description: Typecheck the project
4
3
  ---
5
4
 
6
5
  Run the project's typecheck command (`pnpm ts`, `bun run typecheck`, or equivalent based on the lockfile). Report any errors with file:line references.
@@ -1,22 +1,15 @@
1
1
  #!/usr/bin/env bash
2
- # Example: pnpm + Postgres project cleanup. Generated by environments-manager.
2
+ # Example: backend-neutral worktree cleanup.
3
+ # Generated by environments-manager. Add backend-specific cleanup from references.
3
4
 
4
5
  set -euo pipefail
5
6
 
6
7
  WORKTREE_PATH="${CODEX_WORKTREE_PATH:-${CURSOR_WORKTREE_PATH:-$(pwd)}}"
7
8
  cd "$WORKTREE_PATH"
8
9
 
9
- if [[ ! -f .env ]]; then
10
- echo "no .env in worktree, nothing to clean"
11
- exit 0
12
- fi
13
-
14
- db_name=$(grep -E '^DATABASE_URL=' .env | sed -E 's|.*/([^/?]+).*|\1|' | head -n1 || true)
15
-
16
- if [[ -n "${db_name:-}" ]] && command -v dropdb >/dev/null 2>&1; then
17
- dropdb --if-exists -d postgres "$db_name" || true
18
- echo "dropped $db_name"
19
- fi
10
+ # Backend-specific cleanup goes here.
11
+ # Never guess resource names from branch names. Read them from env/config files
12
+ # or deterministic setup metadata created by worktree-up.sh.
20
13
 
21
14
  rm -f .env .env.local .env.development.local
22
15
  echo "removed local env files"