Skip to content

Commit ee24908

Browse files
authored
docs(skills): add plan-first workflow to conflict resolver (#1998)
1 parent 11a8a96 commit ee24908

2 files changed

Lines changed: 192 additions & 22 deletions

File tree

.forge/skills/resolve-conflicts/SKILL.md

Lines changed: 96 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
---
22
name: resolve-conflicts
3-
description: Resolve Git merge conflicts by intelligently combining changes from both branches. Use when encountering merge conflicts during git merge, rebase, or cherry-pick operations. Specializes in merging imports, tests, lock files (regeneration), configuration files, and handling deleted-but-modified files with backup and analysis.
3+
description: Use this skill immediately when the user mentions merge conflicts that need to be resolved. Do not attempt to resolve conflicts directly - invoke this skill first. This skill specializes in providing a structured framework for merging imports, tests, lock files (regeneration), configuration files, and handling deleted-but-modified files with backup and analysis.
44
---
55

66
# Git Conflict Resolution
77

8-
Resolve Git merge conflicts by intelligently combining changes from both branches while preserving the intent of both changes.
8+
Resolve Git merge conflicts by intelligently combining changes from both branches while preserving the intent of both changes. This skill follows a plan-first approach: assess conflicts, create a detailed resolution plan, get approval, then execute.
99

1010
## Core Principles
1111

12-
1. **Prefer Both Changes**: Default to keeping both changes unless they directly contradict
13-
2. **Merge, Don't Choose**: Especially for imports, tests, and configuration
14-
3. **Regenerate Generated Files**: Never manually merge generated files - always regenerate them from their sources
15-
4. **Backup Before Resolving**: For deleted-modified files, create backups first
16-
5. **Validate with Tests**: Always run tests after resolution
17-
6. **Explain All Resolutions**: For each conflict resolved, provide a one-line explanation of the resolution strategy
18-
7. **Ask When Unclear**: When the correct resolution isn't clear from the diff, present options to the user and ask for their choice
12+
1. **Plan Before Executing**: Always create a structured resolution plan and get user approval before making changes
13+
2. **Prefer Both Changes**: Default to keeping both changes unless they directly contradict
14+
3. **Merge, Don't Choose**: Especially for imports, tests, and configuration
15+
4. **Regenerate Generated Files**: Never manually merge generated files - always regenerate them from their sources
16+
5. **Backup Before Resolving**: For deleted-modified files, create backups first
17+
6. **Validate with Tests**: Always run tests after resolution
18+
7. **Explain All Resolutions**: For each conflict resolved, provide a one-line explanation of the resolution strategy
19+
8. **Ask When Unclear**: When the correct resolution isn't clear from the diff, present options to the user and ask for their choice
1920

2021
## Workflow
2122

@@ -27,15 +28,80 @@ Run initial checks to understand the conflict scope:
2728
git status
2829
```
2930

30-
Identify conflict types:
31+
Identify and categorize all conflicted files:
3132

3233
- Regular file conflicts (both modified)
3334
- Deleted-modified conflicts (one deleted, one modified)
3435
- Generated file conflicts (lock files, build artifacts, generated code)
3536
- Test file conflicts
3637
- Import/configuration conflicts
38+
- Binary file conflicts
3739

38-
### Step 2: Handle Deleted-Modified Files
40+
For each conflicted file, gather information:
41+
42+
- File type and purpose
43+
- Nature of the conflict (content, deletion, type change)
44+
- Scope of changes (lines changed, sections affected)
45+
- Whether the file is generated or hand-written
46+
47+
### Step 2: Create Merge Resolution Plan
48+
49+
Based on the assessment, create a structured plan before resolving any conflicts. Present the plan in the following markdown format:
50+
51+
```markdown
52+
## Merge Resolution Plan
53+
54+
### Conflict Summary
55+
56+
- **Total conflicted files**: [N]
57+
- **Deleted-modified conflicts**: [N]
58+
- **Generated files**: [N]
59+
- **Regular conflicts**: [N]
60+
61+
### Resolution Strategy by File
62+
63+
#### 1. [File Path]
64+
65+
**Conflict Type**: [deleted-modified / generated / imports / tests / code logic / config / struct / binary]
66+
**Strategy**: [Brief description of resolution approach]
67+
**Rationale**: [Why this strategy is appropriate]
68+
**Risk**: [Low/Medium/High] - [Brief risk description]
69+
**Action Items**:
70+
71+
- [ ] [Specific action 1]
72+
- [ ] [Specific action 2]
73+
74+
#### 2. [File Path]
75+
76+
...
77+
78+
### Execution Order
79+
80+
1. **Phase 1: Deleted-Modified Files** - Handle deletions and backups first
81+
2. **Phase 2: Generated Files** - Regenerate from source
82+
3. **Phase 3: Low-Risk Merges** - Imports, tests, documentation
83+
4. **Phase 4: High-Risk Merges** - Code logic, configuration, structs
84+
5. **Phase 5: Validation** - Compile, test, verify
85+
86+
### Questions/Decisions Needed
87+
88+
- [ ] **[File/Decision]**: [Question for user] (Options: 1, 2, 3)
89+
90+
### Validation Steps
91+
92+
- [ ] Run conflict validation script
93+
- [ ] Compile project
94+
- [ ] Run test suite
95+
- [ ] Manual verification of high-risk changes
96+
```
97+
98+
**Present this plan to the user** and wait for their approval before proceeding with resolution. If there are any unclear conflicts where you need user input, list them in the "Questions/Decisions Needed" section.
99+
100+
**For a complete example plan**, see `references/sample-plan.md`.
101+
102+
### Step 3: Handle Deleted-Modified Files
103+
104+
**Execute this phase only after the plan is approved.**
39105

40106
If there are deleted-but-modified files (status: DU, UD, DD, UA, AU):
41107

@@ -52,13 +118,15 @@ This script will:
52118

53119
Review the backup directory and analysis files to understand where changes should be applied.
54120

55-
### Step 3: Resolve Regular Conflicts
121+
### Step 4: Execute Resolution Plan
122+
123+
**Follow the execution order defined in your plan.** For each conflicted file, apply the appropriate resolution pattern according to your plan. **For every conflict you resolve, provide a one-line explanation** of how you're resolving it.
56124

57-
For each conflicted file, apply the appropriate resolution pattern. **For every conflict you resolve, provide a one-line explanation** of how you're resolving it.
125+
As you complete each action item in your plan, mark it as done and report progress to the user.
58126

59127
#### When Resolution is Unclear
60128

61-
When you cannot determine the correct resolution from the diff alone:
129+
When you cannot determine the correct resolution from the diff alone (these should already be listed in your plan's "Questions/Decisions Needed" section):
62130

63131
1. **Present the conflict** to the user with the conflicting code from both sides
64132
2. **Provide numbered options** for resolution (Option 1, Option 2, etc.)
@@ -232,9 +300,9 @@ Read `references/patterns.md` section "Code Logic Conflicts" for detailed exampl
232300

233301
**When unclear**: Ask the user which type definition is correct if field types conflict
234302

235-
### Step 4: Validate Resolution
303+
### Step 5: Validate Resolution
236304

237-
After resolving conflicts, validate that all conflicts are resolved:
305+
After completing all resolution phases in your plan, validate that all conflicts are resolved:
238306

239307
```bash
240308
.forge/skills/resolve-conflicts/scripts/validate-conflicts.sh
@@ -247,9 +315,9 @@ This script checks for:
247315
- Deleted-modified conflicts
248316
- Merge state files
249317

250-
### Step 5: Compile and Test
318+
### Step 6: Compile and Test
251319

252-
Build and test to ensure the resolution is correct:
320+
Build and test to ensure the resolution is correct (as defined in your plan's validation steps):
253321

254322
```bash
255323
# For Rust projects
@@ -268,21 +336,27 @@ If tests fail:
268336
3. Fix integration issues between the merged changes
269337
4. Re-run tests until all pass
270338

271-
### Step 6: Finalize
339+
### Step 7: Finalize
272340

273-
Once all conflicts are resolved and tests pass:
341+
Once all conflicts are resolved and tests pass, review your completed plan and commit:
274342

275343
```bash
276344
# Review the changes
277345
git diff --cached
278346

279-
# Commit with descriptive message
347+
# Commit with descriptive message that references the plan
280348
git commit -m "Resolve merge conflicts: [describe key decisions]
281349
350+
Executed merge resolution plan:
351+
- [Phase 1 summary]
352+
- [Phase 2 summary]
353+
- [Phase 3+ summaries]
354+
355+
Key decisions:
282356
- Merged imports from both branches
283357
- Combined test cases
284358
- Regenerated lock files
285-
- [other significant decisions]
359+
- [other significant decisions from plan]
286360
287361
Co-Authored-By: ForgeCode <noreply@forgecode.dev>"
288362
```
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Sample Merge Resolution Plan
2+
3+
This file provides a complete example of a merge resolution plan for a typical conflict scenario.
4+
5+
## Merge Resolution Plan
6+
7+
### Conflict Summary
8+
9+
- **Total conflicted files**: 5
10+
- **Deleted-modified conflicts**: 1
11+
- **Generated files**: 1
12+
- **Regular conflicts**: 3
13+
14+
### Resolution Strategy by File
15+
16+
#### 1. `Cargo.lock`
17+
18+
**Conflict Type**: generated
19+
**Strategy**: Regenerate from Cargo.toml after merge
20+
**Rationale**: Lock files should never be manually merged; regeneration ensures all dependencies are correctly resolved
21+
**Risk**: Low - Standard procedure for lock files
22+
**Action Items**:
23+
24+
- [ ] Choose either version temporarily
25+
- [ ] Run `cargo update` to regenerate
26+
- [ ] Stage the regenerated file
27+
28+
#### 2. `src/utils/helpers.rs` (deleted in incoming, modified in current)
29+
30+
**Conflict Type**: deleted-modified
31+
**Strategy**: Backup modifications and apply to new location if applicable
32+
**Rationale**: File may have been moved/renamed; need to preserve modifications
33+
**Risk**: Medium - Requires analysis of where changes should go
34+
**Action Items**:
35+
36+
- [ ] Run handle-deleted-modified script to create backup
37+
- [ ] Review analysis report for potential relocation targets
38+
- [ ] Apply modifications to new location if found
39+
40+
#### 3. `src/lib.rs`
41+
42+
**Conflict Type**: imports
43+
**Strategy**: Merge all unique imports from both branches
44+
**Rationale**: Both branches likely added new dependencies; combining ensures all code works
45+
**Risk**: Low - Standard import merge pattern
46+
**Action Items**:
47+
48+
- [ ] Extract imports from both sides
49+
- [ ] Deduplicate and sort by module
50+
- [ ] Verify no unused imports
51+
52+
#### 4. `tests/integration_test.rs`
53+
54+
**Conflict Type**: tests
55+
**Strategy**: Include all test cases from both branches
56+
**Rationale**: Both branches added new test coverage; all tests should be preserved
57+
**Risk**: Low - Tests are additive
58+
**Action Items**:
59+
60+
- [ ] Merge test functions from both branches
61+
- [ ] Combine test fixtures if needed
62+
- [ ] Ensure no duplicate test names
63+
64+
#### 5. `src/config.rs`
65+
66+
**Conflict Type**: code logic
67+
**Strategy**: Need user input - both branches modify validation logic differently
68+
**Rationale**: Cannot determine correct business logic from code alone
69+
**Risk**: High - Affects core validation behavior
70+
**Action Items**:
71+
72+
- [ ] Present both approaches to user
73+
- [ ] Get user decision on which validation logic to use
74+
- [ ] Implement chosen approach
75+
76+
### Execution Order
77+
78+
1. **Phase 1: Deleted-Modified Files** - Handle helpers.rs backup and analysis
79+
2. **Phase 2: Generated Files** - Regenerate Cargo.lock
80+
3. **Phase 3: Low-Risk Merges** - Merge imports in lib.rs and tests in integration_test.rs
81+
4. **Phase 4: High-Risk Merges** - Resolve config.rs after user input
82+
5. **Phase 5: Validation** - Compile, test, verify
83+
84+
### Questions/Decisions Needed
85+
86+
- [ ] **src/config.rs**: Validation logic conflict - which approach should we use?
87+
- Current branch: Validates using regex patterns
88+
- Incoming branch: Validates using a validation library
89+
- Options: (1) Keep current, (2) Keep incoming, (3) Use both with feature flag
90+
91+
### Validation Steps
92+
93+
- [ ] Run conflict validation script
94+
- [ ] Compile with `cargo check`
95+
- [ ] Run full test suite with `cargo test`
96+
- [ ] Manual verification of config.rs changes

0 commit comments

Comments
 (0)