aiblueprint-cli 1.4.59 → 1.4.61
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/README.md +16 -36
- package/agents-config/agents/action.md +1 -1
- package/agents-config/agents/explore-codebase.md +53 -53
- package/agents-config/agents/explore-docs.md +50 -69
- package/agents-config/agents/websearch.md +36 -40
- package/agents-config/claude-config/scripts/.claude/skills/fix-on-my-computer/SKILL.md +81 -0
- package/agents-config/claude-config/scripts/CLAUDE.md +10 -4
- package/agents-config/claude-config/scripts/bun.lockb +0 -0
- package/agents-config/claude-config/scripts/package.json +22 -30
- package/agents-config/claude-config/scripts/statusline/CLAUDE.md +37 -155
- package/agents-config/claude-config/scripts/statusline/README.md +18 -94
- package/agents-config/claude-config/scripts/statusline/defaults.json +13 -10
- package/agents-config/claude-config/scripts/statusline/fixtures/mock-transcript.jsonl +4 -4
- package/agents-config/claude-config/scripts/statusline/fixtures/test-input.json +4 -4
- package/agents-config/claude-config/scripts/statusline/src/commands/interactive-config.ts +403 -0
- package/agents-config/claude-config/scripts/statusline/src/index.ts +33 -82
- package/agents-config/claude-config/scripts/statusline/src/lib/config-types.ts +7 -1
- package/agents-config/claude-config/scripts/statusline/src/lib/formatters.ts +40 -0
- package/agents-config/claude-config/scripts/statusline/src/lib/presets.ts +13 -13
- package/agents-config/claude-config/scripts/statusline/src/lib/render-pure.ts +24 -5
- package/agents-config/claude-config/scripts/statusline/statusline.config.free.json +79 -0
- package/agents-config/claude-config/scripts/statusline/statusline.config.json +77 -77
- package/agents-config/codex-config/config.toml +9 -0
- package/agents-config/codex-config/hooks/command-deny-list.ts +203 -0
- package/agents-config/commands/prompts/create-vitejs-app.md +272 -0
- package/agents-config/commands/prompts/nextjs-add-prisma-db.md +136 -0
- package/agents-config/commands/prompts/nextjs-setup-better-auth.md +173 -0
- package/agents-config/commands/prompts/nextjs-setup-project.md +200 -0
- package/agents-config/commands/prompts/prompt.md +55 -0
- package/agents-config/commands/prompts/saas-challenge-idea.md +135 -0
- package/agents-config/commands/prompts/saas-create-architecture.md +242 -0
- package/agents-config/commands/prompts/saas-create-headline.md +132 -0
- package/agents-config/commands/prompts/saas-create-landing-copywritting.md +267 -0
- package/agents-config/commands/prompts/saas-create-legals-docs.md +176 -0
- package/agents-config/commands/prompts/saas-create-logos.md +240 -0
- package/agents-config/commands/prompts/saas-create-prd.md +195 -0
- package/agents-config/commands/prompts/saas-create-tasks.md +240 -0
- package/agents-config/commands/prompts/saas-define-pricing.md +293 -0
- package/agents-config/commands/prompts/saas-find-domain-name.md +190 -0
- package/agents-config/commands/prompts/saas-implement-landing-page.md +257 -0
- package/agents-config/commands/prompts/setup-tmux.md +160 -0
- package/agents-config/commands/prompts/tools.md +148 -0
- package/agents-config/scripts/.claude/skills/fix-on-my-computer/SKILL.md +81 -0
- package/agents-config/scripts/CLAUDE.md +37 -0
- package/agents-config/scripts/biome.json +37 -0
- package/agents-config/scripts/bun.lockb +0 -0
- package/agents-config/scripts/package.json +24 -0
- package/agents-config/scripts/statusline/CLAUDE.md +87 -0
- package/agents-config/scripts/statusline/README.md +117 -0
- package/agents-config/scripts/statusline/__tests__/context.test.ts +229 -0
- package/agents-config/scripts/statusline/__tests__/formatters.test.ts +108 -0
- package/agents-config/scripts/statusline/__tests__/statusline.test.ts +309 -0
- package/agents-config/scripts/statusline/defaults.json +82 -0
- package/agents-config/scripts/statusline/fixtures/mock-transcript.jsonl +4 -0
- package/agents-config/scripts/statusline/fixtures/test-input.json +35 -0
- package/agents-config/scripts/statusline/src/commands/interactive-config.ts +403 -0
- package/agents-config/scripts/statusline/src/index.ts +141 -0
- package/agents-config/scripts/statusline/src/lib/config-types.ts +110 -0
- package/agents-config/scripts/statusline/src/lib/config.ts +21 -0
- package/agents-config/scripts/statusline/src/lib/context.ts +103 -0
- package/agents-config/scripts/statusline/src/lib/formatters.ts +426 -0
- package/agents-config/scripts/statusline/src/lib/git.ts +100 -0
- package/agents-config/scripts/statusline/src/lib/menu-factories.ts +224 -0
- package/agents-config/scripts/statusline/src/lib/presets.ts +177 -0
- package/agents-config/scripts/statusline/src/lib/render-pure.ts +516 -0
- package/agents-config/scripts/statusline/src/lib/types.ts +36 -0
- package/agents-config/scripts/statusline/src/lib/utils.ts +15 -0
- package/agents-config/scripts/statusline/statusline.config.free.json +79 -0
- package/agents-config/scripts/statusline/statusline.config.json +79 -0
- package/agents-config/scripts/statusline/test-with-fixtures.ts +37 -0
- package/agents-config/scripts/statusline/test.ts +20 -0
- package/agents-config/scripts/statusline/tsconfig.json +27 -0
- package/agents-config/scripts/tsconfig.json +27 -0
- package/agents-config/skills/{subagent-creator → agents-managers}/SKILL.md +47 -47
- package/agents-config/skills/{subagent-creator/references/subagents.md → agents-managers/references/agents.md} +45 -45
- package/agents-config/skills/{subagent-creator → agents-managers}/references/context-management.md +20 -20
- package/agents-config/skills/{subagent-creator → agents-managers}/references/debugging-agents.md +27 -27
- package/agents-config/skills/{subagent-creator → agents-managers}/references/error-handling-and-recovery.md +19 -19
- package/agents-config/skills/{subagent-creator → agents-managers}/references/evaluation-and-testing.md +29 -29
- package/agents-config/skills/{subagent-creator → agents-managers}/references/orchestration-patterns.md +5 -5
- package/agents-config/skills/{subagent-creator/references/writing-subagent-prompts.md → agents-managers/references/writing-agent-prompts.md} +23 -23
- package/agents-config/skills/codex-environment/SKILL.md +2 -0
- package/agents-config/skills/commit/SKILL.md +2 -0
- package/agents-config/skills/create-pr/SKILL.md +2 -0
- package/agents-config/skills/environments-manager/SKILL.md +271 -0
- package/agents-config/skills/environments-manager/examples/claude/.worktreeinclude +3 -0
- package/agents-config/skills/environments-manager/examples/claude/commands/dev.md +5 -0
- package/agents-config/skills/environments-manager/examples/claude/commands/lint.md +5 -0
- package/agents-config/skills/environments-manager/examples/claude/commands/test.md +5 -0
- package/agents-config/skills/environments-manager/examples/claude/commands/typecheck.md +5 -0
- package/agents-config/skills/environments-manager/examples/claude/settings.json +24 -0
- package/agents-config/skills/environments-manager/examples/codex/environments/environment.toml +29 -0
- package/agents-config/skills/environments-manager/examples/cursor/worktrees.json +3 -0
- package/agents-config/skills/environments-manager/examples/scripts/claude-worktree-create.sh +96 -0
- package/agents-config/skills/environments-manager/examples/scripts/claude-worktree-remove.sh +66 -0
- package/agents-config/skills/environments-manager/examples/scripts/dev.sh +15 -0
- package/agents-config/skills/environments-manager/examples/scripts/worktree-down.sh +22 -0
- package/agents-config/skills/environments-manager/examples/scripts/worktree-up.sh +50 -0
- package/agents-config/skills/environments-manager/references/claude.md +156 -0
- package/agents-config/skills/environments-manager/references/codex.md +97 -0
- package/agents-config/skills/environments-manager/references/cursor.md +88 -0
- package/agents-config/skills/fix-pr-comments/SKILL.md +2 -0
- package/agents-config/skills/grill-me/SKILL.md +10 -0
- package/agents-config/skills/merge/SKILL.md +2 -0
- package/agents-config/skills/rules-manager/SKILL.md +191 -0
- package/agents-config/skills/rules-manager/references/agents-vs-claude.md +66 -0
- package/agents-config/skills/rules-manager/references/examples.md +117 -0
- package/agents-config/skills/skill-manager/SKILL.md +101 -0
- package/agents-config/skills/skill-manager/references/claude-code.md +81 -0
- package/agents-config/skills/skill-manager/references/codex.md +288 -0
- package/agents-config/skills/skill-manager/references/cursor.md +125 -0
- package/agents-config/skills/skill-manager/references/description-recommandation.md +97 -0
- package/agents-config/skills/skill-manager/scripts/inspect-description.ts +743 -0
- package/agents-config/skills/ultrathink/SKILL.md +2 -0
- package/dist/cli.js +581 -299
- package/package.json +1 -1
- package/agents-config/claude-config/scripts/statusline/data/.gitignore +0 -8
- package/agents-config/claude-config/scripts/statusline/data/.gitkeep +0 -0
- package/agents-config/claude-config/scripts/statusline/docs/ARCHITECTURE.md +0 -166
- package/agents-config/claude-config/scripts/statusline/src/tests/spend-v2.test.ts +0 -306
- package/agents-config/skills/apex/SKILL.md +0 -261
- package/agents-config/skills/apex/scripts/setup-templates.sh +0 -100
- package/agents-config/skills/apex/scripts/update-progress.sh +0 -80
- package/agents-config/skills/apex/steps/step-00-init.md +0 -267
- package/agents-config/skills/apex/steps/step-00b-branch.md +0 -126
- package/agents-config/skills/apex/steps/step-00b-economy.md +0 -244
- package/agents-config/skills/apex/steps/step-00b-interactive.md +0 -153
- package/agents-config/skills/apex/steps/step-01-analyze.md +0 -361
- package/agents-config/skills/apex/steps/step-02-plan.md +0 -264
- package/agents-config/skills/apex/steps/step-03-execute.md +0 -239
- package/agents-config/skills/apex/steps/step-04-validate.md +0 -251
- package/agents-config/skills/apex/templates/00-context.md +0 -43
- package/agents-config/skills/apex/templates/01-analyze.md +0 -10
- package/agents-config/skills/apex/templates/02-plan.md +0 -10
- package/agents-config/skills/apex/templates/03-execute.md +0 -10
- package/agents-config/skills/apex/templates/04-validate.md +0 -10
- package/agents-config/skills/apex/templates/README.md +0 -176
- package/agents-config/skills/apex/templates/step-complete.md +0 -7
- package/agents-config/skills/claude-memory/SKILL.md +0 -293
- package/agents-config/skills/claude-memory/references/comprehensive-example.md +0 -175
- package/agents-config/skills/claude-memory/references/optimize-guide.md +0 -300
- package/agents-config/skills/claude-memory/references/project-patterns.md +0 -334
- package/agents-config/skills/claude-memory/references/prompting-techniques.md +0 -411
- package/agents-config/skills/claude-memory/references/rules-directory-guide.md +0 -298
- package/agents-config/skills/claude-memory/references/section-templates.md +0 -347
- package/agents-config/skills/fix-errors/SKILL.md +0 -61
- package/agents-config/skills/fix-grammar/SKILL.md +0 -59
- package/agents-config/skills/ralph-loop/SKILL.md +0 -117
- package/agents-config/skills/ralph-loop/scripts/setup.sh +0 -278
- package/agents-config/skills/ralph-loop/steps/step-00-init.md +0 -215
- package/agents-config/skills/ralph-loop/steps/step-01-interactive-prd.md +0 -366
- package/agents-config/skills/ralph-loop/steps/step-02-create-stories.md +0 -273
- package/agents-config/skills/ralph-loop/steps/step-03-finish.md +0 -245
- package/agents-config/skills/skill-creator/LICENSE.txt +0 -202
- package/agents-config/skills/skill-creator/SKILL.md +0 -421
- package/agents-config/skills/skill-creator/package.json +0 -5
- package/agents-config/skills/skill-creator/references/output-patterns.md +0 -82
- package/agents-config/skills/skill-creator/references/progressive-disclosure-patterns.md +0 -374
- package/agents-config/skills/skill-creator/references/prompting-integration.md +0 -363
- package/agents-config/skills/skill-creator/references/real-world-examples.md +0 -513
- package/agents-config/skills/skill-creator/references/script-patterns.md +0 -385
- package/agents-config/skills/skill-creator/references/workflows.md +0 -28
- package/agents-config/skills/skill-creator/references/xml-tag-guide.md +0 -606
- package/agents-config/skills/skill-creator/scripts/init-skill.ts +0 -214
- package/agents-config/skills/skill-creator/scripts/package-skill.ts +0 -146
- package/agents-config/skills/skill-creator/scripts/validate.ts +0 -138
- package/agents-config/skills/workflow-apex-free/SKILL.md +0 -261
- package/agents-config/skills/workflow-apex-free/scripts/setup-templates.sh +0 -100
- package/agents-config/skills/workflow-apex-free/scripts/update-progress.sh +0 -80
- package/agents-config/skills/workflow-apex-free/steps/step-00-init.md +0 -267
- package/agents-config/skills/workflow-apex-free/steps/step-00b-branch.md +0 -126
- package/agents-config/skills/workflow-apex-free/steps/step-00b-economy.md +0 -244
- package/agents-config/skills/workflow-apex-free/steps/step-00b-interactive.md +0 -153
- package/agents-config/skills/workflow-apex-free/steps/step-01-analyze.md +0 -361
- package/agents-config/skills/workflow-apex-free/steps/step-02-plan.md +0 -264
- package/agents-config/skills/workflow-apex-free/steps/step-03-execute.md +0 -239
- package/agents-config/skills/workflow-apex-free/steps/step-04-validate.md +0 -251
- package/agents-config/skills/workflow-apex-free/templates/00-context.md +0 -43
- package/agents-config/skills/workflow-apex-free/templates/01-analyze.md +0 -10
- package/agents-config/skills/workflow-apex-free/templates/02-plan.md +0 -10
- package/agents-config/skills/workflow-apex-free/templates/03-execute.md +0 -10
- package/agents-config/skills/workflow-apex-free/templates/04-validate.md +0 -10
- package/agents-config/skills/workflow-apex-free/templates/README.md +0 -176
- package/agents-config/skills/workflow-apex-free/templates/step-complete.md +0 -7
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Claude Code WorktreeCreate hook wrapper.
|
|
3
|
+
# Replaces default `git worktree add` behavior, then runs the shared scripts/worktree-up.sh.
|
|
4
|
+
#
|
|
5
|
+
# stdin contract: JSON with { "name": "<worktree-name>", ... }
|
|
6
|
+
# stdout contract: the absolute worktree path and NOTHING ELSE.
|
|
7
|
+
# Progress goes to <worktree>/.worktree-setup.log AND /dev/tty when available.
|
|
8
|
+
|
|
9
|
+
set -euo pipefail
|
|
10
|
+
|
|
11
|
+
INPUT=$(cat)
|
|
12
|
+
NAME=$(echo "$INPUT" | jq -r '.name')
|
|
13
|
+
REPO="$CLAUDE_PROJECT_DIR"
|
|
14
|
+
WORKTREE="${REPO}/.claude/worktrees/${NAME}"
|
|
15
|
+
BRANCH="worktree-${NAME}"
|
|
16
|
+
SETUP_TIMEOUT_SEC="${CLAUDE_WORKTREE_SETUP_TIMEOUT:-900}"
|
|
17
|
+
|
|
18
|
+
LOG_FILE=""
|
|
19
|
+
|
|
20
|
+
# Both the /dev/tty redirect AND the log append are guarded so a missing tty or
|
|
21
|
+
# read-only worktree never aborts the hook (the script runs under `set -e`).
|
|
22
|
+
log_to() {
|
|
23
|
+
{ echo "$*" > /dev/tty; } 2>/dev/null || true
|
|
24
|
+
if [[ -n "$LOG_FILE" ]]; then
|
|
25
|
+
echo "$(date '+%H:%M:%S') $*" >> "$LOG_FILE" 2>/dev/null || true
|
|
26
|
+
fi
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
log_to "[claude-worktree-create] Creating worktree (branch: $BRANCH)..."
|
|
30
|
+
|
|
31
|
+
mkdir -p "${REPO}/.claude/worktrees"
|
|
32
|
+
if git -C "$REPO" rev-parse --verify "$BRANCH" >/dev/null 2>&1; then
|
|
33
|
+
git -C "$REPO" worktree add "$WORKTREE" "$BRANCH" >/dev/null 2>&1
|
|
34
|
+
else
|
|
35
|
+
git -C "$REPO" worktree add -b "$BRANCH" "$WORKTREE" HEAD >/dev/null 2>&1
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
LOG_FILE="$WORKTREE/.worktree-setup.log"
|
|
39
|
+
: > "$LOG_FILE"
|
|
40
|
+
|
|
41
|
+
# Hooks inherit the shell default Node, NOT the project's .nvmrc. Many CLIs
|
|
42
|
+
# (e.g. Convex) crash on older Node. Source nvm/fnm so `node` resolves to
|
|
43
|
+
# whatever the worktree's .nvmrc demands.
|
|
44
|
+
if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
|
|
45
|
+
# shellcheck disable=SC1090,SC1091
|
|
46
|
+
. "$HOME/.nvm/nvm.sh" >/dev/null 2>&1 || true
|
|
47
|
+
if [[ -f "$WORKTREE/.nvmrc" ]]; then
|
|
48
|
+
(cd "$WORKTREE" && nvm use >/dev/null 2>&1) || true
|
|
49
|
+
fi
|
|
50
|
+
elif command -v fnm >/dev/null 2>&1; then
|
|
51
|
+
eval "$(fnm env --use-on-cd)" || true
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
log_to "[claude-worktree-create] Using node: $(node --version 2>&1 || echo unknown)"
|
|
55
|
+
|
|
56
|
+
run_setup() {
|
|
57
|
+
cd "$WORKTREE"
|
|
58
|
+
# CI=1 keeps interactive CLIs (convex, prisma, etc.) from prompting and hanging.
|
|
59
|
+
ROOT_WORKTREE_PATH="$REPO" \
|
|
60
|
+
CLAUDE_WORKTREE_NAME="$NAME" \
|
|
61
|
+
CI=1 \
|
|
62
|
+
bash "${REPO}/scripts/worktree-up.sh"
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
# Watchdog: hard-kill setup after SETUP_TIMEOUT_SEC. macOS has no `timeout`
|
|
66
|
+
# command by default, so we background the setup and a sleeper that kills it
|
|
67
|
+
# on timeout. Without this, an interactive prompt would hang the hook forever.
|
|
68
|
+
(
|
|
69
|
+
run_setup >> "$LOG_FILE" 2>&1
|
|
70
|
+
) &
|
|
71
|
+
SETUP_PID=$!
|
|
72
|
+
|
|
73
|
+
(
|
|
74
|
+
sleep "$SETUP_TIMEOUT_SEC"
|
|
75
|
+
if kill -0 "$SETUP_PID" 2>/dev/null; then
|
|
76
|
+
echo "[claude-worktree-create] TIMEOUT after ${SETUP_TIMEOUT_SEC}s - killing setup (PID $SETUP_PID)" >> "$LOG_FILE"
|
|
77
|
+
kill -TERM "$SETUP_PID" 2>/dev/null || true
|
|
78
|
+
sleep 5
|
|
79
|
+
kill -KILL "$SETUP_PID" 2>/dev/null || true
|
|
80
|
+
fi
|
|
81
|
+
) &
|
|
82
|
+
WATCHDOG_PID=$!
|
|
83
|
+
|
|
84
|
+
SETUP_EXIT=0
|
|
85
|
+
wait "$SETUP_PID" || SETUP_EXIT=$?
|
|
86
|
+
kill "$WATCHDOG_PID" 2>/dev/null || true
|
|
87
|
+
wait "$WATCHDOG_PID" 2>/dev/null || true
|
|
88
|
+
|
|
89
|
+
if [[ "$SETUP_EXIT" -ne 0 ]]; then
|
|
90
|
+
log_to "[claude-worktree-create] worktree-up.sh exited $SETUP_EXIT - see $LOG_FILE"
|
|
91
|
+
else
|
|
92
|
+
log_to "[claude-worktree-create] Worktree ready."
|
|
93
|
+
fi
|
|
94
|
+
|
|
95
|
+
# THE ONLY THING ON STDOUT - Claude parses this as the cwd.
|
|
96
|
+
echo "$WORKTREE"
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Claude Code WorktreeRemove hook wrapper.
|
|
3
|
+
# Runs scripts/worktree-down.sh for cleanup, then removes the git worktree and branch.
|
|
4
|
+
#
|
|
5
|
+
# stdin contract: JSON with { "worktree_path": "<absolute-path>", ... }
|
|
6
|
+
|
|
7
|
+
set -euo pipefail
|
|
8
|
+
|
|
9
|
+
INPUT=$(cat)
|
|
10
|
+
WORKTREE=$(echo "$INPUT" | jq -r '.worktree_path')
|
|
11
|
+
REPO="$CLAUDE_PROJECT_DIR"
|
|
12
|
+
CLEANUP_TIMEOUT_SEC="${CLAUDE_WORKTREE_CLEANUP_TIMEOUT:-300}"
|
|
13
|
+
|
|
14
|
+
[[ ! -d "$WORKTREE" ]] && exit 0
|
|
15
|
+
|
|
16
|
+
LOG_FILE="$WORKTREE/.worktree-cleanup.log"
|
|
17
|
+
: > "$LOG_FILE" 2>/dev/null || LOG_FILE=""
|
|
18
|
+
|
|
19
|
+
log_to() {
|
|
20
|
+
{ echo "$*" > /dev/tty; } 2>/dev/null || true
|
|
21
|
+
if [[ -n "$LOG_FILE" ]]; then
|
|
22
|
+
echo "$(date '+%H:%M:%S') $*" >> "$LOG_FILE" 2>/dev/null || true
|
|
23
|
+
fi
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
# Cleanup may call CLIs (e.g. convex env remove) that need the project's Node version.
|
|
27
|
+
if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
|
|
28
|
+
# shellcheck disable=SC1090,SC1091
|
|
29
|
+
. "$HOME/.nvm/nvm.sh" >/dev/null 2>&1 || true
|
|
30
|
+
if [[ -f "$WORKTREE/.nvmrc" ]]; then
|
|
31
|
+
(cd "$WORKTREE" && nvm use >/dev/null 2>&1) || true
|
|
32
|
+
fi
|
|
33
|
+
elif command -v fnm >/dev/null 2>&1; then
|
|
34
|
+
eval "$(fnm env --use-on-cd)" || true
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
run_cleanup() {
|
|
38
|
+
cd "$WORKTREE"
|
|
39
|
+
ROOT_WORKTREE_PATH="$REPO" CI=1 bash "${REPO}/scripts/worktree-down.sh"
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if [[ -x "${REPO}/scripts/worktree-down.sh" ]]; then
|
|
43
|
+
(
|
|
44
|
+
run_cleanup >> "${LOG_FILE:-/dev/null}" 2>&1
|
|
45
|
+
) &
|
|
46
|
+
CLEANUP_PID=$!
|
|
47
|
+
|
|
48
|
+
(
|
|
49
|
+
sleep "$CLEANUP_TIMEOUT_SEC"
|
|
50
|
+
if kill -0 "$CLEANUP_PID" 2>/dev/null; then
|
|
51
|
+
log_to "[claude-worktree-remove] TIMEOUT after ${CLEANUP_TIMEOUT_SEC}s - killing cleanup"
|
|
52
|
+
kill -TERM "$CLEANUP_PID" 2>/dev/null || true
|
|
53
|
+
sleep 3
|
|
54
|
+
kill -KILL "$CLEANUP_PID" 2>/dev/null || true
|
|
55
|
+
fi
|
|
56
|
+
) &
|
|
57
|
+
WATCHDOG_PID=$!
|
|
58
|
+
|
|
59
|
+
wait "$CLEANUP_PID" 2>/dev/null || true
|
|
60
|
+
kill "$WATCHDOG_PID" 2>/dev/null || true
|
|
61
|
+
wait "$WATCHDOG_PID" 2>/dev/null || true
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
BRANCH=$(git -C "$WORKTREE" rev-parse --abbrev-ref HEAD 2>/dev/null || true)
|
|
65
|
+
git -C "$REPO" worktree remove "$WORKTREE" --force 2>/dev/null || true
|
|
66
|
+
[[ -n "$BRANCH" && "$BRANCH" != "HEAD" ]] && git -C "$REPO" branch -D "$BRANCH" 2>/dev/null || true
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Example: dev server on a free port. Generated by environments-manager.
|
|
3
|
+
|
|
4
|
+
set -euo pipefail
|
|
5
|
+
|
|
6
|
+
WORKTREE_PATH="${CODEX_WORKTREE_PATH:-${CURSOR_WORKTREE_PATH:-$(pwd)}}"
|
|
7
|
+
cd "$WORKTREE_PATH"
|
|
8
|
+
|
|
9
|
+
port="${DEV_PORT_START:-3910}"
|
|
10
|
+
while lsof -nP -iTCP:"$port" -sTCP:LISTEN >/dev/null 2>&1; do
|
|
11
|
+
port=$((port + 1))
|
|
12
|
+
done
|
|
13
|
+
|
|
14
|
+
echo "Starting app on http://localhost:$port"
|
|
15
|
+
exec pnpm dev -p "$port"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Example: pnpm + Postgres project cleanup. Generated by environments-manager.
|
|
3
|
+
|
|
4
|
+
set -euo pipefail
|
|
5
|
+
|
|
6
|
+
WORKTREE_PATH="${CODEX_WORKTREE_PATH:-${CURSOR_WORKTREE_PATH:-$(pwd)}}"
|
|
7
|
+
cd "$WORKTREE_PATH"
|
|
8
|
+
|
|
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
|
|
20
|
+
|
|
21
|
+
rm -f .env .env.local .env.development.local
|
|
22
|
+
echo "removed local env files"
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Example: pnpm + Postgres project with all four setup steps enabled.
|
|
3
|
+
# Generated by environments-manager. Adapt the project section for your repo.
|
|
4
|
+
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
WORKTREE_PATH="${CODEX_WORKTREE_PATH:-${CURSOR_WORKTREE_PATH:-$(pwd)}}"
|
|
8
|
+
SOURCE_PATH="${CODEX_SOURCE_TREE_PATH:-${ROOT_WORKTREE_PATH:-$HOME/Developer/saas/myapp}}"
|
|
9
|
+
|
|
10
|
+
cd "$WORKTREE_PATH"
|
|
11
|
+
|
|
12
|
+
# 1. Copy ignored env files
|
|
13
|
+
for f in .env .env.local .env.development.local; do
|
|
14
|
+
if [[ -f "$SOURCE_PATH/$f" && ! -f "$WORKTREE_PATH/$f" ]]; then
|
|
15
|
+
cp "$SOURCE_PATH/$f" "$WORKTREE_PATH/$f"
|
|
16
|
+
echo "copied $f"
|
|
17
|
+
fi
|
|
18
|
+
done
|
|
19
|
+
|
|
20
|
+
# 2. Install dependencies
|
|
21
|
+
if [[ -f pnpm-lock.yaml ]]; then pnpm install
|
|
22
|
+
elif [[ -f bun.lock || -f bun.lockb ]]; then bun install
|
|
23
|
+
elif [[ -f yarn.lock ]]; then yarn install
|
|
24
|
+
elif [[ -f package-lock.json ]]; then npm install
|
|
25
|
+
fi
|
|
26
|
+
|
|
27
|
+
# 3. Worktree-isolated database
|
|
28
|
+
worktree_slug=$(basename "$WORKTREE_PATH" | tr '/' '-' | tr '[:upper:]' '[:lower:]')
|
|
29
|
+
db_name="myapp_${worktree_slug}"
|
|
30
|
+
|
|
31
|
+
if [[ -f .env ]]; then
|
|
32
|
+
if grep -qE '^DATABASE_URL=' .env; then
|
|
33
|
+
if [[ "${MYAPP_RESET_DB:-0}" == "1" ]] && command -v dropdb >/dev/null 2>&1; then
|
|
34
|
+
dropdb --if-exists -d postgres "$db_name" || true
|
|
35
|
+
fi
|
|
36
|
+
if command -v createdb >/dev/null 2>&1; then
|
|
37
|
+
createdb -d postgres "$db_name" 2>/dev/null || true
|
|
38
|
+
fi
|
|
39
|
+
# Rewrite only the DB name in DATABASE_URL
|
|
40
|
+
sed -i.bak -E "s|(DATABASE_URL=postgres://[^/]+)/[^?\"']+|\1/${db_name}|" .env && rm -f .env.bak
|
|
41
|
+
echo "DB set to $db_name"
|
|
42
|
+
fi
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
# 4. Codegen
|
|
46
|
+
if [[ -f prisma/schema.prisma ]]; then
|
|
47
|
+
pnpm prisma generate
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
echo "worktree ready"
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# Claude Code Linking
|
|
2
|
+
|
|
3
|
+
Wire the shared `scripts/worktree-up.sh` and `scripts/worktree-down.sh` into Claude Code's native worktree system.
|
|
4
|
+
|
|
5
|
+
## What Claude Code Actually Provides
|
|
6
|
+
|
|
7
|
+
Claude Code DOES have native worktree support. It is fired on real worktree creation, not on every session.
|
|
8
|
+
|
|
9
|
+
| Mechanism | What it does |
|
|
10
|
+
| :--- | :--- |
|
|
11
|
+
| `claude --worktree <name>` (or `-w`) | Creates worktree at `.claude/worktrees/<name>/` on branch `worktree-<name>` |
|
|
12
|
+
| `.worktreeinclude` file (gitignore syntax) | Auto-copies matching **gitignored** files (e.g. `.env`, `.env.local`) into every new worktree - **no scripting required** |
|
|
13
|
+
| `WorktreeCreate` hook | Runs ONCE when a worktree is created. **Replaces the default `git worktree add` behavior** - the hook script must call `git worktree add` itself and print the worktree path to stdout |
|
|
14
|
+
| `WorktreeRemove` hook | Runs when a worktree is being deleted. Receives `worktree_path` on stdin |
|
|
15
|
+
| `$CLAUDE_PROJECT_DIR` | Path to the source repo root inside hook scripts |
|
|
16
|
+
|
|
17
|
+
**Do NOT use `SessionStart` for worktree setup.** `SessionStart` fires on every new conversation in any worktree, not on worktree creation. It would rerun setup every time the user opens a session.
|
|
18
|
+
|
|
19
|
+
The "run once when worktree is created" hook is `WorktreeCreate` - that is the correct mechanism.
|
|
20
|
+
|
|
21
|
+
There is no separate `PostWorktreeCreate` hook (feature request #27744 is open). Because `WorktreeCreate` replaces the default git logic, the hook script must be responsible for both the `git worktree add` call AND the project setup.
|
|
22
|
+
|
|
23
|
+
## Files to Generate
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
.worktreeinclude # gitignore-syntax list of files to auto-copy
|
|
27
|
+
.claude/
|
|
28
|
+
├── settings.json # WorktreeCreate + WorktreeRemove hooks
|
|
29
|
+
└── commands/ # optional: per-action slash commands
|
|
30
|
+
├── dev.md
|
|
31
|
+
├── typecheck.md
|
|
32
|
+
├── test.md
|
|
33
|
+
└── lint.md
|
|
34
|
+
scripts/
|
|
35
|
+
├── claude-worktree-create.sh # WorktreeCreate hook wrapper
|
|
36
|
+
├── claude-worktree-remove.sh # WorktreeRemove hook wrapper
|
|
37
|
+
└── (shared worktree-up.sh / worktree-down.sh / dev.sh)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`.gitignore` must also include `**/.claude/worktrees/`.
|
|
41
|
+
|
|
42
|
+
## `.worktreeinclude`
|
|
43
|
+
|
|
44
|
+
If "Copy ignored env files" was selected in Step 1, **prefer `.worktreeinclude` over the bash `cp` loop** - it's native, zero-script, and runs on every worktree path (CLI `--worktree`, subagent worktrees, desktop parallel sessions).
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
.env
|
|
48
|
+
.env.local
|
|
49
|
+
.env.development.local
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Only files matching a pattern **and** gitignored are copied. Tracked files are never duplicated.
|
|
53
|
+
|
|
54
|
+
## `.claude/settings.json`
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"hooks": {
|
|
59
|
+
"WorktreeCreate": [
|
|
60
|
+
{
|
|
61
|
+
"hooks": [
|
|
62
|
+
{
|
|
63
|
+
"type": "command",
|
|
64
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/scripts/claude-worktree-create.sh"
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"WorktreeRemove": [
|
|
70
|
+
{
|
|
71
|
+
"hooks": [
|
|
72
|
+
{
|
|
73
|
+
"type": "command",
|
|
74
|
+
"command": "\"$CLAUDE_PROJECT_DIR\"/scripts/claude-worktree-remove.sh"
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
If the project already has a `settings.json`, **merge** the `hooks` block. Do not overwrite.
|
|
84
|
+
|
|
85
|
+
## `scripts/claude-worktree-create.sh` & `claude-worktree-remove.sh`
|
|
86
|
+
|
|
87
|
+
These wrappers exist because Claude's `WorktreeCreate` hook has Claude-specific responsibilities the shared `scripts/worktree-up.sh` cannot handle:
|
|
88
|
+
|
|
89
|
+
1. Call `git worktree add` itself (Claude does not do it).
|
|
90
|
+
2. Print the worktree path - and **only** the path - to stdout.
|
|
91
|
+
3. Send progress output to a log file (and to `/dev/tty` only when available).
|
|
92
|
+
|
|
93
|
+
**Do not inline the wrapper code into this doc.** The full, battle-tested wrappers live in `examples/scripts/claude-worktree-create.sh` and `claude-worktree-remove.sh`. Always start from those — they encode every gotcha listed in "Hook Robustness" below. The wrappers do these things in order:
|
|
94
|
+
|
|
95
|
+
1. Read `name` from stdin JSON, compute `WORKTREE` and `BRANCH`.
|
|
96
|
+
2. Create the worktree (reusing a matching branch if it exists).
|
|
97
|
+
3. Open a log file at `<worktree>/.worktree-setup.log`.
|
|
98
|
+
4. Source `nvm` or `fnm` and activate the worktree's `.nvmrc` (so child CLIs see the right Node).
|
|
99
|
+
5. Run `scripts/worktree-up.sh` with `ROOT_WORKTREE_PATH`, `CLAUDE_WORKTREE_NAME`, and `CI=1` set, under a watchdog that hard-kills after `CLAUDE_WORKTREE_SETUP_TIMEOUT` (default 900s).
|
|
100
|
+
6. Echo the worktree path on stdout — and absolutely nothing else.
|
|
101
|
+
|
|
102
|
+
The remove wrapper mirrors steps 3–5 for cleanup, then runs `git worktree remove --force` + `git branch -D`.
|
|
103
|
+
|
|
104
|
+
`ROOT_WORKTREE_PATH` is set so the shared `scripts/worktree-up.sh` can locate the source checkout via the existing cascade (`CODEX_SOURCE_TREE_PATH` → `ROOT_WORKTREE_PATH`).
|
|
105
|
+
|
|
106
|
+
## Hook Robustness (lessons from a real project)
|
|
107
|
+
|
|
108
|
+
These five fixes turn a wrapper that "works on my machine" into one that survives Claude's actual hook execution context. Every one of these came from a real bug.
|
|
109
|
+
|
|
110
|
+
1. **`set -e` + `> /dev/tty` will abort the hook.** When Claude runs the hook as a child process, `/dev/tty` may exist but be non-writable, and the redirect failure under `set -e` kills the whole script before setup ever runs. Always wrap the redirect: `{ echo "$*" > /dev/tty; } 2>/dev/null || true`. Testing with `[[ -w /dev/tty ]]` is NOT enough — the perm test can pass while the open call still fails.
|
|
111
|
+
|
|
112
|
+
2. **Hooks inherit the shell default Node, not the worktree's `.nvmrc`.** If the project's CLI tools require a newer Node (Convex needs 24+; older Node crashes on regex `v` flag), the hook will instantly die. Source `~/.nvm/nvm.sh` or run `fnm env` at the top of the wrapper, then `nvm use` inside the worktree.
|
|
113
|
+
|
|
114
|
+
3. **Always log to a file.** A hook that crashes silently is impossible to debug from the UI. Open `<worktree>/.worktree-setup.log` early, append every step. The user can `tail -f` it during the next attempt.
|
|
115
|
+
|
|
116
|
+
4. **Add a watchdog timeout — macOS has no `timeout` command.** Background the setup, background a sleep+kill, `wait` on the setup. Without a watchdog, a single interactive CLI prompt (convex, prisma, vercel) can hang the hook forever — which is what users see as "the script is infinite."
|
|
117
|
+
|
|
118
|
+
5. **Set `CI=1` before calling the setup script.** Many CLIs read `CI` and switch to non-interactive mode (skip prompts, suppress spinners). It's the cheapest insurance against interactive hangs.
|
|
119
|
+
|
|
120
|
+
## Common Misconception: Agent Worktrees
|
|
121
|
+
|
|
122
|
+
The `WorktreeCreate` hook **only fires for `claude --worktree` from the CLI**. The Agent tool's `isolation: "worktree"` feature, and parallel-session worktrees created via the desktop app, create worktrees at `~/Developer/worktrees/<repo>/<name>/` on branch `claude/<name>` — those do **not** trigger this hook. If you need setup there, the user must run `scripts/worktree-up.sh` inside the agent worktree manually (or wire a different mechanism).
|
|
123
|
+
|
|
124
|
+
Also: **`.claude/settings.json` changes only take effect after restarting Claude.** A running session keeps the old hook config. Tell the user to restart before testing.
|
|
125
|
+
|
|
126
|
+
## Custom Slash Commands as Actions (optional)
|
|
127
|
+
|
|
128
|
+
Claude Code does not have a top-bar action menu. To expose the standard actions, write one file per action under `.claude/commands/`. Each is a tiny prompt that tells Claude to run the matching shared script or package-manager command.
|
|
129
|
+
|
|
130
|
+
See `examples/claude/commands/` for the four standard ones (`dev.md`, `typecheck.md`, `test.md`, `lint.md`).
|
|
131
|
+
|
|
132
|
+
## Guardrails
|
|
133
|
+
|
|
134
|
+
- **Never use `SessionStart` for one-time worktree setup** - it fires every session. Use `WorktreeCreate`.
|
|
135
|
+
- **Never let `git worktree add` write to stdout** in the `WorktreeCreate` hook - redirect with `>/dev/null 2>&1`. Anything on stdout besides the path breaks Claude's parser.
|
|
136
|
+
- **Read stdin once** with `INPUT=$(cat)` - stdin cannot be re-read.
|
|
137
|
+
- **Always merge** into the existing `.claude/settings.json`, never overwrite.
|
|
138
|
+
- The hook must live in `.claude/settings.json`, not `.claude/settings.local.json` - it must be checked in.
|
|
139
|
+
- Prefer `.worktreeinclude` over a bash `cp` loop for env files. Use the `cp` loop only when you need conditional or non-gitignored copies.
|
|
140
|
+
- Add `**/.claude/worktrees/` to `.gitignore` so worktree contents do not pollute the main repo's `git status`.
|
|
141
|
+
|
|
142
|
+
## Verification
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
python3 -c "import json; json.load(open('.claude/settings.json'))"
|
|
146
|
+
bash -n scripts/claude-worktree-create.sh scripts/claude-worktree-remove.sh
|
|
147
|
+
test -x scripts/claude-worktree-create.sh scripts/claude-worktree-remove.sh
|
|
148
|
+
grep -q '.claude/worktrees' .gitignore || echo "ADD: **/.claude/worktrees/ to .gitignore"
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Online References
|
|
152
|
+
|
|
153
|
+
- Run parallel sessions with worktrees: https://code.claude.com/docs/en/worktrees
|
|
154
|
+
- Hooks reference (WorktreeCreate, WorktreeRemove): https://code.claude.com/docs/en/hooks
|
|
155
|
+
- Community reference implementation: https://github.com/tfriedel/claude-worktree-hooks
|
|
156
|
+
- Open feature request for PostWorktreeCreate: https://github.com/anthropics/claude-code/issues/27744
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Codex Linking
|
|
2
|
+
|
|
3
|
+
Wire the shared `scripts/worktree-up.sh`, `scripts/worktree-down.sh`, and `scripts/dev.sh` into Codex App Local Environments.
|
|
4
|
+
|
|
5
|
+
## What Codex Provides
|
|
6
|
+
|
|
7
|
+
Codex has the richest native model of the three IDEs:
|
|
8
|
+
|
|
9
|
+
1. **`.codex/environments/environment.toml`** - shareable config for setup, cleanup, and actions.
|
|
10
|
+
2. **`[setup] script`** - runs when Codex creates a new worktree for a new thread.
|
|
11
|
+
3. **`[cleanup] script`** - runs before Codex cleans up the worktree.
|
|
12
|
+
4. **`[[actions]]`** - top-bar buttons that run in the integrated terminal.
|
|
13
|
+
|
|
14
|
+
Worktrees only contain checked-in files, so ignored files like `.env` must be copied or recreated by setup.
|
|
15
|
+
|
|
16
|
+
## Environment Variables
|
|
17
|
+
|
|
18
|
+
| Variable | Meaning |
|
|
19
|
+
| :--- | :--- |
|
|
20
|
+
| `$CODEX_WORKTREE_PATH` | The new worktree path |
|
|
21
|
+
| `$CODEX_SOURCE_TREE_PATH` | The original project checkout |
|
|
22
|
+
|
|
23
|
+
## Files to Generate
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
.codex/
|
|
27
|
+
└── environments/
|
|
28
|
+
└── environment.toml
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The TOML file is small - it only points at the shared scripts and lists the actions.
|
|
32
|
+
|
|
33
|
+
## `.codex/environments/environment.toml`
|
|
34
|
+
|
|
35
|
+
```toml
|
|
36
|
+
# THIS IS AUTOGENERATED. DO NOT EDIT MANUALLY.
|
|
37
|
+
version = 1
|
|
38
|
+
name = "Project Worktree"
|
|
39
|
+
|
|
40
|
+
[setup]
|
|
41
|
+
script = "cd \"$CODEX_WORKTREE_PATH\"\nscripts/worktree-up.sh"
|
|
42
|
+
|
|
43
|
+
[cleanup]
|
|
44
|
+
script = "cd \"$CODEX_WORKTREE_PATH\"\nscripts/worktree-down.sh"
|
|
45
|
+
|
|
46
|
+
[[actions]]
|
|
47
|
+
name = "Dev"
|
|
48
|
+
icon = "tool"
|
|
49
|
+
command = "scripts/dev.sh"
|
|
50
|
+
|
|
51
|
+
[[actions]]
|
|
52
|
+
name = "Typecheck"
|
|
53
|
+
icon = "tool"
|
|
54
|
+
command = "pnpm ts"
|
|
55
|
+
|
|
56
|
+
[[actions]]
|
|
57
|
+
name = "Unit tests"
|
|
58
|
+
icon = "tool"
|
|
59
|
+
command = "pnpm test:ci"
|
|
60
|
+
|
|
61
|
+
[[actions]]
|
|
62
|
+
name = "Lint"
|
|
63
|
+
icon = "tool"
|
|
64
|
+
command = "pnpm lint:ci"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Adjust the action commands for the project's package manager (e.g. `bun run typecheck`).
|
|
68
|
+
|
|
69
|
+
## Guardrails
|
|
70
|
+
|
|
71
|
+
- Do not put large fragile shell programs directly in the TOML string. The TOML keeps two lines max - `cd` then call the script.
|
|
72
|
+
- Do not read or write `.conductor` directories.
|
|
73
|
+
- Do not create duplicate environments when the user already has one. Update the existing `.codex/environments/environment.toml`.
|
|
74
|
+
- Do not hardcode a dev port in the Dev action - call `scripts/dev.sh`, which finds a free port.
|
|
75
|
+
- Do not commit `.codex` only on a worktree - it must live on the source checkout / main branch so future worktrees pick it up.
|
|
76
|
+
|
|
77
|
+
## Verification
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
sed -n '1,120p' .codex/environments/environment.toml
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
If Python 3.11+ is available:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
python3 - <<'PY'
|
|
87
|
+
import tomllib
|
|
88
|
+
with open(".codex/environments/environment.toml", "rb") as f:
|
|
89
|
+
tomllib.load(f)
|
|
90
|
+
PY
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Online References
|
|
94
|
+
|
|
95
|
+
- OpenAI Codex Local Environments: https://developers.openai.com/codex/app/local-environments
|
|
96
|
+
- OpenAI Codex Worktrees: https://developers.openai.com/codex/app/worktrees
|
|
97
|
+
- `CODEX_SOURCE_TREE_PATH` / `CODEX_WORKTREE_PATH` note: https://zenn.dev/route06/articles/c1f686b4479957
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Cursor Linking
|
|
2
|
+
|
|
3
|
+
Wire the shared `scripts/worktree-up.sh`, `scripts/worktree-down.sh`, and `scripts/dev.sh` into Cursor.
|
|
4
|
+
|
|
5
|
+
## What Cursor Provides
|
|
6
|
+
|
|
7
|
+
Cursor has native worktree support via `.cursor/worktrees.json`. The file is searched first in the worktree, then in the project root.
|
|
8
|
+
|
|
9
|
+
Three setup keys are supported (Cursor picks the first one that matches the host OS):
|
|
10
|
+
|
|
11
|
+
- `setup-worktree-unix` - macOS/Linux (string filepath or array of commands)
|
|
12
|
+
- `setup-worktree-windows` - Windows (string filepath or array of commands)
|
|
13
|
+
- `setup-worktree` - generic fallback
|
|
14
|
+
|
|
15
|
+
Cursor does **not** support a cleanup script. Cleanup is timer-based via global settings (`cursor.worktreeCleanupIntervalHours`, `cursor.worktreeMaxCount`). To get a real cleanup hook, expose `scripts/worktree-down.sh` as a project command the user runs manually before `/delete-worktree`.
|
|
16
|
+
|
|
17
|
+
Built-in worktree slash commands the user already has: `/worktree`, `/best-of-n`, `/apply-worktree`, `/delete-worktree`.
|
|
18
|
+
|
|
19
|
+
## Environment Variables
|
|
20
|
+
|
|
21
|
+
Only one variable is documented:
|
|
22
|
+
|
|
23
|
+
- `$ROOT_WORKTREE_PATH` - absolute path to the root of the original checkout
|
|
24
|
+
- (On Windows: `%ROOT_WORKTREE_PATH%`)
|
|
25
|
+
|
|
26
|
+
The worktree path itself is just `pwd` inside the worktree.
|
|
27
|
+
|
|
28
|
+
## Files to Generate
|
|
29
|
+
|
|
30
|
+
```text
|
|
31
|
+
.cursor/
|
|
32
|
+
└── worktrees.json
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
That is it. No actions menu, no per-IDE command files - Cursor wires the setup script and stops.
|
|
36
|
+
|
|
37
|
+
## `.cursor/worktrees.json`
|
|
38
|
+
|
|
39
|
+
Preferred shape: point Cursor at the script files. Keep arrays only as a last resort.
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"setup-worktree-unix": "../scripts/worktree-up.sh"
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The path is relative to the location of `.cursor/worktrees.json`. From `.cursor/worktrees.json` at the project root, `scripts/worktree-up.sh` is at `../scripts/worktree-up.sh`.
|
|
48
|
+
|
|
49
|
+
If the project also needs Windows support, add the second key:
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"setup-worktree-unix": "../scripts/worktree-up.sh",
|
|
54
|
+
"setup-worktree-windows": "../scripts/worktree-up.ps1"
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
If the user does not want a separate script and prefers inline commands:
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"setup-worktree": [
|
|
63
|
+
"cp $ROOT_WORKTREE_PATH/.env .env",
|
|
64
|
+
"pnpm install"
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Inline is fine for two-line setups. For anything more, use a script - the worktree-up logic from the parent skill belongs in `scripts/worktree-up.sh`, not in JSON.
|
|
70
|
+
|
|
71
|
+
## Guardrails
|
|
72
|
+
|
|
73
|
+
- Do not put fragile multi-line setup inline. If it does not fit in two clean array entries, call the script.
|
|
74
|
+
- Do not put `.cursor/worktrees.json` only in a worktree - it must be on the source checkout / main branch so future worktrees pick it up.
|
|
75
|
+
- Do not rely on a cleanup hook - Cursor does not have one. Tell the user to run `scripts/worktree-down.sh` before `/delete-worktree`, or document it in the project README.
|
|
76
|
+
- Do not use `$CURSOR_WORKTREE_PATH` - that variable is not documented and not guaranteed. Use `pwd` inside the worktree.
|
|
77
|
+
|
|
78
|
+
## Verification
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
python3 -c "import json; json.load(open('.cursor/worktrees.json'))"
|
|
82
|
+
test -x scripts/worktree-up.sh
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Online References
|
|
86
|
+
|
|
87
|
+
- Cursor Worktrees docs: https://cursor.com/docs/configuration/worktrees
|
|
88
|
+
- Cursor 3 worktrees release notes: https://forum.cursor.com/t/cursor-3-worktrees-best-of-n
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: grill-me
|
|
3
|
+
description: Interview the user relentlessly about a plan or design until reaching shared understanding, resolving each branch of the decision tree. Use when user wants to stress-test a plan, get grilled on their design, or mentions "grill me".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Interview me relentlessly about every aspect of this plan until we reach a shared understanding. Walk down each branch of the design tree, resolving dependencies between decisions one-by-one. For each question, provide your recommended answer.
|
|
7
|
+
|
|
8
|
+
Ask the questions one at a time.
|
|
9
|
+
|
|
10
|
+
If a question can be answered by exploring the codebase, explore the codebase instead.
|
|
@@ -3,6 +3,8 @@ name: merge
|
|
|
3
3
|
description: Intelligently merge branches with context-aware conflict resolution
|
|
4
4
|
allowed-tools: Bash(git :*), Bash(gh :*), Read, Edit, MultiEdit, Task
|
|
5
5
|
argument-hint: <branch-name>
|
|
6
|
+
disable-model-invocation: true
|
|
7
|
+
allow_implicit_invocation: false
|
|
6
8
|
---
|
|
7
9
|
|
|
8
10
|
# Merge
|