Skip to content

Conversation

@cebidhem
Copy link
Owner

@cebidhem cebidhem commented Oct 1, 2025

Summary

This PR adds Claude integration to git-worktree-cli and modernizes the CLI interface by removing the --mode flag in favor of standalone flags.

Breaking Changes

⚠️ The --mode flag has been removed

  • Use --ide <editor> instead of --mode ide --ide <editor>
  • The --mode terminal option has been replaced with new functionality

New Features

  • 🤖 Claude Integration: New --claude flag to automatically start Claude sessions in new worktrees
  • 📁 Claude Settings: Automatically copies .claude/settings.local.json from repo root to new worktrees
  • 🐧 Extended Linux Support: Added support for gnome-terminal, konsole, xfce4-terminal, and xterm
  • 🎯 Simplified CLI: Cleaner interface with standalone --ide and --claude flags

Changes

CLI Interface

  • Removed Mode enum and --mode flag
  • Added standalone --ide flag for opening worktrees in IDEs
  • Added --claude flag for starting Claude sessions
  • Made --ide and --claude mutually exclusive

Functionality

  • copy_claude_settings(): Copies Claude settings to new worktrees if they exist
  • launch_claude(): Opens terminal and starts Claude session
  • Extended _launch_iterm2() to support running commands after cd
  • Added _launch_linux_terminal() with support for multiple terminal emulators

Tests

  • Updated all CLI tests for new interface
  • Added tests for --claude flag and mutual exclusivity
  • Added launcher tests for Claude functionality
  • All 52 tests passing ✅

Other

  • Added MIT License

Migration Guide

Before:

wt create feature-x --mode ide --ide code
wt create feature-x --mode terminal

After:

wt create feature-x --ide code
wt create feature-x --claude

Test Plan

  • All existing tests updated and passing
  • New tests for Claude functionality added
  • Black formatting applied
  • Pylint score: 10.00/10
  • Signed commits with conventional commit format

- Remove Mode enum and --mode flag from CLI
- Add standalone --ide flag to open worktree in specified IDE
- Add --claude flag to automatically start Claude session
- Make --ide and --claude mutually exclusive
- Add copy_claude_settings() to copy .claude/settings.local.json to new worktrees
- Add launch_claude() function to start Claude in terminal
- Extend Linux support for terminal launching (gnome-terminal, konsole, xfce4-terminal, xterm)
- Update all tests to reflect new CLI interface
- Remove handle_mode() function

BREAKING CHANGE: The --mode flag has been removed. Use --ide for IDE launching instead of --mode ide. The --mode terminal option has been replaced with separate functionality.
Copilot AI review requested due to automatic review settings October 1, 2025 14:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds Claude integration to git-worktree-cli and removes the --mode flag in favor of cleaner standalone flags, representing a breaking change to the CLI interface.

  • Added Claude integration with automatic settings copying and session launching
  • Removed --mode enum and replaced with --ide and --claude standalone flags
  • Extended Linux terminal support and improved cross-platform functionality

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
wt/worktree.py Added copy_claude_settings() function and integrated it into worktree creation
wt/launchers.py Added Claude support, extended Linux terminal support, and refactored mode handling
wt/cli.py Removed Mode enum and --mode flag, added --claude flag with mutual exclusivity
tests/test_worktree.py Updated tests to mock new Claude settings functionality
tests/test_launchers.py Replaced mode tests with Claude-specific tests and added Linux terminal tests
tests/test_cli.py Updated CLI tests for new flag structure and mutual exclusivity
specs/ez-leaf.md Removed project specification file
LICENSE Added MIT License

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

- Import shlex module for proper shell escaping
- Use shlex.quote() for worktree_path in all terminal commands
- Use shlex.quote() for command parameter in terminal launchers
- Properly escape AppleScript strings to prevent injection
- Fixes security issues identified by GitHub Copilot review

This prevents command injection if worktree paths contain special
characters like spaces, quotes, semicolons, or other shell metacharacters.
@cebidhem cebidhem requested a review from Copilot October 1, 2025 15:55
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

- Update comment to reflect generic command parameter (not just 'claude')
- Standardize xfce4-terminal argument passing to match other terminals
- Pass arguments as separate list items instead of manual string construction

Addresses GitHub Copilot review feedback for better maintainability.
@cebidhem cebidhem requested a review from Copilot October 1, 2025 16:03
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

iTerm2's 'write text' types command literally into the terminal shell.
Quoting the command with shlex.quote() causes it to be typed as 'claude'
(with quotes) which the shell won't execute properly.

Since the command value is controlled by our code (always 'claude'),
not user input, it's safe to pass it unquoted. The path is still properly
quoted for security.

Fixes GitHub Copilot review comment about double-quoting on line 93.
@cebidhem cebidhem requested a review from Copilot October 1, 2025 16:15
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Replace brittle str(call) checks with explicit call.args[0] access.
This makes assertions less dependent on internal call object representation
and more directly verify the actual arguments passed to mocked functions.

Applied consistently across all error message verification tests.

Addresses GitHub Copilot review feedback on test quality.
@cebidhem cebidhem merged commit b6045be into main Oct 1, 2025
2 checks passed
@cebidhem cebidhem deleted the feature/claude-integration branch October 1, 2025 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants