From c4824148190a7d218425ec6571d0cf24d3dd4915 Mon Sep 17 00:00:00 2001 From: Chaim Date: Sat, 6 Jun 2026 16:39:11 +0000 Subject: [PATCH] =?UTF-8?q?docs+config:=20=D7=91=D7=99=D7=93=D7=95=D7=93-?= =?UTF-8?q?=D7=A1=D7=A9=D7=A0=D7=99=D7=9D=20=D7=A0=D7=AA=D7=9E=D7=9A-?= =?UTF-8?q?=D7=A1=D7=91=D7=99=D7=91=D7=94=20=D7=9C=D7=A2=D7=91=D7=95=D7=93?= =?UTF-8?q?=D7=94=20=D7=9E=D7=A7=D7=91=D7=99=D7=9C=D7=94=20(worktree=20def?= =?UTF-8?q?aults)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit הופך את כלל ה-worktree המבודד מ-דיסציפלינה-ידנית ל-ברירת-מחדל נתמכת-סביבה, לפי המקורות הרשמיים של Anthropic (worktrees + settings) ו-Git. - .claude/settings.json: worktree.baseRef=fresh (בסיס מ-origin/main), worktree.symlinkDirectories=[web-ui/node_modules] (שיתוף 789MB במקום npm ci לכל worktree), ו-WorktreeRemove hook עם --force לעקיפת באג cleanup #40259. spec-guard נשמר. - .worktreeinclude: העתקת .claude/settings.local.json (allowlist הרשאות) + env לכל worktree. - .gitignore: הוספת .claude/worktrees/ (טיפ רשמי) — מנקה את git status של העץ הראשי. - CLAUDE.md: שדרוג מקטע "בידוד-סשנים" — claude --worktree כברירת-מחדל תחת .claude/worktrees/, caveat בידוד-DB (לא migrations מ-2 worktrees), אזכור באג #60588 (אימות baseRef). Co-Authored-By: Claude Opus 4.8 (1M context) --- .claude/settings.json | 14 ++++++++++++++ .gitignore | 1 + .worktreeinclude | 10 ++++++++++ CLAUDE.md | 31 +++++++++++++++++++------------ 4 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 .worktreeinclude diff --git a/.claude/settings.json b/.claude/settings.json index 27322c6..14e188d 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -10,6 +10,20 @@ } ] } + ], + "WorktreeRemove": [ + { + "hooks": [ + { + "type": "command", + "command": "jq -r '.tool_input.path // empty' | { read -r wt; [ -n \"$wt\" ] && git worktree remove --force \"$wt\" 2>/dev/null; git worktree prune 2>/dev/null; } || true" + } + ] + } ] + }, + "worktree": { + "baseRef": "fresh", + "symlinkDirectories": ["web-ui/node_modules"] } } diff --git a/.gitignore b/.gitignore index 2afbb0e..8072286 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ kiryat-yearim/ continuation-prompt.md node_modules/ data/eval/eval-report-* +.claude/worktrees/ diff --git a/.worktreeinclude b/.worktreeinclude new file mode 100644 index 0000000..88312f2 --- /dev/null +++ b/.worktreeinclude @@ -0,0 +1,10 @@ +# קבצים מקומיים (gitignored) שמועתקים אוטומטית לכל worktree חדש שה-harness יוצר. +# תחביר .gitignore. מועתק רק אם הקובץ קיים *וגם* gitignored — קבצים tracked לעולם לא משוכפלים. +# ראה docs: https://code.claude.com/docs/en/worktrees#copy-gitignored-files-into-worktrees + +# allowlist ההרשאות — בלעדיו כל worktree מציף אישורי-הרשאה מחדש +.claude/settings.local.json + +# קבצי-סביבה מקומיים (כיום אין; proactive — בלתי-מזיק אם חסר) +.env +web-ui/.env.local diff --git a/CLAUDE.md b/CLAUDE.md index 49ec951..a5f2dda 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -105,21 +105,28 @@ **לכן — כל סשן שעומד לכתוב/לשנות קוד או תיעוד חייב לעבוד ב-git worktree מבודד משלו. אסור לערוך/לתייק בעץ-העבודה הראשי `~/legal-ai` כשייתכן שסשן אחר פעיל.** -הפרוטוקול: -1. **בתחילת עבודת-כתיבה** — צור worktree ייעודי מ-`main` עדכני: - ```bash - cd ~/legal-ai && git fetch origin - git worktree add -b ~/legal-ai-wt- origin/main - cd ~/legal-ai-wt- # כל העריכות, ה-commit וה-push מכאן - ``` -2. **אמת ענף לפני כל commit** — `git branch --show-current` (גם ב-worktree, הרגל). -3. **push + PR + merge** כרגיל ([[feedback_always_pr_merge]]) — PR תמיד ל-`main`. -4. **נקה אחרי מיזוג** — `cd ~/legal-ai && git worktree remove ~/legal-ai-wt- && git worktree prune && git branch -D `. +הבידוד **נתמך-סביבה** — לא רק כלל-משמעת. ההגדרות נשמרות ב-repo (`.claude/settings.json`, `.worktreeinclude`, `.gitignore`) כך שכל worktree שה-harness יוצר מקבל אוטומטית בסיס נקי, את התלויות, ואת ההרשאות. מקורות רשמיים: [Run parallel sessions with worktrees](https://code.claude.com/docs/en/worktrees), [Settings → worktree](https://code.claude.com/docs/en/settings). + +### הדרך המומלצת — worktree של ה-harness +```bash +cd ~/legal-ai && claude --worktree # או, בתוך סשן: "עבוד ב-worktree" (כלי EnterWorktree) +``` +נוצר תחת `.claude/worktrees//` על ענף `worktree-`, ומקבל **אוטומטית**: +- **בסיס נקי מ-`origin/main`** — דרך `worktree.baseRef: "fresh"` ב-`.claude/settings.json`. +- **`web-ui/node_modules` (789MB) כסימלינק** — דרך `worktree.symlinkDirectories`; אין צורך ב-`npm ci`. (אם משנים deps של web-ui — עשו זאת בעץ הראשי או היו מודעים שה-node_modules משותף.) +- **`.claude/settings.local.json` + קבצי-env מקומיים** — מועתקים דרך `.worktreeinclude` (מונע הצפת אישורי-הרשאה). +- **ניקוי אוטומטי ביציאה** — כולל עקיפת באג סימלינק [#40259](https://github.com/anthropics/claude-code/issues/40259) דרך `WorktreeRemove` hook עם `--force`. + +### הפרוטוקול (חל על שתי הדרכים) +1. **בתחילת עבודת-כתיבה** — צור worktree (מומלץ: `claude --worktree`; ידני-fallback: `git worktree add -b .claude/worktrees/ origin/main` — **תחת `.claude/worktrees/`** כדי שההגדרות יחולו). +2. **אמת ענף לפני כל commit** — `git branch --show-current` (הרגל קשיח; ה-harness עלול להתעלם מ-`baseRef:"fresh"` — באג [#60588](https://github.com/anthropics/claude-code/issues/60588) — אז ודא שהבסיס באמת `origin/main`). +3. **push + PR + merge** כרגיל ([[feedback_always_pr_merge]]) — PR תמיד ל-`main`. הרץ tests לפני merge. +4. **נקה אחרי מיזוג** — יציאת הסשן מנקה worktree של ה-harness אוטומטית; ידני: `git worktree remove .claude/worktrees/ && git worktree prune && git branch -D worktree-`. 5. **קריאה-בלבד** (חקירה, סריקה, הרצת בדיקות ללא שינוי) — מותר בעץ הראשי; אין צורך ב-worktree. 6. **אל תיגע** בשינויים לא-מתויקים שאינם שלך בעץ הראשי — הם של סשן אחר. אם העץ הראשי על ענף זר — אל תתייק עליו. -> מוסכמות: location `~/legal-ai-wt-`, branch לפי הפרוסה (`fix/...`, `feat/...`, `docs/...`). ה-worktree חולק את אותו `.git` והיסטוריה — בידוד-קבצים בלבד, לא בידוד-repo. הקם מ-`origin/main` (לא מהענף שבעץ הראשי) כדי לקבל בסיס נקי ועדכני. -> חריג: סוכני Paperclip שמופעלים עם `cwd` מוכתב ע"י ה-runtime — שם הבידוד נאכף ברמת ה-runtime/issue, לא ידנית. +> **בידוד-DB:** ה-worktree מבודד-קבצים בלבד — לא בידוד-repo ולא בידוד-DB. **אל תריץ migrations מ-2 worktrees במקביל** על Postgres המשותף (`localhost:5433`) — סכמה שאף סשן לא מצפה לה ([Run agents in parallel](https://code.claude.com/docs/en/agents)). +> **חריג Paperclip:** סוכנים שמופעלים עם `cwd` מוכתב ע"י ה-runtime — הבידוד נאכף ברמת ה-runtime/issue, לא ידנית. --- -- 2.49.1