Skip to content

feat: add --editor and --ai flags to new command #72

Merged
helizaga merged 3 commits intomainfrom
feat/new-editor-ai-flags
Jan 6, 2026
Merged

feat: add --editor and --ai flags to new command #72
helizaga merged 3 commits intomainfrom
feat/new-editor-ai-flags

Conversation

@helizaga
Copy link
Collaborator

@helizaga helizaga commented Jan 6, 2026

Pull Request

Description

Motivation

Fixes # (issue)

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring (no functional changes)
  • Other (please describe):

Testing

Manual Testing Checklist

Tested on:

  • macOS
  • Linux (specify distro: **_**)
  • Windows (Git Bash)

Core functionality tested:

  • git gtr new <branch> - Create worktree
  • git gtr go <branch> - Navigate to worktree
  • git gtr editor <branch> - Open in editor (if applicable)
  • git gtr ai <branch> - Start AI tool (if applicable)
  • git gtr rm <branch> - Remove worktree
  • git gtr list - List worktrees
  • git gtr config - Configuration commands (if applicable)
  • Other commands affected by this change: **__**

Test Steps

Expected behavior:

Actual behavior:

Breaking Changes

  • This PR introduces breaking changes
  • I have discussed this in an issue first
  • Migration guide is included in documentation

Checklist

