feat(dev): add AI-generated branch naming for worktrees#416
Merged
basnijholt merged 9 commits intomainfrom Feb 9, 2026
Merged
Conversation
- Narrow except Exception to except OSError in _is_valid_git_branch_name - Remove unnecessary .lower().strip() on Literal-typed branch_name_mode - Remove _run_headless_branch_namer wrapper; use data-driven dispatch to deduplicate the per-agent if/elif branches
…heck Add a Rich status spinner during AI branch name generation so users see progress instead of a silent wait. Reuse worktree.check_branch_exists instead of duplicating the git show-ref logic in cli.py. Simplify the warning message for AI naming fallback.
Remove error-detail machinery (_summarize_agent_error, _parse_branch_name_agent_result, _extract_json_object) and inline small helpers (_resolve_branch_name_agents, _is_valid_git_branch_name). Simplify return types from tuples to plain values. Drop corresponding tests for removed internals.
The simplification removed the availability loop from the random fallback path, which could return a duplicate branch name. Restore the check and add a test covering the collision path.
Move all branch naming logic (word lists, AI agent invocation, output parsing, normalization, uniqueness checks) from cli.py into a dedicated _branch_name.py module to reduce cli.py's size and improve cohesion.
for more information, see https://pre-commit.ci
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.
Summary
Add AI-generated branch naming for
agent-cli dev newwhen no branch is provided.What changed
dev new:--branch-name-mode random|auto|ai--branch-name-agent claude|codex|gemini--branch-name-timeout <seconds>refs/heads/*,refs/remotes/origin/*)--branch-name-agentis omitted,--with-agentis used for naming if it supports headless mode (claude/codex/gemini)Code quality improvements
agent_cli/dev/_branch_name.py(~370 lines) to keepcli.pyfocused on CLI commands_branch_exists_in_repoby reusingworktree.check_branch_exists(renamed from private_check_branch_exists)config.py):_replace_dashed_keysmade recursive,_flatten_nested_sectionspreserves scalar options alongside nested subsectionsAdditional fixes
dev clean --forceforwarding into merged/no-commits cleanup pathsdev clean --forceTest plan
pre-commit run --all-filespasses (ruff, mypy, jscpd, pylint)pytest tests/— 970 passeddev newwith AI naming, fallback, auto mode, config defaultsclaude,codex,geminiCLIs