Skip to content

feat(ci): add git hygiene hooks to the repository template #70

Backlog

Description

@dan-petty

Problem

The repositories that the roadmap Service manages get .pre-commit-config.yaml from templates/repository/ of this repository. That baseline misses standard git project checks, and no CI check of the template runs the hooks. The pre-commit hooks of a repository and its pull request CI are the checks on the work of an agent (dan-petty/devops-cli#8040), so a gap in the baseline is a gap in each managed repository.

Evidence (2026-12-01)

  • templates/repository/.pre-commit-config.yaml holds ten hooks of pre-commit/pre-commit-hooks: no-commit-to-branch, check-merge-conflict, check-yaml, check-json, check-toml, check-added-large-files, detect-private-key, end-of-file-fixer, trailing-whitespace and mixed-line-ending.
  • It holds no secret scan. The .pre-commit-config.yaml of this repository runs gitleaks.
  • It sets no minimum_pre_commit_version and no default_install_hook_types.
  • It checks no commit message. The title check takes its own list of scopes as an input of the caller workflow.
  • templates/repository/.github/workflows/ renders only pr-title.yml and release.yml. The reusable workflow lint.yml runs actionlint, shellcheck and zizmor, not the pre-commit hooks.
  • The configuration of dan-petty/vibes holds only trailing-whitespace of the ten baseline hooks. It has no no-commit-to-branch.

Wanted result

Each managed repository has the same standard git hygiene checks, and a person, an agent and CI run the same hooks.

Acceptance criteria

  • The template configuration adds these upstream hooks: check-case-conflict, check-symlinks, destroyed-symlinks, check-executables-have-shebangs, check-shebang-scripts-are-executable and gitleaks.
  • It sets minimum_pre_commit_version and default_install_hook_types, so one pre-commit install installs each hook type that the configuration uses.
  • A check of each pull request runs pre-commit run --all-files in a managed repository.
  • A check of each pull request scans the new commits for secrets, because a hook that reads only staged changes finds nothing in that run.
  • Each hook comes from an upstream hook repository. The change adds no custom script.
  • A repository gets the change with copier update and keeps its own extra hooks. Each existing repository that lacks a baseline hook gets it, and its findings are fixed in the same pull request.
  • The template configuration adds the upstream commitizen hooks commitizen (commit-msg) and commitizen-branch (pre-push), and default_install_hook_types includes commit-msg.
  • The pull request title check runs cz check --message with the same commitizen configuration. So one configuration of a repository holds its types and scopes, and no second list or custom check repeats them.
  • commitizen only checks messages. release-please stays the release tool.

Related

Alternatives check of 2026-12-01: in-use.
The repository already uses this tool.
Tool: pre-commit (https://github.com/pre-commit/pre-commit), MIT, last activity 2026-11-09, maintained.
Reason: Searches and repository facts show pre-commit and its upstream hook repositories. The issue already names pre-commit with pre-commit-hooks, gitleaks and commitizen, which install and run the git hygiene checks, so they cover the need.

Covers:

  • Installs and runs hooks at pre-commit, commit-msg and pre-push stages
  • Runs each hook over all files in CI
  • Pulls upstream hooks from pinned hook repositories

Lacks:

  • No release management, so release-please stays the release tool
  • Staged-change secret hook finds no secret in a pull request run
  • Rollout to existing repositories stays with issue 6784

Proposed design

Problem statement

The Copier template of this repository gives each managed repository a pre-commit baseline of ten hooks. The baseline misses the standard git hygiene hooks, a secret scan, a commit message check and a pull request run of the hooks. The change adds upstream hooks, a cz.yaml, a pull request workflow that runs the hooks and scans the commit range, and a title check with cz check in the reusable pr-title.yml. The owner direction of 2026-12-01 sets the commitizen defaults, any scope, a 72 character first line and a short pull request template. The template keeps .pre-commit-config.yaml in _skip_if_exists, so the rollout to the existing repositories stays with dan-petty/devops-cli#6784.

Acceptance criteria

Requirement: Template pre-commit baseline hooks

The template pre-commit configuration SHALL add the upstream hooks check-case-conflict, check-symlinks, destroyed-symlinks, check-executables-have-shebangs, check-shebang-scripts-are-executable and gitleaks, and SHALL hold no local hook.

Scenario: The rendered template runs the added hooks

  • WHEN mise exec -- tests/test-repository-template.sh renders the template and runs pre-commit run --all-files in the render
  • THEN the command exits 0 and its output names each added hook id

Requirement: Pre-commit version and install hook types

The template configuration SHALL set minimum_pre_commit_version to 4.7.0 and default_install_hook_types to pre-commit, commit-msg and pre-push.

Scenario: One install writes each hook type

  • WHEN mise exec -- tests/test-repository-template.sh renders the template and runs pre-commit install in the render
  • THEN the render holds the executable files .git/hooks/pre-commit, .git/hooks/commit-msg and .git/hooks/pre-push

Requirement: Commitizen hooks check the commit message

The template configuration SHALL add the upstream commitizen hook for the commit-msg stage and the upstream commitizen-branch hook for the pre-push stage.

Scenario: A non-conventional message fails the commit-msg hook

  • WHEN mise exec -- tests/test-repository-template.sh renders the template, runs pre-commit install and runs git commit with the message a change with no type
  • THEN git commit exits non-zero and names the commitizen hook

Requirement: Commitizen branch hook checks the pushed commits

The commitizen-branch hook SHALL check each commit that a push sends at the pre-push stage.

Scenario: A branch with a bad commit fails the pre-push hook

  • WHEN mise exec -- tests/test-repository-template.sh renders the template, runs pre-commit install and runs git push of a branch that holds a non-conventional commit
  • THEN git push exits non-zero and names the commitizen-branch hook

Requirement: Commitizen accepts the default types and any scope

The rendered commitizen configuration SHALL accept each type of cz_conventional_commits, any scope and a ! breaking change.

Scenario: A scoped breaking change passes

  • WHEN mise exec -- tests/test-repository-template.sh renders the template, runs pre-commit install and runs git commit with the message feat(api)!: add the endpoint
  • THEN git commit exits 0

Requirement: Commitizen message length limit

The rendered commitizen configuration SHALL limit the first line of a commit message to 72 characters.

Scenario: A long first line fails

  • WHEN mise exec -- tests/test-repository-template.sh renders the template, runs pre-commit install and runs git commit with a one-line message of 73 characters
  • THEN git commit exits non-zero and names the commitizen hook

Requirement: Pull request runs all pre-commit hooks

A pull request check of the template SHALL run pre-commit run --all-files.

Scenario: A hook violation fails the pull request check

  • WHEN a live check adds a file with trailing whitespace to a pull request of a rendered template repository
  • THEN the pre-commit job fails and names trailing-whitespace

Requirement: Pull request scans the new commits for secrets

A pull request check of the template SHALL scan the commits from the base branch to the head for secrets with gitleaks.

Scenario: A secret in a new commit fails the pull request check

  • WHEN a live check adds a test secret in a commit of a pull request of a rendered template repository
  • THEN the secret scan job fails and names the secret

Requirement: Pull request title check uses commitizen

The reusable pr-title.yml workflow SHALL drop the required scopes input and the subjectPattern setting, SHALL check the pull request title with cz check and the cz.yaml of the caller, and SHALL keep the check name PR title / Semantic PR title.

Scenario: A non-conventional title fails the required check

  • WHEN a live check opens a pull request of a rendered template repository with the title bad title
  • THEN the required check PR title / Semantic PR title fails

Requirement: Template keeps the pre-commit configuration of the repository

The template SHALL keep .pre-commit-config.yaml in _skip_if_exists, so copier update keeps the hooks of an existing repository.

Scenario: An extra hook survives an update

  • WHEN mise exec -- tests/test-repository-template.sh renders the template, adds an extra hook and runs copier update to the next template release
  • THEN the command exits 0 and the render still holds the extra hook

Requirement: Short pull request template

The template SHALL render a short pull request template at .github/PULL_REQUEST_TEMPLATE.md and SHALL hold no check of the pull request body.

Scenario: The rendered repository holds the template

  • WHEN mise exec -- tests/test-repository-template.sh renders the template
  • THEN the command exits 0 and the render holds .github/PULL_REQUEST_TEMPLATE.md

Requirement: Template workflow syntax

The template pull request workflows SHALL pass actionlint, and the reusable workflows of this repository SHALL pass zizmor.

Scenario: Workflow validation passes

  • WHEN mise exec -- tests/test-repository-template.sh runs and mise exec -- zizmor --offline .github/ runs in this repository
  • THEN both commands exit 0

Existing Tool Considered

pre-commit (https://github.com/pre-commit/pre-commit), MIT, last activity 2026-11-09, maintained. The alternatives check of the issue body records the verdict in-use, and its block holds what pre-commit covers and what it lacks, so this proposal repeats neither. This change adds the upstream commitizen hooks with a cz.yaml and a pull request workflow that runs the hooks and the commit-range secret scan.

Key questions

  • Which framework and hooks cover the git hygiene need?: Use pre-commit with the upstream hooks of pre-commit/pre-commit-hooks, gitleaks/gitleaks and commitizen-tools/commitizen. Add no local hook and no custom script. (best practice) [sources: templates/repository/.pre-commit-config.yaml, .pre-commit-config.yaml]
    • Chosen: pre-commit with upstream hooks. It is the framework of this repository and of the template, and the issue forbids a custom script.
    • Rejected: Local shell scripts. The issue forbids a custom script, and the scripts add maintenance.
    • Rejected: No hook framework. It gives a person, an agent and CI no same check.
  • Which revision of pre-commit-hooks should the template pin?: Pin pre-commit/pre-commit-hooks at v6.0.0, the revision of this repository. (best practice) [sources: .pre-commit-config.yaml, templates/repository/.pre-commit-config.yaml]
    • Chosen: v6.0.0. It is the revision that this repository already uses.
    • Rejected: main. A moving branch changes the render with no template change.
    • Rejected: v4.6.0. It is older than the revision of this repository.
  • Which minimum pre-commit version and install hook types should the template set?: Set minimum_pre_commit_version to 4.7.0, the version that this repository pins, and default_install_hook_types to pre-commit, commit-msg and pre-push. (best practice) [sources: pyproject.toml, templates/repository/.pre-commit-config.yaml]
    • Chosen: 4.7.0 with the three hook types. It is the pre-commit version that this repository pins and tests the template with.
    • Rejected: 3.0.0 with the three hook types. No source shows that 3.0.0 supports each hook type that the configuration uses.
    • Rejected: No minimum version. An old pre-commit fails on the configuration with no clear cause.
  • Which commitizen and pull request rules apply?: Use the defaults of cz_conventional_commits: any scope, a ! and a BREAKING CHANGE footer, and a first line of at most 72 characters. Use the commitizen hooks for the commit message. Add no check of the pull request body; the repository uses a short pull request template. These rules replace the earlier scope list and the 60 character subject pattern. (best practice) [sources: AGENTS.md]
    • Chosen: commitizen defaults with a 72 character first line and a short pull request template. The owner direction of 2026-12-01 sets these rules.
    • Rejected: A fixed scope list and a 60 character subject pattern. The owner direction replaces each stricter rule of the item.
    • Rejected: No commit message check. It removes a check on the work of an agent.
  • Where should the commitizen configuration live?: Render cz.yaml at the template root. The commitizen hooks and the pull request title check read it, and the template renders no pyproject.toml. (best practice) [sources: tests/test-repository-template.sh:198]
    • Chosen: cz.yaml at the template root. The template renders no Python project file, and commitizen reads a dedicated cz.yaml at the repository root.
    • Rejected: pyproject.toml. The template renders no Python project file, so the file would add a Python project.
    • Rejected: A --message-length-limit argument on each cz check call. The number repeats in the hook and in the workflow, and the issue wants one configuration.
  • How should the pull request title check use commitizen?: The reusable .github/workflows/pr-title.yml drops the required scopes input and the subjectPattern setting and runs cz check --message with the cz.yaml of the caller. The job name stays Semantic PR title, so the required check name stays PR title / Semantic PR title. (best practice) [sources: AGENTS.md, .github/workflows/pr-title.yml]
    • Chosen: cz check with the cz.yaml of the repository. One configuration holds the types, and the check name stays.
    • Rejected: Keep the scope list and the 60 character pattern. The owner direction replaces them.
    • Rejected: Remove the title check. The ruleset requires the check name PR title / Semantic PR title.
  • How should the pull request secret scan cover the new commits?: Run gitleaks over the commit range from the base branch to the head in a pull request job. Do not rely on the staged-changes hook alone. (best practice) [sources: .github/workflows/ci.yml:114]
    • Chosen: gitleaks over base..head. It scans each commit that the pull request adds.
    • Rejected: The staged-changes hook only. It finds nothing in a pull request run with no staged changes.
    • Rejected: A custom scanner. The issue requires an upstream hook, and gitleaks covers the need.
  • Does commitizen replace release-please?: No. commitizen checks messages only. release-please stays the release tool. (best practice) [sources: templates/repository/.github/workflows/release.yml.jinja, AGENTS.md]
    • Chosen: Keep release-please. release-please owns the release pull request and the version files.
    • Rejected: commitizen bump. It replaces the release tool, and the issue forbids that.
    • Rejected: Both tools for releases. Two release tools write the same version files.
  • Does this issue apply the template change to the existing repositories?: No. This issue changes the template only. copier.yml lists .pre-commit-config.yaml in _skip_if_exists, so copier update keeps the file of an existing repository and adds no hook. dan-petty/devops-cli#6784 brings the existing repositories to the baseline. (best practice) [sources: copier.yml:22, templates/README.md:153, openspec/specs/template-file-owners/spec.md:10]
    • Chosen: Template only. The file ownership stops copier update from adding a hook.
    • Rejected: Template and rollout. It duplicates dan-petty/devops-cli#6784, and the file ownership stops the update.
    • Rejected: Rollout only. The template must hold the baseline first.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/feature
    status/new
    on Dec 1, 2026
  2. dan-petty commented on Dec 1, 2026

    @dan-petty
    OwnerAuthor
  3. added
    value/medium
    effort/medium
    source/agent
    scope/ci
    priority/p2-medium
    on Dec 1, 2026
  4. dan-petty commented on Dec 1, 2026

    @dan-petty
    OwnerAuthor

    Owner direction (2026-12-01): match commitizen and the industry defaults, and use best practice where there is a gap. The rules: the default types of cz_conventional_commits; any scope; ! and BREAKING CHANGE allowed; a first line of at most 72 characters; the commitizen hooks for commit messages; no custom form rule for the pull request body, which uses a short pull request template. These rules replace each stricter or different rule in this item. So the library workflow pr-title.yml must also drop its required scopes input list and its 60 character subjectPattern, and run cz check under the check name PR title / Semantic PR title. dan-petty/devops-cli#8045 applies the same rules there.

  5. devops-cli-service commented on Dec 1, 2026

    @devops-cli-service
    Contributor

    Next step: the alternatives check records a verdict. See the section Proposed design of the body.

  6. devops-cli-service commented on Dec 1, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.

    Searches (8)

    Tools considered:

    Searches run:

    • pre-commit-hooks standard git hygiene hooks check-case-conflict gitleaks, results: 5
    • pre-commit framework git hooks repository template, results: 5
    • commitizen pre-commit hook cz check conventional commit message, results: 5
    • pre-commit framework manage git pre-commit hooks multi-language, results: 5
    • pre-commit/pre-commit-hooks github repository, results: 5
    • gitleaks github secret scanning, results: 5
    • commitizen conventional commits tool, results: 5
    • pre-commit, results: 5

    Sources:

  7. added
    status/ready
    and removed
    status/new
    on Dec 1, 2026
  8. devops-cli-service commented on Dec 1, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/cisource/agentstatus/readytype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions