agentleFS
xsovad06xsovad06/sova/.agents/skills/sova-after-merge/SKILL.md

sova-after-merge

Skill3 starsChanged 8 days agoApache-2.0View on GitHub

Post-merge cleanup: sync the base branch, delete the branch, clean worktrees, update issue status, capture learnings.

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 2 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    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
  1. Distinctive:

    Run this after a PR has been merged to clean up local state and capture learnings.

    line 10
  2. Very specific:

    Remove worktrees for the merged ticket.

    line 32
  3. Very specific:

    Update the PRIMARY checkout's cookbook (cookbook/<domain>.md when split, otherwise cookbook.md under the matching section) before removing …

    line 71
  4. Very specific:

    Extract broader knowledge: run the sova-extract-knowledge skill if significant patterns emerged

    line 79
  5. Very specific:

    Ready for next task?: Run the sova-find-task skill or the sova-standup skill

    line 80
  6. Very specific:

    Never swallow a failed branch or worktree deletion with || true: report what was kept and why

    line 84
  7. Distinctive:

    NEVER use emojis in any output

    line 85

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

After Merge Cleanup

The sova-integrate-pr skill is the preferred path (it merges, audits and cleans up in one run); this command is kept for PRs merged outside it.

Run this after a PR has been merged to clean up local state and capture learnings.

Instructions

Each shell block below runs as its own shell invocation, so each one assigns every variable it reads.

  1. Get the PR from the arguments provided when this skill is invoked (PR number or branch name). If empty, check for recently merged PRs:
    gh pr list --author @me --state merged --limit 5
  2. Switch to the base branch and pull (from the primary checkout, not a worktree):
    BASE=$(gh pr view <PR_NUMBER> --json baseRefName --jq .baseRefName)
    git checkout "$BASE"
    git pull origin "$BASE"
  3. Clean up worktrees (if any exist for this ticket). Do this before deleting the branch: git refuses to delete a branch that a worktree still has checked out.
    git worktree list
    Remove worktrees for the merged ticket. Do not pass --force: if a worktree has uncommitted changes, leave it in place and report it rather than discarding the work.
    git worktree remove .claude/worktrees/<ID>
    Prune dangling worktree references (directories removed but entries remain):
    git worktree prune
  4. Delete the merged branch locally:
    git branch -d <branch-name>
    If -d refuses ("not fully merged", expected after a rebase merge), confirm BASE=$(gh pr view <PR_NUMBER> --json baseRefName --jq .baseRefName); git diff "origin/$BASE" <branch-name> prints nothing, then git branch -D <branch-name>. If the diff is non-empty only because the base branch moved on after the merge, compare against the PR's merge commit instead (gh pr view <PR_NUMBER> --json mergeCommit --jq .mergeCommit.oid); if that is not empty either, keep the branch and report it.
  5. Update the linked issues and clean up labels. On a GitHub project, the merged PR's body decides which issues the merge finishes:

    sova linked-issues <PR_NUMBER> --apply

    Each issue a closing keyword names (Closes #N, Fixes #N, Resolves #N and their other forms) moves to integration.post_merge_state ("done" closes it). Each Part of #N issue stays open, gets one comment listing what the PR body says it left undone (its Not done in this PR: list, or the issue's unchecked acceptance criteria when the body lists none), and loses the workflow labels agent:in-review, agent:in-progress, sova:revise and sova:block it carries, unless another open PR still links the issue (those labels then stay, and the output says so), so a half-finished issue no longer reads as awaiting review. A bare #N is left alone. Never close an issue by hand instead: a Part of issue must stay open. A non-zero exit means an issue was not updated (a failed comment or label removal included), so name each such issue from the output in the final report and carry on. On a Jira project, move the ticket the PR title names through its workflow instead.

    Then, for each issue the command moved (a closing reference, not a Part of or bare one), remove the workflow labels that no longer apply after the merge. Only the labels the issue carries are passed, since gh errors on a label the repository never created (for example sova:block); name any failure in the final report instead of discarding it:

    if ! LABELS=$(gh issue view <ISSUE_NUMBER> --json labels --jq '.labels[].name'); then
      echo "FAILED: could not read the labels of #<ISSUE_NUMBER>" >&2
    else
      ARGS=()
      for label in agent:in-review agent:in-progress sova:revise sova:block; do
        if printf '%s\n' "$LABELS" | grep -qxF "$label"; then ARGS+=(--remove-label "$label"); fi
      done
      if [ "${#ARGS[@]}" -gt 0 ] && ! gh issue edit <ISSUE_NUMBER> "${ARGS[@]}"; then
        echo "FAILED: could not remove the workflow labels of #<ISSUE_NUMBER>" >&2
      fi
    fi
  6. Capture learnings from the PR review (run the sova-ingest-review skill):
    • Fetch PR review data
    • Extract lessons: patterns to follow, mistakes to avoid, style preferences, test coverage gaps
    • Update the PRIMARY checkout's cookbook (cookbook/<domain>.md when split, otherwise cookbook.md under the matching section) before removing any worktree: a worktree's copy of .claude/agent-memory/ may be gitignored and is deleted with it
  7. Report what was cleaned up, any worktree or branch kept and why, and what was learned.

Cross-References

  • Preferred path: the sova-integrate-pr skill merges, runs the post-merge audit, and does this cleanup in one run
  • Learning from the review: calls the sova-ingest-review skill internally
  • Extract broader knowledge: run the sova-extract-knowledge skill if significant patterns emerged
  • Ready for next task? Run the sova-find-task skill or the sova-standup skill

Rules

  • Never swallow a failed branch or worktree deletion with || true: report what was kept and why
  • NEVER use emojis in any output

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.