From 83e96d29bd5d6931b71973d242bc1d79db49b07d Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 22 Jun 2026 10:06:23 +0000 Subject: [PATCH 1/5] feat: add AI agent branch prefixes from conventional branch spec v1.1.0 Add ai, claude, codex, copilot, and cursor to DEFAULT_BRANCH_TYPES so branches created by AI coding agents are recognized as valid by default. Closes #435 --- commit_check/__init__.py | 9 ++++++++- tests/rule_builder_test.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/commit_check/__init__.py b/commit_check/__init__.py index aeecd10a..7b4ee3de 100644 --- a/commit_check/__init__.py +++ b/commit_check/__init__.py @@ -31,7 +31,8 @@ "build", "ci", ] -# Follow conventional branch +# Follow conventional branch (https://conventional-branch.github.io/) +# Includes AI agent prefixes added in spec v1.1.0 DEFAULT_BRANCH_TYPES = [ "feature", "bugfix", @@ -40,6 +41,12 @@ "chore", "feat", "fix", + # AI agent prefixes (conventional branch spec v1.1.0) + "ai", + "claude", + "codex", + "copilot", + "cursor", ] # Additional allowed branch names (e.g., develop, staging) DEFAULT_BRANCH_NAMES: list[str] = [] diff --git a/tests/rule_builder_test.py b/tests/rule_builder_test.py index 27d37128..2892de1c 100644 --- a/tests/rule_builder_test.py +++ b/tests/rule_builder_test.py @@ -215,6 +215,35 @@ def test_rule_builder_allow_branch_names_empty_list(self): assert "(HEAD)" in rule.regex assert "(PR-.+)" in rule.regex + @pytest.mark.benchmark + def test_ai_agent_branch_types_in_default(self): + """AI agent prefixes from conventional branch spec v1.1.0 are valid by default.""" + import re + from commit_check import DEFAULT_BRANCH_TYPES + + assert "ai" in DEFAULT_BRANCH_TYPES + assert "claude" in DEFAULT_BRANCH_TYPES + assert "codex" in DEFAULT_BRANCH_TYPES + assert "copilot" in DEFAULT_BRANCH_TYPES + assert "cursor" in DEFAULT_BRANCH_TYPES + + config = {"branch": {"conventional_branch": True}} + builder = RuleBuilder(config) + catalog_entry = RuleCatalogEntry(check="branch", regex="", error="", suggest="") + rule = builder._build_conventional_branch_rule(catalog_entry) + assert rule is not None + + ai_agent_branches = [ + "ai/refactor-auth-flow", + "claude/stoic-hypatia-v65p1f", + "claude/fix-login-bug", + "codex/optimize-query", + "copilot/add-login-page", + "cursor/fix-header-bug", + ] + for branch in ai_agent_branches: + assert re.match(rule.regex, branch), f"Branch '{branch}' should be valid" + @pytest.mark.benchmark def test_rule_builder_allow_branch_names_with_duplicates(self): """Test RuleBuilder with duplicate branch names in allow_branch_names.""" From 105feb217a41951dfe078f3dcfa47ca825d48ef6 Mon Sep 17 00:00:00 2001 From: Xianpeng Shen Date: Mon, 22 Jun 2026 13:08:15 +0300 Subject: [PATCH 2/5] Apply suggestion from @shenxianpeng --- commit_check/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commit_check/__init__.py b/commit_check/__init__.py index 7b4ee3de..fcab5eb4 100644 --- a/commit_check/__init__.py +++ b/commit_check/__init__.py @@ -31,7 +31,7 @@ "build", "ci", ] -# Follow conventional branch (https://conventional-branch.github.io/) +# Follow conventional branch (https://conventionalbranch.org/) # Includes AI agent prefixes added in spec v1.1.0 DEFAULT_BRANCH_TYPES = [ "feature", From 30f7ba931abeca2315c0781daefb6b783dec7e67 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 22 Jun 2026 10:08:17 +0000 Subject: [PATCH 3/5] chore: add AI agent branch prefixes to project cchk.toml Dogfood the new AI agent branch support (conventional branch spec v1.1.0) in the project's own config so CI passes on claude/, codex/, cursor/, ai/ branches before the default list is updated in the released package. --- cchk.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cchk.toml b/cchk.toml index 76054f7f..c406b685 100644 --- a/cchk.toml +++ b/cchk.toml @@ -18,6 +18,6 @@ ignore_authors = ["dependabot[bot]", "copilot[bot]", "pre-commit-ci[bot]", "code [branch] # https://conventional-branch.github.io/ conventional_branch = true -allow_branch_types = ["feature", "bugfix", "hotfix", "release", "chore", "feat", "fix", "copilot"] +allow_branch_types = ["feature", "bugfix", "hotfix", "release", "chore", "feat", "fix", "ai", "claude", "codex", "copilot", "cursor"] require_rebase_target = "main" ignore_authors = ["dependabot[bot]", "copilot[bot]", "pre-commit-ci[bot]", "shenxianpeng"] From 54731a78a5ad6fa649b190ba21d5b85b70d4eb56 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 22 Jun 2026 10:14:12 +0000 Subject: [PATCH 4/5] chore: remove redundant allow_branch_types from cchk.toml AI agent prefixes are now part of DEFAULT_BRANCH_TYPES, so the explicit allow_branch_types list in cchk.toml is no longer needed. --- cchk.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/cchk.toml b/cchk.toml index c406b685..3dd874a7 100644 --- a/cchk.toml +++ b/cchk.toml @@ -18,6 +18,5 @@ ignore_authors = ["dependabot[bot]", "copilot[bot]", "pre-commit-ci[bot]", "code [branch] # https://conventional-branch.github.io/ conventional_branch = true -allow_branch_types = ["feature", "bugfix", "hotfix", "release", "chore", "feat", "fix", "ai", "claude", "codex", "copilot", "cursor"] require_rebase_target = "main" ignore_authors = ["dependabot[bot]", "copilot[bot]", "pre-commit-ci[bot]", "shenxianpeng"] From 4b1446dae6a0c5b83cd349e04f4c37ff1c869877 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 22 Jun 2026 10:15:33 +0000 Subject: [PATCH 5/5] chore: restore allow_branch_types in cchk.toml until next release The pre-commit hook uses the installed (released) version of commit-check, which does not yet include AI agent prefixes in DEFAULT_BRANCH_TYPES. Keep an explicit allow_branch_types until this PR is merged and released. --- cchk.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cchk.toml b/cchk.toml index 3dd874a7..a870d711 100644 --- a/cchk.toml +++ b/cchk.toml @@ -18,5 +18,7 @@ ignore_authors = ["dependabot[bot]", "copilot[bot]", "pre-commit-ci[bot]", "code [branch] # https://conventional-branch.github.io/ conventional_branch = true +# Explicit list needed until AI agent prefixes are in a released version of commit-check +allow_branch_types = ["feature", "bugfix", "hotfix", "release", "chore", "feat", "fix", "ai", "claude", "codex", "copilot", "cursor"] require_rebase_target = "main" ignore_authors = ["dependabot[bot]", "copilot[bot]", "pre-commit-ci[bot]", "shenxianpeng"]