clawpowers 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/.claude-plugin/manifest.json +19 -0
- package/.codex/INSTALL.md +36 -0
- package/.cursor-plugin/manifest.json +21 -0
- package/.opencode/INSTALL.md +52 -0
- package/ARCHITECTURE.md +69 -0
- package/README.md +381 -0
- package/bin/clawpowers.js +390 -0
- package/bin/clawpowers.sh +91 -0
- package/gemini-extension.json +32 -0
- package/hooks/session-start +205 -0
- package/hooks/session-start.cmd +43 -0
- package/hooks/session-start.js +163 -0
- package/package.json +54 -0
- package/runtime/feedback/analyze.js +621 -0
- package/runtime/feedback/analyze.sh +546 -0
- package/runtime/init.js +172 -0
- package/runtime/init.sh +145 -0
- package/runtime/metrics/collector.js +361 -0
- package/runtime/metrics/collector.sh +308 -0
- package/runtime/persistence/store.js +433 -0
- package/runtime/persistence/store.sh +303 -0
- package/skill.json +74 -0
- package/skills/agent-payments/SKILL.md +411 -0
- package/skills/brainstorming/SKILL.md +233 -0
- package/skills/content-pipeline/SKILL.md +282 -0
- package/skills/dispatching-parallel-agents/SKILL.md +305 -0
- package/skills/executing-plans/SKILL.md +255 -0
- package/skills/finishing-a-development-branch/SKILL.md +260 -0
- package/skills/learn-how-to-learn/SKILL.md +235 -0
- package/skills/market-intelligence/SKILL.md +288 -0
- package/skills/prospecting/SKILL.md +313 -0
- package/skills/receiving-code-review/SKILL.md +225 -0
- package/skills/requesting-code-review/SKILL.md +206 -0
- package/skills/security-audit/SKILL.md +308 -0
- package/skills/subagent-driven-development/SKILL.md +244 -0
- package/skills/systematic-debugging/SKILL.md +279 -0
- package/skills/test-driven-development/SKILL.md +299 -0
- package/skills/using-clawpowers/SKILL.md +137 -0
- package/skills/using-git-worktrees/SKILL.md +261 -0
- package/skills/verification-before-completion/SKILL.md +254 -0
- package/skills/writing-plans/SKILL.md +276 -0
- package/skills/writing-skills/SKILL.md +260 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: test-driven-development
|
|
3
|
+
description: Enforce RED-GREEN-REFACTOR with mandatory failure witness. Activate whenever writing new code, implementing a feature, or fixing a bug with a reproducible test case.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
requires:
|
|
6
|
+
tools: [bash]
|
|
7
|
+
runtime: false
|
|
8
|
+
metrics:
|
|
9
|
+
tracks: [red_witnessed, green_achieved, refactor_cycles, mutation_score, test_effectiveness]
|
|
10
|
+
improves: [test_granularity, refactor_threshold, mutation_analysis_frequency]
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Test-Driven Development
|
|
14
|
+
|
|
15
|
+
## When to Use
|
|
16
|
+
|
|
17
|
+
Apply this skill when:
|
|
18
|
+
|
|
19
|
+
- Implementing any new feature or function
|
|
20
|
+
- Fixing a bug that has a reproducible failure condition
|
|
21
|
+
- Refactoring code where behavior must be preserved
|
|
22
|
+
- Building an API endpoint, utility function, or module
|
|
23
|
+
- Implementing a specification with defined inputs and outputs
|
|
24
|
+
|
|
25
|
+
**Skip when:**
|
|
26
|
+
- Exploratory prototyping where the interface isn't known yet (write the prototype, then TDD the real implementation)
|
|
27
|
+
- One-off scripts with no production path
|
|
28
|
+
- Pure configuration changes (infrastructure, env vars, YAML)
|
|
29
|
+
|
|
30
|
+
**Decision tree:**
|
|
31
|
+
```
|
|
32
|
+
Do you know what correct behavior looks like?
|
|
33
|
+
├── No → Explore/prototype first, then TDD the real version
|
|
34
|
+
└── Yes → Do you have a reproducible failure condition?
|
|
35
|
+
├── Yes (bug fix) → TDD from the failing test
|
|
36
|
+
└── No (new feature) → TDD from the spec → RED-GREEN-REFACTOR
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Core Methodology
|
|
40
|
+
|
|
41
|
+
### The Laws of TDD
|
|
42
|
+
|
|
43
|
+
1. You may not write production code unless it is to make a failing test pass.
|
|
44
|
+
2. You may not write more of a unit test than is sufficient to fail (compilation failures count as failures).
|
|
45
|
+
3. You may not write more production code than is sufficient to pass the currently failing test.
|
|
46
|
+
|
|
47
|
+
These are not suggestions. Violations produce code that is tested after the fact — which is not TDD.
|
|
48
|
+
|
|
49
|
+
### The RED Phase
|
|
50
|
+
|
|
51
|
+
**Objective:** Write a test that fails for the right reason.
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
Step 1: Write the test before any production code exists
|
|
55
|
+
Step 2: Run the test suite
|
|
56
|
+
Step 3: WITNESS the failure — read the actual error message
|
|
57
|
+
Step 4: Confirm the failure is the expected one (not a compile error, not a wrong import)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Failure witness requirement:** You must see the test runner output showing failure. Copy-pasting the expected error is not sufficient — run it.
|
|
61
|
+
|
|
62
|
+
**Example (Python):**
|
|
63
|
+
```python
|
|
64
|
+
# test_auth.py — write this FIRST
|
|
65
|
+
def test_jwt_issue_returns_token_with_expiry():
|
|
66
|
+
auth = AuthService(secret="test-secret")
|
|
67
|
+
result = auth.issue(user_id="u123", ttl_seconds=3600)
|
|
68
|
+
|
|
69
|
+
assert result["token"] is not None
|
|
70
|
+
assert result["expires_at"] > time.time()
|
|
71
|
+
assert result["user_id"] == "u123"
|
|
72
|
+
|
|
73
|
+
# Run and witness:
|
|
74
|
+
# pytest test_auth.py::test_jwt_issue_returns_token_with_expiry
|
|
75
|
+
# FAILED: ImportError: cannot import name 'AuthService' from 'auth'
|
|
76
|
+
# ← This is the expected RED failure. Correct.
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**What a bad RED looks like:**
|
|
80
|
+
```
|
|
81
|
+
# WRONG: Writing AuthService first, then the test
|
|
82
|
+
# WRONG: Test passes on first run (you tested nothing)
|
|
83
|
+
# WRONG: Test fails with wrong error (syntax error in test, not missing implementation)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### The GREEN Phase
|
|
87
|
+
|
|
88
|
+
**Objective:** Write the minimum production code to make the test pass.
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
Step 1: Write only what the test requires — nothing more
|
|
92
|
+
Step 2: No edge case handling beyond what the test covers
|
|
93
|
+
Step 3: Run the test suite
|
|
94
|
+
Step 4: WITNESS the green — all targeted tests pass
|
|
95
|
+
Step 5: If other tests broke, fix them (don't disable them)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Minimum code principle:** If the test only checks that `add(2, 3)` returns `5`, write `return 5` if that makes it green. The next test will force generalization.
|
|
99
|
+
|
|
100
|
+
**Example:**
|
|
101
|
+
```python
|
|
102
|
+
# auth.py — write this AFTER the test fails
|
|
103
|
+
import jwt
|
|
104
|
+
import time
|
|
105
|
+
|
|
106
|
+
class AuthService:
|
|
107
|
+
def __init__(self, secret: str):
|
|
108
|
+
self.secret = secret
|
|
109
|
+
|
|
110
|
+
def issue(self, user_id: str, ttl_seconds: int) -> dict:
|
|
111
|
+
now = time.time()
|
|
112
|
+
payload = {"sub": user_id, "iat": now, "exp": now + ttl_seconds}
|
|
113
|
+
token = jwt.encode(payload, self.secret, algorithm="HS256")
|
|
114
|
+
return {"token": token, "expires_at": now + ttl_seconds, "user_id": user_id}
|
|
115
|
+
|
|
116
|
+
# Run and witness:
|
|
117
|
+
# pytest test_auth.py::test_jwt_issue_returns_token_with_expiry
|
|
118
|
+
# PASSED
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### The REFACTOR Phase
|
|
122
|
+
|
|
123
|
+
**Objective:** Improve code structure without changing behavior.
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
Step 1: All tests must be green BEFORE refactoring begins
|
|
127
|
+
Step 2: Identify: duplication, poor naming, complex conditionals, missing abstractions
|
|
128
|
+
Step 3: Refactor ONE thing at a time
|
|
129
|
+
Step 4: Run full test suite after each change
|
|
130
|
+
Step 5: If tests break, revert immediately (don't debug during refactor)
|
|
131
|
+
Step 6: Refactor test code too — tests are first-class code
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**What belongs in REFACTOR:**
|
|
135
|
+
- Extract repeated logic into helper functions
|
|
136
|
+
- Rename variables/functions for clarity
|
|
137
|
+
- Simplify nested conditionals
|
|
138
|
+
- Add type annotations
|
|
139
|
+
- Break long functions into smaller ones
|
|
140
|
+
- Move related code into a class
|
|
141
|
+
|
|
142
|
+
**What does NOT belong in REFACTOR:**
|
|
143
|
+
- New functionality (that's the next RED phase)
|
|
144
|
+
- Performance optimization (benchmark first, optimize second)
|
|
145
|
+
- Changing behavior "while you're in there"
|
|
146
|
+
|
|
147
|
+
### The Cycle
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
RED (5-15 min) → GREEN (5-30 min) → REFACTOR (5-20 min) → RED...
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Each cycle covers ONE behavior. Not a feature — one behavior of a feature.
|
|
154
|
+
|
|
155
|
+
For `AuthService`, the full TDD cycle would be:
|
|
156
|
+
1. RED/GREEN/REFACTOR: `issue()` returns token
|
|
157
|
+
2. RED/GREEN/REFACTOR: `issue()` handles invalid user_id
|
|
158
|
+
3. RED/GREEN/REFACTOR: `validate()` returns valid for good token
|
|
159
|
+
4. RED/GREEN/REFACTOR: `validate()` returns invalid for expired token
|
|
160
|
+
5. RED/GREEN/REFACTOR: `validate()` returns invalid for tampered token
|
|
161
|
+
6. RED/GREEN/REFACTOR: `issue()` and `validate()` work end-to-end
|
|
162
|
+
|
|
163
|
+
### Test Naming Convention
|
|
164
|
+
|
|
165
|
+
Tests are documentation. Name them:
|
|
166
|
+
```
|
|
167
|
+
test_[unit]_[action]_[expected_result]
|
|
168
|
+
test_jwt_issue_with_negative_ttl_raises_value_error()
|
|
169
|
+
test_jwt_validate_expired_token_returns_invalid_with_reason()
|
|
170
|
+
test_jwt_validate_tampered_token_returns_invalid_with_reason()
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Not:
|
|
174
|
+
```
|
|
175
|
+
test_1()
|
|
176
|
+
test_auth()
|
|
177
|
+
test_jwt_token_stuff()
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Testing Layers
|
|
181
|
+
|
|
182
|
+
| Layer | What It Tests | Tool |
|
|
183
|
+
|-------|-------------|------|
|
|
184
|
+
| Unit | Single function, isolated | pytest, jest, go test |
|
|
185
|
+
| Integration | Multiple units together | pytest with real DB |
|
|
186
|
+
| Contract | API interface compliance | pact, dredd |
|
|
187
|
+
| E2E | Full system path | playwright, cypress |
|
|
188
|
+
|
|
189
|
+
TDD applies at all layers. Start with unit. Add integration when units pass.
|
|
190
|
+
|
|
191
|
+
## ClawPowers Enhancement
|
|
192
|
+
|
|
193
|
+
When `~/.clawpowers/` runtime is initialized:
|
|
194
|
+
|
|
195
|
+
**Mutation Analysis Integration:**
|
|
196
|
+
|
|
197
|
+
After the GREEN phase, optionally run mutation analysis to verify your tests actually catch bugs — not just pass on correct code:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
# Python: mutmut
|
|
201
|
+
pip install mutmut
|
|
202
|
+
mutmut run --paths-to-mutate src/auth.py --tests-dir tests/
|
|
203
|
+
|
|
204
|
+
# JavaScript: Stryker
|
|
205
|
+
npx stryker run
|
|
206
|
+
|
|
207
|
+
# Go: go-mutesting
|
|
208
|
+
go-mutesting ./...
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Mutation score target: ≥ 80%. Below 70% means your tests would miss real bugs.
|
|
212
|
+
|
|
213
|
+
**Test Portfolio Lifecycle Tracking:**
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
bash runtime/metrics/collector.sh record \
|
|
217
|
+
--skill test-driven-development \
|
|
218
|
+
--outcome success \
|
|
219
|
+
--notes "AuthService: 6 behaviors, mutation score 87%, 0 stubs"
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
**Effectiveness Scoring:**
|
|
223
|
+
|
|
224
|
+
`runtime/feedback/analyze.sh` computes per-feature test effectiveness based on:
|
|
225
|
+
- Mutation score
|
|
226
|
+
- Number of RED phases witnessed (vs skipped)
|
|
227
|
+
- Time from RED to GREEN (indicates test complexity)
|
|
228
|
+
- Defect rate post-merge (bugs found in production = test misses)
|
|
229
|
+
|
|
230
|
+
Skills with declining effectiveness scores trigger recommendations:
|
|
231
|
+
- If mutation score < 70%: add boundary and error case tests
|
|
232
|
+
- If RED skipped: review test authoring process
|
|
233
|
+
- If GREEN > 60 min: tests are too coarse, decompose
|
|
234
|
+
|
|
235
|
+
## Anti-Patterns
|
|
236
|
+
|
|
237
|
+
| Anti-Pattern | Why It Fails | Correct Approach |
|
|
238
|
+
|-------------|-------------|-----------------|
|
|
239
|
+
| Write tests after code | Tests are biased toward existing implementation | Tests must be written first — that's the definition |
|
|
240
|
+
| Skip the failure witness | Tests may pass vacuously (wrong assertion, wrong import) | Run the suite, read the failure message |
|
|
241
|
+
| Test implementation details | Tests break on refactor | Test behavior/interface, not internal state |
|
|
242
|
+
| One giant test | Hard to diagnose failures | One test per behavior |
|
|
243
|
+
| Mocking everything | Tests pass but real system fails | Mock only at true system boundaries (network, DB, time) |
|
|
244
|
+
| Skip REFACTOR | Technical debt accumulates | REFACTOR is mandatory, not optional |
|
|
245
|
+
| Write all tests upfront | Spec changes invalidate all tests | Write tests incrementally, one behavior at a time |
|
|
246
|
+
| Disable failing tests | Silences real bugs | Fix the code, never disable the test |
|
|
247
|
+
|
|
248
|
+
## Examples
|
|
249
|
+
|
|
250
|
+
### Example 1: Pure Function (simplest case)
|
|
251
|
+
|
|
252
|
+
```python
|
|
253
|
+
# RED
|
|
254
|
+
def test_celsius_to_fahrenheit_converts_correctly():
|
|
255
|
+
assert convert_temp(0, "celsius", "fahrenheit") == 32.0
|
|
256
|
+
assert convert_temp(100, "celsius", "fahrenheit") == 212.0
|
|
257
|
+
|
|
258
|
+
# GREEN
|
|
259
|
+
def convert_temp(value, from_unit, to_unit):
|
|
260
|
+
if from_unit == "celsius" and to_unit == "fahrenheit":
|
|
261
|
+
return value * 9/5 + 32
|
|
262
|
+
raise ValueError(f"Unsupported conversion: {from_unit} → {to_unit}")
|
|
263
|
+
|
|
264
|
+
# REFACTOR → add UNIT_CONVERTERS dict, extract conversion logic
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Example 2: Side-effecting Code
|
|
268
|
+
|
|
269
|
+
```python
|
|
270
|
+
# RED — test the effect, not the implementation
|
|
271
|
+
def test_user_created_event_emitted_on_signup(event_bus):
|
|
272
|
+
service = UserService(db=FakeDB(), events=event_bus)
|
|
273
|
+
service.signup(email="a@b.com", password="secure123")
|
|
274
|
+
|
|
275
|
+
assert event_bus.has_event("user.created")
|
|
276
|
+
assert event_bus.last_event("user.created")["email"] == "a@b.com"
|
|
277
|
+
|
|
278
|
+
# Note: FakeDB is a test double for the DB boundary
|
|
279
|
+
# event_bus is a test double for the event system boundary
|
|
280
|
+
# The UserService logic itself is real — no mocking of it
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Example 3: Bug Fix
|
|
284
|
+
|
|
285
|
+
```python
|
|
286
|
+
# Reproduce the bug first
|
|
287
|
+
def test_cart_total_with_discount_code_not_negative():
|
|
288
|
+
cart = Cart()
|
|
289
|
+
cart.add_item(price=10.00, qty=1)
|
|
290
|
+
cart.apply_discount(code="HALF_OFF")
|
|
291
|
+
cart.apply_discount(code="HALF_OFF") # applying twice — the bug
|
|
292
|
+
|
|
293
|
+
assert cart.total() >= 0.0 # was returning -5.00
|
|
294
|
+
|
|
295
|
+
# Run → FAIL (reproduces the bug)
|
|
296
|
+
# Fix the bug
|
|
297
|
+
# Run → PASS
|
|
298
|
+
# Now the bug is regression-protected
|
|
299
|
+
```
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: using-clawpowers
|
|
3
|
+
description: Meta-skill explaining ClawPowers, available skills, and how to trigger them. Auto-injected at session start.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
requires:
|
|
6
|
+
tools: []
|
|
7
|
+
runtime: false
|
|
8
|
+
metrics:
|
|
9
|
+
tracks: [session_starts, skill_activations, platform]
|
|
10
|
+
improves: [onboarding_clarity, trigger_accuracy]
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# ClawPowers — Skills Framework
|
|
14
|
+
|
|
15
|
+
## When to Use
|
|
16
|
+
|
|
17
|
+
This skill activates automatically at session start. You never invoke it manually.
|
|
18
|
+
|
|
19
|
+
- **Session start:** Injected by the session hook to provide skill discovery
|
|
20
|
+
- **New user onboarding:** Reference this document when unsure which skill applies
|
|
21
|
+
- **Skill lookup:** Check the trigger map below to find the right skill for your task
|
|
22
|
+
|
|
23
|
+
## Core Methodology
|
|
24
|
+
|
|
25
|
+
ClawPowers follows a three-layer approach:
|
|
26
|
+
|
|
27
|
+
1. **Pattern Recognition** — Match your current task to a skill via the trigger map
|
|
28
|
+
2. **Skill Application** — Read the matched skill's SKILL.md and follow its methodology
|
|
29
|
+
3. **Outcome Tracking** — If runtime is available, record execution outcomes for self-improvement
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
You have ClawPowers loaded. This gives you 20 skills that go beyond static instructions — they execute tools, persist state across sessions, and track outcomes for self-improvement.
|
|
33
|
+
|
|
34
|
+
## How Skills Work
|
|
35
|
+
|
|
36
|
+
Skills activate automatically when you recognize a matching task pattern. You don't announce them. You just apply them.
|
|
37
|
+
|
|
38
|
+
**Pattern → Skill mapping:**
|
|
39
|
+
|
|
40
|
+
| When you encounter... | Apply this skill |
|
|
41
|
+
|----------------------|-----------------|
|
|
42
|
+
| A complex task that should be broken into parallel workstreams | `subagent-driven-development` |
|
|
43
|
+
| Writing new code, any feature | `test-driven-development` |
|
|
44
|
+
| A request to plan work | `writing-plans` |
|
|
45
|
+
| Executing a plan that already exists | `executing-plans` |
|
|
46
|
+
| "What should we do about X?" or ideation needed | `brainstorming` |
|
|
47
|
+
| A bug, unexpected behavior, or error | `systematic-debugging` |
|
|
48
|
+
| About to complete, merge, or hand off work | `verification-before-completion` |
|
|
49
|
+
| Done with a feature branch, need to merge | `finishing-a-development-branch` |
|
|
50
|
+
| Need someone else to review the code | `requesting-code-review` |
|
|
51
|
+
| Received code review feedback | `receiving-code-review` |
|
|
52
|
+
| Working on multiple branches simultaneously | `using-git-worktrees` |
|
|
53
|
+
| Need to create a new skill | `writing-skills` |
|
|
54
|
+
| Multiple independent tasks that can run concurrently | `dispatching-parallel-agents` |
|
|
55
|
+
| Making a payment or calling a paid API | `agent-payments` |
|
|
56
|
+
| Checking code/containers for vulnerabilities | `security-audit` |
|
|
57
|
+
| Writing blog posts, docs, or social content | `content-pipeline` |
|
|
58
|
+
| Need to understand how to learn something effectively | `learn-how-to-learn` |
|
|
59
|
+
| Competitive research or trend analysis | `market-intelligence` |
|
|
60
|
+
| Finding leads or prospects | `prospecting` |
|
|
61
|
+
|
|
62
|
+
## Reading a Skill
|
|
63
|
+
|
|
64
|
+
Skills are in `skills/<skill-name>/SKILL.md`. Read them with:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# From repo root
|
|
68
|
+
cat skills/systematic-debugging/SKILL.md
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Or reference them by path in your context: `skills/systematic-debugging/SKILL.md`
|
|
72
|
+
|
|
73
|
+
## Runtime Layer
|
|
74
|
+
|
|
75
|
+
If the runtime is initialized (`~/.clawpowers/` exists), skills can:
|
|
76
|
+
|
|
77
|
+
1. **Persist state** — `runtime/persistence/store.sh get|set|list`
|
|
78
|
+
2. **Track outcomes** — `runtime/metrics/collector.sh` appends JSON lines
|
|
79
|
+
3. **Analyze performance** — `runtime/feedback/analyze.sh` computes success rates
|
|
80
|
+
|
|
81
|
+
Check if runtime is available:
|
|
82
|
+
```bash
|
|
83
|
+
[ -d ~/.clawpowers ] && echo "runtime available" || echo "static mode"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Initialize runtime:
|
|
87
|
+
```bash
|
|
88
|
+
npx clawpowers init
|
|
89
|
+
# or directly:
|
|
90
|
+
bash runtime/init.sh
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Graceful Degradation
|
|
94
|
+
|
|
95
|
+
Skills work in two modes:
|
|
96
|
+
|
|
97
|
+
- **Static mode** (no runtime): Skills provide methodology guidance. Same capability as competing frameworks.
|
|
98
|
+
- **Runtime mode** (`~/.clawpowers/` initialized): Full capability — persistence, metrics, RSI feedback, resumable workflows.
|
|
99
|
+
|
|
100
|
+
You never need to check the mode. Skills detect it themselves and adapt their instructions accordingly.
|
|
101
|
+
|
|
102
|
+
## Anti-Patterns
|
|
103
|
+
|
|
104
|
+
- **Don't announce skill usage** — Apply the skill silently, don't say "I'm now using the systematic-debugging skill"
|
|
105
|
+
- **Don't read the skill on every step** — Read once, apply throughout
|
|
106
|
+
- **Don't stack conflicting skills** — If TDD and subagent-driven-development both apply, let subagent-driven-development drive; it includes TDD internally
|
|
107
|
+
- **Don't ignore ClawPowers enhancements** — When the runtime is available, use it; the static path is a fallback, not the goal
|
|
108
|
+
|
|
109
|
+
## Quick Reference: All 20 Skills
|
|
110
|
+
|
|
111
|
+
### Core Development (14)
|
|
112
|
+
1. `subagent-driven-development` — Parallel subagents, two-stage review, worktree isolation
|
|
113
|
+
2. `test-driven-development` — RED-GREEN-REFACTOR with failure witness and mutation analysis
|
|
114
|
+
3. `writing-plans` — Spec to sequenced 2-5 min tasks with dependency graph
|
|
115
|
+
4. `executing-plans` — Tracked execution with resumability and milestone persistence
|
|
116
|
+
5. `brainstorming` — Structured ideation with convergence protocol
|
|
117
|
+
6. `systematic-debugging` — Hypothesis-driven debugging with evidence collection
|
|
118
|
+
7. `verification-before-completion` — Quality gates before any merge or handoff
|
|
119
|
+
8. `finishing-a-development-branch` — Branch cleanup, changelog, squash, merge prep
|
|
120
|
+
9. `requesting-code-review` — Review request with context, risk areas, reviewer matching
|
|
121
|
+
10. `receiving-code-review` — Constructive processing, pattern database, response protocol
|
|
122
|
+
11. `using-git-worktrees` — Isolated parallel branch development
|
|
123
|
+
12. `using-clawpowers` — This document
|
|
124
|
+
13. `writing-skills` — TDD for skills: test scenarios → fail → write skill → pass
|
|
125
|
+
14. `dispatching-parallel-agents` — Fan-out execution, load balancing, result aggregation
|
|
126
|
+
|
|
127
|
+
### Extended Capabilities (6)
|
|
128
|
+
15. `agent-payments` — x402 payment protocol, non-custodial wallets, spending limits
|
|
129
|
+
16. `security-audit` — Trivy, gitleaks, npm audit, bandit — actionable report output
|
|
130
|
+
17. `content-pipeline` — Write → humanize → format → publish workflow
|
|
131
|
+
18. `learn-how-to-learn` — 5-layer learning stack, 14 anti-patterns, confidence calibration
|
|
132
|
+
19. `market-intelligence` — Competitive analysis, trend detection, opportunity scoring
|
|
133
|
+
20. `prospecting` — ICP → company search → contact enrichment → outreach prep
|
|
134
|
+
|
|
135
|
+
## Session Initialization Complete
|
|
136
|
+
|
|
137
|
+
ClawPowers is ready. Skills activate on pattern recognition. Runtime enhancements available when `~/.clawpowers/` exists.
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: using-git-worktrees
|
|
3
|
+
description: Manage isolated Git worktrees for parallel branch development. Activate when you need to work on multiple branches simultaneously or isolate subagent work.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
requires:
|
|
6
|
+
tools: [git, bash]
|
|
7
|
+
runtime: false
|
|
8
|
+
metrics:
|
|
9
|
+
tracks: [worktrees_created, conflicts_encountered, isolation_violations, lifecycle_completion_rate]
|
|
10
|
+
improves: [conflict_prediction, worktree_naming, cleanup_timing]
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Using Git Worktrees
|
|
14
|
+
|
|
15
|
+
## When to Use
|
|
16
|
+
|
|
17
|
+
Apply this skill when:
|
|
18
|
+
|
|
19
|
+
- Working on 2+ branches simultaneously without switching
|
|
20
|
+
- Running subagents in parallel (each needs its own working directory)
|
|
21
|
+
- Testing a feature while bug-fixing on another branch
|
|
22
|
+
- Reviewing a colleague's branch while continuing your own work
|
|
23
|
+
- Running long-running processes (tests, builds) on one branch while editing another
|
|
24
|
+
|
|
25
|
+
**Skip when:**
|
|
26
|
+
- You only have one branch active at a time
|
|
27
|
+
- Your editor doesn't handle multiple root directories well
|
|
28
|
+
- The branches share files that would conflict on disk (same path, different content)
|
|
29
|
+
|
|
30
|
+
## Core Methodology
|
|
31
|
+
|
|
32
|
+
### Understanding Worktrees
|
|
33
|
+
|
|
34
|
+
A Git worktree is a separate working directory linked to the same repository. Each worktree:
|
|
35
|
+
- Has its own checked-out branch
|
|
36
|
+
- Has its own working tree state (staged/unstaged changes)
|
|
37
|
+
- Shares the repository's history, objects, and refs
|
|
38
|
+
- Cannot have the same branch checked out as another worktree
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
.git/ ← Shared repository database
|
|
42
|
+
worktrees/
|
|
43
|
+
feature-auth/ ← Worktree metadata
|
|
44
|
+
feature-payments/ ← Worktree metadata
|
|
45
|
+
|
|
46
|
+
../feature-auth/ ← Separate directory on disk
|
|
47
|
+
src/
|
|
48
|
+
tests/
|
|
49
|
+
|
|
50
|
+
../feature-payments/ ← Separate directory on disk
|
|
51
|
+
src/
|
|
52
|
+
tests/
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Worktree Lifecycle
|
|
56
|
+
|
|
57
|
+
#### Create
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# Create worktree for existing branch
|
|
61
|
+
git worktree add ../feature-auth feature/auth-service
|
|
62
|
+
|
|
63
|
+
# Create worktree and new branch simultaneously
|
|
64
|
+
git worktree add -b feature/payments ../feature-payments main
|
|
65
|
+
|
|
66
|
+
# Create worktree from specific commit
|
|
67
|
+
git worktree add ../hotfix-3.1 v3.1.0
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Naming convention for parallel subagent work:**
|
|
71
|
+
```bash
|
|
72
|
+
# Use task or feature name as both branch and directory
|
|
73
|
+
git worktree add ../clawpowers-task-auth feature/task-auth
|
|
74
|
+
git worktree add ../clawpowers-task-db feature/task-db
|
|
75
|
+
git worktree add ../clawpowers-task-api feature/task-api
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
#### Verify
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
git worktree list
|
|
82
|
+
# output:
|
|
83
|
+
# /Users/you/project a3f9b2c [main]
|
|
84
|
+
# /Users/you/feature-auth 0000000 [feature/auth-service]
|
|
85
|
+
# /Users/you/feature-payments 0000000 [feature/payments]
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
#### Work in the Worktree
|
|
89
|
+
|
|
90
|
+
Each worktree is a full working directory. Navigate to it and work normally:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
cd ../feature-auth
|
|
94
|
+
git status # Independent of main working tree
|
|
95
|
+
git add src/auth.py
|
|
96
|
+
git commit -m "feat(auth): implement JWT issuance"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Changes in one worktree are invisible to others until merged.
|
|
100
|
+
|
|
101
|
+
#### Sync with Main
|
|
102
|
+
|
|
103
|
+
When you need to update a worktree with latest main:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
cd ../feature-auth
|
|
107
|
+
git fetch origin
|
|
108
|
+
git rebase origin/main # Preferred: linear history
|
|
109
|
+
# or
|
|
110
|
+
git merge origin/main # If rebase would cause conflicts
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Run `git worktree list` first — if another worktree has the same base, check for merge conflicts proactively.
|
|
114
|
+
|
|
115
|
+
#### Cleanup
|
|
116
|
+
|
|
117
|
+
When the branch is merged:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
# From main repository directory
|
|
121
|
+
git worktree remove ../feature-auth # Removes directory
|
|
122
|
+
git branch -d feature/auth-service # Remove branch
|
|
123
|
+
|
|
124
|
+
# If the worktree has uncommitted changes and you want to force:
|
|
125
|
+
git worktree remove --force ../feature-auth
|
|
126
|
+
|
|
127
|
+
# List remaining worktrees to verify
|
|
128
|
+
git worktree list
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Cleanup checklist:**
|
|
132
|
+
- [ ] Branch is merged to main (or PR is approved)
|
|
133
|
+
- [ ] Worktree has no uncommitted changes
|
|
134
|
+
- [ ] No processes are running in the worktree directory
|
|
135
|
+
- [ ] Remove directory, then remove branch
|
|
136
|
+
|
|
137
|
+
### Conflict Prevention
|
|
138
|
+
|
|
139
|
+
Worktrees share the index but have separate working trees. Common conflicts:
|
|
140
|
+
|
|
141
|
+
**Same branch in two worktrees:** Git prevents this — you'll get an error:
|
|
142
|
+
```
|
|
143
|
+
fatal: 'feature/auth-service' is already checked out
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**Solution:** Use separate branches even for related work.
|
|
147
|
+
|
|
148
|
+
**Both worktrees editing the same file:** Legal, but merging will require conflict resolution:
|
|
149
|
+
```bash
|
|
150
|
+
# Check overlap before creating worktrees
|
|
151
|
+
git diff --name-only main..feature/branch-a
|
|
152
|
+
git diff --name-only main..feature/branch-b
|
|
153
|
+
# If outputs overlap, consider sequential rather than parallel work
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**Submodule issues:** Worktrees and submodules interact poorly. If your repo uses submodules, test worktree creation in a non-submodule path first.
|
|
157
|
+
|
|
158
|
+
### Pattern: Subagent Work Isolation
|
|
159
|
+
|
|
160
|
+
The primary ClawPowers use case: give each subagent its own worktree.
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# Main orchestrator creates worktrees
|
|
164
|
+
TASKS=("auth" "db" "api" "tests")
|
|
165
|
+
for task in "${TASKS[@]}"; do
|
|
166
|
+
git worktree add "../${REPO_NAME}-task-${task}" -b "feature/task-${task}" main
|
|
167
|
+
echo "Created worktree for task-${task} at ../${REPO_NAME}-task-${task}"
|
|
168
|
+
done
|
|
169
|
+
|
|
170
|
+
# Each subagent receives its worktree path
|
|
171
|
+
# Subagent-auth works in: ../project-task-auth/
|
|
172
|
+
# Subagent-db works in: ../project-task-db/
|
|
173
|
+
# They cannot interfere with each other's files
|
|
174
|
+
|
|
175
|
+
# After all subagents complete, merge in dependency order
|
|
176
|
+
MERGE_ORDER=("db" "auth" "api" "tests")
|
|
177
|
+
git checkout main
|
|
178
|
+
for task in "${MERGE_ORDER[@]}"; do
|
|
179
|
+
git merge --no-ff "feature/task-${task}" -m "merge: task-${task}"
|
|
180
|
+
git worktree remove "../${REPO_NAME}-task-${task}"
|
|
181
|
+
git branch -d "feature/task-${task}"
|
|
182
|
+
done
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Pattern: Hotfix While Feature Work Continues
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
# You're in the middle of a long feature
|
|
189
|
+
git worktree list
|
|
190
|
+
# /Users/you/project [feature/auth-service]
|
|
191
|
+
|
|
192
|
+
# Production alert fires — need to hotfix
|
|
193
|
+
git worktree add ../hotfix main
|
|
194
|
+
cd ../hotfix
|
|
195
|
+
# ... fix the bug ...
|
|
196
|
+
git commit -m "fix: critical payment timeout in production"
|
|
197
|
+
git push origin hotfix/payment-timeout
|
|
198
|
+
# PR/merge the hotfix from this worktree
|
|
199
|
+
|
|
200
|
+
# Back to feature work
|
|
201
|
+
cd ../project # Original feature work untouched
|
|
202
|
+
git status # Clean, feature work is exactly where you left it
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## ClawPowers Enhancement
|
|
206
|
+
|
|
207
|
+
When `~/.clawpowers/` runtime is initialized:
|
|
208
|
+
|
|
209
|
+
**Worktree Lifecycle Management:**
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
# Register a worktree
|
|
213
|
+
bash runtime/persistence/store.sh set "worktree:task-auth:path" "../project-task-auth"
|
|
214
|
+
bash runtime/persistence/store.sh set "worktree:task-auth:branch" "feature/task-auth"
|
|
215
|
+
bash runtime/persistence/store.sh set "worktree:task-auth:status" "active"
|
|
216
|
+
bash runtime/persistence/store.sh set "worktree:task-auth:created_at" "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
217
|
+
|
|
218
|
+
# List all active worktrees with their status
|
|
219
|
+
bash runtime/persistence/store.sh list "worktree:*:status"
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
If a session is interrupted, the worktree registry shows which are active and which branches they hold — preventing orphaned worktrees.
|
|
223
|
+
|
|
224
|
+
**Conflict Prediction:**
|
|
225
|
+
|
|
226
|
+
Before creating parallel worktrees, the framework checks for file overlap:
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
# For each planned worktree pair, check for overlapping file changes
|
|
230
|
+
# High overlap = schedule sequentially; low overlap = safe to parallelize
|
|
231
|
+
bash runtime/persistence/store.sh set "worktree:conflict_check:task-auth_vs_task-db" "no_overlap"
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
**Cleanup Automation:**
|
|
235
|
+
|
|
236
|
+
After merge detection, automatically prompt for worktree cleanup:
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
bash runtime/feedback/analyze.sh --worktrees
|
|
240
|
+
# Output:
|
|
241
|
+
# Merged branches with active worktrees:
|
|
242
|
+
# - feature/task-auth (merged 3 hours ago) → worktree at ../project-task-auth
|
|
243
|
+
# Run: git worktree remove ../project-task-auth && git branch -d feature/task-auth
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Anti-Patterns
|
|
247
|
+
|
|
248
|
+
| Anti-Pattern | Why It Fails | Correct Approach |
|
|
249
|
+
|-------------|-------------|-----------------|
|
|
250
|
+
| Checking out same branch in two worktrees | Git prevents this — error on checkout | Each worktree must have a unique branch |
|
|
251
|
+
| Never cleaning up worktrees | Disk fills up, confusion about active branches | Cleanup immediately after branch merges |
|
|
252
|
+
| `--force` on worktree with uncommitted work | Loses uncommitted changes permanently | Commit or stash before removing |
|
|
253
|
+
| Parallel worktrees editing the same file | Merge conflicts on integration | Check file overlap before creating parallel worktrees |
|
|
254
|
+
| Forgetting which worktree you're in | Wrong branch gets commits | `git worktree list` before committing |
|
|
255
|
+
| Long-lived worktrees diverging from main | Painful rebase/merge on integration | Regularly sync worktrees with `git rebase origin/main` |
|
|
256
|
+
|
|
257
|
+
## Integration with Other Skills
|
|
258
|
+
|
|
259
|
+
- Used by `subagent-driven-development` for task isolation
|
|
260
|
+
- Used by `dispatching-parallel-agents` for concurrent work
|
|
261
|
+
- Used by `finishing-a-development-branch` when cleaning up
|