Skip to content

Latest commit

 

History

History
417 lines (342 loc) · 30 KB

delivery.md

File metadata and controls

417 lines (342 loc) · 30 KB

Delivery

GitHub CI confirms that work is ready; it is not where you find out whether it works. Each push costs a full CI cycle (often 30 minutes or more), and each merge to the default branch can trigger the CI of every other open PR again. devkit's method, which the global instructions and the devkit delivery skill teach both agents, is integrate and verify locally, push once, get one CI run. The dev commands for git and GitHub (Git and GitHub) apply it at every step: dev push, dev pr create, and dev release refuse to run without local CI evidence.

Local-first delivery: feature branches are merged on one local integration branch, where dev ci --run runs the local equivalent of CI and records the evidence; only a green local run is pushed once with dev push and opened as one PR with dev pr create, so CI runs once; a red CI run is reproduced and fixed locally; a green run is merged with dev pr merge, tagged and released with dev release under a CalVer version, and verified.

The delivery policy

Every project has one recorded way to version, test, release, and ship: its delivery policy. devkit detects what the repository does today, recommends a policy that keeps what works, and records the one you choose in the handoff repository, where every session sees it and dev release follows it.

Delivery policy: dev delivery detects what the repository does today and recommends a policy that keeps what works, listing the gaps; dev delivery apply records it with a reason in policies/<scope>.json, versioned with its history, and --tasks opens a work item per gap; every session sees the policy, dev release refuses tags that break it, and releases follow it.

Detect and recommend

dev delivery            # detected · recorded or recommended policy · gaps, each with its fix
dev delivery --json     # the same, for tools and agents

devkit reads the repository:

It looks at For example
Version tags and version files v26.11.0 tags; package.json, pom.xml, pyproject.toml, composer.json, gradle.properties, build.gradle.kts, Cargo.toml, VERSION
Release tools release-please, semantic-release, goreleaser, git-cliff, changesets, bump-my-version, commitizen, maven-release-plugin
Changelog CHANGELOG.md in Keep a Changelog format, or another changelog file
CI and the test gate GitHub Actions, GitLab CI, Bitbucket Pipelines, Azure Pipelines, Jenkins; the commands CI runs
Branch model Trunk-based, GitFlow (develop), release branches
What it publishes and deploys Maven, npm, PyPI, Packagist, container images; GitHub Pages, Kubernetes, containers, platform configs

Then it recommends, keeping what works:

Situation Versioning
The repository already has a consistent scheme Keep it. PEP 440 versions with pre, post, or dev releases (0.1.0a16, 1.0.0.post1, 2.0.0.dev3, 1.1.0rc1) are their own scheme, pep440, with the tag format vMAJOR.MINOR.MICRO[{a|b|rc}N][.postN][.devN] and PEP 440's bump rule; plain vX.Y.Z and SemVer pre-release tags stay SemVer
A library others depend on (it publishes to Maven, npm, PyPI, or Packagist) SemVer, vMAJOR.MINOR.PATCH, bumped from Conventional Commits
An app, service, platform, or internal tool CalVer, vYY.MM.PATCH (dev calver --next)
Projects that release together as one set A release train on their initiative (-i <slug>)

The gaps are what stands between the project and a release you can trust, by severity: no recorded policy, no CI, no test gate (high); no version scheme, no changelog, artifacts published without a release workflow (medium); a version file out of step with the tags, a long-lived develop branch (low).

Record it

dev delivery apply --why "first release policy: service, CalVer, Maven verify gate" --tasks
dev delivery apply --set versioning=semver --set test_gate="./mvnw -B verify" --why "it is a library now"

dev delivery apply writes policies/<project id>.json (or policies/initiatives/<slug>.json) in the handoff repository: the versioning and tag format, the version source, the release flow, the changelog, the test gate, the CI, the branch model, what it publishes and deploys, the bump rule, and an optional release train. Each change bumps the policy's version, adds a history line (who, when, what changed, why), and makes one commit. --tasks opens a work item for each gap. Change policies/ only with dev delivery apply, which keeps that history.

