A pull-request workflow on one long-lived branch, main: every change enters main through a squashed pull request, a merge to main deploys to development or publishes a -dev prerelease, and release-please keeps the release pull request whose merge tags the version and publishes or deploys it. Use it whenever the work touches branching, pushing or releasing in a repository whose AGENTS.md says it follows git-workflow: starting a change; pushing a branch; opening or merging a pull request; prepa...
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Git Workflow?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/jorgecostamacia-git-workflow)
---
name: git-workflow
description: >-
A pull-request workflow on one long-lived branch, main: every change enters
main through a squashed pull request, a merge to main deploys to development
or publishes a -dev prerelease, and release-please keeps the release pull
request whose merge tags the version and publishes or deploys it. Use it
whenever the work touches branching, pushing or releasing in a repository
whose AGENTS.md says it follows git-workflow: starting a change; pushing a
branch; opening or merging a pull request; preparing or cutting a release;
the version; tags; patching an old major; or moving a repository over from
develop or gitflow. Use it even when the person does not name it ("push
this", "ship it", "merge the PR", "cut a release", "saca una versión", "tag
it"). It encodes the branch model, the versions and the -dev
prereleases, the release with release-please, the hotfix of an old major,
what an agent may and may not do, and the one-time repository settings. A
repository that follows gitflow keeps gitflow.
---
# Git workflow
One branch lives forever: `main`. Every change is a short branch that enters `main` through a squashed pull request. A merge to `main` deploys to the development environment or publishes a `-dev` prerelease. [release-please](https://github.com/googleapis/release-please) keeps one release pull request open; when the person merges it, the release gets its tag `v*` and its GitHub Release, and deploys to production or publishes the stable package.
The repository's `AGENTS.md` says which workflow it follows. A repository that follows `gitflow` keeps `gitflow` until someone moves it to this workflow (see the last section). Never mix the two in one repository.
## Before following it
Check that the repository really is set up for this workflow:
- Its `AGENTS.md` names `git-workflow`. When it names another workflow, follow that one and say so. When it names none, ask the person which workflow the repository follows.
- `git ls-remote --heads origin develop` shows nothing. When `develop` still exists, the repository has not moved yet: tell the person, and follow the last section if they want to move it now.
- `release-please-config.json` and `.release-please-manifest.json` exist at the root, and a Release workflow calls `github-release-please` of [github-workflows](https://github.com/JorgeCostaMacia/github-workflows) on pushes to `main`.
- `gh repo view --json defaultBranchRef,mergeCommitAllowed,squashMergeAllowed,rebaseMergeAllowed` shows `main` as the default branch, squash allowed, and merge commit and rebase off.
- `gh api repos/<owner>/<repo> --jq '{squash_merge_commit_title, squash_merge_commit_message, delete_branch_on_merge}'` shows `PR_TITLE`, `PR_BODY` and `true`.
If something is missing, tell the person what and how to change it (see "Repository settings"). Go on only when they say so. A change to a repository setting is their decision.
## Branch model
| Branch | Starts from | Enters through | Merge method |
| --- | --- | --- | --- |
| `<name>-<ts>` | `main` | pull request to `main` | squash |
| `release-please--branches--main` | release-please opens it | its release pull request to `main` | squash |
| `release/<major>.x` | the last tag of an old major | never merges | |
- `main` is the default branch. People see, clone and install it. Its tip is what the development environment runs, and the latest stable tag is what production runs.
- A work branch has a flat name with no prefix: what changes and the local time, `agent-guards-tag-push-202612031230`. The type of the change is in the title of its pull request, not in the branch name.
- `<name>`: a lowercase letter or digit first, then lowercase letters, digits, `.`, `_` and `-`. No `/`, uppercase letters, spaces or accents: reject them; do not correct them. It never starts with `release` and is never `main`, `master` or `develop`. It never looks like a version: it does not start with `v` and a digit (`v3-pin-workflows`), or with digits and dots (`1.4-fix`), because tools take such a name for a tag. `<ts>` is the local time as `YYYYMMDDHHmm`.
- Squash only: one commit per pull request, whose subject is the pull request title in Conventional Commits and whose body is the pull request description. The history reads as a list of changes, and the commit types say how the next version grows.
- `Closes #12` in a pull request closes the issue when the pull request merges. For an issue in another repository, write `Closes <owner>/<repo>#12`.
- The release branch belongs to release-please: it rewrites it on every push to `main`. Never commit to it.
- A `release/<major>.x` branch exists only to patch an old major (see "Hotfix").
## A change
1. Validate `<name>`. Check that the working tree is clean.
2. `git switch main && git pull --ff-only`
3. `git switch -c <name>-<ts>`
4. `git push -u origin <branch>` for backup.
5. If `main` moved, merge it before you open the pull request: `git fetch origin && git merge origin/main`. Never rebase a branch that is already pushed: that needs a force push.
6. Open the pull request with `--base main`. Its title is a Conventional Commit and its description is the body of the squash commit, so both reach release-please: a breaking change has `!` in the title, and the last paragraph of the description is `BREAKING CHANGE: <what breaks and what to do>`, the footer of the squash commit (see `create-pull-request`).
7. The checks pass and a person merges it. After the merge, run `git switch main && git pull --ff-only`.
8. Before you delete the local branch, run `gh pr view <branch> --json state,headRefOid`. Check that `state` is `MERGED` and that `headRefOid` is the tip of the local branch (`git rev-parse <branch>`). If not, stop and tell the person: the branch can hold work that is not merged.
9. Delete the local branch with `git branch -D <branch>`. After a squash, `-d` refuses the branch as unmerged, although its changes are in `main`.
## Versions
The version grows from the Conventional Commits: a breaking change (`feat!`, `fix!` or a `BREAKING CHANGE` footer) is a major, a `feat` a minor, and a `fix`, `perf` or `revert` a patch. The other types (`docs`, `ci`, `chore`, `build`, `test`, `refactor`, `style`) change nothing for whoever consumes the repository: release-please hides them, so they make no release and no changelog line. A change to a text that an agent reads or runs (a skill, a rule, a hook, a prompt) changes behavior, so it is a `feat` or a `fix`, never `docs`. A dependency update that reaches consumers is a `fix(deps)`. release-please applies this rule; nobody picks the version by hand. A change that fails or behaves differently for someone who does nothing (a changed default, a new requirement on the environment, a check that now blocks) is a breaking change, because the `BREAKING CHANGE:` paragraph is the only place where the changelog says what to do.
- `.release-please-manifest.json` holds the last released version of every repository. A package also keeps it in its own files, which release-please bumps in the release pull request: `version` in `package.json` (release type `node`), `<VersionPrefix>` in the root `Directory.Build.props` (an `extra-files` entry of type `xml`), or the files that `release-please-config.json` lists.
- On each merge to `main`, CI publishes the prerelease `X.Y.Z-dev.<run>`, where `<run>` is the number of the CI run. When the tag `v<file version>` already exists, CI bumps the patch (`1.4.0` gives `1.4.1-dev.<run>`), so a `-dev` version always sorts above the last stable one. On npm it goes under the dist-tag `dev`, so that `latest` stays the stable version; on NuGet the suffix makes it a prerelease. CI changes no file and makes no commit. The agent never chooses or publishes these versions.
- A web or a service publishes no package: its merge to `main` deploys to development, and its release deploys to production. Its version lives only in the manifest and the tag.
- A release never references a prerelease of another package (`-dev`, `-rc`). Before the release pull request merges, check the package references.
## Release
release-please runs on every push to `main`. It reads the Conventional Commits since the last release and keeps one pull request open, `chore(main): release X.Y.Z`, with the version bump and the `CHANGELOG.md` entry. More merges to `main` update it, and it stays open until the person wants a release. When it is merged, the same run creates the tag `vX.Y.Z` and its GitHub Release, then publishes the stable package or deploys to production.
The person decides when to release, by merging that pull request. When the person asks for a release:
1. Find the release pull request: `gh pr list --label "autorelease: pending" --base main`. When there is none, nothing has merged since the last release, or the last Release run failed (`gh run list --workflow Release --branch main`): tell the person.
2. Show the person its version, the reason for it (the commits that set it) and its entry. Check that it changes only the version files, the manifest and `CHANGELOG.md`.
3. Check the package references (see "Versions").
4. Wait for the person's yes. A major always needs their explicit confirmation.
5. The person merges it: `gh pr merge <number> --squash --admin`. Its checks do not run, because GitHub runs no workflow job for a pull request that the run's own token opens: it shows a failed or waiting run with no jobs, which does not matter. The Release workflow builds and tests again before it publishes or deploys.
6. Follow the Release run (`gh run list --workflow Release --branch main`) and tell the person the tag, the Release and what was published or deployed.
To release another version than the computed one, a pull request carries a `Release-As: X.Y.Z` line in its description, which becomes the footer of its squash commit. To fix the entry of a merged pull request, the person edits its description with a `BEGIN_COMMIT_OVERRIDE` … `END_COMMIT_OVERRIDE` block; the next run rewrites the release pull request.
When the Release run fails, fix the cause in a new pull request; the next release carries it. Never delete or move a tag, and never cut a new version to replace a failed one without the person's decision.
## Hotfix
A fix for the current major is a normal change to `main`, then a release.
To patch an old major that `main` has left behind:
1. The person creates `release/<major>.x` from the last tag of that major, once, and adds it to the ruleset of `main` (see "Repository settings"). If that major was released before the repository used release-please, the branch has no release-please configuration. Then the first pull request to `release/<major>.x` adds `release-please-config.json`, a `.release-please-manifest.json` with the last version of that major, and the Release workflow that calls `github-release-please` on pushes to that branch.
2. `git switch release/<major>.x && git pull --ff-only && git switch -c <name>-<ts>`. The fix, then a pull request to `release/<major>.x`, squash.
3. release-please opens the release pull request of that branch, against it, and its merge releases the patch as on `main`. On npm, the publish of an old major uses its own dist-tag (`v<major>`), so that `latest` stays on the current major.
4. When the fix applies to `main` too, open a separate pull request to `main` with it. The two branches never merge.
## What an agent does and does not do
- It never pushes to `main`, to a `release/<major>.x` branch or to the release branch of release-please, and it never force-pushes a shared branch.
- It merges a pull request only when the person asks for that merge in the conversation. Before a merge, name the pull request, its base and what it publishes or deploys, and wait for a yes. "Ship it" or "put this in production" is not by itself the approval to merge the release pull request.
- It never creates, pushes, deletes or moves a release tag: release-please creates it.
- When it cannot push or merge, it does every local step, then stops and gives the person the exact command.
- It commits as the `git-commit` skill says: the identity, the format of the message and its trailers.
## Packages that publish in tiers
When packages depend on each other through a package registry, a dependent can try a change against a `-dev` prerelease of the package below, but it releases only against a stable version. A tiered set then needs one release per tier. Wait until the registry indexes each tier before the next tier references it. Tell the person before you start, and agree the order with them. Each tier is a normal release with its own tag.
## Repository settings (once per repository)
- `main` is the default branch.
- A ruleset on `main`, and on the `release/<major>.x` branches when they exist: pull request required, the required checks passing, review from code owners (a `CODEOWNERS` file that names the owner), no force push, no deletion. The owner is in the bypass list for pull requests only.
- A ruleset on the tags `v*`: block updates and deletions, with only the repository admins in the bypass list. Creations stay allowed, because the run's token creates the tag.
- Actions may create pull requests ("Allow GitHub Actions to create and approve pull requests"), and `googleapis/release-please-action@*` is among the allowed actions.
- `release-please-config.json` lists every commit type in a changelog group, in this order: `feat` in Added, `perf` and `revert` in Changed, `fix` in Fixed, and the other types in Maintenance with `"hidden": true`, because they make no release; and `.release-please-manifest.json` holds the last released version. The header of `github-release-please` shows both.
- The environments that publish or deploy to production accept only `main` and the `release/<major>.x` branches, which publish the patches of an old major.
- Squash is the only merge method. The squash commit takes the pull request's title and description (`squash_merge_commit_title` set to `PR_TITLE`, `squash_merge_commit_message` set to `PR_BODY`): a pull request with one commit still lands with its title, and the body does not list the branch's commits, which release-please would count as more changes. Automatic deletion of head branches is on.
- CI checks that pull request titles use Conventional Commits.
## Moving a repository from develop and main, or from gitflow
1. In gitflow, finish or close every open `release/*` and `hotfix/*` branch with `gitflow` first.
2. Release what `develop` holds, so that `git rev-list --count origin/main..origin/develop` is `0`.
3. Change the base of the open pull requests to `main` (`gh pr edit <number> --base main`), and merge `main` into their branches.
4. In one pull request: CI runs on `main` and on `release/<major>.x`, and no longer on `develop`; the Release workflow calls `github-release-please` on pushes to them instead of running on tags; `release-please-config.json` and `.release-please-manifest.json`, with the last released version; Dependabot has no `target-branch`; and `AGENTS.md` and `CONTRIBUTING.md` say the repository follows `git-workflow`.
5. The person applies the repository settings above, removes the protection of `develop` and deletes it.