Before submitting this PR, please check:

  • I have read CONTRIBUTING.md
  • My code follows the project's style guidelines
  • I have performed manual testing on at least one platform
  • I have updated documentation (README.md, CLAUDE.md, etc.) if needed
  • My changes work on multiple platforms (or I've noted platform-specific behavior)
  • I have added/updated shell completions (if adding new commands or flags)
  • I have tested with both git gtr (production) and ./bin/gtr (development)
  • No new external dependencies are introduced (Bash + git only)
  • All existing functionality still works

Additional Context


License Acknowledgment

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache License 2.0.

Summary by CodeRabbit

  • New Features

    • Added --editor (-e) flag to open newly created worktrees in your configured editor.
    • Added --ai (-a) flag to launch your configured AI tool in newly created worktrees.
    • "Next steps" is now conditional when editor/AI auto-launch is used.
  • Documentation

    • Streamlined README with quick-start commands and editor/AI integration options.
    • Added comprehensive guides: Advanced Usage, Configuration Reference, and Troubleshooting.

✏️ Tip: You can customize this high-level summary in your review settings.

…tation

- Enhanced README with new sections including Table of Contents, Shell Completions, and License.
- Introduced new documentation files for advanced usage, configuration reference, and troubleshooting to provide comprehensive guidance for users.
@helizaga helizaga requested a review from NatoBoram as a code owner January 6, 2026 18:15
@coderabbitai
Copy link

coderabbitai bot commented Jan 6, 2026

Walkthrough

Adds --editor (-e) and --ai (-a) flags to the gtr create flow to optionally auto-open an editor or start an AI tool after worktree creation. Updates README (badges, TOC, streamlined content) and adds comprehensive docs (configuration, advanced usage, troubleshooting). Shell completions extended for new flags.

Changes

Cohort / File(s) Summary
Feature Implementation: Editor & AI Integration
bin/gtr
Adds --editor (-e) and --ai (-a) flags to the create command; introduces local flags open_editor and start_ai; conditionally loads configured editor/AI adapters and launches the tool in the new worktree; suppresses the default "Next steps" block when either flag is used; updates CLI help text.
Shell Completions
completions/_git-gtr, completions/git-gtr.fish, completions/gtr.bash
Adds short and long-form completions for --editor/-e and --ai/-a across completion scripts (Fish and Bash) and updates the new command's completion option list.
Documentation: README & Consolidation
README.md
Replaces header with badges and TOC, reforms narrative and feature list, adds quick-start lines including --editor/--ai flags, removes many in-repo tutorials and redirects to external docs; simplifies licensing and contributing pointers.
New Docs: Advanced Usage
docs/advanced-usage.md
Adds an advanced usage guide covering multi-branch/multi-repo workflows, CI/CD integration, custom workflows, multi-worktree handling, and parallel AI development with examples and notes.
New Docs: Configuration Reference
docs/configuration.md
Adds comprehensive configuration reference detailing sources, precedence, editor/AI tool settings, hooks, copy behavior, examples, and environment variables.
New Docs: Troubleshooting Guide
docs/troubleshooting.md
Adds troubleshooting guidance with checklists and diagnostics for installation, worktree creation, editor integration, copying, platform support, and reliability topics.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI as gtr CLI
    participant Worktree as Worktree Creator
    participant EditorAdapter as Editor Adapter
    participant AIAdapter as AI Adapter
    participant Tool as External Tool

    User->>CLI: gtr create [args] (--editor / --ai / none)
    CLI->>Worktree: create worktree at path
    Worktree-->>CLI: created

    alt --editor flag present
        rect rgb(240,248,255)
        note over CLI,EditorAdapter: Load editor adapter (configured or fallback)
        CLI->>EditorAdapter: load & open path
        EditorAdapter->>Tool: launch editor with worktree path
        Tool-->>User: editor opened
        end
    else --ai flag present
        rect rgb(255,240,245)
        note over CLI,AIAdapter: Load AI adapter (configured or warn)
        CLI->>AIAdapter: load & start in path
        AIAdapter->>Tool: start AI tool for worktree
        Tool-->>User: AI tool started
        end
    else neither flag
        rect rgb(245,245,220)
        CLI-->>User: print "Next steps" guidance
        end
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 Flags twitch, new doors ajar,
I hop and open editor-star,
AI hums where worktrees lay,
Docs tucked tidy, guides at play,
Nibble, sprint, then celebrate! 🎉

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding --editor and --ai flags to the new command. It directly corresponds to the primary modifications across bin/gtr, completion files, and related documentation.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/new-editor-ai-flags

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 98da845 and 2abed13.

📒 Files selected for processing (2)
  • README.md
  • docs/configuration.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/configuration.md
🧰 Additional context used
📓 Path-based instructions (1)
README.md

📄 CodeRabbit inference engine (CLAUDE.md)

README.md: Update README.md with installation/setup instructions when adding a new editor adapter
Update README.md with installation instructions and use cases when adding a new AI tool adapter

Files:

  • README.md
🔇 Additional comments (9)
README.md (9)

3-6: Well-structured header with appropriate badges.

The badges clearly communicate the project's license, language, minimum requirements, and platform support. Good addition for discoverability.


12-26: Table of Contents improves navigation.

Clear organization with all major sections represented. Ensures readers can quickly find relevant information.


92-94: New flag examples in Quick Start are well-placed.

Examples clearly demonstrate the --editor, --ai, and combined usage patterns in practical workflow context. Short forms (-e, -a) are properly introduced.


115-125: Comparison table gain demonstrates new feature value.

Adding the "Create + open" row with --editor support strengthens the value proposition against native git worktree.


130-139: Features section is clean and consistent.

Uniform bullet formatting improves readability. All new functionality (editor integration, AI tool support, shell completions) is clearly listed.


172-173: New flags properly documented in command reference.

--editor/-e and --ai/-a are clearly listed with descriptions matching Quick Start and Daily workflow sections.


275-279: Configuration setup examples are practical and clear.

Shows users how to set editor and AI tool defaults. However, verify that installation instructions for individual editors and AI tools are documented elsewhere (e.g., external docs).

As per the coding guidelines, the README should include installation/setup instructions when adding new editor and AI tool adapters. Please confirm that these installation instructions are documented in the referenced external documentation (docs/configuration.md) or elsewhere in the repository. If not provided, consider adding a subsection with links to installation guides for common editors (Cursor, VS Code, Zed) and AI tools (Aider, Claude, etc.).


278-278: No changes needed — the AI tool list in line 278 is accurate and exhaustive.

The list (aider, claude, codex, continue, copilot, cursor, gemini, opencode) matches all implemented adapters in adapters/ai/. Codeium is correctly positioned as a wanted future contribution in the Contributing section (line ~370), not as a currently supported tool.


312-312: All external documentation files are present and comprehensive.

The three external documentation files referenced in README.md exist and contain the promised content:

  • docs/configuration.md (402 lines) covers configuration details, hooks, file copying patterns, and shell completions setup as referenced in lines 312 and 339
  • docs/advanced-usage.md (203 lines) covers advanced workflows and multiple repository scenarios as referenced in line 363
  • docs/troubleshooting.md (242 lines) covers troubleshooting, platform-specific guidance, and architecture details as referenced in line 351

No issues found.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI Agents
In @docs/configuration.md:
- Around line 122-136: The table is missing the Copilot adapter; add a row for
"Copilot" matching the other entries using the adapter name/key "copilot" and
reference the adapter script "copilot.sh" from adapters/ai; include an Install
hint (e.g., how to obtain or run copilot.sh or a short install command if
applicable), a concise Use Case (e.g., GitHub Copilot CLI integration / AI
coding assistant), and the Set as Default example `git gtr config set
gtr.ai.default copilot` so the docs list all eight adapters consistently.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9c3bf73 and 98da845.

📒 Files selected for processing (8)
  • README.md
  • bin/gtr
  • completions/_git-gtr
  • completions/git-gtr.fish
  • completions/gtr.bash
  • docs/advanced-usage.md
  • docs/configuration.md
  • docs/troubleshooting.md
🧰 Additional context used
📓 Path-based instructions (10)
completions/*

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Shell completion files must be updated for bash, zsh, and fish when commands or adapters are added

Files:

  • completions/gtr.bash
  • completions/_git-gtr
  • completions/git-gtr.fish
completions/{gtr.bash,_git-gtr,gtr.fish}

📄 CodeRabbit inference engine (.github/instructions/completions.instructions.md)

completions/{gtr.bash,_git-gtr,gtr.fish}: Always update all three completion files (gtr.bash, _git-gtr, gtr.fish) when adding new commands, flags, editors, or AI adapters
Implement command completion in all three completion files to support top-level commands (new, rm, editor, ai, list, etc.) with appropriate tab-completion
Implement flag completion in all three completion files to support command-specific flags (e.g., --from, --force, --editor) with appropriate tab-completion
Implement adapter name completion in all three completion files, listing available editor names (cursor, vscode, zed) and AI tool names (aider, claude, codex) for --editor and --ai flags

Files:

  • completions/gtr.bash
  • completions/_git-gtr
completions/gtr.bash

📄 CodeRabbit inference engine (.github/instructions/completions.instructions.md)

completions/gtr.bash: In completions/gtr.bash, implement command completion using COMPREPLY array and compgen filtering for the current word ($cur)
In completions/gtr.bash, support dynamic branch completion using 'git branch --format='%(refname:short)' and include special ID '1' for main repo

Update shell completion files when adding new commands or flags: completions/gtr.bash, completions/_git-gtr, and completions/git-gtr.fish

Files:

  • completions/gtr.bash
**/*.{bash,fish,sh}

📄 CodeRabbit inference engine (.github/instructions/sh.instructions.md)

**/*.{bash,fish,sh}: Bash 3.2+ compatible (macOS default), but 4.0+ features allowed where appropriate
Always quote variables: use "$var" not $var
Use function-scoped variables: local var="value"
Check return codes; functions return 1 on failure
Use snake_case for functions and variables, UPPER_CASE for constants
Prefer [ ] over [[ ]] for POSIX portability; use [[ only when needed
Always quote glob inputs; disable unintended globbing with set -f temporarily if required
Avoid associative arrays in shell scripts; use simple string/loop constructs for Bash 3.2+ compatibility
Avoid readarray and process substitution unsupported in older Bash
Debug with bash -x ./bin/gtr <cmd> or wrap suspicious blocks with set -x / set +x
Check function presence with declare -f create_worktree or declare -f resolve_target
Use stderr for variable inspection: echo "DEBUG var=$var" >&2 to keep stdout clean for command substitution
Keep dependencies minimal: only use git, sed, awk, find, grep; avoid jq/curl unless justified
Check availability of external commands before use when adding new tools
Use "${var}" for variable expansion; for line loops use while IFS= read -r line; do ... done to preserve spaces
Sanitize branch names via sanitize_branch_name function; do NOT duplicate logic elsewhere
Everything is sourced at startup with set -e enabled; functions call each other directly; no subshells except for hooks and AI tools

Files:

  • completions/gtr.bash
  • completions/git-gtr.fish
completions/{gtr.bash,_git-gtr,git-gtr.fish}

📄 CodeRabbit inference engine (CLAUDE.md)

completions/{gtr.bash,_git-gtr,git-gtr.fish}: Update completion files (bash, zsh, fish) to include new editor adapter names when adding a new editor adapter
Update completion files (bash, zsh, fish) to include new AI tool names when adding a new AI tool adapter

Files:

  • completions/gtr.bash
  • completions/_git-gtr
  • completions/git-gtr.fish
bin/gtr

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

bin/gtr: Dispatch commands through cmd_* functions in bin/gtr (case block lines 36‑77)
Update GTR_VERSION on line 8 of bin/gtr when releasing; this affects gtr version / --version output

Global set -e in bin/gtr: guard non-critical commands with || true

list --porcelain output must remain stable for scripting purposes

bin/gtr: Update bin/gtr version constant (GTR_VERSION) when releasing a new version
Update help text in bin/gtr by searching for 'Available editors:' in cmd_help function and load_editor_adapter function when adding a new editor adapter
Update help text in bin/gtr by searching for 'Available AI tools:' in cmd_help function and load_ai_adapter function when adding a new AI tool adapter

Files:

  • bin/gtr
{bin/gtr,lib/**/*.sh,adapters/**/*.sh}

