docs+config: בידוד-סשנים נתמך-סביבה לעבודה מקבילה (worktree defaults) #73
@@ -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"]
|
||||
}
|
||||
}
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -17,3 +17,4 @@ kiryat-yearim/
|
||||
continuation-prompt.md
|
||||
node_modules/
|
||||
data/eval/eval-report-*
|
||||
.claude/worktrees/
|
||||
|
||||
10
.worktreeinclude
Normal file
10
.worktreeinclude
Normal file
@@ -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
|
||||
31
CLAUDE.md
31
CLAUDE.md
@@ -105,21 +105,28 @@
|
||||
|
||||
**לכן — כל סשן שעומד לכתוב/לשנות קוד או תיעוד חייב לעבוד ב-git worktree מבודד משלו. אסור לערוך/לתייק בעץ-העבודה הראשי `~/legal-ai` כשייתכן שסשן אחר פעיל.**
|
||||
|
||||
הפרוטוקול:
|
||||
1. **בתחילת עבודת-כתיבה** — צור worktree ייעודי מ-`main` עדכני:
|
||||
```bash
|
||||
cd ~/legal-ai && git fetch origin
|
||||
git worktree add -b <branch-name> ~/legal-ai-wt-<slug> origin/main
|
||||
cd ~/legal-ai-wt-<slug> # כל העריכות, ה-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-<slug> && git worktree prune && git branch -D <branch-name>`.
|
||||
הבידוד **נתמך-סביבה** — לא רק כלל-משמעת. ההגדרות נשמרות ב-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 <slug> # או, בתוך סשן: "עבוד ב-worktree" (כלי EnterWorktree)
|
||||
```
|
||||
נוצר תחת `.claude/worktrees/<slug>/` על ענף `worktree-<slug>`, ומקבל **אוטומטית**:
|
||||
- **בסיס נקי מ-`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 <branch> .claude/worktrees/<slug> 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/<slug> && git worktree prune && git branch -D worktree-<slug>`.
|
||||
5. **קריאה-בלבד** (חקירה, סריקה, הרצת בדיקות ללא שינוי) — מותר בעץ הראשי; אין צורך ב-worktree.
|
||||
6. **אל תיגע** בשינויים לא-מתויקים שאינם שלך בעץ הראשי — הם של סשן אחר. אם העץ הראשי על ענף זר — אל תתייק עליו.
|
||||
|
||||
> מוסכמות: location `~/legal-ai-wt-<slug>`, 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, לא ידנית.
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user