Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .claude/commands/worktree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Worktree Management

You have access to the `wt` CLI tool for managing git worktrees.

## Common Commands

- `wt new <branch> -c` — Create new worktree (create branch if needed)
- `wt setup <branch> -c` — Create worktree + run setup scripts
- `wt status` — Show status of all worktrees (clean/dirty, ahead/behind)
- `wt list` — List all worktrees
- `wt remove <branch>` — Remove a worktree
- `wt merge <branch> --auto-commit --remove` — Merge and cleanup
- `wt pr <number> --setup` — Create worktree from PR/MR

## Workflow for Parallel Tasks

When asked to work on multiple tasks in parallel:

1. Create a worktree for each task: `wt setup feature/<task-name> -c`
2. Note the paths returned
3. Work in each worktree directory independently
4. Check status: `wt status`
5. When complete, merge back: `wt merge feature/<task-name> --auto-commit`

## Configuration

This project has trust mode enabled (no confirmation prompts) and uses subfolder organization for worktrees.

**User Request:** $ARGUMENTS

299 changes: 299 additions & 0 deletions CHANGELOG-SESSION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,299 @@
# Session Changelog - December 23, 2025

This document summarizes all changes made during the Claude Code enhancement session.

## Overview

This session focused on enhancing the `@johnlindquist/worktree-cli` tool to better support AI-assisted parallel development workflows, specifically for integration with Claude Code and Cursor.

---

## Major Changes

### 1. Merged PR #35: Trust and Subfolder Configuration ✅

**Branch:** `feature/claude-code-enhancements`

**What was merged:**
- Added `trust` config option to skip setup command confirmations
- Added `subfolder` config option to organize worktrees in subdirectories
- Updated TUI logic to respect global trust configuration

**Commands added:**
```bash
wt config set trust true/false
wt config set subfolder true/false
```

**Impact:**
- Enables headless automation for CI/CD and AI agents
- Provides cleaner project organization
- Essential for Claude Code integration

---

### 2. Implemented `wt status` Command ✅

**New file:** `src/commands/status.ts`

**Features:**
- Shows all worktrees with comprehensive status information
- Git working tree status (clean/dirty)
- Upstream tracking status (ahead/behind)
- Branch information and indicators
- Handles edge cases (detached HEAD, bare repos, missing directories)

**Example output:**
```bash
$ wt status
Worktree Status:

main → /Users/me/projects/myapp [main] [clean] [up-to-date]
feature/auth → /Users/me/projects/myapp-worktrees/feature-auth [dirty] [ahead 2]
feature/api → /Users/me/projects/myapp-worktrees/feature-api [clean] [no upstream]
```

**Status indicators:**
- `[main]` - Main worktree
- `[clean]` / `[dirty]` - Working tree status
- `[up-to-date]` - In sync with upstream
- `[ahead N]` - N commits ahead
- `[behind N]` - N commits behind
- `[ahead N, behind M]` - Diverged
- `[no upstream]` - No tracking branch
- `[locked]` - Worktree is locked

---

### 3. Created Claude Code Slash Command ✅

**New file:** `.claude/commands/worktree.md`

**Purpose:**
- Provides quick reference for `wt` commands in Claude Code
- Defines workflow for parallel task management
- Enables natural language worktree operations

**Usage:**
```
/worktree create three parallel features for authentication, UI, and API
```

---

### 4. Documentation Updates ✅

**Updated:** `README.md`
- Added new features to feature list
- Documented `wt status` command with examples
- Added trust mode configuration section
- Added subfolder mode configuration section
- Added AI Assistant Integration section
- Added link to Quick Start Guide

**Created:** `QUICKSTART.md`
- Comprehensive quick start guide
- Common scenarios with practical examples
- Configuration for AI assistants
- Advanced workflows
- Troubleshooting section
- Quick reference card

---

## Test Fixes

### Fixed Test Failures ✅

**Issue:** Tests were failing due to `master` vs `main` branch naming

**Files modified:**
- `test/git-utils.test.ts`
- `test/integration.test.ts`

