← Catalog

@srobroek/pi-trunk-dev-policy

Trunk-based delivery for OpenCode, Claude Code, and pi: Conventional Commit and main-push gates, skip-CI and MR/PR advisories, feature-flag cleanup beads, and release-setup skills.

Package

Install

Install with PiG

pig install npm:@srobroek/pi-trunk-dev-policy

Install with Pi

pi install npm:@srobroek/pi-trunk-dev-policy
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "skills": [
    "./skills"
  ],
  "extensions": [
    "./extensions/trunk-dev.js"
  ]
}

README

Written by the package's publisher, shown as published in version 1.0.0 (README.md). PiG does not review it.

trunk-dev

Trunk-based delivery for OpenCode, Claude Code, and pi. The plugin checks Conventional Commit subjects and direct pushes to main or master. It adds skip-CI and merge-request advisories, then creates a feature-flag cleanup bead after flagged merges. Its skills cover the release workflow (semantic-release as one option, alongside release-please where supported), feature flags, and trunk-based delivery.

Ported from the omp-plugins trunk-dev plugin. The omp rules trunk-dev-workflow and trunk-dev-feature-flags are skills here; the trunk-dev-skip-ci-text rule is code (below). Session-start reminders are delivered once on the first completed shell/bash result, never in the system prompt. The OpenCode and pi adapters share the parser and decision functions in shared/. The parser reads only statically visible shell commands. It does not evaluate shell text, so wrappers, expansions, and aliases may be outside its view.

Install

Install the Pi package from npm:

pi install npm:@srobroek/pi-trunk-dev-policy
opencode plugin add 'github:srobroek/harness-plugins::path:plugins/trunk-dev/opencode'

Needs git. The flag-cleanup bead also needs gh or glab, bd, bun, and the srobroek.beads plugin installed beside this one.

Claude Code install the skills from this repository's marketplace:

claude plugin install trunk-dev@harness-plugins

There the skills have no gate or advisories behind them.

Commit gate

tool.hook("execute.before") on shell throws, so the command does not run, only in a repository that releases from commits (a .releaserc*, release.config.*, release-please config or manifest, commitlint config, or a release key in package.json at the root):

  • git commit whose first -m/--message, -F/--file file or -F - here-document subject is not a Conventional Commit header. Editor commits, fixup!, squash!, Merge … and Revert … subjects pass. Override with TRUNK_DEV_ALLOW_NONCONVENTIONAL_COMMIT=1.
  • git push to main/master: an explicit destination, a bare HEAD/@ or no refspec from the main branch, or --all/--mirror. Dry runs, deletions, tags, other branches and unknown options pass. Override with TRUNK_DEV_ALLOW_MAIN_PUSH=1.

Overrides count as a NAME=1 prefix on the command (or through env) or in the process environment. This is an early local guardrail, not enforcement: protected branches, required pipelines and forge title checks enforce the policy.

Here and in the advisories, git means git, or a wrapper listed in gitWrappers (see Options).

Advisories

tool.hook("execute.after") appends notes to a completed shell call that did not exit non-zero. They never block. The Conventional Commit title hint is on by default. In OpenCode, use { "disable": ["mr-title"] } to turn off only that hint; the rest of the MR advisories stay enabled. Use mr-advisory to disable all MR advisories.

AdvisoryFires on
Skip-CIgit commit, glab mr … or gh pr … whose words or here-document contain [skip ci], [ci skip], [no ci] or [skip actions], case-insensitive. Forges skip the pipeline even for a marker quoted as prose.
Titleglab mr create/gh pr create with a literal title that is not a Conventional Commit.
Flag lineA feat or breaking create without a Flag: line, or with Flag: none and no reason. Flag: none -- <reason> is valid. A body from a file, stdin or an expansion gets a reminder to review it.
Squashglab mr merge/gh pr merge without --squash/-s in a release repository.
Branch ageA branch push whose merge base with the default branch is more than two days old.

Session reminders

In a commit-released repository with a Beads ledger, the first completed shell result (including a failed command) receives any stale-branch or missing CI-job reminder. Only local branches linked by bead metadata.branch count: claims older than TRUNK_DEV_STALE_HOURS (default 48), or closed/merged beads with live branches. At most five branches are listed. Known GitHub/GitLab remotes are checked for the stale-bead-branches job; the release-setup skill ships its templates.

Reads use supervised git (2 s) and readonly bd (5 s), without starting a Dolt server. Each session is probed once, including concurrent calls; failures and clean repositories are silent. Disable with "session-reminders" in disable.

Flag-cleanup bead

