claude-multi-session 1.0.0

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/STRATEGY.md ADDED
@@ -0,0 +1,179 @@
1
+ # Multi-Session Strategy Guide
2
+
3
+ This guide teaches Claude Code WHEN and HOW to use the multi-session tools effectively.
4
+ Place this content in your project's `CLAUDE.md` or reference it as a system prompt.
5
+
6
+ ---
7
+
8
+ ## When to Use Multi-Session
9
+
10
+ ### DO delegate when:
11
+ - **Task has 3+ independent parts** — build login, signup, and reset in parallel
12
+ - **Task is too large for one context** — full feature implementation with tests
13
+ - **You need different models for different subtasks** — haiku for simple lookups, opus for architecture
14
+ - **You want to try multiple approaches** — fork and compare
15
+ - **Task involves risky operations** — delegate with safety limits instead of doing it directly
16
+
17
+ ### DON'T delegate when:
18
+ - **Task is small** — a few lines of code, a quick fix
19
+ - **Task needs tight coordination** — changes that must happen atomically across files
20
+ - **You're just reading/exploring** — use Read, Grep, Glob directly
21
+
22
+ ---
23
+
24
+ ## Decision Framework
25
+
26
+ ```
27
+ Is the task simple (< 5 minutes, < 3 files)?
28
+ → YES: Do it yourself. No delegation needed.
29
+ → NO: Continue...
30
+
31
+ Can the task be split into independent parts?
32
+ → YES: Delegate each part in parallel.
33
+ → NO: Delegate as one task, use continue_task for corrections.
34
+
35
+ Does the task need special safety limits?
36
+ → YES: Use delegate_task with max_cost and max_turns.
37
+ → NO: Use spawn_session + send_message for direct control.
38
+ ```
39
+
40
+ ---
41
+
42
+ ## Task Decomposition
43
+
44
+ When breaking a large task into subtasks:
45
+
46
+ 1. **Identify independent pieces** — parts that don't depend on each other
47
+ 2. **Identify dependencies** — part B needs part A's output
48
+ 3. **Assign models** — haiku for simple, sonnet for standard, opus for complex
49
+ 4. **Set budgets** — split total budget proportionally
50
+
51
+ **Example: "Build the authentication system"**
52
+ ```
53
+ Independent (run in parallel):
54
+ - child-1 (sonnet): "Build login endpoint with JWT"
55
+ - child-2 (sonnet): "Build signup endpoint with validation"
56
+ - child-3 (sonnet): "Build password reset with email tokens"
57
+
58
+ Dependent (run after all above complete):
59
+ - child-4 (sonnet): "Write integration tests for auth system"
60
+ ```
61
+
62
+ ---
63
+
64
+ ## Model Selection Guide
65
+
66
+ | Task Type | Model | Why |
67
+ |-----------|-------|-----|
68
+ | Simple lookups, counting, listing | haiku | Fast and cheap |
69
+ | Standard code edits, bug fixes | sonnet | Good balance |
70
+ | Architecture decisions, complex refactoring | opus | Best reasoning |
71
+ | Code review, analysis | sonnet | Good enough |
72
+ | Writing tests | sonnet | Reliable |
73
+
74
+ ---
75
+
76
+ ## Budget Allocation
77
+
78
+ When delegating a complex task with a total budget:
79
+
80
+ | Allocation | Percentage | Purpose |
81
+ |------------|-----------|---------|
82
+ | Main work | 60% | The core implementation |
83
+ | Tests | 20% | Writing and running tests |
84
+ | Reserve | 20% | Corrections, follow-ups, retries |
85
+
86
+ **Example:** $5 total budget for 3 parallel tasks
87
+ - Each task gets $1.00 (60% = $3.00 total)
88
+ - Tests task gets $1.00 (20%)
89
+ - Reserve $1.00 for corrections (20%)
90
+
91
+ ---
92
+
93
+ ## The Correction Loop
94
+
95
+ After EVERY delegation, evaluate the result:
96
+
97
+ ```
98
+ 1. delegate_task → get result
99
+ 2. Read result.status:
100
+ - "completed" → Read result.response, evaluate quality
101
+ - "failed" → Read result.error, decide: retry or different approach
102
+ - "cost_exceeded" → Budget was too low. Increase or reduce scope.
103
+ - "turns_exceeded" → Task too complex. Break it down further.
104
+ 3. Is the result good?
105
+ - YES → finish_task
106
+ - NO → continue_task with specific corrections
107
+ - HOPELESS → abort_task, try a different approach
108
+ ```
109
+
110
+ ### Writing Good Corrections
111
+
112
+ **Bad correction:** "Fix it"
113
+ **Good correction:** "The login function is missing password hashing. Add bcrypt hashing before saving to database. Use 12 salt rounds."
114
+
115
+ Be specific about:
116
+ - WHAT is wrong
117
+ - WHERE in the code
118
+ - HOW to fix it
119
+
120
+ ---
121
+
122
+ ## Parallel Coordination
123
+
124
+ When running multiple child sessions that work on related code:
125
+
126
+ 1. **Spawn all independent tasks** in parallel
127
+ 2. **Wait for all results**
128
+ 3. **Evaluate each result** independently
129
+ 4. **Send corrections** to any that need fixing (in parallel)
130
+ 5. **If task B needs output from task A**, read A's result and include relevant details in B's context
131
+
132
+ **Example:**
133
+ ```
134
+ # Step 1: Parallel delegation
135
+ delegate_task(name="auth-api", task="Build auth endpoints")
136
+ delegate_task(name="auth-ui", task="Build login screen")
137
+
138
+ # Step 2: Read results
139
+ # auth-api completed: "Created /api/login and /api/register"
140
+ # auth-ui completed but used wrong endpoint path
141
+
142
+ # Step 3: Correct auth-ui with info from auth-api
143
+ continue_task(name="auth-ui", message="The API endpoint is /api/login not /login. Update the fetch URL.")
144
+ ```
145
+
146
+ ---
147
+
148
+ ## Session Recovery
149
+
150
+ If a conversation ends and you start a new one:
151
+
152
+ 1. **Always check for existing sessions first:** `list_sessions`
153
+ 2. **Resume important sessions:** `resume_session`
154
+ 3. **Clean up finished work:** `delete_session` for completed tasks
155
+ 4. **Sessions persist across conversations** — the data is saved to disk
156
+
157
+ ---
158
+
159
+ ## Safety Presets Quick Reference
160
+
161
+ | Preset | Use When |
162
+ |--------|----------|
163
+ | `read-only` | Analyzing code, gathering information, code review |
164
+ | `review` | Same as read-only |
165
+ | `edit` | Normal development work (DEFAULT — use this most of the time) |
166
+ | `full` | Trusted tasks that need unrestricted access (use sparingly) |
167
+ | `plan` | Exploring architecture, planning (no file modifications) |
168
+
169
+ ---
170
+
171
+ ## Anti-Patterns (What NOT to do)
172
+
173
+ 1. **Don't delegate trivial tasks** — overhead of spawning a session isn't worth it for simple fixes
174
+ 2. **Don't use `full` preset by default** — use `edit` and escalate only if needed
175
+ 3. **Don't ignore failed results** — always check status and handle errors
176
+ 4. **Don't set budgets too low** — a realistic task needs $0.50-2.00, complex tasks need more
177
+ 5. **Don't send vague corrections** — be specific about what's wrong and how to fix it
178
+ 6. **Don't forget to finish_task** — stopped sessions consume stored data
179
+ 7. **Don't coordinate file edits across parallel sessions on the same file** — they'll conflict