agentleFS
BostonOrangeBostonOrange/claude-code-framework/skills/merge-resolve/SKILL.md

merge-resolve

Skill2 starsChanged 6 months agoMITView on GitHub

AI-powered merge conflict resolution. Reads both features' story docs to understand intent, resolves conflicts per file type, validates merged result. Works for any codebase.

  • Commits and pushes

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 4 are distinctive, and 3 are 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.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If no conflicts → merge cleanly → done.

    line 44
  2. Very specific:

    Read docs/stories/{OTHER_TICKET_ID}/story.md — understand the feature intent

    line 56
  3. Very specific:

    Read docs/stories/{OTHER_TICKET_ID}/solutions-components.md — understand what was built

    line 57
  4. Distinctive:

    Read the current ticket's equivalent docs

    line 58
  5. Distinctive:

    If tests fail → the merge resolution introduced an issue.

    line 126
  6. Distinctive:

    If CI is configured, the push triggers validation automatically.

    line 134
  7. Very specific:

    When factory-auto-merge.yml fails due to conflicts:

    line 159

≈ “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

Merge Resolve

Resolve merge conflicts by understanding both features' intent — not just the code diff.

Usage

/merge-resolve TICKET-1234                  # Resolve conflicts on TICKET-1234's PR
/merge-resolve TICKET-1234 --auto           # Resolve, push, and notify automatically

When This Runs

  1. Factory PR can't merge — base branch has changed since PR was created
  2. CI workflow detects conflict — auto-merge fails
  3. Developer notices — PR shows merge conflicts on GitHub

Why This Is Better Than Manual Resolution

Traditional conflict resolution looks at code only — which lines overlap. This skill reads both features' story documentation to understand why each side made changes, then resolves based on intent:

  • Method A was added for "invoice line item validation" (Story US-100)
  • Method B was added for "batch processing of work orders" (Story US-200)
  • Resolution: keep both methods — they serve different purposes

Step 1: Identify Conflicts

git fetch origin {{BASE_BRANCH}}

BRANCH="{TICKET_ID}"
git checkout "$BRANCH"
git merge origin/{{BASE_BRANCH}} --no-commit --no-ff 2>&1 | tee /tmp/merge-status.txt

# List conflicted files
git diff --name-only --diff-filter=U

If no conflicts → merge cleanly → done. Skip to Step 5.

Step 2: Understand Both Features

For each conflicted file, identify which tickets modified it:

MERGE_BASE=$(git merge-base HEAD origin/{{BASE_BRANCH}})
git log --oneline "$MERGE_BASE..origin/{{BASE_BRANCH}}" -- {conflicted_file}

For each ticket involved:

  1. Read docs/stories/{OTHER_TICKET_ID}/story.md — understand the feature intent
  2. Read docs/stories/{OTHER_TICKET_ID}/solutions-components.md — understand what was built
  3. Read the current ticket's equivalent docs

This gives full context on why each side made its changes.

Step 3: Resolve Conflicts

Apply resolution rules based on file type and feature intent:

Resolution Rules by File Type

File TypeStrategyHuman Review?
Source code — different functions/methodsKeep bothNo
Source code — same function modifiedMerge logic based on story intentYes, if complex
Source code — imports/dependenciesCombine both setsNo
Configuration filesUnion of both, deduplicateNo
Permission/access filesUnion of both — never removeNo
Manifest/package filesUnion of components, deduplicateNo
Schema/migration filesKeep both (may need ordering)Yes
Flow/workflow filesFlag for review unless changes are in different elementsYes
Test filesKeep both test casesNo
Test data factories/fixturesMerge factory methodsNo
UI components — same fileMerge based on feature intentYes, if complex
Story docsNo conflict (different ticket folders)No

General Principles

  1. Both features should work after merge — don't break either side
  2. When uncertain, keep both sides and flag for human review
  3. Never silently drop changes — if you can't merge confidently, ask
  4. Permission/access is additive — always union, never intersect
  5. Manifest/config is additive — combine entries, deduplicate

Language-Specific Patterns

JavaScript/TypeScript:

  • Both added exports → combine export list
  • Both modified same function → check if changes are in different code paths
  • Package.json conflicts → take higher version numbers, combine scripts

Python:

  • Both added imports → combine, sort
  • Both added methods to same class → keep both
  • requirements.txt → take higher versions

Java/Apex/C#:

  • Both added methods → keep both
  • Both modified same method → merge based on story intent
  • Annotation conflicts → combine

XML/JSON config:

  • Element ordering → sort consistently
  • Both added entries → deduplicate by key/name

Step 4: Validate Merged Result

After resolving conflicts:

git add {resolved_files}
git commit -m "{TICKET_ID}: merge resolve with {{BASE_BRANCH}}"

Run validation:

{{TEST_COMMAND}}

If tests fail → the merge resolution introduced an issue. Review and fix before pushing.

Step 5: Push

git push origin {TICKET_ID}

If CI is configured, the push triggers validation automatically. Errors appear as PR comments.

Report to user:

Merge conflicts resolved for TICKET-{id}.

Conflicted FileResolution
ServiceHandler.tsMerged methods from TICKET-1234 and TICKET-5678
permissions.jsonCombined access entries

Pushed — CI will validate. PR is ready for re-review.

Step 6: Notify (--auto mode)

In --auto mode, post notification for smoke testing:

{{NOTIFY_MERGE_RESOLVE}}

This creates a verification gate — merged result of two features needs human sign-off.

Integration with Factory Pipeline

Automatic Detection

When factory-auto-merge.yml fails due to conflicts:

  1. Post notification: "TICKET-{id} has merge conflicts with {{BASE_BRANCH}}"
  2. Suggest running /merge-resolve TICKET-{id}

Overlap Detection

Multiple factory PRs modifying the same files will conflict when the second one tries to merge. The AI reads both stories' docs to understand intent and resolve confidently.

Edge Cases

ScenarioBehavior
No conflicts (clean merge)Skip to Step 5, push
Conflict in file neither story's docs explainFlag for human review, do not guess
More than 2 tickets conflictingResolve pairwise — merge with base (which contains all previously merged changes)
Schema/migration conflictsAlways flag for human review — ordering matters
Deployment config conflictsUnion of all entries, deduplicate
Tests fail after resolutionReport failure, suggest human review
CI deploy fails after pushError posted as PR comment — fix and push again

Related Skills

  • /factory — invokes merge-resolve when PR has conflicts
  • /develop — the implementation pipeline that created the PR
  • /validate — code standards check on merged result

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.