The optional field job_timeout_minutes (default 30, from 5 to 360) is the CI job limit that dev ci audit suggests, dev ci audit --fix writes, and dev ci init gives every job it generates (see CI/CD pipelines › Job timeouts). The policy's test gate is also what the test job of a generated pipeline runs.

dev delivery apply --set job_timeout_minutes=45 --why "integration tests take 35 minutes"

What the policy does

  • Every session sees it. The session context shows the policy in one line: versioning and tag format, release flow, and test gate. A project without one gets a reminder to run dev delivery before its first release.
  • dev release refuses tags that break it. In a CalVer project, dev release --version 2.0.0 is refused with the next version to use (dev calver --next); in a SemVer project, a tag that is not vMAJOR.MINOR.PATCH is refused, and in a pep440 project, a tag that is not a PEP 440 version. Change the policy to release another way. A raw git tag is not checked.
  • dev release names the tag in the project's format. The tag is v26.11.4 when the policy's tag format starts with v (vYY.MM.PATCH) and 26.11.4 when it does not (YY.MM.PATCH). When no policy is recorded, or the policy names no tag format, the format is the one dev delivery detects from the repository's CalVer, SemVer, or PEP 440 tags, spelled as the newest version tag is (after v26.10.0 and 26.11.0, without the v), and v<version> when there is none. dev release pushes that tag and names the GitHub release after it, a refused tag is told in that spelling, and dev calver and devkit's CI watch use it too.
  • The release workflow runs on every release tag of the format. The pipeline that dev ci init generates runs on tags spelled as dev release spells them: X.Y.Z under CalVer; X.Y.Z and its pre-releases (X.Y.Z-rc.1) under SemVer; and under PEP 440, X.Y.Z with an aN, bN, or rcN pre-release, a .postN, and a .devN (0.1.0a17). On GitHub and GitLab no other tag starts a release, v1.2.3junk and SemVer build metadata (1.2.3+build.5) included; the Bitbucket and Azure patterns are wider (v*.*.*, v*). dev release takes X.Y.Z only, so a SemVer pre-release tag comes from dev push, and under PEP 440 a version without three release numbers or with an epoch (0.2a1, 1!1.0.0) starts no release workflow.
  • Release work requires the release-policy skill. Tags and releases (git tag, dev release, gh release), release work, and changes to VERSION or release-tool configuration require the delivery and release-policy skills. A push or a PR requires delivery, and a CHANGELOG.md entry requires docs (see Skills and plugins › Required skills).

devkit records its own policy this way, with CalVer vYY.MM.PATCH from VERSION, a Keep a Changelog CHANGELOG.md, and a test gate that compiles the code and runs the suite with Homebrew's Python and with the macOS system Python 3.9.

1. Know the pipeline

dev ci                 # workflows, triggers, jobs, runners, matrices, setup actions, every run: command
dev ci --commands      # only the commands, in order
dev ci --runs          # plus the recent runs
dev ci --run --dry-run # which of those steps run on your Mac, and why the others do not
dev ci audit           # what makes the pipeline slow, unreliable, or unsafe, with the fixes

Use the same tool versions as the setup steps (setup-node, setup-java, setup-python). To diagnose, fix, or set up the pipeline itself, see CI/CD pipelines.

2. A single change

dev branch new feat/x                   # from an up-to-date origin/main
# … small steps, targeted tests while iterating …
dev commit -a -m "feat(scope): summary" --why "the problem and who it affects" --verified "the command and its result"
dev ci --run            # the full local equivalent of CI: lint, types, unit, integration (Testcontainers), build
dev sec scan            # secrets, dependencies, code patterns, IaC, workflows
dev push                # one push, only with local CI evidence for exactly these files
dev pr create --dry-run | sed '1,/^---$/d' > body.md   # the pre-filled body; fill "What and why", then:
dev pr create --body-file body.md
dev ci watch --wait --pr <n>   # an agent arms it as a Monitor or background command and names its task id

The commit message follows devkit's commit template: --why writes the reason, --verified the Verified: line with the command you ran and its result (see Git and GitHub › Commits).

