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
In this repository45 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- improveSkill
- teamSkill
- ccf-architecture-contractSkill
- ccf-build-and-envSkill
- ccf-change-controlSkill
- ccf-debugging-playbookSkill
- ccf-doc-sync-campaignSkill
- ccf-dogfood-and-driftSkill
- ccf-domain-referenceSkill
- ccf-failure-archaeologySkill
- ccf-onboarding-tourSkill
- ccf-parity-playbookSkill
- ccf-release-and-installSkill
- ccf-testing-and-qaSkill
- improveSkill
- teamSkill
- add-referenceSkill
- ai-updateSkill
- app-blueprintSkill
- buildSkill
- check-readinessSkill
- deploySkill
- developSkill
- draft-storySkill
- error-analyzeSkill
- factorySkill
- fetch-docsSkill
- generate-internal-appSkill
- impactSkill
- improveSkill
- indexSkill
- iterative-reviewSkill
- mock-endpointSkill
- planSkill
- promoteSkill
- refine-storySkill
- scaffold-design-systemSkill
- searchSkill
- setupSkill
- teamSkill
- skill-nameSkill
- update-trackerSkill
- validateSkill
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
- Distinctive: line 44
If no conflicts → merge cleanly → done.
- Very specific: line 56
Read docs/stories/{OTHER_TICKET_ID}/story.md — understand the feature intent
- Very specific: line 57
Read docs/stories/{OTHER_TICKET_ID}/solutions-components.md — understand what was built
- Distinctive: line 58
Read the current ticket's equivalent docs
- Distinctive: line 126
If tests fail → the merge resolution introduced an issue.
- Distinctive: line 134
If CI is configured, the push triggers validation automatically.
- Very specific: line 159
When factory-auto-merge.yml fails due to conflicts:
≈ “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.
Files
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 automaticallyWhen This Runs
- Factory PR can't merge — base branch has changed since PR was created
- CI workflow detects conflict — auto-merge fails
- 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=UIf 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:
- Read
docs/stories/{OTHER_TICKET_ID}/story.md— understand the feature intent - Read
docs/stories/{OTHER_TICKET_ID}/solutions-components.md— understand what was built - 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 Type | Strategy | Human Review? |
| Source code — different functions/methods | Keep both | No |
| Source code — same function modified | Merge logic based on story intent | Yes, if complex |
| Source code — imports/dependencies | Combine both sets | No |
| Configuration files | Union of both, deduplicate | No |
| Permission/access files | Union of both — never remove | No |
| Manifest/package files | Union of components, deduplicate | No |
| Schema/migration files | Keep both (may need ordering) | Yes |
| Flow/workflow files | Flag for review unless changes are in different elements | Yes |
| Test files | Keep both test cases | No |
| Test data factories/fixtures | Merge factory methods | No |
| UI components — same file | Merge based on feature intent | Yes, if complex |
| Story docs | No conflict (different ticket folders) | No |
General Principles
- Both features should work after merge — don't break either side
- When uncertain, keep both sides and flag for human review
- Never silently drop changes — if you can't merge confidently, ask
- Permission/access is additive — always union, never intersect
- 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 File Resolution 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:
- Post notification: "TICKET-{id} has merge conflicts with {{BASE_BRANCH}}"
- 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
| Scenario | Behavior |
| No conflicts (clean merge) | Skip to Step 5, push |
| Conflict in file neither story's docs explain | Flag for human review, do not guess |
| More than 2 tickets conflicting | Resolve pairwise — merge with base (which contains all previously merged changes) |
| Schema/migration conflicts | Always flag for human review — ordering matters |
| Deployment config conflicts | Union of all entries, deduplicate |
| Tests fail after resolution | Report failure, suggest human review |
| CI deploy fails after push | Error 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
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
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.

