mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-11 02:33:51 +08:00
docs(issue): Simplify worktree instructions with auto-detection
ccw issue commands now auto-detect worktree and redirect to main repo, so shell_command no longer needs workdir parameter.
This commit is contained in:
@@ -13,7 +13,7 @@ argument-hint: "[--worktree] [--queue <queue-id>]"
|
|||||||
|
|
||||||
When `--worktree` is specified, create a separate git worktree to isolate work.
|
When `--worktree` is specified, create a separate git worktree to isolate work.
|
||||||
|
|
||||||
**⚠️ IMPORTANT**: `ccw issue` commands MUST run from the **main repo directory**, NOT inside the worktree. The `.workflow/issues/` directory only exists in the main repo.
|
**Note**: `ccw issue` commands auto-detect worktree and redirect to main repo automatically.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Step 0: Setup worktree before starting (run from MAIN REPO)
|
# Step 0: Setup worktree before starting (run from MAIN REPO)
|
||||||
@@ -43,23 +43,19 @@ cleanup_worktree() {
|
|||||||
}
|
}
|
||||||
trap cleanup_worktree EXIT INT TERM
|
trap cleanup_worktree EXIT INT TERM
|
||||||
|
|
||||||
# IMPORTANT: Fetch solution BEFORE entering worktree (ccw needs .workflow/)
|
# Change to worktree directory
|
||||||
SOLUTION_JSON=$(ccw issue next)
|
|
||||||
|
|
||||||
# NOW change to worktree directory for implementation
|
|
||||||
cd "${WORKTREE_PATH}"
|
cd "${WORKTREE_PATH}"
|
||||||
|
|
||||||
# Execute implementation in isolated worktree...
|
# ccw issue commands auto-detect worktree and use main repo's .workflow/
|
||||||
|
# So you can run ccw issue next/done directly from worktree
|
||||||
```
|
```
|
||||||
|
|
||||||
**Worktree Execution Pattern**:
|
**Worktree Execution Pattern**:
|
||||||
```
|
```
|
||||||
1. [MAIN REPO] ccw issue next → get solution JSON
|
1. [WORKTREE] ccw issue next → auto-redirects to main repo's .workflow/
|
||||||
2. [MAIN REPO] cd to worktree
|
2. [WORKTREE] Implement all tasks, run tests, git commit
|
||||||
3. [WORKTREE] Implement all tasks, run tests, git commit
|
3. [WORKTREE] ccw issue done <item_id> → auto-redirects to main repo
|
||||||
4. [WORKTREE] cd back to main repo
|
4. Repeat from step 1
|
||||||
5. [MAIN REPO] ccw issue done <item_id> → report completion
|
|
||||||
6. Repeat from step 1
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note**: Add `.ccw/worktrees/` to `.gitignore` to prevent tracking worktree contents.
|
**Note**: Add `.ccw/worktrees/` to `.gitignore` to prevent tracking worktree contents.
|
||||||
@@ -164,14 +160,11 @@ WHEN queue empty:
|
|||||||
|
|
||||||
## Step 1: Fetch First Solution
|
## Step 1: Fetch First Solution
|
||||||
|
|
||||||
Run this command to get your first solution (**must run from main repo**):
|
Run this command to get your first solution:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// Fetch solution from main repo (not worktree)
|
// ccw auto-detects worktree and uses main repo's .workflow/
|
||||||
const result = shell_command({
|
const result = shell_command({ command: "ccw issue next" })
|
||||||
command: "ccw issue next",
|
|
||||||
workdir: REPO_ROOT // Main repo path, NOT worktree
|
|
||||||
})
|
|
||||||
```
|
```
|
||||||
|
|
||||||
This returns JSON with the full solution definition:
|
This returns JSON with the full solution definition:
|
||||||
@@ -401,46 +394,35 @@ Continue to next task in `solution.tasks` array until all tasks are complete.
|
|||||||
|
|
||||||
## Step 4: Report Completion
|
## Step 4: Report Completion
|
||||||
|
|
||||||
After ALL tasks in the solution are complete, report to queue system (**must run from main repo**):
|
After ALL tasks in the solution are complete, report to queue system:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// Report completion from main repo (not worktree)
|
// ccw auto-detects worktree and uses main repo's .workflow/
|
||||||
shell_command({
|
shell_command({
|
||||||
command: `ccw issue done ${item_id} --result '${JSON.stringify({
|
command: `ccw issue done ${item_id} --result '${JSON.stringify({
|
||||||
files_modified: ["path1", "path2"],
|
files_modified: ["path1", "path2"],
|
||||||
tests_passed: true,
|
tests_passed: true,
|
||||||
acceptance_passed: true,
|
commits: [{ task_id: "T1", hash: "abc123" }],
|
||||||
committed: true,
|
|
||||||
commits: [
|
|
||||||
{ task_id: "T1", hash: "abc123" },
|
|
||||||
{ task_id: "T2", hash: "def456" }
|
|
||||||
],
|
|
||||||
summary: "[What was accomplished]"
|
summary: "[What was accomplished]"
|
||||||
})}'`,
|
})}'`
|
||||||
workdir: REPO_ROOT // Main repo path, NOT worktree
|
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
**If solution failed and cannot be fixed:**
|
**If solution failed:**
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// Report failure from main repo
|
|
||||||
shell_command({
|
shell_command({
|
||||||
command: `ccw issue done ${item_id} --fail --reason '{"task_id": "TX", "error_type": "test_failure", "message": "..."}'`,
|
command: `ccw issue done ${item_id} --fail --reason '{"task_id": "TX", "error_type": "test_failure", "message": "..."}'`
|
||||||
workdir: REPO_ROOT
|
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
## Step 5: Continue to Next Solution
|
## Step 5: Continue to Next Solution
|
||||||
|
|
||||||
Fetch next solution (**must run from main repo**):
|
Fetch next solution:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// Fetch next solution from main repo
|
// ccw auto-detects worktree
|
||||||
const result = shell_command({
|
const result = shell_command({ command: "ccw issue next" })
|
||||||
command: "ccw issue next",
|
|
||||||
workdir: REPO_ROOT
|
|
||||||
})
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**Output progress:**
|
**Output progress:**
|
||||||
@@ -489,7 +471,7 @@ When `ccw issue next` returns `{ "status": "empty" }`:
|
|||||||
7. **Report accurately** - Use `ccw issue done` after each solution
|
7. **Report accurately** - Use `ccw issue done` after each solution
|
||||||
8. **Handle failures gracefully** - If a solution fails, report via `ccw issue done --fail` and continue to next
|
8. **Handle failures gracefully** - If a solution fails, report via `ccw issue done --fail` and continue to next
|
||||||
9. **Track with update_plan** - Use update_plan tool for task progress tracking
|
9. **Track with update_plan** - Use update_plan tool for task progress tracking
|
||||||
10. **Worktree ccw commands** - Run `ccw issue next/done` from main repo, NOT worktree
|
10. **Worktree auto-detect** - `ccw issue` commands auto-redirect to main repo from worktree
|
||||||
|
|
||||||
## Error Handling
|
## Error Handling
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user