tlc-claude-code 1.2.5 → 1.2.7

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.
Files changed (4) hide show
  1. package/help.md +9 -0
  2. package/package.json +1 -1
  3. package/sync.md +178 -206
  4. package/tlc.md +37 -25
package/help.md CHANGED
@@ -115,6 +115,8 @@ That's it. `/tlc` handles everything:
115
115
 
116
116
  Rebase detected? → "Run sync? (Y/n)" → Reconcile
117
117
 
118
+ Main ahead? → "Integrate? [1/2]" → Read & rebuild (no rebase)
119
+
118
120
  Already synced? → Dashboard + next actions
119
121
  ```
120
122
 
@@ -125,6 +127,13 @@ git rebase origin/main
125
127
  /tlc ← Detects changes, asks, syncs, continues
126
128
  ```
127
129
 
130
+ **When main is ahead (no rebase):**
131
+ ```
132
+ /tlc ← Detects main ahead, offers to integrate
133
+
134
+ [1] Integrate ← Claude reads changes, rebuilds locally
135
+ ```
136
+
128
137
  ---
129
138
 
130
139
  ## What `/tlc` Does
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tlc-claude-code",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "description": "TLC - Test Led Coding for Claude Code",
5
5
  "bin": {
6
6
  "tlc": "./bin/tlc.js",
package/sync.md CHANGED
@@ -8,6 +8,8 @@ The unified entry point for TLC adoption and codebase synchronization.
8
8
 
9
9
  **Post-rebase:** Detect changes and reconcile incoming code with TLC standards.
10
10
 
11
+ **Main ahead:** Read changes from main, understand context, rebuild locally without rebasing.
12
+
11
13
  ## Usage
12
14
 
13
15
  ```
@@ -16,20 +18,42 @@ The unified entry point for TLC adoption and codebase synchronization.
16
18
 
17
19
  No arguments. TLC auto-detects the scenario.
18
20
 
19
- ## Scenario Detection
21
+ ## CRITICAL: Execution Flow
22
+
23
+ **You MUST detect the scenario FIRST, then execute ONLY that scenario.**
20
24
 
21
25
  ```
22
- Check for .tlc.json:
23
- ├── Not found → First-time adoption
24
- └── FoundCheck for changes
25
- ├── HEAD matches lastSync → Already synced
26
- └── HEAD differs Post-rebase reconciliation
26
+ Step 1: Check for .tlc.json
27
+
28
+ ├── NOT FOUND Execute "Scenario 1: First-Time Adoption" ONLY
29
+
30
+ └── FOUNDStep 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
27
47
  ```
28
48
 
49
+ **DO NOT run multiple scenarios. Pick ONE based on detection.**
50
+
29
51
  ---
30
52
 
31
53
  ## Scenario 1: First-Time Adoption
32
54
 
55
+ **ONLY run this if .tlc.json does NOT exist.**
56
+
33
57
  Complete onboarding questionnaire. All settings in one flow so nothing gets forgotten.
34
58
 
35
59
  ### Step 1.1: Welcome
@@ -293,6 +317,8 @@ Happy testing! 🧪
293
317
 
294
318
  ## Scenario 2: Post-Rebase Reconciliation
295
319
 
320
+ **ONLY run this if .tlc.json EXISTS and HEAD differs from lastSync.**
321
+
296
322
  Detect and handle code changes from rebase.
297
323
 
298
324
  ### Step 2.1: Detect Changes
@@ -358,254 +384,219 @@ Changes detected:
358
384
  Tests for new code: 0 found ⚠️
359
385
  ```
360
386
 
361
- ### Step 2.3: Choose Reconciliation Strategy
387
+ ### Step 2.3: Auto-Sync (Default Behavior)
362
388
 
363
- ```
364
- ─────────────────────────────────────────────────────
365
- RECONCILIATION STRATEGY
366
- ─────────────────────────────────────────────────────
367
-
368
- How should TLC handle the incoming code?
369
-
370
- [1] CONFORM TO TLC (Recommended)
371
- → Analyze incoming code
372
- → Generate tests for new files
373
- → Apply TLC patterns (if needed)
374
- → May modify incoming files
375
-
376
- Best when: You want all code to follow TLC standards
377
-
378
- [2] PRESERVE INCOMING
379
- → Keep incoming code exactly as-is
380
- → Update YOUR existing code to work with it
381
- → Incoming files are untouched
389
+ **DO NOT ask about individual files. Just sync automatically.**
382
390
 
383
- Best when: Incoming code is reviewed/approved,
384
- you just need to integrate
385
-
386
- [3] MANUAL REVIEW
387
- → Show detailed diff
388
- → Let me decide file-by-file
389
-
390
- Best when: Mixed situation, some files need
391
- conforming, others should be preserved
392
-
393
- Choice [1/2/3]: _
394
391
  ```
392
+ Syncing...
395
393
 
396
- ### Step 2.4a: Strategy - Conform to TLC
394
+ Updated lastSync to ${currentHead:0:7}
395
+ ✓ Removed rebase marker (if present)
397
396
 
397
+ Sync complete.
398
398
  ```
399
- ─────────────────────────────────────────────────────
400
- CONFORMING INCOMING CODE TO TLC
401
- ─────────────────────────────────────────────────────
402
-
403
- Analyzing 4 new files...
404
-
405
- src/api/payments.ts
406
- → No tests found
407
- → Generating: tests/api/payments.test.ts
408
- → 6 test cases identified
409
-
410
- src/api/webhooks.ts
411
- → No tests found
412
- → Generating: tests/api/webhooks.test.ts
413
- → 4 test cases identified
414
-
415
- src/services/stripe.ts
416
- → No tests found
417
- → Generating: tests/services/stripe.test.ts
418
- → 8 test cases identified (mocking Stripe API)
419
399
 
420
- src/utils/currency.ts
421
- → No tests found
422
- → Generating: tests/utils/currency.test.ts
423
- → 5 test cases identified
400
+ That's it. The sync just updates the tracking. Tests are written when you run `/tlc:build`.
424
401
 
425
- Analyzing 7 modified files...
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
426
406
 
427
- src/api/users.ts
428
- → Existing tests: tests/api/users.test.ts
429
- → 2 new functions added, need 3 new test cases
430
- → Updating test file
407
+ ### Step 2.4: Optional - Add Tests for Untested Code
431
408
 
432
- src/db/schema.ts
433
- → Existing tests cover changes ✓
409
+ If `.tlc.json` has `existingCode.strategy: "backlog"`, silently note any new untested files:
434
410
 
435
- ...
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)
436
418
 
437
- ─────────────────────────────────────────────────────
438
- PROPOSED CHANGES
439
- ─────────────────────────────────────────────────────
419
+ if [ -n "$newUntested" ]; then
420
+ echo "Note: $(echo "$newUntested" | wc -l) new files added to test backlog"
421
+ fi
422
+ ```
440
423
 
441
- Will create:
442
- + tests/api/payments.test.ts (6 tests)
443
- + tests/api/webhooks.test.ts (4 tests)
444
- + tests/services/stripe.test.ts (8 tests)
445
- + tests/utils/currency.test.ts (5 tests)
424
+ DO NOT ask about them. Just note and continue.
446
425
 
447
- Will update:
448
- ~ tests/api/users.test.ts (+3 tests)
426
+ ### Step 2.6: Update Sync State
449
427
 
450
- Total: 26 new tests
428
+ After sync completes:
451
429
 
452
- Apply changes? (Y/n): _
453
- ```
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
454
435
 
455
- If confirmed, write tests and run them:
436
+ # Remove rebase marker if exists
437
+ rm -f .tlc-rebase-marker
456
438
 
439
+ # Commit the sync
440
+ git add .
441
+ git commit -m "sync: reconcile changes from rebase"
457
442
  ```
458
- Creating tests...
459
443
 
460
- ✓ tests/api/payments.test.ts
461
- Running... 6 passing
444
+ ---
462
445
 
463
- tests/api/webhooks.test.ts
464
- Running... 4 passing
446
+ ## Scenario 3: Integrate Main (No Rebase)
465
447
 
466
- tests/services/stripe.test.ts
467
- Running... 7 passing, 1 failing
448
+ **ONLY run this if main branch is ahead of current branch.**
468
449
 
469
- ⚠️ stripe.test.ts:45 - handleRefund expects different response
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.
470
451
 
471
- Options:
472
- [1] Fix the test (incoming code is correct)
473
- [2] Fix the code (test expectation is correct)
474
- [3] Skip for now (add to backlog)
452
+ ### When to Use This
475
453
 
476
- Choice: _
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
477
458
 
478
- tests/utils/currency.test.ts
479
- Running... 5 passing
459
+ ### Step 3.1: Detect Main Ahead
480
460
 
481
- ✓ tests/api/users.test.ts (updated)
482
- Running... 12 passing
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
+ ```
483
486
 
484
- ─────────────────────────────────────────────────────
487
+ ### Step 3.2: Analyze Main's Changes
485
488
 
486
- Sync complete!
487
- → 25 tests passing
488
- → 1 issue added to backlog
489
- → Committed: "sync: add tests for rebased code"
489
+ If user chooses to integrate:
490
490
 
491
- Updated .tlc.json lastSync to def456
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
492
495
  ```
493
496
 
494
- ### Step 2.4b: Strategy - Preserve Incoming
497
+ Present summary:
495
498
 
496
499
  ```
497
500
  ─────────────────────────────────────────────────────
498
- PRESERVING INCOMING CODE
501
+ CHANGES IN MAIN
499
502
  ─────────────────────────────────────────────────────
500
503
 
501
- Incoming files will NOT be modified.
502
- Checking integration points...
503
-
504
- Analyzing impact on existing TLC code...
504
+ 12 commits to integrate:
505
505
 
506
- src/api/users.ts (incoming) affects:
507
- tests/api/users.test.ts (yours)
508
- 3 tests now failing due to API changes
506
+ abc1234 feat: add payment processing
507
+ def5678 fix: user validation bug
508
+ ghi9012 refactor: cleanup auth module
509
+ ...
509
510
 
510
- src/db/schema.ts (incoming) affects:
511
- tests/db/schema.test.ts (yours)
512
- 1 test failing - new required field
513
- src/api/auth.ts (yours)
514
- Type error - User type changed
511
+ Files changed: 23
512
+ + 8 new files
513
+ ~ 12 modified files
514
+ - 3 deleted files
515
515
 
516
- ─────────────────────────────────────────────────────
517
- REQUIRED UPDATES TO YOUR CODE
518
- ─────────────────────────────────────────────────────
519
-
520
- To integrate incoming changes, TLC needs to update:
521
-
522
- tests/api/users.test.ts
523
- → Update 3 test expectations to match new API
524
-
525
- tests/db/schema.test.ts
526
- → Add required field to test fixtures
516
+ Key changes:
517
+ New payment system (src/payments/*)
518
+ • Auth module refactored
519
+ • Bug fixes in user validation
520
+ ```
527
521
 
528
- src/api/auth.ts
529
- → Update User type usage (line 45, 67)
522
+ ### Step 3.3: Read and Understand
530
523
 
531
- Apply updates? (Y/n): _
532
- ```
524
+ **Claude reads the actual changes (not just filenames):**
533
525
 
534
- If confirmed:
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
535
531
 
532
+ # Read diffs for modified files
533
+ git diff HEAD...origin/$mainBranch
536
534
  ```
537
- Updating your code to integrate...
538
-
539
- ✓ tests/api/users.test.ts - 3 expectations updated
540
- ✓ tests/db/schema.test.ts - fixture updated
541
- ✓ src/api/auth.ts - type usage fixed
542
535
 
543
- Running all tests...
544
- 47 passing
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?
545
541
 
546
- Sync complete!
547
- → Incoming code preserved
548
- → Your code updated to integrate
549
- → Committed: "sync: integrate rebased changes"
542
+ ### Step 3.4: Rebuild Locally
550
543
 
551
- Updated .tlc.json lastSync to def456
552
- ```
544
+ Instead of rebasing, Claude:
553
545
 
554
- ### Step 2.4c: Strategy - Manual Review
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)
555
550
 
556
551
  ```
557
552
  ─────────────────────────────────────────────────────
558
- MANUAL FILE-BY-FILE REVIEW
553
+ INTEGRATING CHANGES
559
554
  ─────────────────────────────────────────────────────
560
555
 
561
- Review each changed file:
556
+ Reading main's changes...
562
557
 
563
- [1/4] src/api/payments.ts (NEW)
558
+ New: src/payments/processor.ts
559
+ → Created in your branch (adapted to your patterns)
564
560
 
565
- No tests. 142 lines. Payment processing logic.
561
+ Fix: src/api/users.ts - validation bug
562
+ → Applied fix to your version
566
563
 
567
- Action:
568
- [C] Conform - generate tests
569
- [P] Preserve - add to backlog for later
570
- [S] Skip - ignore this file
564
+ ✓ Refactor: src/auth/login.ts
565
+ Incorporated improvements
571
566
 
572
- Choice: _
567
+ ⚠ Skipped: src/api/orders.ts
568
+ → Conflicts with your changes (noted for manual review)
573
569
 
574
- [2/4] src/api/webhooks.ts (NEW)
575
- ...
570
+ ─────────────────────────────────────────────────────
576
571
 
577
- [3/4] src/api/users.ts (MODIFIED)
572
+ Integrated 11 of 12 changes.
573
+ 1 change skipped (see .planning/INTEGRATION-NOTES.md)
578
574
 
579
- Changes: +45 lines, -12 lines
580
- 2 new functions: updateProfile, deleteAccount
575
+ Commit these changes? (Y/n): _
576
+ ```
581
577
 
582
- Existing tests: tests/api/users.test.ts
583
- Tests affected: 3 failing
578
+ ### Step 3.5: Commit Integration
584
579
 
585
- Action:
586
- [C] Conform - update tests for new behavior
587
- [P] Preserve - update your code to match
588
- [V] View diff
580
+ ```bash
581
+ git add -A
582
+ git commit -m "integrate: incorporate changes from main (no rebase)
589
583
 
590
- Choice: _
591
- ```
584
+ Changes integrated:
585
+ - Payment processing system
586
+ - User validation fix
587
+ - Auth module improvements
592
588
 
593
- ### Step 2.5: Update Sync State
589
+ Skipped (manual review needed):
590
+ - src/api/orders.ts (conflicts with current work)"
591
+ ```
594
592
 
595
- After any strategy completes:
593
+ ### Step 3.6: Update Sync State
596
594
 
597
595
  ```bash
598
- # Update lastSync in .tlc.json
599
- currentHead=$(git rev-parse HEAD)
600
- jq ".lastSync = \"$currentHead\"" .tlc.json > .tlc.json.tmp
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
601
599
  mv .tlc.json.tmp .tlc.json
602
-
603
- # Remove rebase marker if exists
604
- rm -f .tlc-rebase-marker
605
-
606
- # Commit the sync
607
- git add .
608
- git commit -m "sync: reconcile changes from rebase"
609
600
  ```
610
601
 
611
602
  ---
@@ -655,26 +646,7 @@ Run: git init
655
646
  **Uncommitted changes:**
656
647
  ```
657
648
  ⚠️ You have uncommitted changes.
658
-
659
- TLC sync works best with a clean working tree.
660
- Options:
661
- [1] Stash changes, sync, then restore
662
- [2] Commit changes first
663
- [3] Continue anyway (not recommended)
664
-
665
- Choice: _
649
+ Commit or stash them before syncing.
666
650
  ```
667
651
 
668
- **Merge conflicts during reconciliation:**
669
- ```
670
- ⚠️ Conflict in tests/api/users.test.ts
671
-
672
- The incoming code and your tests have conflicting changes.
673
-
674
- Options:
675
- [1] Keep yours (incoming tests discarded)
676
- [2] Keep theirs (your tests replaced)
677
- [3] Open in editor to resolve manually
678
-
679
- Choice: _
680
- ```
652
+ Then stop. Don't offer choices.
package/tlc.md CHANGED
@@ -34,57 +34,69 @@ if [ ! -f ".tlc.json" ]; then
34
34
  echo "This configures test framework, team settings, quality gates, and more."
35
35
  echo ""
36
36
  echo "Run setup now? (Y/n)"
37
- # If yes → Run /tlc:sync inline (first-time flow)
37
+ # If yes → Run sync.md "Scenario 1: First-Time Adoption" ONLY
38
+ # DO NOT run Scenario 2
38
39
  # Then continue to Step 1
40
+ exit # Don't fall through to other checks
39
41
  fi
40
42
 
41
- # Check for rebase marker
42
- if [ -f ".tlc-rebase-marker" ]; then
43
- echo "⚠️ Rebase detected since last sync."
44
- echo ""
45
- echo "TLC needs to reconcile incoming changes."
46
- echo "This ensures new code meets TLC standards."
47
- echo ""
48
- echo "Run sync now? (Y/n)"
49
- # If yes → Run /tlc:sync inline (post-rebase flow)
50
- # Then continue to Step 1
51
- fi
52
-
53
- # Check if HEAD matches lastSync
43
+ # .tlc.json exists - check sync state
54
44
  lastSync=$(jq -r '.lastSync // ""' .tlc.json)
55
45
  currentHead=$(git rev-parse HEAD 2>/dev/null)
56
46
 
57
- # If lastSync missing, initialize it (existing config, first sync tracking)
47
+ # If lastSync missing, initialize it
58
48
  if [ -z "$lastSync" ]; then
59
49
  echo "Initializing sync tracking..."
60
- # Update .tlc.json with current HEAD as lastSync
61
50
  jq ".lastSync = \"$currentHead\"" .tlc.json > .tlc.json.tmp && mv .tlc.json.tmp .tlc.json
62
51
  echo "✓ Synced (initialized to ${currentHead:0:7})"
63
- # Continue to Step 1
52
+ # Continue to Step 1 - NO sync needed
64
53
  fi
65
54
 
66
- if [ -n "$lastSync" ] && [ "$lastSync" != "$currentHead" ]; then
55
+ # Check for rebase marker OR HEAD mismatch
56
+ if [ -f ".tlc-rebase-marker" ] || [ "$lastSync" != "$currentHead" ]; then
67
57
  echo "⚠️ Codebase changed since last sync."
68
58
  echo " Last sync: ${lastSync:0:7}"
69
59
  echo " Current: ${currentHead:0:7}"
70
- echo ""
71
60
  changedCount=$(git diff --name-only $lastSync $currentHead 2>/dev/null | wc -l)
72
61
  echo " $changedCount files changed"
73
62
  echo ""
74
63
  echo "Run sync now? (Y/n)"
75
- # If yes → Run /tlc:sync inline (post-rebase flow)
64
+ # If yes → Run sync.md "Scenario 2: Post-Rebase Reconciliation" ONLY
65
+ # DO NOT run Scenario 1 (no questionnaire!)
76
66
  # Then continue to Step 1
67
+ exit # Don't fall through to main-ahead check
68
+ fi
69
+
70
+ # Check if main is ahead of current branch
71
+ mainBranch=$(jq -r '.git.mainBranch // "main"' .tlc.json)
72
+ git fetch origin $mainBranch 2>/dev/null
73
+ behindCount=$(git rev-list HEAD..origin/$mainBranch --count 2>/dev/null)
74
+
75
+ if [ "$behindCount" -gt 0 ]; then
76
+ echo "⚠️ Main branch is $behindCount commits ahead."
77
+ echo ""
78
+ echo "Options:"
79
+ echo " [1] Integrate changes (read & rebuild without rebase)"
80
+ echo " [2] Skip for now"
81
+ echo ""
82
+ # If 1 → Run sync.md "Scenario 3: Integrate Main" ONLY
83
+ # If 2 → Continue to dashboard
77
84
  fi
78
85
 
79
86
  # If we get here, sync is current
80
87
  echo "✓ Synced"
81
88
  ```
82
89
 
83
- **Key behavior:**
84
- - Detects if sync needed
85
- - Asks for confirmation
86
- - Runs sync flow inline (not separate command)
87
- - Then continues to dashboard/status
90
+ **CRITICAL - Which sync scenario to run:**
91
+
92
+ | Condition | Action |
93
+ |-----------|--------|
94
+ | No `.tlc.json` | Run sync.md **Scenario 1** (questionnaire) |
95
+ | `.tlc.json` exists, HEAD changed | Run sync.md **Scenario 2** (reconciliation only, NO questionnaire) |
96
+ | Main is ahead of current branch | Run sync.md **Scenario 3** (integrate without rebase) |
97
+ | `.tlc.json` exists, all synced | Already synced, skip to dashboard |
98
+
99
+ **The questionnaire ONLY runs on first-time setup, NEVER after rebase or integrate.**
88
100
 
89
101
  User never needs to know about `/tlc:sync` as a separate command - `/tlc` handles everything.
90
102