Receber por email
← Voltar para o catálogo

conflict-resolver

Smart git merge conflict resolution with context analysis, pattern detection, and automated resol...

367estrelas
Atualizado há 4 meses

Ver no GitHub ↗

Como adicionar

/plugin marketplace add aiskillstore/marketplace

O comando exato pode variar conforme o repositório. Confira o README no GitHub.

Para o autor da skill

Cole no README do seu repo

Mostra que sua skill está catalogada na Skillteca, gera backlink e tráfego rastreável.

[![Skillteca](https://www.skillteca.com.br/api/badge/conflict-resolver/svg)](https://www.skillteca.com.br/skills/conflict-resolver)

Skills relacionadas

Ver todas de Segurança →

Alerta por categoria

Receba novas skills de Segurança toda segunda

1 email curto, só com as skills novas de Segurança. 4 minutos de leitura, sem spam, cancela com 1 clique.

Você confirma o email no primeiro envio. Sem spam. Cancela com 1 clique.

Ler descrição completa

Conflict Resolver Skill

Smart git merge conflict resolution with context analysis, pattern detection, and automated resolution strategies.

Instructions

You are a git merge conflict resolution expert. When invoked:

  1. Analyze Conflicts:
  2. Identify conflict types (content, structural, whitespace)
  3. Understand context of both changes
  4. Determine intent of each branch
  5. Assess merge strategy viability
  1. Propose Resolutions:
  2. Suggest automatic resolutions when safe
  3. Provide manual resolution guidance
  4. Explain trade-offs of each approach
  5. Warn about potential issues
  1. Resolution Strategies:
  2. Accept incoming/current changes
  3. Combine both changes intelligently
  4. Restructure code to accommodate both
  5. Suggest refactoring when needed
  1. Validate Solutions:
  2. Ensure syntax correctness
  3. Maintain code consistency
  4. Preserve both sets of functionality
  5. Recommend testing approach

Conflict Types

1. Content Conflicts

  • Line-level changes in same location
  • Different modifications to same code
  • Overlapping feature changes

2. Structural Conflicts

  • Function/class reorganization
  • File moves and renames
  • Module restructuring

3. Semantic Conflicts

  • API signature changes
  • Interface modifications
  • Breaking changes

4. Whitespace/Formatting

  • Indentation differences
  • Line ending changes
  • Code formatting conflicts

Usage Examples

@conflict-resolver
@conflict-resolver --analyze src/auth/login.js
@conflict-resolver --auto-resolve simple
@conflict-resolver --strategy combine
@conflict-resolver --validate

Understanding Git Conflicts

Conflict Markers

<<<<<<< HEAD (Current Change)
// Your current branch code
const result = newImplementation();
=======
// Incoming branch code
const result = differentImplementation();
>>>>>>> feature-branch (Incoming Change)

Conflict Anatomy

  • <<<<<<< HEAD: Start of current branch changes
  • =======: Separator between changes
  • >>>>>>> branch-name: End of incoming changes

Resolution Strategies

Strategy 1: Accept Current (Ours)

# Accept all current branch changes
git checkout --ours path/to/file

# For specific files
git checkout --ours src/utils/helper.js

# After resolving
git add src/utils/helper.js

When to use:

  • Feature branch changes are incorrect
  • Current implementation is more complete
  • Incoming changes are outdated

Strategy 2: Accept Incoming (Theirs)

# Accept all incoming branch changes
git checkout --theirs path/to/file

# For specific files
git checkout --theirs src/api/endpoints.js

# After resolving
git add src/api/endpoints.js

When to use:

  • Incoming changes supersede current
  • Major refactor on incoming branch
  • Current changes are experimental

Strategy 3: Manual Resolution

# Open file in editor and manually resolve
# Look for conflict markers and edit

# After editing, stage the file
git add path/to/file

# Check status
git status

Strategy 4: Three-Way Merge Tool

# Configure merge tool (one-time setup)
git config --global merge.tool vimdiff
# Or: meld, kdiff3, p4merge, etc.

# Use merge tool
git mergetool

# Clean up backup files
git clean -f

Common Conflict Scenarios

Scenario 1: Import Statement Conflicts

Conflict:

<<<<<<< HEAD
import { useState, useEffect } from 'react';
import { useAuth } from './hooks/useAuth';
=======
import { useState, useEffect, useContext } from 'react';
import { useAuth } from './hooks/auth';
>>>>>>> feature-branch

Resolution (Combine Both):

import { useState, useEffect, useContext } from 'react';
import { useAuth } from './hooks/useAuth'; // Keep correct path

Scenario 2: Function Implementation Conflicts

Conflict:

<<<<<<< HEAD
async function fetchUser(userId) {
  const response = await fetch(`/api/users/${userId}`);
  return response.json();
}
=======
async function fetchUser(userId) {
  const response = await fetch(`/api/v2/users/${userId}`, {
    headers: { 'Authorization': `Bearer ${token}` }
  });
  if (!response.ok) {
    throw new Error('Failed to fetch user');
  }
  return response.json();
}
>>>>>>> feature-branch

Resolution (Combine Best of Both):

async function fetchUser(userId) {
  const response = await fetch(`/api/v2/users/${userId}`, {
    headers: { 'Authorization': `Bearer ${token}` }
  });
  if (!response.ok) {
    throw new Error('Failed to fetch user');
  }
  return response.json();
}

Scenario 3: Configuration Conflicts

Conflict:

<<<<<<< HEAD
{
  "name": "my-app",
  "version": "1.2.0",
  "scripts": {
    "start": "node server.js",
    "test": "jest"
  }
}
=======
{
  "name": "my-app",
  "version": "1.3.0",
  "scripts": {
    "start": "node server.js",
    "test": "jest",
    "lint": "eslint ."
  }
}
>>>>>>> feature-branch

Resolution (Use Higher Version + All Scripts):

{
  "name": "my-app",
  "version": "1.3.0",
  "scripts": {
    "start": "node server.js",
    "test": "jest",
    "lint": "eslint ."
  }
}

Scenario 4: Class Method Conflicts

Conflict:

class UserService {
  <<<<<<< HEAD
  async createUser(userData: UserData): Promise<User> {
    const user = await this.db.users.create(userData);
    return user;
  }
  =======
  async createUser(userData: CreateUserDto): Promise<User> {
    const validated = await this.validate(userData);
    const user = await this.db.users.create(validated);
    await this.sendWelcomeEmail(user);
    return user;
  }
  >>>>>>> feature-branch
}

Resolution (Combine Validation + Email):

class UserService {
  async createUser(userData: CreateUserDto): Promise<User> {
    const validated = await this.validate(userData);
    const user = await this.db.users.create(validated);
    await this.sendWelcomeEmail(user);
    return user;
  }
}

Advanced Resolution Techniques

Pattern 1: Parallel Feature Development

Situation: Two branches add different features to same file

<<<<<<< HEAD
function processData(data) {
  // Feature A: Add logging
  console.log('Processing data:', data);
  const result = transform(data);
  console.log('Result:', result);
  return result;
}
=======
function processData(data) {
  // Feature B: Add validation
  if (!data || !data.length) {
    throw new Error('Invalid data');
  }
  const result = transform(data);
  return result;
}
>>>>>>> feature-branch

Resolution (Combine Both Features):

function processData(data) {
  // Feature B: Add validation
  if (!data || !data.length) {
    throw new Error('Invalid data');
  }

  // Feature A: Add logging
  console.log('Processing data:', data);
  const result = transform(data);
  console.log('Result:', result);

  return result;
}

Pattern 2: Refactoring Conflicts

Situation: One branch refactors while other adds features

<<<<<<< HEAD
// Refactored version with new structure
class AuthService {
  constructor(private config: AuthConfig) {}

  async authenticate(credentials: Credentials) {
    return this.performAuth(credentials);
  }

  private async performAuth(credentials: Credentials) {
    // Auth logic
  }
}
=======
// Original with new feature
class AuthService {
  async authenticate(username, password) {
    // Auth logic
  }

  async refreshToken(token) {
    // New feature: token refresh
  }
}
>>>>>>> feature-branch

Resolution (Keep Refactor + Add Feature):

class AuthService {
  constructor(private config: AuthConfig) {}

  async authenticate(credentials: Credentials) {
    return this.performAuth(credentials);
  }

  async refreshToken(token: string) {
    // New feature: token refresh
    // Implement using new structure
  }

  private async performAuth(credentials: Credentials) {
    // Auth logic
  }
}

Pattern 3: API Signature Changes

Situation:

Compartilhar X LinkedIn