--- name: git-flow-master description: "Git operator that adapts to the repo's branching strategy. Use when creating a branch, committing, pushing, opening a pull request, fixing a merge conflict or rejected push, splitting a large change into stacked PRs, isolating work in a worktree, or choosing or setting up the git strategy." license: MIT compatibility: [claude-code, codex, opencode, pi] phase: implementation complementary_categories: [] metadata: kind: workflow --- # Git Flow Master: Branches, Commits, Pushes, PRs and Conflicts This skill is the single entry point for everything on the version-control layer: creating branches, writing commits, pushing safely, opening pull requests, resolving conflicts, and planning chained or stacked PRs when a change outgrows the review budget. It runs the operations; the `edd` doctrine skill (`.agents/skills/edd/SKILL.md`) decides when a change may land, so load it before the first push, PR or merge. It does not assume one branching model. The project may run on `main` only, on `main + staging`, on a multi-branch enterprise layout, or on a well-known flow (trunk-based, GitFlow, GitHub Flow, GitLab Flow). The skill detects which one is active and adapts every command to it. Detection is sticky: once resolved, the strategy is recorded in the `git_strategy:` block of `.agents/project.yaml`, so later invocations skip the question. --- ## Compact Rules - Read the repo state (status, branches, diff, log, fetch, upstream, remotes) at the start of every invocation and report it before acting. A wrong guess about state is the most common git mistake. - Resolve the branching strategy from the `git_strategy:` block in `.agents/project.yaml` first, then layout heuristics, then by asking; never pick one silently. Persist the resolution back into that block, not into a separate file and not as policy prose in `AGENTS.md`. The yaml snippets in `references/` (per-strategy field rules, policy examples) are illustrations: a claim about THIS repo's strategy, branches or policy cites `.agents/project.yaml` (or `git:policy verify` output) read in the same turn. - When `git_strategy.meta.strategy_source` is `chosen`, the strategy is confirmed, whatever `project.project_name` holds, and there is no offer. Otherwise, when `git_strategy.strategy` is set but `project.project_name` is null, or `meta.strategy_source` is `inherited` (or absent) on a named project, the strategy came from the template and nobody chose it. Treat it as unconfirmed and offer Strategy Setup once per session. Never auto-run it, and on a "no" proceed under the inherited strategy. - Before any direct push to a protected branch, read `git_strategy.policy.direct_push_to_protected` in `.agents/project.yaml`. `evidence` pushes without asking when the pre-push gate passes; a failed gate means no push and no question, so fix forward and retry. `allowed` is a standing authorization to push without asking and without a gate (asking anyway collapses it into `confirm`). `confirm` asks before every push, because the team chose it. `forbidden` never direct-pushes and routes through a PR. A missing or null value reads as `evidence`. For a PR, `git_strategy.policy.merge_mode` decides: `auto` (missing or null reads as this) and `human-approves` merge on green after `bun run git:policy verify --merge` (host auto-merge where the host requires the checks, the agent's own merge where it does not), `manual` stops after opening. - Never amend, rebase or otherwise rewrite a pushed commit (Critical Rule #6, an invariant: no authorization relaxes it). Fix forward with a new commit. - Force push, `--force-with-lease` and `--no-verify` are a human gate: ask the user, and never use one on a shared branch. - Never run a repo-wide discard (`git restore .`, `git checkout -- .`, `git reset --hard`, untargeted `git stash`, `git clean -f`): concurrent sessions may share this working tree. Discard only explicit paths this session modified, and when ownership is unclear, stop and ask. - Never `git add -A` or `git add .`. List explicit paths, so a secret or another session's work cannot ride along. - One commit has one responsibility, in conventional format (`{type}({ISSUE-KEY}): {description}`). Commit messages, branch names and PR bodies are English and carry no AI attribution. - Close every commit message, in every strategy, with the two forensic trailers `Worktree: ` then `Session: