aiblueprint-cli 1.4.88 → 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.
- package/agents-config/skills/agents-manager/SKILL.md +14 -3
- package/agents-config/skills/agents-manager/references/writing-agent-prompts.md +1 -1
- package/agents-config/skills/apex/SKILL.md +116 -55
- package/agents-config/skills/apex/scripts/setup-templates.sh +154 -0
- package/agents-config/skills/apex/scripts/update-progress.sh +80 -0
- package/agents-config/skills/apex/steps/step-00-init.md +278 -0
- package/agents-config/skills/apex/steps/step-00b-branch.md +126 -0
- package/agents-config/skills/apex/steps/step-00b-economy.md +247 -0
- package/agents-config/skills/apex/steps/step-00b-interactive.md +170 -0
- package/agents-config/skills/apex/steps/step-00b-save.md +125 -0
- package/agents-config/skills/apex/steps/step-01-analyze.md +388 -0
- package/agents-config/skills/apex/steps/step-02-plan.md +593 -0
- package/agents-config/skills/apex/steps/step-02b-tasks.md +301 -0
- package/agents-config/skills/apex/steps/step-03-execute-teams.md +296 -0
- package/agents-config/skills/apex/steps/step-03-execute.md +240 -0
- package/agents-config/skills/apex/steps/step-04-validate.md +272 -0
- package/agents-config/skills/apex/steps/step-05-examine.md +400 -0
- package/agents-config/skills/apex/steps/step-06-resolve.md +239 -0
- package/agents-config/skills/apex/steps/step-07-tests.md +250 -0
- package/agents-config/skills/apex/steps/step-08-run-tests.md +314 -0
- package/agents-config/skills/apex/steps/step-09-finish.md +223 -0
- package/agents-config/skills/apex/steps/step-10-verify.md +296 -0
- package/agents-config/skills/apex/templates/00-context.md +55 -0
- package/agents-config/skills/apex/templates/01-analyze.md +10 -0
- package/agents-config/skills/apex/templates/02-plan.md +10 -0
- package/agents-config/skills/apex/templates/03-execute.md +10 -0
- package/agents-config/skills/apex/templates/04-validate.md +10 -0
- package/agents-config/skills/apex/templates/05-examine.md +10 -0
- package/agents-config/skills/apex/templates/06-resolve.md +10 -0
- package/agents-config/skills/apex/templates/07-tests.md +10 -0
- package/agents-config/skills/apex/templates/08-run-tests.md +10 -0
- package/agents-config/skills/apex/templates/09-finish.md +10 -0
- package/agents-config/skills/apex/templates/10-verify.md +9 -0
- package/agents-config/skills/apex/templates/README.md +195 -0
- package/agents-config/skills/apex/templates/step-complete.md +7 -0
- package/agents-config/skills/appstore-connect/SKILL.md +3 -9
- package/agents-config/skills/environments-manager/SKILL.md +86 -94
- package/agents-config/skills/environments-manager/examples/{skills/dev/SKILL.md → claude/commands/dev.md} +1 -2
- package/agents-config/skills/environments-manager/examples/{skills/lint/SKILL.md → claude/commands/lint.md} +1 -2
- package/agents-config/skills/environments-manager/examples/{skills/test/SKILL.md → claude/commands/test.md} +1 -2
- package/agents-config/skills/environments-manager/examples/{skills/typecheck/SKILL.md → claude/commands/typecheck.md} +1 -2
- package/agents-config/skills/environments-manager/examples/scripts/worktree-down.sh +5 -12
- package/agents-config/skills/environments-manager/examples/scripts/worktree-up.sh +11 -21
- package/agents-config/skills/environments-manager/references/claude.md +9 -13
- package/agents-config/skills/environments-manager/references/convex.md +120 -0
- package/agents-config/skills/environments-manager/references/cursor.md +2 -2
- package/agents-config/skills/environments-manager/references/postgresql.md +89 -0
- package/agents-config/skills/oneshot/SKILL.md +21 -37
- package/agents-config/skills/rules-manager/SKILL.md +15 -2
- package/agents-config/skills/skill-manager/SKILL.md +30 -2
- package/agents-config/skills/ultrathink/SKILL.md +1 -1
- package/agents-config/skills/use-fable/SKILL.md +64 -0
- package/package.json +1 -1
- package/agents-config/skills/appstore-connect/references/setup.md +0 -156
- 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
|
|
@@ -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.
|
|
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
|
|
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
|
-
-
|
|
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
|
|
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
|
|
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 |
|
|
23
|
-
| Install dependencies | `pnpm install
|
|
24
|
-
|
|
|
25
|
-
| Run codegen
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
38
|
-
- Cursor
|
|
39
|
-
- Codex
|
|
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
|
|
68
|
+
Plus one or more IDE config files. The IDE config is thin; all logic lives in `scripts/`.
|
|
54
69
|
|
|
55
|
-
|
|
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
|
|
69
|
-
| Cursor
|
|
70
|
-
| Claude
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
84
|
-
5. If
|
|
85
|
-
6. If
|
|
86
|
-
7. If
|
|
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
|
-
|
|
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
|
-
#
|
|
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. `
|
|
126
|
-
3.
|
|
127
|
-
4.
|
|
128
|
-
5. Remove copied env files.
|
|
129
|
-
6. If
|
|
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
|
-
|
|
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
|
|
170
|
+
Every project should expose these four actions through the IDE's own mechanism:
|
|
174
171
|
|
|
175
|
-
| Action
|
|
176
|
-
|
|
|
177
|
-
| Dev
|
|
178
|
-
| Typecheck
|
|
179
|
-
| Unit tests | `pnpm test:ci` / `bun test`
|
|
180
|
-
| 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>
|
|
191
|
-
- Print
|
|
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
|
-
-
|
|
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
|
-
|
|
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
|
|
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
|
-
##
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
252
|
-
│ ├── worktree-down.sh
|
|
253
|
-
│ ├── dev.sh
|
|
254
|
-
│ ├──
|
|
255
|
-
│
|
|
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
|
|
258
|
-
│ ├── settings.json
|
|
259
|
-
|
|
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
|
|
259
|
+
│ └── worktrees.json
|
|
266
260
|
└── codex/
|
|
267
261
|
└── environments/
|
|
268
|
-
└── environment.toml
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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"
|