merge-to-staging
Skill17 starsChanged 9 months agoMITView on GitHub
Merge current feature branch into fresh staging branch with conflict resolution. Use when ready to deploy a feature branch to the staging environment.
- Commits and pushes
In this repository12 other files it gives its agents.
- commitSkill
- create-branchSkill
- create-prSkill
- create-skillSkill
- fix-ciSkill
- gh-issueSkill
- review-pr-commentsSkill
- slack-pr-recapSkill
- start-working-on-issueSkill
- test-coverage-improveSkill
- testing-guideSkill
- ui-patternsSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
55 rules. About 0 are common, 44 are distinctive, and 11 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈44
Distinctive · estimate
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 25
Zero user prompts: - All conflicts have ≥90% confidence and are auto-resolved (formatting, non-overlapping changes, additive imports).
- Distinctive: line 38
Run git fetch origin to fetch latest remote branches
- Distinctive: line 39
Check if local staging branch exists: git branch --list staging
- Distinctive: line 40
If local staging exists:
- Distinctive: line 41
Run git branch -D staging to delete the local staging branch
- Very specific: line 43
Run git checkout -b staging origin/staging to create a fresh local staging branch from remote
- Distinctive: line 44
Verify: "Now on a fresh staging branch tracking origin/staging"
- Distinctive: line 47
Run git branch --show-current to save the current feature branch name (if not already done)
- Very specific: line 48
Run git merge <feature-branch-name> --no-edit to merge the feature branch
- Distinctive: line 49
If merge is successful, proceed to step 4
- Distinctive: line 50
If there are merge conflicts, proceed to step 3
- Distinctive: line 118
Use Edit tool to combine both changes
- Very specific: line 132
Run git add <file> for each resolved file
- Distinctive: line 196
Wait for user's decision: before proceeding
- Very specific: line 199
Use git log <file> to show commit history
- Very specific: line 200
Use git show <commit>:<file> to see specific versions
- Very specific: line 201
Use git diff --ours --theirs <file> for detailed diff
- Distinctive: line 202
Read surrounding code for additional context
- Distinctive: line 215
Read both versions using Read tool
- Distinctive: line 218
Verify the merge makes sense
- Distinctive: line 222
Run git status to confirm no unmerged paths
- Distinctive: line 223
If conflicts remain, stop and report error
- Distinctive: line 227
After resolving all conflicts:
- Distinctive: line 228
Run git add . to ensure all resolved files are staged
- Distinctive: line 229
Run git status to verify clean state
- Distinctive: line 230
Run git commit --no-edit to complete the merge
- Very specific: line 231
If commit fails, create merge commit with: git commit -m "Merge <feature-branch> into staging"
- Distinctive: line 248
Run git log --oneline -5 to show recent commits
- Very specific: line 249
Run git diff origin/staging --stat to show what will be pushed
- Distinctive: line 252
Run git push origin staging to push the merged changes
- Very specific: line 256
Run git checkout <feature-branch-name> to return to the original branch
- Distinctive: line 284
When analyzing conflicts, apply deep reasoning:
- Distinctive: line 286
Read Completely: Always read both file versions in full using Read tool
- Distinctive: line 288
Consider Context: Look at surrounding code, imports, dependencies
- Distinctive: line 289
Check History: Use git log to understand the evolution of conflicting code
- Distinctive: line 290
Analyze Impact: Consider what breaks if either version is chosen
- Distinctive: line 297
100%: Only formatting/whitespace → Always auto-resolve
- Distinctive: line 306
When auto-resolving (to maintain 100% automatic path):
- Distinctive: line 309
Be Conservative: If in doubt, ask the user (lower the confidence score to <90%)
- Distinctive: line 310
Preserve Both Sides: When possible, merge rather than choose
- Distinctive: line 311
Verify Syntax: Ensure merged code is syntactically valid
- Distinctive: line 318
Only Ask When Necessary: Don't interrupt for trivial conflicts (maintain automatic path)
- Distinctive: line 321
Offer Clear Options: Not just "what do you want?" but "here are 3 options with pros/cons"
- Distinctive: line 327
Analysis: Check if changes are independent or overlapping
- Distinctive: line 333
Recommended Action: Keep feature branch addition with staging modifications
- Distinctive: line 337
Analysis: Verify it's only formatting, no logic changes
- Distinctive: line 338
Recommended Action: Keep feature branch (newer)
- Distinctive: line 342
Analysis: Check changelog for breaking changes between versions
- Distinctive: line 343
Recommended Action: Use newer version with compatibility note
- Distinctive: line 360
Verify remote URL: git remote -v
- Distinctive: line 361
Check if you have access to the repository
- Very specific: line 368
Check if origin/staging exists: git branch -r | grep origin/staging
- Very specific: line 376
Keep merge commits clean: Use --no-edit for automatic merge messages
- Distinctive: line 377
Document complex conflict resolutions: Add comments explaining decisions
- Distinctive: line 381
Before pushing to staging:
≈ “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.
Files
Merge to Staging
You are tasked with merging the current feature branch into a fresh staging branch (recreated from remote) and pushing the changes to remote. This ensures you're always working with the latest staging state without local modifications.
Execution Paths (Automatic vs Manual)
This command supports fully automatic execution when possible:
Path A: Clean Merge (100% Automatic)
1. Prepare staging → 2. Merge → ✅ Success → 4. Verify → 5. Push → 6. ReturnZero user prompts - Completes automatically when there are no conflicts.
Path B: High-Confidence Conflicts Only (100% Automatic)
1. Prepare staging → 2. Merge → ⚠️ Conflicts → 3.1 Analyze → 3.2 Auto-resolve all → 3.5 Commit → 4. Verify → 5. Push → 6. ReturnZero user prompts - All conflicts have ≥90% confidence and are auto-resolved (formatting, non-overlapping changes, additive imports).
Path C: Complex Conflicts Present (Semi-Automatic)
1. Prepare staging → 2. Merge → ⚠️ Conflicts → 3.1 Analyze → 3.2 Auto-resolve simple → 3.3 Ask user for complex → 3.4 Apply decisions → 3.5 Commit → 4. Verify → 5. Push → 6. ReturnUser prompted ONLY for complex conflicts - Simple conflicts auto-resolve, you only see conflicts that require business logic decisions.
Process:
1. Prepare Fresh Staging Branch
- Run
git fetch originto fetch latest remote branches - Check if local staging branch exists:
git branch --list staging - If local staging exists:
- Run
git branch -D stagingto delete the local staging branch - Confirm deletion: "Deleted local staging branch to ensure fresh start"
- Run
- Run
git checkout -b staging origin/stagingto create a fresh local staging branch from remote - Verify: "Now on a fresh staging branch tracking origin/staging"
2. Merge Feature Branch
- Run
git branch --show-currentto save the current feature branch name (if not already done) - Run
git merge <feature-branch-name> --no-editto merge the feature branch - If merge is successful, proceed to step 4
- If there are merge conflicts, proceed to step 3
3. Handle Merge Conflicts (if they occur)
3.1 Analyze All Conflicts (Deep Thinking Phase)
For each conflicted file, perform ultra-detailed analysis:
- Read both versions completely using Read tool
- Understand the context of changes in both versions
- Classify the conflict into one of these categories:
- TRIVIAL: Formatting, whitespace, comment changes only
- SIMPLE: Non-overlapping logic changes, import additions, simple refactors
- COMPLEX: Overlapping logic changes, business rule conflicts, architecture differences
- Calculate confidence score (0-100%) based on:
- 100%: Pure formatting/whitespace differences
- 90-99%: Clear non-overlapping changes (e.g., different functions modified, additive imports)
- 70-89%: Same area modified but changes are compatible and can be combined logically
- 50-69%: Changes affect related logic but resolution path is unclear
- 0-49%: Conflicting business logic, mutually exclusive changes, or unknown impact
- Determine resolution strategy for each conflict:
Decision Tree:
Conflict Analysis
↓
Confidence ≥ 90% ?
↓
├─ YES → AUTO-RESOLVE
│ ├─ Trivial (100%): Apply feature branch version
│ ├─ Simple additive (90-99%): Merge both changes
│ └─ Log decision with clear reasoning
│
└─ NO → REQUIRES USER INPUT
└─ Prepare detailed analysis for user review3.2 Auto-Resolve High-Confidence Conflicts
Automatically resolve conflicts with ≥90% confidence:
For TRIVIAL conflicts (confidence = 100%):
- Formatting/whitespace only → Use feature branch version (newer)
- Run:
git checkout --theirs <file> - Log: "✓ Auto-resolved
<file>: formatting difference (kept feature branch)"
For SIMPLE conflicts (confidence = 90-99%):
Pattern 1: Non-overlapping imports/exports
Staging adds: import { A } from 'lib'
Feature adds: import { B } from 'lib'
→ Resolution: Combine both, deduplicate, sort
→ Confidence: 95%- Read both versions
- Merge imports intelligently using Edit tool
- Log: "✓ Auto-resolved
<file>: merged imports from both branches"
Pattern 2: Different functions modified
Staging modifies: function foo()
Feature modifies: function bar()
→ Resolution: Keep both changes
→ Confidence: 95%- Use Edit tool to combine both changes
- Log: "✓ Auto-resolved
<file>: combined independent changes"
Pattern 3: Additive changes (no deletions)
Staging adds: new field X
Feature adds: new field Y
→ Resolution: Include both additions
→ Confidence: 90%- Merge both additions using Edit tool
- Log: "✓ Auto-resolved
<file>: included additions from both branches"
After auto-resolution:
- Run
git add <file>for each resolved file - Provide summary: "Auto-resolved X/Y conflicts with high confidence"
Determine next step:
- ✅ If ALL conflicts were auto-resolved (100% automatic path): Proceed directly to step 3.5 (skip 3.3 and 3.4)
- ⚠️ If complex conflicts remain (confidence < 90%): Continue to step 3.3
3.3 Present Complex Conflicts to User (⚠️ SKIP THIS STEP if all conflicts were auto-resolved)
If conflicts with confidence < 90% exist:
- Create detailed analysis for each complex conflict:
🧠 COMPLEX CONFLICT ANALYSIS
File: <filename>
Confidence: <X>%
Complexity: COMPLEX
📊 STAGING VERSION (HEAD):
<show relevant code section>
Intent: <what this change tries to achieve>
Modified by: <commit info if helpful>
📊 FEATURE BRANCH VERSION:
<show relevant code section>
Intent: <what this change tries to achieve>
⚠️ CONFLICT NATURE:
<detailed explanation of why these changes conflict>
🤔 RESOLUTION OPTIONS:
Option A: Keep Feature Branch
Pros: <specific benefits>
Cons: <specific risks>
Impact: <what breaks/works>
Option B: Keep Staging
Pros: <specific benefits>
Cons: <specific risks>
Impact: <what breaks/works>
Option C: Intelligent Merge
Approach: <specific merge strategy>
Pros: <specific benefits>
Cons: <specific risks>
Requires: <manual code changes needed>
💡 RECOMMENDED ACTION: <Option X>
Reasoning: <ultra-detailed explanation of why this is best>
---- Present ALL complex conflicts together in one message
- Ask user for decision with clear options:
- "✅ Approve all recommendations" - Execute recommended actions
- "✏️ Customize resolution for specific files" - User chooses different option per file
- "🔍 Show full diff for
<file>" - See complete file comparison - "❌ Abort merge" - Cancel and return to feature branch
- Wait for user's decision before proceeding
- If user asks for more context:
- Use
git log <file>to show commit history - Use
git show <commit>:<file>to see specific versions - Use
git diff --ours --theirs <file>for detailed diff - Read surrounding code for additional context
- Use
3.4 Execute User-Approved Resolutions (⚠️ SKIP THIS STEP if no user input was needed)
Apply resolutions in this order:
- Auto-resolved conflicts (already staged in 3.2 - nothing to do here)
- User-approved complex conflicts (only if step 3.3 occurred):
For each conflict resolution:
- Keep Feature Branch:
git checkout --theirs <file> - Keep Staging:
git checkout --ours <file> - Intelligent Merge:
- Read both versions using Read tool
- Combine changes logically using Edit tool
- Preserve functionality from both sides
- Verify the merge makes sense
- Stage with
git add <file>
- Verify all conflicts resolved:
- Run
git statusto confirm no unmerged paths - If conflicts remain, stop and report error
- Run
3.5 Complete Merge Resolution
After resolving all conflicts:
- Run
git add .to ensure all resolved files are staged - Run
git statusto verify clean state - Run
git commit --no-editto complete the merge - If commit fails, create merge commit with:
git commit -m "Merge <feature-branch> into staging"
Provide resolution summary:
✅ Conflict Resolution Complete
Total conflicts: <N>
├─ Auto-resolved (≥90% confidence): <X>
│ ├─ Trivial (formatting): <N1>
│ └─ Simple (non-overlapping): <N2>
└─ User-approved (complex): <Y>
All changes verified and committed.4. Verify Merge Success
After successful merge:
- Run
git log --oneline -5to show recent commits - Run
git diff origin/staging --statto show what will be pushed
5. Push to Remote Staging
- Run
git push origin stagingto push the merged changes - Push should succeed since we're working with a fresh staging branch
6. Return to Feature Branch
- Run
git checkout <feature-branch-name>to return to the original branch - Confirm successful merge with a summary
7. Summary Report
Provide a clear summary:
✅ Successfully merged to staging!
Branch merged: <feature-branch-name> → staging (fresh from remote)
Commits included: <number>
Files changed: <stats>
Current status:
- ✅ Local staging branch recreated from remote
- ✅ Changes merged into fresh staging branch
- ✅ Staging pushed to remote
- ✅ You're back on your feature branch
Next steps (optional):
- Monitor staging environment for any issues
- Notify team members about staging deployment
- Test the changes on staging before productionConflict Resolution Best Practices
Ultra-Thinking Approach
When analyzing conflicts, apply deep reasoning:
- Read Completely: Always read both file versions in full using Read tool
- Understand Intent: Determine what each change is trying to accomplish
- Consider Context: Look at surrounding code, imports, dependencies
- Check History: Use
git logto understand the evolution of conflicting code - Analyze Impact: Consider what breaks if either version is chosen
- Think Critically: Question assumptions - is there a better third option?
Confidence Scoring Guidelines
Be rigorous with confidence scores to ensure automatic path works correctly:
- 100%: Only formatting/whitespace → Always auto-resolve
- 95%: Different parts of file modified, zero overlap → Auto-resolve with logging
- 90%: Additive changes (both add, neither deletes) → Auto-resolve with intelligent merge
- 80%: Same function modified but changes are clearly compatible → User review needed
- 70%: Related logic modified, unclear if compatible → User review needed
- <70%: Overlapping business logic, conflicting approaches → Detailed user review required
Auto-Resolution Safety
When auto-resolving (to maintain 100% automatic path):
- Log Every Decision: Clearly state what was done and why
- Be Conservative: If in doubt, ask the user (lower the confidence score to <90%)
- Preserve Both Sides: When possible, merge rather than choose
- Verify Syntax: Ensure merged code is syntactically valid
- Document Assumptions: State any assumptions made during resolution
User Interaction Principles
To minimize interruptions while ensuring quality:
- Only Ask When Necessary: Don't interrupt for trivial conflicts (maintain automatic path)
- Batch Complex Conflicts: Present all complex conflicts together in one prompt
- Provide Context: Give enough information for informed decisions
- Offer Clear Options: Not just "what do you want?" but "here are 3 options with pros/cons"
- Recommend Confidently: Ultra-think first, then make a strong recommendation
Common Conflict Scenarios & Resolution Guidance
Scenario 1: Different Changes to Same Function
- Analysis: Check if changes are independent or overlapping
- Recommended Action: Intelligent merge - combine both modifications
- Plan Example: "Both versions modify error handling. Recommend merging: keep new validation from feature branch + add logging from staging."
Scenario 2: One Branch Added, Other Modified
- Analysis: Determine if modification applies to the addition
- Recommended Action: Keep feature branch addition with staging modifications
- Plan Example: "Feature branch adds new function, staging modifies similar pattern. Recommend: Keep new function and apply staging's pattern improvements."
Scenario 3: Formatting/Style Conflicts
- Analysis: Verify it's only formatting, no logic changes
- Recommended Action: Keep feature branch (newer)
- Plan Example: "Only whitespace/formatting differs. Recommend: Keep feature branch version."
Scenario 4: Dependency Version Conflicts
- Analysis: Check changelog for breaking changes between versions
- Recommended Action: Use newer version with compatibility note
- Plan Example: "package.json: staging has v2.1, feature has v2.3. No breaking changes. Recommend: Keep v2.3 from feature branch."
Scenario 5: Import/Export Conflicts
- Analysis: Identify unique vs. overlapping imports
- Recommended Action: Intelligent merge - combine and deduplicate
- Plan Example: "Both add imports. Recommend: Merge both sets, remove duplicates, sort alphabetically."
Scenario 6: Configuration Changes
- Analysis: Understand business impact of each config change
- Recommended Action: Often requires manual review
- Plan Example: "Environment config differs. Staging sets timeout=30s, feature sets timeout=60s. Recommend: Manual review needed - depends on performance requirements."
Error Handling
If git fetch origin fails:
- Check network connectivity
- Verify remote URL:
git remote -v - Check if you have access to the repository
If git branch -D staging fails:
- Branch might not exist (this is fine, continue)
- Or you might be currently on staging (shouldn't happen after step 1)
If git checkout -b staging origin/staging fails:
- Check if origin/staging exists:
git branch -r | grep origin/staging - Verify remote URL:
git remote -v - Try:
git fetch originagain
Important Notes
- Communicate with team: Let others know you're merging to staging
- Never force push to staging: Unless you have explicit permission
- Keep merge commits clean: Use
--no-editfor automatic merge messages - Document complex conflict resolutions: Add comments explaining decisions
Safety Checks
Before pushing to staging:
- ✅ Merge conflicts resolved
- ✅ Fresh staging branch created from remote
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.

