From 56e7042664b2b2474502c29071ede53898e69269 Mon Sep 17 00:00:00 2001 From: Xianpeng Shen <3353385+shenxianpeng@users.noreply.github.com> Date: Fri, 4 Dec 2026 08:06:21 +0000 Subject: [PATCH 1/2] docs: document CC502, CC503 and ai_attribution = "require", and pin v2.26.0 --- docs/changelog.md | 10 +++ docs/compare/tools.md | 2 +- docs/configuration.md | 13 +-- docs/example.md | 2 +- docs/guides/other-ci.md | 19 +++- docs/guides/policies.md | 69 +++++++++++++++ docs/guides/pre-commit.md | 6 +- docs/rules.md | 177 +++++++++++++++++++++++++++++++++++--- 8 files changed, 272 insertions(+), 26 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 6daecc9..90239c5 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -11,6 +11,7 @@ page that documents it. | Version | What changed | Documented in | |---|---|---| +| [2.26.0](#v2260) | A pull request description must name an issue or say enough (opt-in); `ai_attribution = "require"` asks every commit to declare AI use | [CC502](rules.md#cc502) · [CC503](rules.md#cc503) · [Asking every commit to answer](guides/policies.md#asking-every-commit-to-answer) | | [2.25.0](#v2250) | Risky settings in committed coding agent config files reported: MCP servers approved without asking, another API endpoint, full access, workflows anyone can start (opt-in) | [Agent config rules](rules.md#agent-config-rules) · [`[agent]`](configuration.md#agent) | | [2.24.2](#v2242) | A Bitbucket Pipelines pipe runs `commit-check-ci` in a step with no install | [Bitbucket Pipelines](guides/other-ci.md#bitbucket-pipelines) | | [2.24.0](#v2240) | `body_max_line_length` limits the length of a body line (opt-in); the JSON lists settings that are not in force in `notices` | [CC018](rules.md#cc018) · [Reading the JSON](example.md#reading-the-json) | @@ -48,6 +49,15 @@ page that documents it. | [2.5.0](#v250) | Organization-wide config with `inherit_from` | [Across an organization](guides/organization.md) | | [2.0.0](#v200) | Configuration moved from YAML to TOML — breaking | [Migrating from v1](migration.md) | +## v2.26.0 (2026-12-04) { #v2260 } + +### Added + +* `--pr-body` checks a pull request description against every rule a description can meet. ([Checking a pull request description](guides/policies.md#checking-a-pull-request-description), [#750](https://github.com/commit-check/commit-check/pull/750)) +* `require_issue_reference` fails a pull request description that names no issue. ([CC502](rules.md#cc502), [#750](https://github.com/commit-check/commit-check/pull/750)) +* `description_min_length` fails a pull request description with too few of the author's own words. ([CC503](rules.md#cc503), [#751](https://github.com/commit-check/commit-check/pull/751)) +* `ai_attribution = "require"` asks every commit for `Assisted-by: ` or `Assisted-by: none`; list Dependabot and Renovate in `ignore_authors`. ([CC014](rules.md#cc014), [#749](https://github.com/commit-check/commit-check/pull/749)) + ## v2.25.0 (2026-11-27) { #v2250 } ### Added diff --git a/docs/compare/tools.md b/docs/compare/tools.md index 9f5c048..2ece3e1 100644 --- a/docs/compare/tools.md +++ b/docs/compare/tools.md @@ -143,7 +143,7 @@ Replace the hook: ```yaml title=".pre-commit-config.yaml" repos: - repo: https://github.com/commit-check/commit-check - rev: v2.25.0 + rev: v2.26.0 hooks: - id: check-message ``` diff --git a/docs/configuration.md b/docs/configuration.md index 206ee09..555d338 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -276,7 +276,7 @@ Used from a hook definition, with no config file anywhere in the repository: ```yaml title=".pre-commit-config.yaml" repos: - repo: https://github.com/commit-check/commit-check - rev: v2.25.0 + rev: v2.26.0 hooks: - id: check-message args: @@ -420,9 +420,9 @@ These two sit above every section, at the top of the file. | `author_email_pattern` | str | `^.+@.+$` | Custom regex for the author email check. When empty, the built-in default pattern is used. This option only takes effect when the author_email check is enabled (`-e` / `--author-email`). | | `author_name_pattern` | str | "" (built-in default) | Custom regex for the author name check. When empty, the built-in default pattern is used (it is not disabled). This option only takes effect when the author_name check is enabled (`-n` / `--author-name`). | | `require_signed_off_by` | bool | false | Require "Signed-off-by" line in the commit message footer. | -| `ai_attribution` | str | "ignore" | AI attribution policy. `"forbid"` rejects any commit carrying AI attribution — a co-author or sign-off line naming a known tool, a disclosure trailer, a vendor mark ([CC013](rules.md#cc013)). `"disclose"` accepts AI assistance that is disclosed with one of `ai_disclosure_trailers` ([CC014](rules.md#cc014)) and rejects the tool as a co-author ([CC015](rules.md#cc015)) or as a sign-off ([CC016](rules.md#cc016)). `"ignore"` disables the check. Any other value is a configuration error. | -| `ai_disclosure_trailers` | list[str] | ["Assisted-by", "Generated-by"] | The trailers that disclose AI assistance under `"disclose"`. The first one is what a correction is written with. Listing `Co-authored-by` says the project accepts the tool as a co-author, and CC015 then passes. `Signed-off-by` is refused: only a person can certify the DCO. | -| `ai_disclosure_pattern` | str | "" (any value) | A regex the disclosure trailer's value must match under `"disclose"`, e.g. `'^\S+/\S+$'` for an `agent/model` format. Empty accepts any value, but a trailer with no value at all is reported whatever the pattern is. | +| `ai_attribution` | str | "ignore" | AI attribution policy. `"forbid"` rejects any commit carrying AI attribution — a co-author or sign-off line naming a known tool, a disclosure trailer, a vendor mark ([CC013](rules.md#cc013)). `"disclose"` accepts AI assistance that is disclosed with one of `ai_disclosure_trailers` ([CC014](rules.md#cc014)) and rejects the tool as a co-author ([CC015](rules.md#cc015)) or as a sign-off ([CC016](rules.md#cc016)). `"require"` is `"disclose"` with a disclosure on every commit: `Assisted-by: none` when no AI tool helped; merge, revert and fixup commits are not asked. Add bots such as `"dependabot[bot]"` to `ignore_authors` under `"require"`. `"ignore"` disables the check. Any other value is a configuration error. | +| `ai_disclosure_trailers` | list[str] | ["Assisted-by", "Generated-by"] | The trailers that disclose AI assistance under `"disclose"` and `"require"`. The first one is what a correction is written with. Listing `Co-authored-by` says the project accepts the tool as a co-author, and CC015 then passes. `Signed-off-by` is refused: only a person can certify the DCO. | +| `ai_disclosure_pattern` | str | "" (any value) | A regex the disclosure trailer's value must match under `"disclose"` and `"require"`, e.g. `'^\S+/\S+$'` for an `agent/model` format. Empty accepts any value, but a trailer with no value at all is reported whatever the pattern is. | {.fields} @@ -486,7 +486,10 @@ Read by `--files`. See [Agent config rules](rules.md#agent-config-rules). | Option | Type | Default | Description | |---|---|---|---| | `check` | str | "commits" | GitHub App only. `"commits"` checks every commit of a pull request on its own; `"squash"` checks the one message a squash merge would land, built from the repository's merge settings. See [Pull requests](#pull-requests-every-commit-or-the-squash-message). | -| `ai_declaration_checkboxes` | list[str] | [] (rule off) | The texts of the AI declaration boxes in the pull request template, one per box. When set, a pull request description checked with `--ai-attribution-only` must tick exactly one of them; see [CC501](rules.md#cc501). Read by the CLI, the Action and the App. | +| `ai_declaration_checkboxes` | list[str] | [] (rule off) | The texts of the AI declaration boxes in the pull request template, one per box. When set, a pull request description checked with `--pr-body` or `--ai-attribution-only` must tick exactly one of them; see [CC501](rules.md#cc501). Read by the CLI, the Action and the App. | +| `require_issue_reference` | bool | false | A pull request description checked with `--pr-body` must name an issue: `#123`, `GH-123`, `owner/repo#123`, or a link to an issue on GitHub, GitLab or Bitbucket Cloud, or to a Jira ticket. References in HTML comments and code do not count. See [CC502](rules.md#cc502). | +| `issue_reference_pattern` | str | "" (the forms above) | A regex that replaces what counts as naming an issue, e.g. `"\\bPROJ-\\d+\\b"` for the Jira keys of one project. See [CC502](rules.md#cc502). | +| `description_min_length` | int | 0 (rule off) | A pull request description checked with `--pr-body` must have at least this many characters of the author's own words. HTML comments, headings, task-list lines, rules (`---`) and empty bullets do not count, so an untouched template fails. See [CC503](rules.md#cc503). | | `body_ai_attribution` | bool | false | GitHub App only. Check the pull request description against the AI rules (CC013 to CC016), and its AI declaration boxes when `ai_declaration_checkboxes` is set. The Action's `pr-body-ai-attribution` input does the same. See [AI-written pull requests](guides/github-app.md#ai-written-pull-requests). | | `ai_label` | bool or str | false | GitHub App only. Label a pull request an AI tool wrote any of: `true` for `ai-assisted`, or the label's name. Labels are only added, never removed. | diff --git a/docs/example.md b/docs/example.md index 7cfe551..e4bb7d6 100644 --- a/docs/example.md +++ b/docs/example.md @@ -186,7 +186,7 @@ pushed: ```yaml title=".pre-commit-config.yaml" repos: - repo: https://github.com/commit-check/commit-check - rev: v2.25.0 + rev: v2.26.0 hooks: - id: check-no-force-push stages: [pre-push] diff --git a/docs/guides/other-ci.md b/docs/guides/other-ci.md index d2dc914..5f9ad87 100644 --- a/docs/guides/other-ci.md +++ b/docs/guides/other-ci.md @@ -170,10 +170,17 @@ In a job written by hand they are `--pr-title` and `--pr-body-ai-attribution`. `ai_attribution` policy, and, when `[pull_request] ai_declaration_checkboxes` is set, that it ticks exactly one AI declaration box (CC501). GitLab task lists (`- [x]`, `* [x]`, `1. [x]`) are read like GitHub's. +- The description is also checked, with no input, as soon as `cchk.toml` + sets `[pull_request] require_issue_reference` (CC502) or + `description_min_length` (CC503); see + [Requiring an issue and a real description](policies.md#requiring-an-issue-and-a-real-description). + `#123` and links to GitLab issues and work items count as references. - GitLab passes a job only the first 2700 characters of a description, so only that part is checked, and the job says so when it happens. Put the AI declaration boxes near the top of the merge request template, so a long - description does not cut them off. To fail a description that was cut + description does not cut them off. When the part GitLab passed does not + name an issue or is too short, CC502 and CC503 are left undecided rather + than failed, since the rest may meet them. To fail a description that was cut rather than check part of it, give the job a `before_script`. A job of the same name in your `.gitlab-ci.yml` is merged with the component's: @@ -197,7 +204,7 @@ pipelines: clone: depth: full script: - - pipe: commit-check/commit-check:2.25.0 + - pipe: commit-check/commit-check:2.26.0 ``` The pipe runs `commit-check-ci` from the commit-check release of the same @@ -229,7 +236,7 @@ Each check is a variable, with the same defaults as the | `PR_BODY_AI_ATTRIBUTION` | `false` | The description, against the AI attribution rules. | ```yaml - - pipe: commit-check/commit-check:2.25.0 + - pipe: commit-check/commit-check:2.26.0 variables: AUTHOR_EMAIL: 'true' BRANCH: 'false' @@ -271,7 +278,7 @@ with the **Pull requests: Read** scope, store it as a secured repository variable named `BITBUCKET_ACCESS_TOKEN`, and switch the two checks on: ```yaml - - pipe: commit-check/commit-check:2.25.0 + - pipe: commit-check/commit-check:2.26.0 variables: PR_TITLE: 'true' PR_BODY_AI_ATTRIBUTION: 'true' @@ -282,6 +289,10 @@ In a step written by hand they are `commit-check-ci --pr-title --pr-body-ai-attribution`, and the variable reaches the command without being named. +Once `cchk.toml` sets `[pull_request] require_issue_reference` (CC502) or +`description_min_length` (CC503), the description is checked without +`PR_BODY_AI_ATTRIBUTION`, so the step needs the token for them too. + Without the token, or with one Bitbucket refuses, the two checks fail and say why: a title that could not be read is never checked as empty text. The two checks work as in the diff --git a/docs/guides/policies.md b/docs/guides/policies.md index f411e66..619d32c 100644 --- a/docs/guides/policies.md +++ b/docs/guides/policies.md @@ -229,6 +229,12 @@ $ gh pr view 42 --json body -q .body | commit-check --ai-attribution-only --form ["Devin"] ``` +`--pr-body` reads the description the same way and runs every rule a +description can meet: the AI rules, and the +[AI declaration](#requiring-the-templates-ai-declaration), +[issue reference and length](#requiring-an-issue-and-a-real-description) +when `[pull_request]` turns them on. + ### Requiring the template's AI declaration Many pull request templates ask the author to tick one of two boxes, such as @@ -265,6 +271,43 @@ It works on its own: `ai_attribution` can stay at `"ignore"`. In the edited; the Action does too once its workflow lists `edited` under `pull_request` `types`. +### Requiring an issue and a real description + +Two more checks catch a pull request nobody prepared: no issue behind it, or +the template sent back untouched. Both are off until you set them: + +```toml title="cchk.toml" +[pull_request] +require_issue_reference = true # CC502 +description_min_length = 50 # CC503 +``` + +```console +$ gh pr view 42 --json body -q .body | commit-check --pr-body +✖ Rejected by Commit Check · 2 checks failed + +✖ CC502 issue-reference failed: (none) + The pull request description does not reference an issue + Suggest: Name the issue this change is for, e.g. "Fixes #123" + Docs: https://commit-check.com/rules/#cc502 + +✖ CC503 description-min-length failed: (none) + The pull request description is too short: 0 of at least 50 characters + Suggest: Say what the change does and why + Docs: https://commit-check.com/rules/#cc503 +``` + +[CC502](../rules.md#cc502) accepts `#123`, `GH-123`, `owner/repo#123` and +links to GitHub, GitLab, Bitbucket Cloud and Jira issues; set +`issue_reference_pattern` for anything else. [CC503](../rules.md#cc503) +counts only the author's own words, so comments, headings and checkboxes from +the template do not add up to a description. References and words inside HTML +comments do not count for either. List bots in `commit.ignore_authors`, since +a Dependabot pull request names no issue. + +`commit-check-ci` runs both on [GitLab and Bitbucket](other-ci.md#merge-request-title-and-description) +as soon as they are set. + ### Asking for disclosure instead Most projects that allow AI assistance ask to be told about it. @@ -321,6 +364,32 @@ a commit in the kernel's `Assisted-by:` format passes all three: printf 'feat: add caching layer\n\nAssisted-by: LLM coccinelle sparse\nSigned-off-by: Jane Dev ' | commit-check -m ``` +### Asking every commit to answer + +`"disclose"` only asks commits that show AI assistance. A project that wants a +yes or no on every commit, for a report or an audit, sets `"require"`: + +```toml title="cchk.toml" +[commit] +ai_attribution = "require" +ignore_authors = ["dependabot[bot]", "renovate[bot]"] +``` + +Every commit then carries `Assisted-by: `, or `Assisted-by: none` when +no AI tool helped; merge, revert and fixup commits are not asked. It runs the +same three rules as `"disclose"`, and [CC014](../rules.md#cc014) also fails a +commit that says nothing: + +```text +✖ CC014 ai-disclosure failed: fix: handle empty input + No AI disclosure: every commit must say whether an AI tool helped, with Assisted-by or Generated-by + Suggest: Add "Assisted-by: ", or "Assisted-by: none" when no AI tool helped (set by ai_attribution = "require" in the [commit] config) + Docs: https://commit-check.com/rules/#cc014 +``` + +`Assisted-by: none` on a commit that does show an AI tool fails too. Bots +write no disclosure, so list them in `ignore_authors`. + ### Choosing the format `ai_disclosure_trailers` is the list of trailers that count as a disclosure, diff --git a/docs/guides/pre-commit.md b/docs/guides/pre-commit.md index 575a3e0..30d48fc 100644 --- a/docs/guides/pre-commit.md +++ b/docs/guides/pre-commit.md @@ -8,7 +8,7 @@ Add Commit Check to `.pre-commit-config.yaml`: ```yaml title=".pre-commit-config.yaml" repos: - repo: https://github.com/commit-check/commit-check - rev: v2.25.0 + rev: v2.26.0 hooks: - id: check-message - id: check-branch @@ -68,7 +68,7 @@ Options can be passed as hook arguments, which keeps everything in one file: ```yaml title=".pre-commit-config.yaml" repos: - repo: https://github.com/commit-check/commit-check - rev: v2.25.0 + rev: v2.26.0 hooks: - id: check-message args: @@ -90,7 +90,7 @@ colon, and lets the commit through: ```yaml title=".pre-commit-config.yaml" repos: - repo: https://github.com/commit-check/commit-check - rev: v2.25.0 + rev: v2.26.0 hooks: - id: check-message args: [--fix] diff --git a/docs/rules.md b/docs/rules.md index b644101..e7681b4 100644 --- a/docs/rules.md +++ b/docs/rules.md @@ -158,6 +158,21 @@ Run with `-t` / `--tag`. +### Pull request rules (`CC5xx`) { #pr-rules } + +Run with `--pr-body`, on a pull or merge request description piped on stdin. +Each is off until its `[pull_request]` option is set. + +
+ +| Code | Name | Message | Check | Default | +|---|---|---|---|---| +| [CC501](#cc501) | `ai-declaration` | The pull request description does not say whether AI tools were used | `--pr-body` | ⚪ Off | +| [CC502](#cc502) | `issue-reference` | The pull request description does not reference an issue | `--pr-body` | ⚪ Off | +| [CC503](#cc503) | `description-min-length` | The pull request description is too short | `--pr-body` | ⚪ Off | + +
+ ### Agent config rules (`CC6xx`) { #agent-rules } Run with `-f` / `--files`, once `[agent] enabled = true` is set. Unlike the @@ -664,7 +679,7 @@ mechanically rather than relitigated in every review. **Options** * `commit.ai_attribution` — `"forbid"` enables this rule. `"ignore"` (the - default) disables it; `"disclose"` replaces it with + default) disables it; `"disclose"` and `"require"` replace it with [CC014](#cc014)–[CC016](#cc016). ### ai-disclosure (CC014) { #cc014 } @@ -680,6 +695,11 @@ all count as signs; none of them counts as the disclosure. A trailer that is there but says nothing — no value, or a value that does not match `ai_disclosure_pattern` — fails too. +Under `ai_attribution = "require"` every commit has to answer, with or without +signs of AI: `Assisted-by: `, or `Assisted-by: none` when no AI tool +helped. Merge, revert and fixup commits are not asked. `Assisted-by: none` on +a commit that does show AI assistance fails. + **Why is this bad?** A project that allows AI assistance and asks for it to be disclosed has an @@ -704,9 +724,20 @@ commits that look much the same. The suggestion keeps the name the tool gave itself, and `--format json` carries the whole corrected message in `fix`. +Under `"require"`, a commit that says nothing: + +```text +✖ CC014 ai-disclosure failed: fix: handle empty input + No AI disclosure: every commit must say whether an AI tool helped, with Assisted-by or Generated-by + Suggest: Add "Assisted-by: ", or "Assisted-by: none" when no AI tool helped (set by ai_attribution = "require" in the [commit] config) +``` + **Options** -* `commit.ai_attribution` — set to `"disclose"` to enable this rule. +* `commit.ai_attribution` — set to `"disclose"` to enable this rule, or to + `"require"` to ask every commit for a disclosure. Under `"require"`, add + Dependabot and Renovate to `commit.ignore_authors`, since their commits + carry no disclosure. * `commit.ai_disclosure_trailers` — the trailers that count as a disclosure. The first one is what a correction is written with. * `commit.ai_disclosure_pattern` — a regex the disclosure's value must match, @@ -716,7 +747,7 @@ carries the whole corrected message in `fix`. **What it does** -Under `ai_attribution = "disclose"`, rejects a commit that credits an AI tool +Under `ai_attribution = "disclose"` or `"require"`, rejects a commit that credits an AI tool as a person: a `Co-authored-by:` or `Co-developed-by:` trailer naming a recognised tool. @@ -739,7 +770,7 @@ and authorship are different claims. **Options** -* `commit.ai_attribution` — set to `"disclose"` to enable this rule. +* `commit.ai_attribution` — set to `"disclose"` or `"require"` to enable this rule. * `commit.ai_disclosure_trailers` — listing `Co-authored-by` here says the project accepts the tool as a co-author, and this rule then passes. @@ -747,7 +778,7 @@ and authorship are different claims. **What it does** -Under `ai_attribution = "disclose"`, rejects a commit whose `Signed-off-by:` +Under `ai_attribution = "disclose"` or `"require"`, rejects a commit whose `Signed-off-by:` trailer names an AI tool. **Why is this bad?** @@ -769,14 +800,14 @@ off by accepting it as a disclosure. **Options** -* `commit.ai_attribution` — set to `"disclose"` to enable this rule. +* `commit.ai_attribution` — set to `"disclose"` or `"require"` to enable this rule. ### ai-author (CC017) { #cc017 } **What it does** -Under `ai_attribution = "forbid"` or `"disclose"`, rejects a commit whose -author is an AI tool: `claude[bot]`, `copilot-swe-agent[bot]`, +Under `ai_attribution = "forbid"`, `"disclose"` or `"require"`, rejects a commit +whose author is an AI tool: `claude[bot]`, `copilot-swe-agent[bot]`, `google-labs-jules[bot]`, `devin-ai-integration[bot]`, OpenHands, a name ending in `(aider)`, or any name at a tool's own address such as `noreply@anthropic.com`. The author is read the same way as a @@ -813,8 +844,8 @@ tool set them. All four outrank `user.name` and `user.email`. **Options** -* `commit.ai_attribution` — set to `"forbid"` or `"disclose"` to enable this - rule. +* `commit.ai_attribution` — set to `"forbid"`, `"disclose"` or `"require"` to + enable this rule. * `commit.ignore_authors` — authors listed here are skipped, for a bot you trust to commit on its own. * Top-level `warn = ["ai_author"]` reports the rule without failing the run. @@ -1256,8 +1287,9 @@ git tag v1.2.3-rc.1 Checks that a pull request description answers the AI question its template asks, often under an "AI disclosure" heading: exactly one of the boxes listed in -`pull_request.ai_declaration_checkboxes` is ticked. It runs only under `--ai-attribution-only`, the mode that reads a -pull request description, and only when that option is set. +`pull_request.ai_declaration_checkboxes` is ticked. It runs only under `--pr-body` +or `--ai-attribution-only`, the modes that read a pull request description, and +only when that option is set. A box is a task-list item (`- [ ]`, `* [x]`, `1. [X]`) whose text starts with one of the options, compared without case, emphasis or extra spaces, on whole @@ -1320,6 +1352,127 @@ Use instead: and the [GitHub App](guides/github-app.md) with `[pull_request] body_ai_attribution = true`. +### issue-reference (CC502) { #cc502 } + +**What it does** + +Checks that a pull request description names the issue it is for. It runs +under `--pr-body` when `pull_request.require_issue_reference` is `true`. + +By default any of these counts: + +* `#123`, `GH-123` or `owner/repo#123` +* a link to an issue on GitHub, a GitLab issue or work item, or a Bitbucket + Cloud issue +* a link to a Jira ticket (`.../browse/PROJ-123`) + +It reads only the text: `#123` passes whether or not issue 123 exists. A +reference inside an HTML comment, a code block or a code span does not count, +so the `Fixes #123` a template shows as an example is not an answer. + +Authors in `commit.ignore_authors` are skipped, so a bot's pull request does +not need an issue. + +**Why is this bad?** + +A pull request with no issue has had no discussion before the code was +written. Many projects ask contributors to open an issue first, and with +coding agents opening pull requests in bulk, a link to an agreed issue is the +cheapest sign that someone asked for the change. Projects check it today with +scripts of their own. + +**Example** + +```toml title="cchk.toml" +[pull_request] +require_issue_reference = true +``` + +```console +$ gh pr view 42 --json body -q .body | commit-check --pr-body +✖ Rejected by Commit Check · 1 check failed + +✖ CC502 issue-reference failed: (none) + The pull request description does not reference an issue + Suggest: Name the issue this change is for, e.g. "Fixes #123" + Docs: https://commit-check.com/rules/#cc502 +``` + +Use instead: + +```markdown +Drop the cache when the config changes. + +Fixes #412 +``` + +**Options** + +* `pull_request.require_issue_reference` — `true` turns the rule on. Off by + default. +* `pull_request.issue_reference_pattern` — a regex that replaces the forms + above, e.g. `"\\bPROJ-\\d+\\b"` for the Jira keys of one project. + +### description-min-length (CC503) { #cc503 } + +**What it does** + +Checks that a pull request description has at least +`pull_request.description_min_length` characters of the author's own words. It +runs under `--pr-body` when that option is above `0`. + +What the template brings does not count: HTML comments, headings, task-list +lines (`- [ ]`, `- [x]`), rules (`---`) and empty bullets. Code does count. A +template left as it came therefore has `0` characters and fails. + +Authors in `commit.ignore_authors` are skipped. + +**Why is this bad?** + +An empty description, or the template with nothing filled in, leaves the +reviewer to work out from the diff what the change is for and why. It is also +a common mark of a pull request nobody looked at before opening it. + +**Example** + +```toml title="cchk.toml" +[pull_request] +description_min_length = 50 +``` + +```markdown +## Summary + + + +## Related issue + + +``` + +```console +$ gh pr view 42 --json body -q .body | commit-check --pr-body +✖ Rejected by Commit Check · 1 check failed + +✖ CC503 description-min-length failed: (none) + The pull request description is too short: 0 of at least 50 characters + Suggest: Say what the change does and why + Docs: https://commit-check.com/rules/#cc503 +``` + +Use instead: + +```markdown +## Summary + +Drop the cache when the config changes, so a new rule takes effect on the next run. +``` + +**Options** + +* `pull_request.description_min_length` — the fewest characters of the + author's own words. `0` (the default) turns the rule off. + ## Agent config rules Coding agents read project settings from files in the repository, such as From dd61479432f684b46657127c50f105543c2b4637 Mon Sep 17 00:00:00 2001 From: Xianpeng Shen <3353385+shenxianpeng@users.noreply.github.com> Date: Fri, 4 Dec 2026 08:13:52 +0000 Subject: [PATCH 2/2] docs: qualify the template, none and exemption wording --- docs/changelog.md | 2 +- docs/configuration.md | 2 +- docs/rules.md | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 90239c5..9054ab1 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -56,7 +56,7 @@ page that documents it. * `--pr-body` checks a pull request description against every rule a description can meet. ([Checking a pull request description](guides/policies.md#checking-a-pull-request-description), [#750](https://github.com/commit-check/commit-check/pull/750)) * `require_issue_reference` fails a pull request description that names no issue. ([CC502](rules.md#cc502), [#750](https://github.com/commit-check/commit-check/pull/750)) * `description_min_length` fails a pull request description with too few of the author's own words. ([CC503](rules.md#cc503), [#751](https://github.com/commit-check/commit-check/pull/751)) -* `ai_attribution = "require"` asks every commit for `Assisted-by: ` or `Assisted-by: none`; list Dependabot and Renovate in `ignore_authors`. ([CC014](rules.md#cc014), [#749](https://github.com/commit-check/commit-check/pull/749)) +* `ai_attribution = "require"` asks every commit, except merges, reverts and fixups, for `Assisted-by: ` or `Assisted-by: none`; list Dependabot and Renovate in `ignore_authors`. ([CC014](rules.md#cc014), [#749](https://github.com/commit-check/commit-check/pull/749)) ## v2.25.0 (2026-11-27) { #v2250 } diff --git a/docs/configuration.md b/docs/configuration.md index 555d338..ce3f411 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -422,7 +422,7 @@ These two sit above every section, at the top of the file. | `require_signed_off_by` | bool | false | Require "Signed-off-by" line in the commit message footer. | | `ai_attribution` | str | "ignore" | AI attribution policy. `"forbid"` rejects any commit carrying AI attribution — a co-author or sign-off line naming a known tool, a disclosure trailer, a vendor mark ([CC013](rules.md#cc013)). `"disclose"` accepts AI assistance that is disclosed with one of `ai_disclosure_trailers` ([CC014](rules.md#cc014)) and rejects the tool as a co-author ([CC015](rules.md#cc015)) or as a sign-off ([CC016](rules.md#cc016)). `"require"` is `"disclose"` with a disclosure on every commit: `Assisted-by: none` when no AI tool helped; merge, revert and fixup commits are not asked. Add bots such as `"dependabot[bot]"` to `ignore_authors` under `"require"`. `"ignore"` disables the check. Any other value is a configuration error. | | `ai_disclosure_trailers` | list[str] | ["Assisted-by", "Generated-by"] | The trailers that disclose AI assistance under `"disclose"` and `"require"`. The first one is what a correction is written with. Listing `Co-authored-by` says the project accepts the tool as a co-author, and CC015 then passes. `Signed-off-by` is refused: only a person can certify the DCO. | -| `ai_disclosure_pattern` | str | "" (any value) | A regex the disclosure trailer's value must match under `"disclose"` and `"require"`, e.g. `'^\S+/\S+$'` for an `agent/model` format. Empty accepts any value, but a trailer with no value at all is reported whatever the pattern is. | +| `ai_disclosure_pattern` | str | "" (any value) | A regex the disclosure trailer's value must match under `"disclose"` and `"require"`, e.g. `'^\S+/\S+$'` for an `agent/model` format. Empty accepts any value, but a trailer with no value at all is reported whatever the pattern is. `Assisted-by: none` is accepted whatever the pattern is. | {.fields} diff --git a/docs/rules.md b/docs/rules.md index e7681b4..8db2526 100644 --- a/docs/rules.md +++ b/docs/rules.md @@ -1423,7 +1423,8 @@ runs under `--pr-body` when that option is above `0`. What the template brings does not count: HTML comments, headings, task-list lines (`- [ ]`, `- [x]`), rules (`---`) and empty bullets. Code does count. A -template left as it came therefore has `0` characters and fails. +template made only of those counts `0` when it is sent back untouched, and +fails. Authors in `commit.ignore_authors` are skipped.