Skip to Content
harness-kit

pull-request

The built-in Policy pull-request, against a turn that ends with failing lint, unsaved work or an incomplete hand-off: its defaults, its options and a configuration that writes it.

To learn what it guards against and see it at work, read the guide: Stop checks and hand-off.

Defaults

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

Options

OptionTypeDefaultDescription
bodyfalse | object{"enforceOn":["create","edit"],"firstLine":"^{issue_url}$"}After a create or an edit, the body opens with the configured first line, such as the issue's URL; false switches the check off.
copiesobject{"multiTargetSuffix":"-onto-","worktreeSuffix":"-[0-9]+$"}The suffixes of a branch's copies.
currencyfalse | object{"checks":["ahead","open_threads","ready_when_finished","stale_body"],"finishMarker":"<!-- harness-finish -->","readyVerdict":"ready","threadMarker":"<!-- harness-thread: (open|fixed) -->"}The open pull request of every touched branch is current: it carries the branch's commits, a body edited after its last commit, no unanswered review thread, and is out of draft once marked finished; false switches the check off.
existsfalse | object{"createHint":"gh pr create --draft --base {base} --title \"<the issue’s title>\" --body-file <file>","integrationBranches":["epic/*"],"seenMinutes":60}Every touched work branch with commits beyond the branches it was cut from has a pull request, or pushes to its worktree sibling's; false switches the check off.
protectedBranchesstring[]—The shared branches, which are never judged; the repository's default branch when absent.
remotestring"origin"The remote the branches are pushed to.

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: 'pull-request',
      // The constructor's options, which it decodes.
      options: {
        // After a create or an edit, the body opens with the configured first line, such as the
        // issue's URL; `false` switches the check off.
        body: {
          // The commands after which a pull request's body is read back: `create` for
          // `gh pr create`, `edit` for `gh pr edit`.
          enforceOn: ['create', 'edit'],
          // The pattern the first non-blank line of a pull request's body must match, with
          // `{issue_url}` standing for the URL of any issue of the tracker.
          firstLine: '^{issue_url}$',
        },
        // The suffixes of a branch's copies.
        copies: {
          // The text that opens the suffix of a branch's copy made for one target, such as `-onto-`
          // in `feat-x-onto-release-3`.
          multiTargetSuffix: '-onto-',
          // The pattern of the suffix a worktree's copy of a branch adds, such as `-[0-9]+$` for
          // `feat-x-2`, a copy of `feat-x`.
          worktreeSuffix: '-[0-9]+$',
        },
        // The open pull request of every touched branch is current: it carries the branch's
        // commits, a body edited after its last commit, no unanswered review thread, and is out of
        // draft once marked finished; `false` switches the check off.
        currency: {
          // The ways a pull request may fall behind its branch that are looked for: `ahead`,
          // `stale_body`, `open_threads` and `ready_when_finished`.
          checks: [
            'ahead',
            'open_threads',
            'ready_when_finished',
            'stale_body',
          ],
          // The marker of the finish comment, which says the pull request is ready at its head.
          finishMarker: '<!-- harness-finish -->',
          // The word the line after the finish marker starts with when the pull request is ready,
          // followed by the head it was judged at (`ready 3f2c1a9`, at least 7 characters).
          readyVerdict: 'ready',
          // The pattern of the marker of a review thread's answer, whose first group is `open` (the
          // thread stays open on purpose) or another word such as `fixed`.
          threadMarker: '<!-- harness-thread: (open|fixed) -->',
        },
        // Every touched work branch with commits beyond the branches it was cut from has a pull
        // request, or pushes to its worktree sibling's; `false` switches the check off.
        exists: {
          // The command that opens the pull request, with `{base}` and `{branch}` standing for the
          // base and the branch.
          createHint: 'gh pr create --draft --base {base} --title "<the issue’s title>" --body-file <file>',
          // Globs of the integration branches a work branch may be cut from and target.
          integrationBranches: ['epic/*'],
          // How many minutes a branch found with a pull request is not asked about again.
          seenMinutes: 60,
        },
        // The shared branches, which are never judged; the repository's default branch when absent.
        protectedBranches: ['release/*'],
        // The remote the branches are pushed to.
        remote: 'origin',
      },
      // The name of the kit's Policy constructor that builds the Policy.
      use: 'pull-request',
    },
  ],
});

On this page