| name | deep-fork |
| description | Use when the user wants to fork an existing deep-work session to explore an alternative approach without losing the original. Triggers on `/deep-fork`, "fork session", "alternative approach", "์ธ์
fork", "๋ค๋ฅธ ์ ๊ทผ", "๋ถ๊ธฐ ํ์". Resolves target session-id (explicit arg or auto-detect active), parses `--from-phase=<phase>` (brainstorm|research|plan|implement) to choose restart point, creates a new worktree+session pair, copies brainstorm.md/research.md/plan.md up to the from-phase boundary, and registers `fork_parent` link in `.claude/deep-work-sessions.json`. |
| user-invocable | true |
Invocation
์ด ์คํฌ์ ๋ ๊ฐ์ง ๊ฒฝ๋ก๋ก ํธ์ถ๋ฉ๋๋ค โ ์ด๋ ์ชฝ์ด๋ ๋ณธ SKILL ๋ณธ๋ฌธ์ ์ ์ฐจ๋ฅผ ๊ทธ๋๋ก ์คํํฉ๋๋ค:
- Claude Code ์ฌ๋์ โ ์ฌ์ฉ์๊ฐ
/deep-fork [args...] ์
๋ ฅ (skill ์ user-invocable: true ๊ฐ ์ฌ๋์ ์ง์
์ ํ์ฉ).
- ํ ์์ด์ ํธ / Codex / Copilot CLI / Gemini CLI / SDK โ
Skill({ skill: "deep-work:deep-fork", args: "..." }) ํํ๋ก ๋ช
์ invoke (cross-platform ํ์ค ๊ฒฝ๋ก).
๋ ๊ฒฝ๋ก ๋ชจ๋ args ๋ ๋์ผํ ํ ํฐ ๋ฌธ์์ด๋ก ์ ๋ฌ๋๋ฉฐ, ๋ณธ๋ฌธ ($ARGUMENTS ์๋ฆฌ) ์ ํ์๊ฐ ๋์ผํ๊ฒ ์ฒ๋ฆฌํฉ๋๋ค.
Inputs (skill args)
| ์ธ์ | ์๋ฏธ |
|---|
| (์์) | Auto-detect ํ์ฑ ์ธ์
+ AskUserQuestion from-phase ์ ํ |
<session-id> | ๋ช
์๋ ์ธ์
fork |
--from-phase=<phase> | `brainstorm |
๋น args / ๋งค์นญ๋์ง ์๋ ํ ํฐ โ ๋ณธ๋ฌธ์ default ๋ถ๊ธฐ๋ก ์ง์
.
Prerequisites
์ด entry skill ์ deep-work-orchestrator (Phase dispatch) ๋ฐ deep-work-workflow (reference skill โ Phase ๊ท์ฝ/Exit Gate/M3 envelope) ์ ํจ๊ป ๋์ํฉ๋๋ค. ํ์ฑ deep-work ์ธ์
์ด ์์ ๋๋ ์ธ์
state file (.claude/deep-work.<SESSION_ID>.md) ์ ๋ณ์ (work_dir, current_phase, active_slice ๋ฑ) ๋ฅผ ์ฝ์ด ๋์ํ๋ฉฐ, ์ธ์
์ธ๋ถ์์๋ standalone ์คํ์ด ๊ฐ๋ฅํ ๊ฒฝ์ฐ ๋ณธ๋ฌธ์ ๋ถ๊ธฐ๋ฅผ ๋ฐ๋ฆ
๋๋ค.
Cross-platform self-containment: Claude Code ์์๋ sibling skill ์ด description ๋งค์นญ์ผ๋ก ์๋ ๋ก๋๋ฉ๋๋ค. Codex / Copilot CLI / Gemini CLI / Agent SDK ์์ Skill() ๋ก ํธ์ถ ์ sibling auto-load ๋ณด์ฅ์ด ์ฝํ ์ ์์ผ๋ฏ๋ก, ๋ณธ๋ฌธ์ self-contained ์ผ๋ก ๋ณด์กด๋์ด ์์ต๋๋ค โ state file ํด์, $ARGUMENTS ํ์ฑ, AskUserQuestion ๋ถ๊ธฐ, ์ถ๋ ฅ ํฌ๋งท์ด ์ธ๋ผ์ธ.
/deep-fork โ ์ธ์
Fork
ํ์ฌ ๋๋ ์ง์ ๋ deep-work ์ธ์
์ forkํ์ฌ ๋ค๋ฅธ ์ ๊ทผ๋ฒ์ ํ์ํฉ๋๋ค.
Arguments
session-id (optional): forkํ ์ธ์
ID. ์๋ต ์ ํ์ฌ ํ์ฑ ์ธ์
์๋ ๊ฐ์ง
--from-phase=PHASE (optional): ์ฌ์์ํ phase ์ง์ (brainstorm|research|plan|implement). ์๋ต ์ ๋ํํ์ผ๋ก ์ ํ
์คํ ๋จ๊ณ
Output ALL messages in the user's detected language. Use Korean as template.
Step 1: ๋์ ์ธ์
ํด์
$ARGUMENTS์์ session-id์ --from-phase ํ๋๊ทธ๋ฅผ ์ถ์ถํ๋ค.
ARGS="$ARGUMENTS"
FROM_PHASE=""
# Extract --from-phase flag
if echo "$ARGS" | grep -q '\-\-from-phase='; then
FROM_PHASE=$(echo "$ARGS" | grep -o '\-\-from-phase=[a-z]*' | cut -d= -f2)
ARGS=$(echo "$ARGS" | sed 's/--from-phase=[a-z]*//')
fi
TARGET_SESSION=$(echo "$ARGS" | tr -s ' ' | xargs)
์ธ์
ID๊ฐ ๋น์ด์์ผ๋ฉด:
$PROJECT_ROOT/.claude/deep-work-current-session ํฌ์ธํฐ ํ์ผ์์ ์ฝ๋๋ค
- ์์ผ๋ฉด
$PROJECT_ROOT/.claude/deep-work-sessions.json์์ ํ์ฑ(idle์ด ์๋) ์ธ์
๋ชฉ๋ก์ ๋ณด์ฌ์ฃผ๊ณ ์ ํํ๊ฒ ํ๋ค
- ํ์ฑ ์ธ์
์ด ์์ผ๋ฉด ์๋ฌ: "ํ์ฑ ์ธ์
์ด ์์ต๋๋ค. /deep-work๋ก ์ ์ธ์
์ ์์ํ์ธ์."
Step 2: Fork ๋์ ๊ฒ์ฆ
๋์ ์ธ์
์ ์ํ ํ์ผ($PROJECT_ROOT/.claude/deep-work.{SESSION_ID}.md)์ ์ฝ๋๋ค.
๊ฒ์ฆ ํญ๋ชฉ:
- ์ํ ํ์ผ์ด ์กด์ฌํ๋์ง
current_phase๊ฐ idle์ด ์๋์ง (idle์ด๋ฉด: "์๋ฃ๋ ์ธ์
์ forkํ ์ ์์ต๋๋ค.")
fork_generation์ด 3 ๋ฏธ๋ง์ธ์ง (3 ์ด์์ด๋ฉด: "์ด๋ฏธ 3์ธ๋ fork์
๋๋ค. ๋ณต์ก๋๊ฐ ๋์์ง ์ ์์ต๋๋ค. ๊ณ์ํ์๊ฒ ์ต๋๊น?" โ AskUserQuestion์ผ๋ก ํ์ธ)
Stale ๋ถ๋ชจ ์ธ์
๊ฒ์ฆ:
Git ํ๊ฒฝ:
PARENT_COMMIT=$(read_frontmatter_field "$PARENT_STATE" "worktree_base_commit")
if [[ -n "$PARENT_COMMIT" ]] && ! git cat-file -e "$PARENT_COMMIT" 2>/dev/null; then
echo "๋ถ๋ชจ ์ธ์
์ ๊ธฐ์ค commit์ด ๋ ์ด์ ์กด์ฌํ์ง ์์ต๋๋ค. forkํ ์ ์์ต๋๋ค."
exit 1
fi
Non-git ํ๊ฒฝ:
PARENT_WORK_DIR=$(read_frontmatter_field "$PARENT_STATE" "work_dir")
if [[ ! -d "$PROJECT_ROOT/$PARENT_WORK_DIR" ]]; then
echo "๋ถ๋ชจ ์ธ์
์ ์ฐ์ถ๋ฌผ์ด ์ญ์ ๋์์ต๋๋ค. forkํ ์ ์์ต๋๋ค."
exit 1
fi
Step 3: ์ฌ์์ Phase ๊ฒฐ์
--from-phase๊ฐ ์ง์ ๋์ง ์์์ผ๋ฉด AskUserQuestion์ผ๋ก ์ ํ:
ํ์ฌ phase ์ดํ์ phase๋ง ์ ํ ๊ฐ๋ฅํ๋ค. Phase ์์: brainstorm < research < plan < implement.
์์ (๋ถ๋ชจ๊ฐ implement์ธ ๊ฒฝ์ฐ):
์ด๋ค phase๋ถํฐ ๋ค์ ์์ํ์๊ฒ ์ต๋๊น?
1. brainstorm โ ์ฒ์๋ถํฐ ๋ค์ ๊ตฌ์
2. research โ ๋ฆฌ์์น๋ถํฐ ๋ค์
3. plan โ ์๋ก์ด ๊ณํ ์๋ฆฝ
4. implement โ ๊ตฌํ๋ถํฐ (ํ์ฌ phase)
Step 4: ํ๊ฒฝ ๊ฐ์ง ๋ฐ Fork ์คํ
Git ํ๊ฒฝ ๊ฐ์ง
IS_GIT=$(git rev-parse --git-dir 2>/dev/null && echo "true" || echo "false")
Case A: Git ํ๊ฒฝ (worktree ๊ธฐ๋ฐ ์ ์ฒด ๋ณต์ )
A-1. Dirty ์ํ ๊ฒ์ฆ:
DIRTY_STATUS=$(git status --porcelain 2>/dev/null)
dirty๊ฐ ์๋๋ฉด ๋ฐ๋ก ์งํ. dirty์ด๋ฉด AskUserQuestion:
- "์ปค๋ฐ ํ fork" โ
git add -A && git commit -m "deep-work: pre-fork snapshot"
- "ํ์ฌ ์ํ๋ก fork" โ
git stash push --include-untracked -m "deep-work: fork ${NEW_SESSION_ID}"๋ก ์บก์ฒ. Worktree ์์ฑ ํ ์ worktree์์ git stash pop์ผ๋ก ์ ์ฉ. fork-snapshot.yaml์ parent_dirty: true, dirty_resolution: stash-apply ๊ธฐ๋ก. stash pop ์คํจ ์ fork๋ฅผ ์ฐจ๋จํ๊ณ ์๋ฌ ๋ฉ์์ง ์ถ๋ ฅ.
- "์ทจ์" โ fork ์ค๋จ
A-2. ์ session ID ์์ฑ:
source "$HOOKS_DIR/utils.sh"
NEW_SESSION_ID=$(generate_session_id)
A-3. Branch/Worktree ์ด๋ฆ ๊ฒฐ์ :
Session ID ๊ธฐ๋ฐ suffix๋ฅผ ์ฌ์ฉํ์ฌ ์ถฉ๋์ ์์ฒ ์ฐจ๋จํ๋ค (์นด์ดํฐ ๊ธฐ๋ฐ race condition ์ ๊ฑฐ):
PARENT_BRANCH=$(read_frontmatter_field "$PARENT_STATE" "git_branch")
CURRENT_COMMIT=$(git rev-parse HEAD)
FORK_SUFFIX=$(echo "$NEW_SESSION_ID" | sed 's/^s-//')
WORKTREE_PATH="$(dirname "$PROJECT_ROOT")/$(basename "$PROJECT_ROOT")-wt-fork-${FORK_SUFFIX}"
FORK_BRANCH="${PARENT_BRANCH}-fork-${FORK_SUFFIX}"
git worktree add "$WORKTREE_PATH" -b "$FORK_BRANCH" "$CURRENT_COMMIT"
A-3.5. Worktree ์ปจํ
์คํธ ์ ํ (์ค์):
์ดํ ๋ชจ๋ ์์
(์ฐ์ถ๋ฌผ ๋ณต์ฌ, ์ํ ํ์ผ ์์ฑ, auto-flow)์ ์ worktree ์์์ ์คํํด์ผ ํ๋ค. ๊ธฐ์กด /deep-work์ worktree ๊ณ์ฝ๊ณผ ๋์ผํ๊ฒ, FORK_PROJECT_ROOT๋ฅผ ๊ธฐ์ค์ผ๋ก ์์
ํ๋ค:
FORK_PROJECT_ROOT="$WORKTREE_PATH"
A-4. ์ฐ์ถ๋ฌผ ๋ณต์ฌ:
๋ถ๋ชจ์ work_dir์์ fork worktree ๋ด ์ ์์
๋๋ ํ ๋ฆฌ๋ก ๋ณต์ฌ:
PARENT_WORK_DIR=$(read_frontmatter_field "$PARENT_STATE" "work_dir")
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
TASK_SLUG=$(echo "$TASK_DESC" | tr ' ' '-' | tr '[:upper:]' '[:lower:]' | head -c 30)
NEW_WORK_DIR=".deep-work/${TIMESTAMP}-${TASK_SLUG}-fork-${FORK_SUFFIX}"
mkdir -p "$FORK_PROJECT_ROOT/$NEW_WORK_DIR"
cp -r "$PROJECT_ROOT/$PARENT_WORK_DIR/"* "$FORK_PROJECT_ROOT/$NEW_WORK_DIR/" 2>/dev/null || true
A-5. ์ฌ์์ phase ์ดํ ์ฐ์ถ๋ฌผ ์ ๊ฑฐ:
Phase ์์์ ๋ฐ๋ผ ์ดํ ์ฐ์ถ๋ฌผ์ ์ญ์ :
- brainstorm ์ดํ: research.md, plan.md, receipts/, test-results.md, file-changes.log ์ญ์
- research ์ดํ: plan.md, receipts/, test-results.md, file-changes.log ์ญ์
- plan ์ดํ: receipts/, test-results.md, file-changes.log ์ญ์
- implement: ์ญ์ ์์ (ํ์ฌ phase ๊ทธ๋๋ก)
Case B: Non-git ํ๊ฒฝ (์ฐ์ถ๋ฌผ๋ง ๋ณต์ )
B-1. ์ session ID ๋ฐ ์์
๋๋ ํ ๋ฆฌ ์์ฑ (๋์ผ)
B-2. ์ฐ์ถ๋ฌผ๋ง ๋ณต์ฌ:
for f in brainstorm.md research.md plan.md; do
[[ -f "$PROJECT_ROOT/$PARENT_WORK_DIR/$f" ]] && cp "$PROJECT_ROOT/$PARENT_WORK_DIR/$f" "$PROJECT_ROOT/$NEW_WORK_DIR/"
done
[[ -d "$PROJECT_ROOT/$PARENT_WORK_DIR/receipts" ]] && cp -r "$PROJECT_ROOT/$PARENT_WORK_DIR/receipts" "$PROJECT_ROOT/$NEW_WORK_DIR/"
B-3. ์ฌ์์ phase ์ดํ ์ฐ์ถ๋ฌผ ์ ๊ฑฐ (๋์ผ)
B-4. Phase ์ํ ํ์ธ:
artifacts-only fork์์ FROM_PHASE๊ฐ implement ๋๋ test์ด๋ฉด ์๋ฌ:
"Non-git fork๋ plan๊น์ง๋ง ์งํ ๊ฐ๋ฅํฉ๋๋ค. ๊ตฌํ์ ์งํํ๋ ค๋ฉด git ํ๊ฒฝ์์ /deep-fork๋ฅผ ์ฌ์ฉํ์ธ์."
Step 5: Fork Snapshot ์์ฑ
์ ์์
๋๋ ํ ๋ฆฌ์ fork-snapshot.yaml ์์ฑ:
forked_at: "{ISO_TIMESTAMP}"
parent_session: "{PARENT_SESSION_ID}"
parent_phase_at_fork: "{PARENT_CURRENT_PHASE}"
restart_phase: "{FROM_PHASE}"
parent_work_dir: "{PARENT_WORK_DIR}"
fork_mode: "worktree"
parent_commit: "{CURRENT_COMMIT}"
parent_dirty: false
dirty_resolution: null
artifacts_copied:
- brainstorm.md
- research.md
- plan.md
artifacts_removed:
- receipts/
Step 6: ์ํ ํ์ผ ์์ฑ
์ ์ธ์
์ ์ํ ํ์ผ์ ์์ฑํ๋ค. Git ํ๊ฒฝ์์๋ $FORK_PROJECT_ROOT/.claude/deep-work.{NEW_SESSION_ID}.md, Non-git์์๋ $PROJECT_ROOT/.claude/deep-work.{NEW_SESSION_ID}.md์ ์์ฑํ๋ค.
๋ถ๋ชจ ์ํ ํ์ผ์์ YAML frontmatter๋ฅผ ๋ณต์ ํ๋:
Step 7: ๋ ์ง์คํธ๋ฆฌ ๋ฑ๋ก ๋ฐ ๋ถ๋ชจ ์
๋ฐ์ดํธ
register_fork_session "$NEW_SESSION_ID" "$PARENT_SESSION_ID" "$FORK_GENERATION" "$TASK_DESC" "$NEW_WORK_DIR" "$FROM_PHASE"
write_session_pointer "$NEW_SESSION_ID"
Step 8: ๊ฒฐ๊ณผ ์ถ๋ ฅ ๋ฐ Auto-flow ์์
๊ฒฐ๊ณผ ๋ฉ์์ง ์ถ๋ ฅ:
๐ Session forked successfully
Parent: {PARENT_SESSION_ID} ({PARENT_PHASE} phase)
Fork: {NEW_SESSION_ID} (restarting from {FROM_PHASE})
Work dir: {NEW_WORK_DIR}
Branch: {FORK_BRANCH} (worktree) โ git์ผ ๋๋ง
Mode: artifacts-only (plan๊น์ง) โ non-git์ผ ๋๋ง
Auto-flow ์์:
์ ํํ FROM_PHASE์ ํด๋นํ๋ ์ปค๋งจ๋์ ์ง์นจ์ ๋ฐ๋ผ ์๋์ผ๋ก ์งํํ๋ค:
- brainstorm โ
/deep-brainstorm ์ง์นจ ์คํ
- research โ
/deep-research ์ง์นจ ์คํ
- plan โ
/deep-plan ์ง์นจ ์คํ
- implement โ
/deep-implement ์ง์นจ ์คํ
์ด์ phase์ ์ฐ์ถ๋ฌผ์ด ์์ผ๋ฉด ํด๋น ์ฐ์ถ๋ฌผ์ ์ฝ์ด์ ์ปจํ
์คํธ๋ก ํ์ฉํ๋ค.