agentleFS
educlopezeduclopez/mallard/skills/mr-flow/SKILL.md

mr-flow

Skill4 starsChanged 13 days agoMITView on GitHub

Branch, commit, push, open and merge a GitLab merge request for a project, after detecting which branch (main or master) that project actually uses as its base. Use when the user says "haz MR", "crea la MR", "sube esto", "mergea la MR", "abre una merge request", "empieza una rama para la tarea X", "haz commit y push", or finishes a change and wants it reviewed/merged. Works with `glab` on GitLab.com. Runs only the steps the user asked for.

  • Commits and pushes

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    Do only the steps the user asked for.

    line 21
  2. Distinctive:

    Never commit on the base branch or any protected branch.

    line 22
  3. Distinctive:

    Follow the CLAUDE.md of the repo and of the user for commit message language, attribution lines (e.g.

    line 23
  4. Distinctive:

    Check git status -sb and git diff --cached --stat before committing and report what is in the commit.

    line 60
  5. Very specific:

    Add --squash or --remove-source-branch only if the user or the repo convention says so.

    line 88

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

mr-flow

One consistent path from "I changed some files" to "merged into the base branch", without mixing up main and master.

Rules

  • Do only the steps the user asked for. "Haz commit" is not "haz MR"; "haz MR" is not "mergea". Each of commit, push, MR creation and merge needs its own request (or one message that clearly covers them).
  • Never commit on the base branch or any protected branch. Never force-push. Never merge a failing or still-running pipeline, and never merge unless asked.
  • Follow the CLAUDE.md of the repo and of the user for commit message language, attribution lines (e.g. co-author trailers) and PR/MR footers. Do not add any by default.
  • Commits use Conventional Commits (feat:, fix:, refactor:, chore:, docs:, style:), with the scope when it helps.
  • Stage explicit paths, not git add -A, so untracked scratch files do not end up in the commit.

1. Detect the base branch

Projects differ: some use main, others master. Never assume.

git fetch -q origin
git remote set-head origin -a >/dev/null 2>&1   # refresh origin/HEAD from the remote
git symbolic-ref --short refs/remotes/origin/HEAD   # e.g. origin/master
git branch -r | grep -E 'origin/(main|master)$'
  • Exactly one of origin/main / origin/master exists and origin/HEAD points to it: that is the base. State it to the user in one line before continuing.
  • Both exist, or origin/HEAD disagrees with what the task says (for example the task mentions a deploy branch), or the detection fails: stop and ask which one. A wrong base opens a huge, unrelated MR.
  • Branch protection can tell you more: glab api "projects/:fullpath/protected_branches" | head -c 600. Use it only when in doubt.

2. Start the branch

git checkout -q -b <branch> origin/<base>

Branch name: follow the task/ticket convention of the project (feat/<id>-short-slug, fix/<id>-short-slug, or the id alone for tickets such as 42565). If the working tree already has unrelated changes, say so before branching.

3. Commit and push

git add <explicit paths>
git commit -q -m "<type>(<scope>): <summary in English>

<why, in one or two sentences>"
git push -u origin <branch> 2>&1 | tail -3

Check git status -sb and git diff --cached --stat before committing and report what is in the commit.

4. Create the MR

glab mr create --source-branch <branch> --target-branch <base> \
  --title "<same Conventional Commit title>" \
  --description "<what changed, why, how it was tested>" --yes

Target branch is the detected base. Report the MR URL.

5. Wait for the pipeline (only if asked to merge or to check)

glab mr view <iid> -F json | python3 -c 'import json,sys; d=json.load(sys.stdin); p=d.get("head_pipeline") or {}; print(p.get("status","none"), d.get("detailed_merge_status"))'

Poll every ~15 s, at most a few minutes. Statuses: success → continue; running/pending/created → keep waiting; failed/canceled → stop and report the failing job (glab ci status, glab ci trace <job>); none → the repo has no pipeline, proceed only if the user confirms. If detailed_merge_status is not mergeable, report why (conflicts, discussions, approvals) instead of forcing it.

6. Merge (only when asked)

glab mr merge <iid> --yes --auto-merge=false
git fetch -q origin && git checkout -q <base> && git pull -q --ff-only origin <base>
git log --oneline -3 && git status -sb | head -1

Add --squash or --remove-source-branch only if the user or the repo convention says so. After merging, tell the user the base branch now contains the change and what remains on their side (pull on the server, reload, verification).

Gotchas

  • glab prints [glab] noise on stderr; pipe through grep -v '^\[glab\]' when parsing.
  • On a repo where the default branch on GitLab is not the branch that gets deployed, ask which one to target. Do not infer it from origin/HEAD alone.
  • A fatal: ... --ff-only on pull after merge means the base moved or the local base had commits; report it, do not reset.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.