Model: Claude Sonnet 4, via GitHub Copilot Chat. See: About Claude in GitHub Copilot Chat
I'm writing a custom branch name AI prompt for GitButler, it's going to be fed to Claude (probably 3.5, they don't specify the version, only that it's Anthropic).
This is the default prompt:
User:
Please could you write a branch name for my changes.
A branch name represent a brief description of the changes in the diff (branch).
Branch names should contain no whitespace and instead use dashes to separate words.
Branch names should contain a maximum of 5 words.
Only respond with the branch name.Here is my git diff:
diff --git a/src/utils/typing.ts b/src/utils/typing.ts index 1cbfaa2..7aeebcf 100644 --- a/src/utils/typing.ts +++ b/src/utils/typing.ts @@ -35,3 +35,10 @@ export function isNonEmptyObject(something: unknown): something >is UnknownObject (Object.keys(something).length > 0 || Object.getOwnPropertySymbols(something).>length > 0) ); } + +export function isArrayOf<T>( + something: unknown, + check: (value: unknown) => value is T +): something is T[] { + return Array.isArray(something) && something.every(check); +}Assistant:
utils-typing-is-array-of-type
I want to follow GitFlow naming conventions with prefixes that align with the Conventional Commits specification I use for commit messages.
The branch name should be structured as follows:
<prefix>/<description>The prefixes should correlate with the commit types from Conventional Commits:
- feature/ - for new features (correlates with
feat:commits) - fix/ - for bug fixes (correlates with
fix:commits, merging both hotfix and bugfix) - docs/ - for documentation changes (correlates with
docs:commits) - style/ - for formatting changes (correlates with
style:commits) - refactor/ - for code restructuring (correlates with
refactor:commits) - perf/ - for performance improvements (correlates with
perf:commits) - test/ - for test additions/updates (correlates with
test:commits) - build/ - for build system changes (correlates with
build:commits) - ci/ - for CI configuration changes (correlates with
ci:commits) - chore/ - for maintenance tasks (correlates with
chore:commits)
Branch names should be descriptive but concise, using kebab-case formatting, and should not exceed 5 words in the description part.
And, some documentation from GitButler:
Custom prompts can contain three variables which we will replace with the appropriate values. Those include:
%{diff} - The contents of the diff.
%{commits} - The commit messages (for branch naming context).
You are generating a Git branch name following GitFlow naming conventions.
REQUIREMENTS:
- Use GitFlow prefixes:
feature/,fix/,docs/,style/,refactor/,perf/,test/,build/,ci/,chore/ - Branch name format:
<prefix>/<description> - Description should be 2-5 words maximum
- Use kebab-case (lowercase with dashes)
- Be descriptive but concise
- Only respond with the branch name
PREFIX GUIDELINES:
feature/- new features or enhancementsfix/- bug fixes (both critical and non-critical)docs/- documentation changesstyle/- formatting, missing semicolons, etc (no code change)refactor/- code restructuring without functional changesperf/- performance improvementstest/- adding or updating testsbuild/- changes to build system or dependenciesci/- changes to CI configurationchore/- other maintenance tasks that don't modify src or test files
Git diff:
%{diff}Commit messages (if available):
%{commits}Here are several examples showing how the prompt would work with different types of changes:
Git diff:
diff --git a/src/auth/oauth.ts b/src/auth/oauth.ts
new file mode 100644
index 0000000..1234567
--- /dev/null
+++ b/src/auth/oauth.ts
@@ -0,0 +1,25 @@
+export class OAuthService {
+ async authenticate(provider: string): Promise<string> {
+ // OAuth implementation
+ }
+}Commit messages:
feat(auth): add OAuth authentication service
Implement OAuth flow for external providers including Google,
GitHub, and Discord. Supports token validation and user creation.Expected output:
feat/oauth-authentication-serviceGit diff:
diff --git a/src/utils/validation.ts b/src/utils/validation.ts
index 1234567..abcdefg 100644
--- a/src/utils/validation.ts
+++ b/src/utils/validation.ts
@@ -5,7 +5,7 @@ export function validateEmail(email: string): boolean {
- return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
+ return /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(email);
}Commit messages:
fix(validation): require minimum TLD length in email regex
Ensure top-level domain has at least 2 characters to prevent
validation of invalid emails like [email protected]Expected output:
fix/email-validation-regexGit diff:
diff --git a/README.md b/README.md
index 1234567..abcdefg 100644
--- a/README.md
+++ b/README.md
@@ -45,6 +45,18 @@ npm start
+## Authentication
+
+The application supports multiple authentication methods:
+
+- Email/password login
+- OAuth providers (Google, GitHub, Discord)Commit messages:
Expected output:
docs/authentication-setup-guideGit diff:
diff --git a/src/components/UserCard.tsx b/src/components/UserCard.tsx
index 1234567..abcdefg 100644
--- a/src/components/UserCard.tsx
+++ b/src/components/UserCard.tsx
@@ -1,8 +1,8 @@
- const fullName = user.firstName + ' ' + user.lastName;
+ const fullName = getUserDisplayName(user);
+
+function getUserDisplayName(user: User): string {
+ return `${user.firstName} ${user.lastName}`;
+}Commit messages:
Expected output:
refactor/user-display-name-logicGit diff:
diff --git a/src/api/client.ts b/src/api/client.ts
index 1234567..abcdefg 100644
--- a/src/api/client.ts
+++ b/src/api/client.ts
@@ -1,3 +1,3 @@
-export const API_TIMEOUT = 5000;
+export const API_TIMEOUT = 10000;
-export const MAX_RETRIES = 3;
+export const MAX_RETRIES = 5;Commit messages:
perf: increase API timeout and retry limits
Improve reliability for slower connections by extending timeout
to 10 seconds and allowing up to 5 retry attempts.Expected output:
perf/api-timeout-retry-limitsGit diff:
diff --git a/src/auth/login.ts b/src/auth/login.ts
[... multiple file changes ...]
diff --git a/src/auth/oauth.ts b/src/auth/oauth.ts
[... OAuth implementation ...]
diff --git a/tests/auth.test.ts b/tests/auth.test.ts
[... test additions ...]Commit messages:
feat(auth): add OAuth login support
Implement OAuth authentication flow for external providers.
Creates user session after successful OAuth token validation.
test(auth): add OAuth integration tests
Add comprehensive test suite for OAuth authentication flow
including provider validation and token handling.
docs(auth): update authentication documentation
Document OAuth setup process and configuration options
for supported providers.Expected output:
feat/oauth-login-integrationGit diff:
diff --git a/package.json b/package.json
index 1234567..abcdefg 100644
--- a/package.json
+++ b/package.json
@@ -15,8 +15,8 @@
"dependencies": {
- "react": "^17.0.0",
- "typescript": "^4.5.0"
+ "react": "^18.2.0",
+ "typescript": "^5.0.0"
}Commit messages:
Expected output:
chore/update-dependencies