feat: add git worktree discovery support - #42
Merged
Conversation
Add --worktrees and --no-worktrees flags for controlling git worktree discovery behavior: - Default (no flags): worktrees found during normal walk are tagged with IsWorktree metadata but otherwise included as usual - --worktrees: actively discovers worktrees from parent repos' .git/worktrees/ directory, even if they live outside search paths - --no-worktrees: filters out any worktree projects from results Detection works via two paths: - Path A: detects .git files (vs directories) during walk, parses gitdir reference to identify worktree parent - Path B: reads .git/worktrees/ entries from parent repos to discover linked worktrees outside search paths Worktree metadata is exposed in JSON output (isWorktree, worktreeParent), format strings (%w for parent path), and display labels show "(worktree)" suffix. Cache keys include worktree flags to prevent stale results. https://claude.ai/code/session_01136P3sSGSiRns9QuTMRF1q
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
- Add errcheck nolint directive for read-only file close - Use tagged switch instead of if-else chain per staticcheck QF1003 https://claude.ai/code/session_01136P3sSGSiRns9QuTMRF1q
Refactor walkPath to use the shared findBestMarker method instead of duplicating marker-checking logic inline. Remove redundant hardcoded "/.git" suffix check in discoverWorktrees since os.PathSeparator already covers it. Revert unrelated alignment changes to NoIgnore and NoNested fields in CLI struct. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add worktree feature to README: Features list, CLI Flags table, Format Placeholders table, and a dedicated Git Worktree Support section with usage examples and config options. Update CLAUDE.md architecture section with worktree detection design pattern. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
--worktreesand--no-worktreesflags for controlling git worktreediscovery behavior:
IsWorktreemetadata but otherwise included as usual--worktrees: actively discovers worktrees from parent repos'.git/worktrees/directory, even if they live outside search paths--no-worktrees: filters out any worktree projects from resultsDetection works via two paths:
.gitfiles (vs directories) during walk, parsesgitdirreference to identify worktree parent
.git/worktrees/entries from parent repos to discoverlinked worktrees outside search paths
Worktree metadata is exposed in JSON output (
isWorktree,worktreeParent),format strings (
%wfor parent path), and display labels show(worktree)suffix. Cache keys include worktree flags to prevent stale results.
https://claude.ai/code/session_01136P3sSGSiRns9QuTMRF1q