Skip to content

feat: add configurable branch prefix to avoid naming conflicts#121

Open
note89 wants to merge 1 commit into
anthropics:mainfrom
up-to-speed:fix-branch-prefix-config
Open

feat: add configurable branch prefix to avoid naming conflicts#121
note89 wants to merge 1 commit into
anthropics:mainfrom
up-to-speed:fix-branch-prefix-config

Conversation

@note89

@note89 note89 commented Jun 3, 2025

Copy link
Copy Markdown

Problem

When a repository has an existing branch named claude, the action fails with a 422 error when trying to create branches like
claude/issue-123. This is due to Git's limitation where you cannot have both a branch named X and branches named X/....

This can easily happen if:

  • You have a team member named Claude who creates their own branch
  • You previously created a claude branch for testing (what happend to us, took a long time to figure out)
  • You have a feature/module/component named "claude" in your project

Solution

This PR adds a configurable branch_prefix input parameter that allows users to customize the prefix used for branch creation.

Changes

  • Add branch_prefix input parameter to action.yml (defaults to 'claude' for backward compatibility)
  • Pass branch prefix through context and use it for branch creation
  • Improve error serialization to show full error details instead of [Object ...]
  • Add detailed error messages for 422 errors explaining the Git naming conflict
  • Provide clear solutions when branch creation fails

Example Usage

- uses: anthropics/claude-code-action@v1
  with:
    branch_prefix: 'claude-agent'  # Avoids conflicts with existing 'claude' branch

Testing

Successfully tested on a private repository which had an existing claude branch causing 422 errors. With this fix
 and branch_prefix: 'claude-agent', the action now works correctly.

- Add 'branch_prefix' input parameter to action.yml (defaults to 'claude')
- Pass branch prefix through context and use it for branch creation
- Improve error serialization using JSON.stringify for better debugging
- Add detailed error messages for 422 errors explaining Git naming conflicts
- Provide clear solutions when branch creation fails due to existing branches

This allows users to configure a custom branch prefix (e.g., 'claude-agent')
to avoid conflicts when a branch named 'claude' already exists in the repository.
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