**Fix:** Added explicit `git config init.defaultBranch main` in test repository setup

**Issue:** TUI tests failing after PR #35 merge due to global trust configuration

**File modified:**
- `test/tui.test.ts`

**Fix:** Mocked `config` module to isolate tests from global configuration

### New Tests Added ✅

**New file:** `test/status.test.ts`

**Coverage:**
- Main worktree status display
- Dirty worktree detection
- Multiple worktrees
- Detached HEAD state
- Locked status
- No upstream branch handling

**Result:** 6 new passing tests

---

## Test Results

### Baseline Tests
- **Before changes:** 104 tests passing
- **After PR #35 merge:** 104 tests passing (after fixes)
- **After status implementation:** 110 tests passing
- **Final:** 110 tests passing

### Coverage
All new functionality is covered by unit tests with comprehensive mocking.

---

## End-to-End Testing ✅

**Tested workflows:**
1. Configuration changes (`trust` and `subfolder` modes)
2. Worktree creation with subfolder organization
3. Status command with clean and dirty worktrees
4. Merge with auto-commit and removal
5. Full workflow: create → modify → status → merge → cleanup

**Results:** All workflows functioning as expected

---

## Configuration Changes

### Recommended Settings for AI Workflows

```bash
wt config set editor none # Headless operation
wt config set trust true # Skip confirmations
wt config set subfolder true # Organized directories
```

### Config File Location
`~/.config/worktree-cli/config.json`

---

## File Structure Changes

### New Files
```
.claude/
└── commands/
└── worktree.md # Claude Code slash command

src/
└── commands/
└── status.ts # Status command implementation

test/
└── status.test.ts # Status command tests

QUICKSTART.md # Quick start guide
CHANGELOG-SESSION.md # This file
```

### Modified Files
```
src/index.ts # Registered status command
test/git-utils.test.ts # Fixed branch naming
test/integration.test.ts # Fixed branch naming and bare repo test
test/tui.test.ts # Added config mocking
README.md # Updated documentation
```

---

## Git History

### Commits Made

1. Initial baseline testing and fixes
2. Merged PR #35 (trust + subfolder config)
3. Implemented `wt status` command
4. Added tests for status command
5. Created Claude Code slash command
6. Updated documentation
7. End-to-end testing cleanup

### Branch
`feature/claude-code-enhancements`

---

## Integration Points

### Claude Code
- Custom slash command at `.claude/commands/worktree.md`
- Headless operation support via `editor: none`
- Trust mode for non-interactive execution

### Cursor
- Compatible with Cursor's parallel agents feature
- Setup scripts via `.cursor/worktrees.json`
- Organized worktree structure

### CI/CD
- Trust mode enables automated workflows
- No interactive prompts when configured
- Atomic operations with rollback

---

## Performance

- No performance regressions detected
- All tests pass in reasonable time
- Git operations remain efficient

---

## Breaking Changes

**None.** All changes are backward compatible:
- New config options default to `false`
- New `status` command is additive
- Existing commands unchanged

---

## Future Enhancements

### Potential Next Steps
1. Agent ID generation for parallel agent coordination
2. Automatic CLAUDE.md copying to new worktrees
3. `wt clone` command for bare repo + initial worktree setup
4. `wt sync` command to fetch + rebase all worktrees
5. Better GitLab parity testing

### Community Feedback
Consider gathering feedback on:
- Subfolder naming convention (`repo-worktrees` vs `repo-wt` vs `.worktrees`)
- Status output format preferences
- Additional status indicators needed

---

## Known Issues

**None identified.** All tests passing, end-to-end testing successful.

---

## Acknowledgments

- Original repository: `@johnlindquist/worktree-cli`
- PR #35 author for trust and subfolder modes
- Cursor team for parallel agents inspiration

---

**Session completed:** December 23, 2025
**Total duration:** ~2 hours
**Tests passing:** 110/110
**New features:** 3 (trust mode, subfolder mode, status command)
**Documentation:** Comprehensive updates to README and new QUICKSTART guide

Loading