Skip to Content
harness-kit

commit-subject

The built-in Policy commit-subject, against commits and pushes to shared branches, lost stashes, merges only people should make: its defaults, its options and a configuration that writes it.

To learn what it guards against and see it at work, read the guide: Git and forge.

Defaults

DefaultValue
On by defaultno: an entry turns it on
Fail modeopen
Timeout5000 ms
EventsPostToolUse
ToolsBash
Agent typesevery agent, or as its options set

Options

OptionTypeDefaultDescription
baseCandidatesstring[]["origin/main"]Where the branch's own commits start when origin/HEAD names no default branch, the first that exists.
rules("no_repeat_on_branch" | "not_branch_slug")[]["no_repeat_on_branch","not_branch_slug"]The checks: no_repeat_on_branch objects to a subject an earlier commit of the branch has, not_branch_slug to one that only restates the branch's issue identifier.
skipPrefixesstring[]["amend!","fixup!","squash!"]The subject prefixes git writes for fix-ups, whose commits pass.

Example

A configuration that writes every option, a comment above each:

import { defineConfig } from '@microeinhundert/harness-kit';

export default defineConfig({
  // The Policy entries, in the order their Decisions merge in.
  policies: [
    {
      // The Policy's name, unique in the configuration; messages and logs name the Policy by it.
      id: 'commit-subject',
      // The constructor's options, which it decodes.
      options: {
        // Where the branch's own commits start when `origin/HEAD` names no default branch, the
        // first that exists.
        baseCandidates: ['origin/main'],
        // The checks: `no_repeat_on_branch` objects to a subject an earlier commit of the branch
        // has, `not_branch_slug` to one that only restates the branch's issue identifier.
        rules: ['no_repeat_on_branch', 'not_branch_slug'],
        // The subject prefixes git writes for fix-ups, whose commits pass.
        skipPrefixes: ['amend!', 'fixup!', 'squash!'],
      },
      // The name of the kit's Policy constructor that builds the Policy.
      use: 'commit-subject',
    },
  ],
});

On this page