📄 CodeRabbit inference engine (.github/instructions/testing.instructions.md)

{bin/gtr,lib/**/*.sh,adapters/**/*.sh}: All commands must exit 0 (except intentional failures) and produce expected side-effects
No unquoted path errors; spaces must be handled in file paths
Hooks must run only once per creation/removal event

Files:

  • bin/gtr
completions/_git-gtr

📄 CodeRabbit inference engine (.github/instructions/completions.instructions.md)

completions/_git-gtr: In completions/_git-gtr, use Zsh completion framework with _arguments and _describe/_values for sophisticated completion logic with descriptions and grouping
In completions/_git-gtr, support dynamic branch completion using 'git branch --format='%(refname:short)' and include special ID '1' for main repo

Update shell completion files when adding new commands or flags: completions/gtr.bash, completions/_git-gtr, and completions/git-gtr.fish

Files:

  • completions/_git-gtr
completions/git-gtr.fish

📄 CodeRabbit inference engine (CLAUDE.md)

Update shell completion files when adding new commands or flags: completions/gtr.bash, completions/_git-gtr, and completions/git-gtr.fish

Files:

  • completions/git-gtr.fish
README.md

📄 CodeRabbit inference engine (CLAUDE.md)

README.md: Update README.md with installation/setup instructions when adding a new editor adapter
Update README.md with installation instructions and use cases when adding a new AI tool adapter

Files:

  • README.md
🧠 Learnings (1)
📚 Learning: 2025-12-29T18:46:36.983Z
Learnt from: helizaga
Repo: coderabbitai/git-worktree-runner PR: 64
File: bin/gtr:746-750
Timestamp: 2025-12-29T18:46:36.983Z
Learning: When error messages reference missing CLI tools (such as gh for GitHub CLI), use platform-agnostic installation guidance by directing users to the official website (e.g., https://cli.github.com/) instead of platform-specific package managers (brew, apt, choco) to ensure the guidance works across all operating systems. Apply this messaging to the bin/gtr script where applicable.

Applied to files:

  • bin/gtr
🪛 Shellcheck (0.11.0)
completions/gtr.bash

[warning] 62-62: Prefer mapfile or read -a to split command output (or quote to avoid splitting).

(SC2207)

🔇 Additional comments (27)
docs/configuration.md (2)

1-401: Excellent comprehensive documentation!

This configuration reference is well-structured, thorough, and provides clear examples for each setting. The organization with a table of contents, cross-references, and practical examples makes it very user-friendly.


66-66: Template file reference is valid.

The referenced templates/.gtrconfig.example file exists and contains proper configuration examples for users to reference.

docs/troubleshooting.md (2)

1-242: Great troubleshooting resource!

This guide provides practical, command-based solutions for common issues. The platform-specific notes, architecture overview, and transparent discussion of limitations are particularly helpful.


231-231: The git gtr doctor command is properly implemented in bin/gtr with a cmd_doctor() function that performs health checks for git, repository status, editors, and AI tools. The command is registered in all shell completions and documented consistently across the codebase.

completions/_git-gtr (1)

53-57: LGTM! Zsh completion updated correctly.

The new --editor/-e and --ai/-a flags are properly added to the new command completion. The implementation is consistent with the other completion files.

completions/gtr.bash (1)

62-62: LGTM! Bash completion updated correctly.

The new --editor/-e and --ai/-a flags are properly added to the new command completion.

Note: The shellcheck SC2207 warning about using mapfile instead of command substitution is a false positive for this use case. The compgen | COMPREPLY pattern is the standard idiomatic way to implement bash completions and is used consistently throughout this file.

completions/git-gtr.fish (1)

59-60: LGTM! Fish completion updated correctly.

The new --editor/-e and --ai/-a flags are properly added to the new command completion with clear descriptions. All three completion files (bash, zsh, fish) have been updated consistently as required by the coding guidelines.

docs/advanced-usage.md (3)

1-7: LGTM!

Well-structured documentation with clear navigation links and a comprehensive table of contents. The structure aligns with the new features introduced in this PR.


110-130: LGTM!

The CI/CD integration section accurately documents the automation flags available in the CLI, which is helpful for scripting and pipeline integration.


174-200: LGTM!

The Parallel AI Development section provides practical guidance for running multiple AI agents on the same feature branch. The workflow tips for avoiding conflicts are valuable.

bin/gtr (6)

124-125: LGTM!

Variable initialization follows the existing pattern for boolean flags in the function.


162-169: LGTM!

Flag parsing for --editor/-e and --ai/-a follows the existing patterns in the function. The short flags are intuitive and consistent.


299-311: LGTM!

The auto-launch editor logic properly handles the case when no editor is configured by falling back to the file browser. The implementation reuses existing infrastructure (cfg_default, load_editor_adapter, editor_open).


313-324: LGTM!

The auto-launch AI logic appropriately warns when no AI tool is configured (rather than failing hard), providing guidance on how to configure one. This is a sensible UX decision for the shortcut flag.


326-333: LGTM!

The conditional "Next steps" block correctly suppresses the manual workflow hints when auto-launch flags are used, keeping the output clean and relevant.


1402-1403: LGTM!

Help text accurately documents the new flags with appropriate descriptions. The format is consistent with other options in the help output.

README.md (11)

3-6: LGTM!

Badges provide quick visual indicators for license, requirements, and platform support. The version numbers are consistent with the Requirements section.


12-26: LGTM!

Table of Contents provides clear navigation and all linked sections are present in the document.


92-94: LGTM!

New usage examples clearly demonstrate the --editor and --ai flags, including the ability to combine them with short flags -e -a.


118-118: LGTM!

The comparison table effectively highlights the DX improvement of the new --editor flag over the manual multi-command approach.


172-173: LGTM!

Options documentation for --editor/-e and --ai/-a is accurate and consistent with the implementation.


270-312: LGTM!

The configuration section provides a good balance of quick-start examples while deferring comprehensive documentation to the external reference. The .gtrconfig example demonstrates common use cases.


314-339: LGTM!

Shell completion setup instructions are practical and cover the three major shells. The reference to external documentation for detailed setup and troubleshooting is appropriate.


341-351: LGTM!

Platform support table is clear and informative. The Windows notes appropriately set expectations about Git Bash/WSL requirements.


353-363: LGTM!

The advanced usage section appropriately summarizes the available advanced topics and directs readers to the detailed documentation.


365-374: LGTM!

Contributing section clearly identifies areas where help is appreciated and appropriately references the project's contribution guidelines and code of conduct.


382-390: LGTM!

Clean footer with appropriate license reference and issue link for user support.

- Expanded the list of supported AI tools in README and configuration documentation to include GitHub Copilot.
- Updated default AI tool settings to reflect the new options available for users.
@helizaga helizaga merged commit 65a5400 into main Jan 6, 2026
1 check passed
@helizaga helizaga deleted the feat/new-editor-ai-flags branch January 6, 2026 19:06
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.

1 participant