CLI tool for managing git worktrees for parallel AI agent coding sessions. Creates isolated worktrees with configurable file sharing/cloning and post-creation commands.
- You have access to
bun type,bun lint, andbun fmtcommands -- make sure to run them after making changes.
src/index.ts- Main CLI entry, routes commands, handles errorssrc/cli.ts- Parses CLI arguments into typed command structures
create.ts- Creates new worktree, applies config, executes commandsremove.ts- Removes worktree (by branch or current directory)list.ts- Lists active treefrog worktreescheckout.ts- Removes worktree and checks out branch in main repo
git.ts - Git operations
ensureGitRepository()- Validates git repogetMainRepoDir()- Gets main repo rootcreateWorktree()- Creates git worktreeremoveWorktree()- Removes worktreefindWorktreeByBranch()- Locates worktree by branch nameisTreefrogWorktree()- Detects treefrog worktree pattern
fs.ts - File operations
createSymlinks()- Creates symlinks for shared filescopyFiles()- Copies files/directoriesdirectoryExists()- Checks directory existence
config.ts - Configuration parsing
parseTreefrogConfig()- Parses.treefrogfile (share/clone directives, commands section)executeTreefrogConfig()- Executes post-creation commands
ui.ts - Output utilities
printError(),printSuccess(),printInfo()- Colored console outputprintUsage()- CLI usage help
TreefrogConfig- Configuration structure- Command args interfaces (
CreateArgs,RemoveArgs,CheckoutArgs) - Custom errors (
NotInGitRepoError,NotInWorktreeError,WorktreeExistsError,FileNotFoundError)
- Functional style: pure functions, minimal state
- Error handling: custom error classes with typed error handling in main
- Worktree detection: pattern matching on
repo-name-branch-namedirectory structure - Configuration:
.treefrogfile withshare=,clone=, and[commands]sections