When a flagged feat request merges, trunk-dev creates one chore, chore: remove feature flag <name>, due on the recorded removal date, with metadata.trunk_dev_flag, the PR URL, and a discovered-from link to the landed bead. The Flag: line must be Flag: <name> (default off; owner <alias>; remove by YYYY-MM-DD).

A merge is observed in execute.after as a completed delivery_land whose output is ok: true (from the srobroek.delivery plugin), or a gh pr merge <n>/glab mr merge <n> shell call that exited 0. The request is then read back with gh pr view/glab mr view, and only one the forge reports as merged counts, so an --auto merge creates nothing. An open cleanup bead for the flag (by metadata or a remove … flag title) suppresses a duplicate.

The write follows the beads plugin's conventions: bd --actor <actor> create … runs under that plugin's bd-embedded-write-runner, which holds the embedded store's single-writer lock for the life of bd, with BEADS_DIR pinned and BEADS_DOLT_SHARED_SERVER cleared. The actor is BEADS_ACTOR, else BD_ACTOR, else opencode/trunk-dev (pi/trunk-dev on pi). The hook waits 30 s and never kills the writer. When the runner cannot be found or refuses, the result carries the exact bd create command to run through the shell tool, where the beads gates apply and the beads plugin supplies a subagent's actor (the command names none). Every other failure is silent.

Skills

Only trunk-dev-guide is listed to the model in OpenCode: it is a router whose body maps each situation to the skills below, which set opencode/autoinvoke: false and load by id. One listing entry instead of one per skill keeps the per-request skills listing short. Claude Code ignores that metadata, so there every skill is listed and triggers directly.

Registered through ctx.skill.transform (a user skill of the same name wins):

NameWhen
trunk-dev-workflowBranching, opening, merging or landing an MR/PR: small batches, short-lived branches, required CI, squash release units, exact-SHA previews, forge enforcement, skip-CI markers.
trunk-dev-feature-flagsAdding a feat, writing the Flag: line, rolling out or removing a flag. Code and storage details live in quality-code-design's feature-flags.md; AWS specifics live in aws-guidance.
trunk-dev-release-setupSetting up release automation with semantic-release as one option, release-please where supported, or another project-chosen tool; the daily stale-branch CI job for Beads repositories (templates in templates/).

pi

One extension, pi/extensions/trunk-dev.js (source pi-src/trunk-dev.ts), carries every pi feature. Advisories keep the OpenCode order. It replaces the skip-ci entry that shipped skip-CI alone.

Featurepi hookBehavior
Commit gatetool_call on bashReturns { block: true, reason: "trunk-dev: …" } for the commits and pushes listed under Commit gate, checked in ctx.cwd. The same overrides apply. A gate that throws allows the call.
Advisoriestool_result on bashAppends skip-CI, then the title, flag-line, squash and branch-age advice, as one text block on a result that is not an error. The structured result is kept.
Flag-cleanup beadtool_result on bashFollows a gh pr merge <n>/glab mr merge <n> that exited 0, as described under Flag-cleanup bead.

The gate never asks: it refuses as the OpenCode gate does, so print, JSON and RPC modes, where pi has no dialog, behave the same as the TUI.

Not on pi: the delivery_land merge source, session reminders, and the disable option (including the Conventional Commit title toggle).

pi passes no options to an extension. This one reads only gitWrappers, from the trunk-dev key of pi's user settings, ~/.pi/agent/settings.json (or settings.json under PI_CODING_AGENT_DIR), for example { "trunk-dev": { "gitWrappers": ["git", "<wrapper>"] } }. The extension ignores a project's .pi/settings.json, so a repository cannot change which commands the gate treats as git. Without the key, the gate treats only git as git. A trunk-dev value that is not an object leaves only git and warns at session start. So does a settings.json that is unreadable or not valid JSON.

pi-subagents' foreground children do not load the parent's extensions (required host extensions). List this extension for every child in ~/.pi/agent/settings.json, with the path where pi installed this repository:

{
  "subagents": {
    "defaultSubagentOnlyExtensions": ["<harness-plugins>/plugins/trunk-dev/pi/extensions/trunk-dev.js"]
  }
}

An agent that sets its own subagentOnlyExtensions replaces this default, so it must list the path too.

Options

{
  "disable": ["commit-gate", "skip-ci", "mr-advisory", "mr-title", "flag-cleanup", "session-reminders"],
  "gitWrappers": ["git"]
}

gitWrappers lists the commands the commit gate and the advisories treat as git: git itself and any wrapper that takes git's own arguments. The default is ["git"], a list replaces it, and each entry matches the command word's basename.