agentleFS
Cody-SimsCody-Sims/agent-skills/skills/git-and-pr-workflow/SKILL.md

git-and-pr-workflow

Skill0 starsChanged 4 months agoMITView on GitHub

Guides Git branching, atomic commits, rebasing, resolving merge conflicts, worktrees, pull request descriptions, and safely finishing a branch. Use when creating branches, staging and committing changes, rebasing or squashing, resolving conflicts, opening or updating a pull request, or cleaning up after merge.

  • Deletes or force-pushes
  • Commits and pushes

The file

Show its rules and text

We split this skill into the rules it gives an agent

18 rules. About 0 are common, 13 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈13

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    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:

    Never rewrite history that is already published or shared.

    line 21
  2. Distinctive:

    Never force-push a shared branch.

    line 23
  3. Distinctive:

    Keep one logical change per commit.

    line 27
  4. Distinctive:

    Write commit subjects in the imperative mood: "Add", "Fix", "Rename".

    line 28
  5. Distinctive:

    Update the base branch: git switch main then git pull --ff-only.

    line 34
  6. Very specific:

    Create a topic branch: git switch -c <type>/<short-description>.

    line 35
  7. Distinctive:

    Commit with a clear subject and, when the change needs justification, a body.

    line 46
  8. Very specific:

    Prefer rebase over merge to integrate the latest base into an in-progress, unshared branch: git fetch then git rebase origin/main.

    line 53
  9. Distinctive:

    If the branch is already shared and others may have based work on it, merge the base in instead of rebasing, to avoid rewriting shared …

    line 55
  10. Very specific:

    After a rebase, push your own branch with git push --force-with-lease, never plain --force.

    line 61
  11. Distinctive:

    Read git status to list conflicted files.

    line 66
  12. Distinctive:

    Remove all conflict markers, then stage the resolved file by explicit path.

    line 69
  13. Distinctive:

    Run the repository's test command to confirm the resolution is correct.

    line 70
  14. Distinctive:

    Write the description so a reviewer needs no other context:

    line 81
  15. Distinctive:

    Keep the pull request focused on one logical change.

    line 86
  16. Very specific:

    Verify no unpushed commits remain: git log origin/<branch>..HEAD returns nothing.

    line 92
  17. Distinctive:

    Delete the local branch (git branch -d, which refuses unmerged work) and the remote branch when the platform did not remove it.

    line 93
  18. Very specific:

    Remove any worktree created for the branch: git worktree remove <path>.

    line 95

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 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

Git and PR Workflow

Produce clean, reviewable history and a clear pull request without corrupting shared branches or losing work. This workflow is intentionally low-freedom: history and remote state are hard to recover, so follow the safety rules exactly.

Safety Rules

  • Stage explicit paths (git add path/to/file). Never use git add -A or git add ., which capture unrelated edits, scratch files, and secrets.
  • Never rewrite history that is already published or shared. Rebase, amend, and squash only commits that live solely on your local branch.
  • Never force-push a shared branch. If a rewrite of your own branch is required, use git push --force-with-lease, which refuses to overwrite unseen remote work.
  • Review the full diff before every commit. Read git diff --staged in full, not just the file list.
  • Keep one logical change per commit. Unrelated changes belong in separate commits.
  • Write commit subjects in the imperative mood: "Add", "Fix", "Rename".

Start Work

  1. Confirm a clean starting point with git status. Stash or commit unrelated local changes before branching.
  2. Update the base branch: git switch main then git pull --ff-only.
  3. Create a topic branch: git switch -c <type>/<short-description>. Use a descriptive slug such as fix/login-null-check.
  4. Confirm the new branch and base with git status before editing.

Commit Changes

  1. Review every change with git status and git diff.
  2. Group related edits. Stage each group by explicit path.
  3. Re-read the staged diff with git diff --staged. Unstage anything unrelated.
  4. Scan the staged diff for secrets, credentials, tokens, and debug output before committing.
  5. Commit with a clear subject and, when the change needs justification, a body. See commit message rules.
  6. Split accidental mixed changes: unstage, then re-stage one logical group at a time so each commit stands alone.

Keep History Current

  1. Prefer rebase over merge to integrate the latest base into an in-progress, unshared branch: git fetch then git rebase origin/main.
  2. If the branch is already shared and others may have based work on it, merge the base in instead of rebasing, to avoid rewriting shared commits.
  3. To tidy local-only commits before review, use git rebase -i to reorder, squash, or reword. Never do this to commits others already pulled.
  4. Resolve any conflicts that arise, then continue. See worktrees and conflicts.
  5. After a rebase, push your own branch with git push --force-with-lease, never plain --force.

Resolve Conflicts

  1. Read git status to list conflicted files.
  2. Open each file and reconcile the intent of both sides. Do not blindly keep one side or delete the markers without understanding the change.
  3. Remove all conflict markers, then stage the resolved file by explicit path.
  4. Run the repository's test command to confirm the resolution is correct.
  5. Continue the operation with git rebase --continue or git merge --continue. Abort with --abort if the resolution is unclear and a fresh attempt is safer. See worktrees and conflicts for worktree-based isolation.

Open a Pull Request

  1. Push the branch: git push -u origin <branch>.
  2. Confirm the diff against the base is exactly the intended change; remove stray commits first.
  3. Write the description so a reviewer needs no other context:
    • What changed and why, in the first sentences.
    • The problem or issue it addresses, with a link when one exists.
    • How it was verified, naming the commands run.
    • Risks, follow-ups, and anything intentionally out of scope.
  4. Keep the pull request focused on one logical change. Split unrelated work into separate pull requests.

Finish a Branch

  1. Confirm the change is merged into the base and the base is updated locally.
  2. Verify no unpushed commits remain: git log origin/<branch>..HEAD returns nothing.
  3. Delete the local branch (git branch -d, which refuses unmerged work) and the remote branch when the platform did not remove it.
  4. Remove any worktree created for the branch: git worktree remove <path>.
  5. Return to an updated base branch and confirm a clean git status.

Report

State the branch, the commits made, verification commands run and their result, the pull request opened or updated, and any cleanup still pending.

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.