The pull request description follows the template in Templates › Pull request description: what and why, changes, how to verify (with the local results), risk and rollback, links. dev pr create fills the changes, the local CI result, and the links, and refuses a PR whose "What and why" or "How to verify" is still empty. The title follows the repository's own convention: a Conventional Commit, or a plain imperative sentence where the recent pull request titles are sentences (see Git and GitHub › Create).

When only a CI host setting changed

A local run cannot test how long a job may run or which runs cancel each other. When a commit changes only those settings after a local run, such as a longer timeout-minutes for a slow test job, devkit keeps that run's evidence instead of asking for a new one. The evidence carries over to HEAD when all of these hold:

  • Every file changed since the tree with evidence is a GitHub workflow (.github/workflows/*.yml) that was edited, not added or deleted.
  • Each one differs only in timeout-minutes, concurrency (its group and cancel-in-progress), or comments. Two checks must agree: devkit's reading of the workflow is the same once those settings are left out, and every added or removed line is blank, a comment, or one of those settings.
  • No changed workflow uses YAML anchors, aliases, merge keys, tags, or directives.
  • Nothing under .github, and no zizmor.yml or zizmor.yaml at the root, has uncommitted changes, and actionlint (brew install actionlint) and dev ci audit (no high or critical finding) pass on the workflows.

dev push, dev pr create, dev pr ready, dev release, and dev ci --evidence then record a host-only marker for HEAD that names the run it rests on and what was checked, and say so:

  local CI evidence carried over: only CI host settings changed since the local run on c6fedeb (.github/workflows/ci.yml: jobs.test.timeout-minutes), which a local run cannot exercise · actionlint: no findings · dev ci audit: no high or critical finding
✓ local CI evidence for 23899fb: dev ci --mark-passed on c6fedeb, then CI host settings only (.github/workflows/ci.yml: jobs.test.timeout-minutes), just now

Any other change needs a local run: a run command, a step, a trigger, the permissions, the matrix, the runner (runs-on), or another file. The refusal names the first difference, such as .github/workflows/ci.yml changed jobs.test.steps[1].run, which a local run exercises. dev ci --run --resume keeps a passed step after a host-only change, except a scanner that reads every file (such as gitleaks, semgrep, trivy, Vale, or dev sec scan), which runs again because it reads the workflow too.

Back up early, CI once

"Push once" protects CI time, not your work: a commit that exists only on this Mac is lost with the disk. Back up as you go whenever that costs no CI run, open the PR early as a draft, and mark it ready once:

dev backup               # the branch to origin, only when the push starts no CI run (fast-forward, scanned)
dev pr create --draft    # visible early; a draft runs no job when ci.yml has the draft gate
dev pr ready             # the one CI run: marking it ready starts it, with local CI evidence for HEAD

dev backup reads the CI configuration of the commit it would send and pushes only when it shows that the push starts no run: in this repository, ci.yml runs on pull requests and pushes to main, so a branch push is free. When the push would start CI, or devkit cannot tell, it does not push and says why and what to do (dev backup --accept-ci, or a branches-ignore entry). It never pushes the default branch, a long-lived branch (main, master, develop, gh-pages) or a branch a workflow deploys from, never forces, stops at a diverged remote branch with the commands to resolve it, and runs the secret scan on exactly the commits it sends: those the remote it pushes to does not have, even when another remote has them. dev sync does the same every hour and at the end of a session, for commits older than backup.after_minutes (30 by default; backup.auto: false turns it off). The branch map (dev branch ls, dev status, the handoff note) shows each branch's last backup, or why it is not backed up.

Each project has a backup policy, kept in its handoff note so that every machine and the team follow it: on (dev backup and the hourly dev sync push its branches), off (never), or ask. Without a choice, a private repository is on and a public one is ask (so is one whose visibility devkit cannot read), because a backup of a public repository publishes the branch at once. With ask, a dev backup run in a terminal asks once and records on or off. A backup with no terminal to ask in (an agent's call, dev sync) asks nobody: in auto mode a private or internal repository's branches are backed up, and a public repository's branches wait for dev backup --public or a policy of on; in guided mode every branch waits and the message says so. Explicit off remains effective. Set the policy through dev backup policy on --why "open source: the code is public anyway" (or off, or ask); dev backup policy shows it, and so do dev status, dev branch ls, the handoff note and the messages of dev backup. The policy records the repository's visibility when it was set. An on set while the repository was private, or before devkit recorded the visibility, no longer holds once the repository is public or its visibility cannot be read: devkit treats it as ask again, because a backup would now publish the branch. A policy set while visibility was unavailable records unknown; a later visibility change triggers that check too. The skipped backup says which visibility the policy was decided for. dev backup --public pushes once, whatever the policy. With on, embargoes still hold, and on a public repository a branch whose new commits read as a security fix, or change a red-team test that still expects a failure (an open gap), still waits for an embargo or --public. Changing the policy, dev backup --public, and dev branch embargo --lift run for whoever calls them, you or an agent: in guided mode, the global instructions have the agent ask you first, as for any decision about risk. A backup does not incidentally lift an embargo.

A branch that must stay off a public remote, such as an unreleased security fix, gets an embargo: dev branch embargo fix/x --why "discloses an open hole" --until "the security release". No backup pushes it, nor a branch that holds its commits (also after fix/x is merged into a release branch and deleted: the embargo keeps the branch's tips), until dev branch embargo --lift fix/x. dev push and dev backup read the embargoes of every project in one pass and hold any project's embargoed commits, so a copy of the project under another project's remote, or with none, still keeps them here. A branch's own name counts only for this checkout's project and the one the push target names. Only the commits the push target already has count as public: a commit on another remote stays held. When devkit cannot read a project's handoff note, or an audit trail file it reads embargoes from, it backs up and pushes nothing, and the refusal names what it could not read. On a public repository, devkit suggests an embargo when a branch's commits read as a security fix.

An embargo binds devkit's own commands: dev backup, dev sync, and dev push never send an embargoed branch or the commits its embargo holds. It does not stop a raw git push or gh pr create, which run with your permissions whoever types them; protect the branch on your Git host when that matters.

The embargo list and the backup policy in the handoff note change through dev branch embargo (--lift to lift one) and dev backup policy, which record who changed them and why. An embargo that disappears from the note without its lift record (git.embargo in the audit trail) keeps holding, in backups and the branch map, until dev branch embargo --lift.

dev ci init writes the draft gate, and dev ci audit --fix adds it to an existing workflow: types: [opened, synchronize, reopened, ready_for_review] on pull_request and if: github.event.pull_request.draft == false on the jobs. With delivery.draft_pr on, dev pr create opens drafts by default (--ready for a PR that is ready now).

3. Branches or PRs that land together

dev branch new release/26.11.4
git merge --no-ff origin/feat/a          # oldest dependency first
git merge --no-ff feat/b                 # local branches of other worktrees work too: same repository
# resolve conflicts once; bump the version, CHANGELOG and docs once
dev ci --run                             # the full local suite on the result
dev push
dev pr create --title "chore(release): 26.11.4" --body-file body.md   # "Integrates #12, #17, #22"
dev ci watch --wait --pr <n>

Ask the sessions working on those branches to commit locally and stop pushing. Never merge the individual PRs one after another to see what CI says; the integration PR supersedes them. dev calver prints the next version and the release branch name when the project uses CalVer.

Change fragments

Branches that run in parallel all edit CHANGELOG.md, so their merges collide on it even when their code does not. A repository that keeps a changes/ folder takes its CHANGELOG lines from fragments instead:

  1. Each branch writes its lines to changes/<branch>.md, its name with / as -: feat/invoice-export writes changes/feat-invoice-export.md. The lines go under Keep a Changelog headings (### Added, ### Changed, ### Deprecated, ### Removed, ### Fixed, ### Security); each entry starts with a - bullet, and its next lines are indented by two spaces:

    ### Added
    
    - The invoice list exports a month as CSV.
    
    ### Fixed
    
    - The login page keeps the last user for 30 days, as
      the settings page says.
  2. On the release branch, after the merges, dev release writes every fragment into the version's section of CHANGELOG.md, in Keep a Changelog's order, and removes the fragment files; both are staged for the release commit. The version is --version, else the one the branch names (release/26.11.4); an integration/<topic> or hotfix/<topic> branch names none, so it needs --version. The version is checked as dev release checks a tag's: X.Y.Z (a plausible YY.MM.PATCH under CalVer), or PEP 440 where the repository uses it, and refused when its tag already exists here or on origin, with or without the v (v26.11.4 or 26.11.4), so a released section takes no new lines. A section the release already has keeps its lines and takes the fragments' entries after them; a new one goes before the newest release, below an Unreleased section, or, with no release yet, at the end. The link definitions at the end of the file stay there. Nothing is tagged on a release branch.

  3. Review the section, bump the version files, and commit. A second dev release before that commit says so. Then go on as for any change: dev ci --run, dev push, dev pr create. After the merge, dev release on the default branch tags the release, and refuses while a fragment is left.

dev release --dry-run                    # on release/26.11.4: the fragments it would write into CHANGELOG.md
dev release                              # writes them and removes the fragments, staged; tags nothing here
dev commit -m "chore(release): 26.11.4" --why "…" --verified "…"

dev ci --run and dev ci --mark-passed fail a branch that changes CHANGELOG.md when it is not a release/, hotfix/ or integration/ branch. They name the commits that changed it and the fragment to move the lines to, and a branch cut from an unmerged release branch is judged by its own commits only. They also fail, and dev release refuses, naming the file and line, on a fragment they cannot read or that is not UTF-8, a symbolic link in changes/, or a file there that is no .md fragment. dev ci --run --dry-run names the first of these problems it finds and still plans the steps. changes/README.md is no fragment: it explains the format and keeps the folder, which turns these checks on, after a release removed every fragment. A repository without a changes/ folder keeps editing CHANGELOG.md as before.

4. Follow CI

After every push, PR, merge or release, devkit follows the run in the background (dev ci watch) and tells the session how it ended at the session's next hook. A hook runs only when the session does something, so that watch wakes no idle agent. An agent that waits on the run arms a wait that wakes it, in the same turn, and names its task id in its reply. CI is one source of the one wait for every devkit event, dev watch --wait: the background watch's result reaches the agent through it, together with its crew's questions and decisions (see Progress and communication › Waiting and waking). To follow one run job by job, the agent arms dev ci watch --wait instead: in Claude Code as a Monitor or a background command; in Codex, which has no background wake-up, in the foreground with a timeout. A wait that ends before its run (exit 3) is armed again with the command dev watches or dev ci watches prints. The Stop hook sends back a turn that sent work to origin and left its unfinished run with nothing that wakes the agent.

dev watch --wait                      # every devkit event, the CI result included (Claude Code: in the background)
dev ci watch --wait --pr <n>          # a PR's head, or its merge commit once merged
dev ci watch --wait --tag v26.11.4    # a release tag
dev ci watches                        # live watches, and expired ones with the command to re-arm each
dev ci status                         # a look at the runs of the branch: state, jobs, current step, elapsed, ETA

dev ci status is for a look; it wakes nobody. It works with GitHub Actions, GitLab CI, Bitbucket Pipelines and Azure Pipelines; the ETA comes from the last successful runs of the same pipeline. The details and the sign-in each host needs are in Commands › dev ci status, and the watch's exit codes in CI/CD pipelines › Watch every run.

5. When CI fails

After every push, dev ci watch follows the run and, when it fails, reports the first error, its class, and one next action (see CI/CD pipelines › Watch every run).

  1. Read the real error: dev run view --failed (or dev pr checks) shows the failing step and the relevant lines of its log.

  2. Reproduce it locally with the same command and versions, fix it, and run the full local suite (dev ci --run).

  3. Push once. One fix per push, never a "try this and see."

  4. If the failure truly cannot be reproduced on macOS (Linux-only paths, case-sensitive file system, a CI-only secret, runner limits), say so, make the smallest targeted fix, push once, and explain it in the PR.

  5. A flaky failure is re-run only with evidence (passes locally repeatedly, unrelated to the change, known history), recorded in the handoff note, with an explicit acknowledgement:

    dev run rerun <run-id> --flaky "PaymentIT times out on the runner; passed 5 times locally, unrelated to this change"

    devkit records the reason in the project's session log and re-runs only the failed jobs.

6. Release

Release by the recorded policy (see The delivery policy); dev delivery shows it.

  1. Run dev sec scan on the integration branch and fix or justify every finding.

  2. From the verified, green integration branch, merge with the repository's strategy: dev pr merge (squash or merge commit). A squash message repeats the PR title and says what changed and why in one or two sentences, with no attribution lines; dev pr merge writes it from the PR, and marks the open work items linked to the merged branch done.

  3. Tag with the policy's format (signed if the project signs tags), push the tag, and create the release with notes from the CHANGELOG: dev release (--dry-run first) does all three, after it checks the version files, the local CI evidence, and the CI of the commit. It also refuses while work items linked to branches merged since the previous tag are still open: close the shipped ones (dev task reconcile --apply), or give --why "<reason>". In a repository that keeps change fragments, it refuses while a fragment is left: write them into the CHANGELOG on the release branch first. dev calver gives the next CalVer version.

    Python metadata may omit zero padding in the three numeric version components: 26.11.8 in pyproject.toml matches a requested 26.11.08. The tag retains the requested spelling; other version files still match exactly. The release CI check excludes only authenticated GitHub Dependabot update automation. Repository workflows, including Dependabot pull request CI, and runs whose updater identity cannot be verified still count. See Release checks for the verification rules.

    A failed run on the commit refuses the release. A run still in progress does not hold it when a pull request run already passed the same tree: dev release looks for a commit with HEAD's tree whose pull request run, from this repository and not a fork, passed every job still running or queued on HEAD (a job with the same name, in the same workflow file, that succeeded, not skipped), first among HEAD's parents (a merge commit's second parent is the PR's head), then among the PR heads GitHub links to HEAD (a squash or rebase merge). It names that commit (and the PR, when GitHub linked it) and releases without waiting. A skipped, still running, or push-only run does not count, and a job the PR run did not pass holds the release until it passes on HEAD, even before HEAD lists it. When main moved on before the merge, dev release still refuses until the run on HEAD ends (dev ci status --watch).

  4. Download or install the published artifact and smoke-test it.

  5. Update the handoff note (version, what shipped, follow-ups), and mark done with dev task done <id> any task that shipped without a branch of its own.

7. GitOps rules

  • Git is the source of truth for code, configuration, infrastructure, and deployment manifests.
  • Environments change only through merged PRs and tags that pipelines deploy; no manual changes, no drift. An emergency manual change is captured in git immediately.
  • Secrets live in the secret manager or CI secrets, referenced by name, never in the repository. dev commit refuses a commit when gitleaks finds a secret in it.
  • Workflows use least-privilege permissions: and actions pinned to a full commit SHA; dev sec scan checks them with zizmor.

What devkit's commands enforce

These rules belong to devkit's own commands. An agent runs with your permissions, so a raw git or gh command skips them (see Concepts › Agents act with your permissions).

Rule Behavior
Blind re-runs dev run rerun needs --flaky with the reason.
Merges and releases dev pr merge waits for green checks and reviews, and dev gh pr merge refuses --admin; dev release follows the delivery policy and needs CI evidence.
Force pushes dev push refuses a diverged branch without --force-with-lease, a lease that would drop someone else's commits, and any push to the default branch; dev git push refuses plain --force, -f, and +refspec.
Branch names dev branch new, dev branch rename, dev push, and dev pr create refuse a name that breaks <type>/<ticket>-<topic>.
Secrets dev commit refuses a commit that contains a secret found by gitleaks.
Tags dev release refuses a tag that breaks the recorded delivery policy.
Change fragments With a changes/ folder, dev ci --run and dev ci --mark-passed fail a CHANGELOG.md edit outside a release branch and a fragment they cannot read; dev release on a release branch refuses a version that is already tagged, and on the default branch while a fragment is left.
Policies dev delivery apply is the one writer of policies/ in the handoff repository.

See also Git and GitHub, Security policy, Commands › dev ci and Templates.