tlc-claude-code 1.5.3 → 1.5.4
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/commands/tlc/audit.md +129 -0
- package/.claude/commands/tlc/autofix.md +217 -0
- package/.claude/commands/tlc/bug.md +255 -0
- package/.claude/commands/tlc/build.md +731 -0
- package/.claude/commands/tlc/checklist.md +212 -0
- package/.claude/commands/tlc/ci.md +414 -0
- package/.claude/commands/tlc/claim.md +189 -0
- package/.claude/commands/tlc/cleanup.md +187 -0
- package/.claude/commands/tlc/complete.md +160 -0
- package/.claude/commands/tlc/config.md +395 -0
- package/.claude/commands/tlc/coverage.md +222 -0
- package/.claude/commands/tlc/deploy.md +723 -0
- package/.claude/commands/tlc/discuss.md +185 -0
- package/.claude/commands/tlc/docs.md +194 -0
- package/.claude/commands/tlc/edge-cases.md +241 -0
- package/.claude/commands/tlc/export.md +456 -0
- package/.claude/commands/tlc/help.md +169 -0
- package/.claude/commands/tlc/import-project.md +246 -0
- package/.claude/commands/tlc/init.md +443 -0
- package/.claude/commands/tlc/issues.md +376 -0
- package/.claude/commands/tlc/llm.md +111 -0
- package/.claude/commands/tlc/new-milestone.md +172 -0
- package/.claude/commands/tlc/new-project.md +399 -0
- package/.claude/commands/tlc/next.md +129 -0
- package/.claude/commands/tlc/outdated.md +200 -0
- package/.claude/commands/tlc/plan.md +224 -0
- package/.claude/commands/tlc/progress.md +153 -0
- package/.claude/commands/tlc/quality.md +185 -0
- package/.claude/commands/tlc/quick.md +52 -0
- package/.claude/commands/tlc/refactor.md +190 -0
- package/.claude/commands/tlc/release.md +135 -0
- package/.claude/commands/tlc/review-pr.md +184 -0
- package/.claude/commands/tlc/review.md +200 -0
- package/.claude/commands/tlc/security.md +195 -0
- package/.claude/commands/tlc/server.md +19 -0
- package/.claude/commands/tlc/start.md +137 -0
- package/.claude/commands/tlc/status.md +65 -0
- package/.claude/commands/tlc/sync.md +652 -0
- package/.claude/commands/tlc/tlc.md +279 -0
- package/.claude/commands/tlc/verify.md +159 -0
- package/.claude/commands/tlc/who.md +151 -0
- package/bin/postinstall.js +54 -0
- package/package.json +3 -1
|
@@ -0,0 +1,652 @@
|
|
|
1
|
+
# /tlc:sync - One Command to Rule Them All
|
|
2
|
+
|
|
3
|
+
The unified entry point for TLC adoption and codebase synchronization.
|
|
4
|
+
|
|
5
|
+
## What This Does
|
|
6
|
+
|
|
7
|
+
**First-time adoption:** Complete onboarding with all configuration in one flow.
|
|
8
|
+
|
|
9
|
+
**Post-rebase:** Detect changes and reconcile incoming code with TLC standards.
|
|
10
|
+
|
|
11
|
+
**Main ahead:** Read changes from main, understand context, rebuild locally without rebasing.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
/tlc:sync
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
No arguments. TLC auto-detects the scenario.
|
|
20
|
+
|
|
21
|
+
## CRITICAL: Execution Flow
|
|
22
|
+
|
|
23
|
+
**You MUST detect the scenario FIRST, then execute ONLY that scenario.**
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
Step 1: Check for .tlc.json
|
|
27
|
+
│
|
|
28
|
+
├── NOT FOUND → Execute "Scenario 1: First-Time Adoption" ONLY
|
|
29
|
+
│
|
|
30
|
+
└── FOUND → Step 2: Check branch status
|
|
31
|
+
│
|
|
32
|
+
├── HEAD == lastSync AND main not ahead → "✓ Already synced" STOP
|
|
33
|
+
│
|
|
34
|
+
├── HEAD != lastSync → Execute "Scenario 2: Post-Rebase" ONLY
|
|
35
|
+
│
|
|
36
|
+
└── Main is ahead of current branch → Execute "Scenario 3: Integrate Main" ONLY
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Detection for "main ahead":**
|
|
40
|
+
```bash
|
|
41
|
+
mainBranch=$(jq -r '.git.mainBranch // "main"' .tlc.json)
|
|
42
|
+
git fetch origin $mainBranch
|
|
43
|
+
behindCount=$(git rev-list HEAD..origin/$mainBranch --count)
|
|
44
|
+
if [ "$behindCount" -gt 0 ]; then
|
|
45
|
+
# Main is ahead - offer Scenario 3
|
|
46
|
+
fi
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**DO NOT run multiple scenarios. Pick ONE based on detection.**
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Scenario 1: First-Time Adoption
|
|
54
|
+
|
|
55
|
+
**ONLY run this if .tlc.json does NOT exist.**
|
|
56
|
+
|
|
57
|
+
Complete onboarding questionnaire. All settings in one flow so nothing gets forgotten.
|
|
58
|
+
|
|
59
|
+
### Step 1.1: Welcome
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
████████╗██╗ ██████╗
|
|
63
|
+
╚══██╔══╝██║ ██╔════╝
|
|
64
|
+
██║ ██║ ██║
|
|
65
|
+
██║ ██║ ██║
|
|
66
|
+
██║ ███████╗╚██████╗
|
|
67
|
+
╚═╝ ╚══════╝ ╚═════╝
|
|
68
|
+
|
|
69
|
+
Welcome to TLC - Test Led Coding
|
|
70
|
+
|
|
71
|
+
Let's configure your project. This takes about 2 minutes.
|
|
72
|
+
All settings can be changed later in .tlc.json
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Step 1.2: Detect Existing Setup
|
|
76
|
+
|
|
77
|
+
Scan the codebase:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Detect language/framework
|
|
81
|
+
if [ -f "package.json" ]; then
|
|
82
|
+
stack="node"
|
|
83
|
+
if grep -q "react\|next" package.json; then
|
|
84
|
+
stack="react"
|
|
85
|
+
fi
|
|
86
|
+
elif [ -f "pyproject.toml" ] || [ -f "requirements.txt" ]; then
|
|
87
|
+
stack="python"
|
|
88
|
+
elif [ -f "go.mod" ]; then
|
|
89
|
+
stack="go"
|
|
90
|
+
elif [ -f "Cargo.toml" ]; then
|
|
91
|
+
stack="rust"
|
|
92
|
+
fi
|
|
93
|
+
|
|
94
|
+
# Detect existing tests
|
|
95
|
+
tests_exist=$(find . -name "*.test.*" -o -name "test_*.py" -o -name "*_test.go" | head -1)
|
|
96
|
+
|
|
97
|
+
# Detect git branch
|
|
98
|
+
main_branch=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Step 1.3: Configuration Questionnaire
|
|
102
|
+
|
|
103
|
+
Present all options with smart defaults based on detection:
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
─────────────────────────────────────────────────────
|
|
107
|
+
1. TEST FRAMEWORK
|
|
108
|
+
─────────────────────────────────────────────────────
|
|
109
|
+
|
|
110
|
+
Detected: Node.js project
|
|
111
|
+
|
|
112
|
+
Choose test framework:
|
|
113
|
+
[1] Mocha + Chai + Sinon (TLC default, recommended)
|
|
114
|
+
[2] Vitest
|
|
115
|
+
[3] Jest
|
|
116
|
+
[4] Keep existing: jest (47 test files found)
|
|
117
|
+
|
|
118
|
+
Choice [1/2/3/4]: _
|
|
119
|
+
|
|
120
|
+
─────────────────────────────────────────────────────
|
|
121
|
+
2. GIT CONFIGURATION
|
|
122
|
+
─────────────────────────────────────────────────────
|
|
123
|
+
|
|
124
|
+
Detected main branch: main
|
|
125
|
+
|
|
126
|
+
Is this your trunk branch? (Y/n): _
|
|
127
|
+
|
|
128
|
+
─────────────────────────────────────────────────────
|
|
129
|
+
3. TEAM MODE
|
|
130
|
+
─────────────────────────────────────────────────────
|
|
131
|
+
|
|
132
|
+
How many people work on this codebase?
|
|
133
|
+
[1] Solo - just me
|
|
134
|
+
[2] Team - multiple developers
|
|
135
|
+
|
|
136
|
+
Choice [1/2]: _
|
|
137
|
+
|
|
138
|
+
(If team selected)
|
|
139
|
+
Require task claiming before work? (Y/n): _
|
|
140
|
+
Slack webhook for notifications (optional): _
|
|
141
|
+
|
|
142
|
+
─────────────────────────────────────────────────────
|
|
143
|
+
4. QUALITY STANDARDS
|
|
144
|
+
─────────────────────────────────────────────────────
|
|
145
|
+
|
|
146
|
+
Set your quality gates:
|
|
147
|
+
|
|
148
|
+
Minimum test coverage [80]: ___%
|
|
149
|
+
Minimum quality score [75]: ___/100
|
|
150
|
+
Require tests before code (TDD) [Y/n]: _
|
|
151
|
+
|
|
152
|
+
─────────────────────────────────────────────────────
|
|
153
|
+
5. CI/CD INTEGRATION
|
|
154
|
+
─────────────────────────────────────────────────────
|
|
155
|
+
|
|
156
|
+
Set up continuous integration?
|
|
157
|
+
[1] GitHub Actions (recommended)
|
|
158
|
+
[2] GitLab CI
|
|
159
|
+
[3] Azure Pipelines
|
|
160
|
+
[4] Skip for now
|
|
161
|
+
|
|
162
|
+
Choice [1/2/3/4]: _
|
|
163
|
+
|
|
164
|
+
(If CI selected)
|
|
165
|
+
Block PRs on test failure? (Y/n): _
|
|
166
|
+
Block PRs on coverage drop? (Y/n): _
|
|
167
|
+
|
|
168
|
+
─────────────────────────────────────────────────────
|
|
169
|
+
6. EXISTING CODE
|
|
170
|
+
─────────────────────────────────────────────────────
|
|
171
|
+
|
|
172
|
+
Found 34 source files without tests.
|
|
173
|
+
|
|
174
|
+
How should TLC handle existing code?
|
|
175
|
+
[1] Create test backlog - I'll add tests gradually
|
|
176
|
+
[2] Generate tests now - for critical paths first
|
|
177
|
+
[3] Ignore existing - only enforce TLC on new code
|
|
178
|
+
|
|
179
|
+
Choice [1/2/3]: _
|
|
180
|
+
|
|
181
|
+
─────────────────────────────────────────────────────
|
|
182
|
+
7. ADVANCED OPTIONS
|
|
183
|
+
─────────────────────────────────────────────────────
|
|
184
|
+
|
|
185
|
+
Configure advanced settings? (y/N): _
|
|
186
|
+
|
|
187
|
+
(If yes)
|
|
188
|
+
Auto-fix failing tests [Y/n]: _
|
|
189
|
+
Edge case generation [Y/n]: _
|
|
190
|
+
PR auto-review [Y/n]: _
|
|
191
|
+
Max parallel agents [10]: _
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Step 1.4: Generate Configuration
|
|
195
|
+
|
|
196
|
+
Create `.tlc.json` with all settings:
|
|
197
|
+
|
|
198
|
+
```json
|
|
199
|
+
{
|
|
200
|
+
"version": "1.0",
|
|
201
|
+
"lastSync": "abc123def456",
|
|
202
|
+
"git": {
|
|
203
|
+
"mainBranch": "main"
|
|
204
|
+
},
|
|
205
|
+
"testFrameworks": {
|
|
206
|
+
"primary": "mocha",
|
|
207
|
+
"installed": ["mocha", "chai", "sinon", "proxyquire"],
|
|
208
|
+
"run": ["mocha"]
|
|
209
|
+
},
|
|
210
|
+
"team": {
|
|
211
|
+
"mode": "team",
|
|
212
|
+
"requireClaim": true,
|
|
213
|
+
"slackWebhook": null
|
|
214
|
+
},
|
|
215
|
+
"quality": {
|
|
216
|
+
"coverageThreshold": 80,
|
|
217
|
+
"qualityScoreThreshold": 75,
|
|
218
|
+
"enforceTDD": true
|
|
219
|
+
},
|
|
220
|
+
"ci": {
|
|
221
|
+
"provider": "github",
|
|
222
|
+
"blockOnTestFailure": true,
|
|
223
|
+
"blockOnCoverageDrop": true
|
|
224
|
+
},
|
|
225
|
+
"existingCode": {
|
|
226
|
+
"strategy": "backlog"
|
|
227
|
+
},
|
|
228
|
+
"advanced": {
|
|
229
|
+
"autofix": true,
|
|
230
|
+
"edgeCases": true,
|
|
231
|
+
"prAutoReview": true,
|
|
232
|
+
"maxAgents": 10
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Step 1.5: Apply Configuration
|
|
238
|
+
|
|
239
|
+
Based on choices, set up the project:
|
|
240
|
+
|
|
241
|
+
```
|
|
242
|
+
Applying configuration...
|
|
243
|
+
|
|
244
|
+
✓ Test framework: mocha
|
|
245
|
+
→ Installed: mocha, chai, sinon, proxyquire
|
|
246
|
+
→ Created: .mocharc.json
|
|
247
|
+
→ Added test scripts to package.json
|
|
248
|
+
|
|
249
|
+
✓ Git: main branch set to "main"
|
|
250
|
+
→ Installed: post-rebase hook
|
|
251
|
+
|
|
252
|
+
✓ Team mode: enabled
|
|
253
|
+
→ Task claiming required
|
|
254
|
+
|
|
255
|
+
✓ Quality gates: 80% coverage, 75 quality score
|
|
256
|
+
|
|
257
|
+
✓ CI: GitHub Actions
|
|
258
|
+
→ Created: .github/workflows/tlc.yml
|
|
259
|
+
|
|
260
|
+
✓ Existing code: backlog created
|
|
261
|
+
→ Created: .planning/BACKLOG.md (34 files to test)
|
|
262
|
+
|
|
263
|
+
✓ Planning structure
|
|
264
|
+
→ Created: PROJECT.md
|
|
265
|
+
→ Created: .planning/ROADMAP.md
|
|
266
|
+
→ Created: .planning/STATE.md
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Step 1.6: Install Git Hook
|
|
270
|
+
|
|
271
|
+
Create `.git/hooks/post-rebase`:
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
#!/bin/bash
|
|
275
|
+
# TLC post-rebase hook
|
|
276
|
+
|
|
277
|
+
echo ""
|
|
278
|
+
echo "⚠️ Rebase detected. Run /tlc:sync to reconcile changes."
|
|
279
|
+
echo ""
|
|
280
|
+
|
|
281
|
+
# Update marker file so TLC knows rebase happened
|
|
282
|
+
touch .tlc-rebase-marker
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
Make executable:
|
|
286
|
+
```bash
|
|
287
|
+
chmod +x .git/hooks/post-rebase
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Step 1.7: Summary
|
|
291
|
+
|
|
292
|
+
```
|
|
293
|
+
─────────────────────────────────────────────────────
|
|
294
|
+
TLC SETUP COMPLETE
|
|
295
|
+
─────────────────────────────────────────────────────
|
|
296
|
+
|
|
297
|
+
Configuration saved to .tlc.json
|
|
298
|
+
|
|
299
|
+
Your setup:
|
|
300
|
+
• Test framework: Mocha + Chai + Sinon
|
|
301
|
+
• Main branch: main
|
|
302
|
+
• Team mode: Enabled (claiming required)
|
|
303
|
+
• Coverage target: 80%
|
|
304
|
+
• CI: GitHub Actions
|
|
305
|
+
|
|
306
|
+
Next steps:
|
|
307
|
+
/tlc → See what to do next
|
|
308
|
+
/tlc:plan → Plan your first phase
|
|
309
|
+
/tlc:build → Start building (test-first)
|
|
310
|
+
|
|
311
|
+
Run /tlc:sync anytime after rebasing to reconcile changes.
|
|
312
|
+
|
|
313
|
+
Happy testing! 🧪
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## Scenario 2: Post-Rebase Reconciliation
|
|
319
|
+
|
|
320
|
+
**ONLY run this if .tlc.json EXISTS and HEAD differs from lastSync.**
|
|
321
|
+
|
|
322
|
+
Detect and handle code changes from rebase.
|
|
323
|
+
|
|
324
|
+
### Step 2.1: Detect Changes
|
|
325
|
+
|
|
326
|
+
```bash
|
|
327
|
+
# Get stored commit
|
|
328
|
+
lastSync=$(jq -r '.lastSync // ""' .tlc.json)
|
|
329
|
+
|
|
330
|
+
# Get current HEAD
|
|
331
|
+
currentHead=$(git rev-parse HEAD)
|
|
332
|
+
|
|
333
|
+
# Check for rebase marker
|
|
334
|
+
rebaseMarker=".tlc-rebase-marker"
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
If `lastSync` equals `currentHead` and no rebase marker:
|
|
338
|
+
```
|
|
339
|
+
✓ Already synced. Nothing to do.
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
Otherwise, continue to analysis.
|
|
343
|
+
|
|
344
|
+
### Step 2.2: Analyze Incoming Changes
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
# Get changed files since last sync
|
|
348
|
+
changedFiles=$(git diff --name-only $lastSync $currentHead 2>/dev/null)
|
|
349
|
+
|
|
350
|
+
# Categorize changes
|
|
351
|
+
newFiles=$(git diff --name-only --diff-filter=A $lastSync $currentHead)
|
|
352
|
+
modifiedFiles=$(git diff --name-only --diff-filter=M $lastSync $currentHead)
|
|
353
|
+
deletedFiles=$(git diff --name-only --diff-filter=D $lastSync $currentHead)
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
Present analysis:
|
|
357
|
+
|
|
358
|
+
```
|
|
359
|
+
─────────────────────────────────────────────────────
|
|
360
|
+
REBASE DETECTED
|
|
361
|
+
─────────────────────────────────────────────────────
|
|
362
|
+
|
|
363
|
+
Last sync: abc123 (2 hours ago)
|
|
364
|
+
Current: def456 (just now)
|
|
365
|
+
|
|
366
|
+
Changes detected:
|
|
367
|
+
|
|
368
|
+
New files (4):
|
|
369
|
+
+ src/api/payments.ts
|
|
370
|
+
+ src/api/webhooks.ts
|
|
371
|
+
+ src/services/stripe.ts
|
|
372
|
+
+ src/utils/currency.ts
|
|
373
|
+
|
|
374
|
+
Modified files (7):
|
|
375
|
+
~ src/api/users.ts
|
|
376
|
+
~ src/db/schema.ts
|
|
377
|
+
~ src/middleware/auth.ts
|
|
378
|
+
~ tests/api/users.test.ts
|
|
379
|
+
~ ...
|
|
380
|
+
|
|
381
|
+
Deleted files (1):
|
|
382
|
+
- src/old-payment.ts
|
|
383
|
+
|
|
384
|
+
Tests for new code: 0 found ⚠️
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### Step 2.3: Auto-Sync (Default Behavior)
|
|
388
|
+
|
|
389
|
+
**DO NOT ask about individual files. Just sync automatically.**
|
|
390
|
+
|
|
391
|
+
```
|
|
392
|
+
Syncing...
|
|
393
|
+
|
|
394
|
+
✓ Updated lastSync to ${currentHead:0:7}
|
|
395
|
+
✓ Removed rebase marker (if present)
|
|
396
|
+
|
|
397
|
+
Sync complete.
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
That's it. The sync just updates the tracking. Tests are written when you run `/tlc:build`.
|
|
401
|
+
|
|
402
|
+
**Why no file-by-file questions?**
|
|
403
|
+
- Incoming code was already reviewed in the PR
|
|
404
|
+
- Tests will be written during the build phase
|
|
405
|
+
- Asking about every file is annoying and slow
|
|
406
|
+
|
|
407
|
+
### Step 2.4: Optional - Add Tests for Untested Code
|
|
408
|
+
|
|
409
|
+
If `.tlc.json` has `existingCode.strategy: "backlog"`, silently note any new untested files:
|
|
410
|
+
|
|
411
|
+
```bash
|
|
412
|
+
# Find new source files without tests
|
|
413
|
+
newUntested=$(for f in $newFiles; do
|
|
414
|
+
if [[ $f == src/* ]] && ! [ -f "tests/${f#src/}" ]; then
|
|
415
|
+
echo "$f"
|
|
416
|
+
fi
|
|
417
|
+
done)
|
|
418
|
+
|
|
419
|
+
if [ -n "$newUntested" ]; then
|
|
420
|
+
echo "Note: $(echo "$newUntested" | wc -l) new files added to test backlog"
|
|
421
|
+
fi
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
DO NOT ask about them. Just note and continue.
|
|
425
|
+
|
|
426
|
+
### Step 2.6: Update Sync State
|
|
427
|
+
|
|
428
|
+
After sync completes:
|
|
429
|
+
|
|
430
|
+
```bash
|
|
431
|
+
# Update lastSync in .tlc.json
|
|
432
|
+
currentHead=$(git rev-parse HEAD)
|
|
433
|
+
jq ".lastSync = \"$currentHead\"" .tlc.json > .tlc.json.tmp
|
|
434
|
+
mv .tlc.json.tmp .tlc.json
|
|
435
|
+
|
|
436
|
+
# Remove rebase marker if exists
|
|
437
|
+
rm -f .tlc-rebase-marker
|
|
438
|
+
|
|
439
|
+
# Commit the sync
|
|
440
|
+
git add .
|
|
441
|
+
git commit -m "sync: reconcile changes from rebase"
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
---
|
|
445
|
+
|
|
446
|
+
## Scenario 3: Integrate Main (No Rebase)
|
|
447
|
+
|
|
448
|
+
**ONLY run this if main branch is ahead of current branch.**
|
|
449
|
+
|
|
450
|
+
This is for when you want to incorporate changes from main WITHOUT rebasing. Claude reads and understands the changes, then rebuilds them in your branch's context.
|
|
451
|
+
|
|
452
|
+
### When to Use This
|
|
453
|
+
|
|
454
|
+
- Rebase would cause too many conflicts
|
|
455
|
+
- You want to cherry-pick specific improvements
|
|
456
|
+
- You need to understand what changed before integrating
|
|
457
|
+
- Your branch has diverged significantly from main
|
|
458
|
+
|
|
459
|
+
### Step 3.1: Detect Main Ahead
|
|
460
|
+
|
|
461
|
+
```bash
|
|
462
|
+
mainBranch=$(jq -r '.git.mainBranch // "main"' .tlc.json)
|
|
463
|
+
git fetch origin $mainBranch
|
|
464
|
+
|
|
465
|
+
behindCount=$(git rev-list HEAD..origin/$mainBranch --count)
|
|
466
|
+
aheadCount=$(git rev-list origin/$mainBranch..HEAD --count)
|
|
467
|
+
|
|
468
|
+
if [ "$behindCount" -gt 0 ]; then
|
|
469
|
+
echo "─────────────────────────────────────────────────────"
|
|
470
|
+
echo " MAIN IS AHEAD"
|
|
471
|
+
echo "─────────────────────────────────────────────────────"
|
|
472
|
+
echo ""
|
|
473
|
+
echo "Your branch: $(git branch --show-current)"
|
|
474
|
+
echo "Main branch: $mainBranch"
|
|
475
|
+
echo ""
|
|
476
|
+
echo " $behindCount commits behind main"
|
|
477
|
+
echo " $aheadCount commits ahead of main"
|
|
478
|
+
echo ""
|
|
479
|
+
echo "Options:"
|
|
480
|
+
echo " [1] Integrate changes (read & rebuild without rebase)"
|
|
481
|
+
echo " [2] Skip for now"
|
|
482
|
+
echo ""
|
|
483
|
+
echo "Choice [1/2]: _"
|
|
484
|
+
fi
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
### Step 3.2: Analyze Main's Changes
|
|
488
|
+
|
|
489
|
+
If user chooses to integrate:
|
|
490
|
+
|
|
491
|
+
```bash
|
|
492
|
+
# Get the changes from main that we don't have
|
|
493
|
+
git log --oneline HEAD..origin/$mainBranch
|
|
494
|
+
git diff HEAD...origin/$mainBranch --stat
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
Present summary:
|
|
498
|
+
|
|
499
|
+
```
|
|
500
|
+
─────────────────────────────────────────────────────
|
|
501
|
+
CHANGES IN MAIN
|
|
502
|
+
─────────────────────────────────────────────────────
|
|
503
|
+
|
|
504
|
+
12 commits to integrate:
|
|
505
|
+
|
|
506
|
+
abc1234 feat: add payment processing
|
|
507
|
+
def5678 fix: user validation bug
|
|
508
|
+
ghi9012 refactor: cleanup auth module
|
|
509
|
+
...
|
|
510
|
+
|
|
511
|
+
Files changed: 23
|
|
512
|
+
+ 8 new files
|
|
513
|
+
~ 12 modified files
|
|
514
|
+
- 3 deleted files
|
|
515
|
+
|
|
516
|
+
Key changes:
|
|
517
|
+
• New payment system (src/payments/*)
|
|
518
|
+
• Auth module refactored
|
|
519
|
+
• Bug fixes in user validation
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
### Step 3.3: Read and Understand
|
|
523
|
+
|
|
524
|
+
**Claude reads the actual changes (not just filenames):**
|
|
525
|
+
|
|
526
|
+
```bash
|
|
527
|
+
# Read new files entirely
|
|
528
|
+
for f in $(git diff --name-only --diff-filter=A HEAD...origin/$mainBranch); do
|
|
529
|
+
git show origin/$mainBranch:$f
|
|
530
|
+
done
|
|
531
|
+
|
|
532
|
+
# Read diffs for modified files
|
|
533
|
+
git diff HEAD...origin/$mainBranch
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
**Build context:**
|
|
537
|
+
- What new features were added?
|
|
538
|
+
- What bugs were fixed?
|
|
539
|
+
- What was refactored and why?
|
|
540
|
+
- What was deleted and why?
|
|
541
|
+
|
|
542
|
+
### Step 3.4: Rebuild Locally
|
|
543
|
+
|
|
544
|
+
Instead of rebasing, Claude:
|
|
545
|
+
|
|
546
|
+
1. **Creates new files** based on understanding (not copy-paste)
|
|
547
|
+
2. **Applies fixes** to your branch's version of files
|
|
548
|
+
3. **Incorporates refactors** that make sense in your context
|
|
549
|
+
4. **Skips changes** that conflict with your work (notes them)
|
|
550
|
+
|
|
551
|
+
```
|
|
552
|
+
─────────────────────────────────────────────────────
|
|
553
|
+
INTEGRATING CHANGES
|
|
554
|
+
─────────────────────────────────────────────────────
|
|
555
|
+
|
|
556
|
+
Reading main's changes...
|
|
557
|
+
|
|
558
|
+
✓ New: src/payments/processor.ts
|
|
559
|
+
→ Created in your branch (adapted to your patterns)
|
|
560
|
+
|
|
561
|
+
✓ Fix: src/api/users.ts - validation bug
|
|
562
|
+
→ Applied fix to your version
|
|
563
|
+
|
|
564
|
+
✓ Refactor: src/auth/login.ts
|
|
565
|
+
→ Incorporated improvements
|
|
566
|
+
|
|
567
|
+
⚠ Skipped: src/api/orders.ts
|
|
568
|
+
→ Conflicts with your changes (noted for manual review)
|
|
569
|
+
|
|
570
|
+
─────────────────────────────────────────────────────
|
|
571
|
+
|
|
572
|
+
Integrated 11 of 12 changes.
|
|
573
|
+
1 change skipped (see .planning/INTEGRATION-NOTES.md)
|
|
574
|
+
|
|
575
|
+
Commit these changes? (Y/n): _
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
### Step 3.5: Commit Integration
|
|
579
|
+
|
|
580
|
+
```bash
|
|
581
|
+
git add -A
|
|
582
|
+
git commit -m "integrate: incorporate changes from main (no rebase)
|
|
583
|
+
|
|
584
|
+
Changes integrated:
|
|
585
|
+
- Payment processing system
|
|
586
|
+
- User validation fix
|
|
587
|
+
- Auth module improvements
|
|
588
|
+
|
|
589
|
+
Skipped (manual review needed):
|
|
590
|
+
- src/api/orders.ts (conflicts with current work)"
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
### Step 3.6: Update Sync State
|
|
594
|
+
|
|
595
|
+
```bash
|
|
596
|
+
# Note that we've seen main's changes (even if not fully merged)
|
|
597
|
+
mainHead=$(git rev-parse origin/$mainBranch)
|
|
598
|
+
jq ".lastMainCheck = \"$mainHead\"" .tlc.json > .tlc.json.tmp
|
|
599
|
+
mv .tlc.json.tmp .tlc.json
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
---
|
|
603
|
+
|
|
604
|
+
## Auto-Detection in /tlc
|
|
605
|
+
|
|
606
|
+
The main `/tlc` command should check sync status first:
|
|
607
|
+
|
|
608
|
+
```
|
|
609
|
+
/tlc
|
|
610
|
+
|
|
611
|
+
Checking sync status...
|
|
612
|
+
⚠️ Rebase detected since last sync.
|
|
613
|
+
|
|
614
|
+
Run /tlc:sync to reconcile changes before continuing.
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
This ensures users don't accidentally work on out-of-sync code.
|
|
618
|
+
|
|
619
|
+
---
|
|
620
|
+
|
|
621
|
+
## Configuration Reference
|
|
622
|
+
|
|
623
|
+
Settings managed by `/tlc:sync`:
|
|
624
|
+
|
|
625
|
+
| Setting | First-Time | Post-Rebase |
|
|
626
|
+
|---------|------------|-------------|
|
|
627
|
+
| `lastSync` | Set to current HEAD | Updated after reconciliation |
|
|
628
|
+
| `git.mainBranch` | Asked | Unchanged |
|
|
629
|
+
| `testFrameworks` | Asked | Unchanged |
|
|
630
|
+
| `team` | Asked | Unchanged |
|
|
631
|
+
| `quality` | Asked | Unchanged |
|
|
632
|
+
| `ci` | Asked | Unchanged |
|
|
633
|
+
| `advanced` | Asked | Unchanged |
|
|
634
|
+
|
|
635
|
+
---
|
|
636
|
+
|
|
637
|
+
## Error Handling
|
|
638
|
+
|
|
639
|
+
**No git repository:**
|
|
640
|
+
```
|
|
641
|
+
Error: Not a git repository.
|
|
642
|
+
TLC requires git for sync tracking.
|
|
643
|
+
Run: git init
|
|
644
|
+
```
|
|
645
|
+
|
|
646
|
+
**Uncommitted changes:**
|
|
647
|
+
```
|
|
648
|
+
⚠️ You have uncommitted changes.
|
|
649
|
+
Commit or stash them before syncing.
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
Then stop. Don't offer choices.
|