Skip to content

Commit 896d40e

Browse files
committed
config: record learning M233 - check for base file deletions before merge
Added Step 2b to git-merge-linear skill that detects when task branch incorrectly deletes files from base branch (e.g., after bad rebase conflict resolution). Checks .claude/cat/ and plugin/ paths specifically.
1 parent 110211f commit 896d40e

3 files changed

Lines changed: 74 additions & 1 deletion

File tree

.claude/cat/retrospectives/mistakes.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3090,6 +3090,32 @@
30903090
"catches_variations": true
30913091
},
30923092
"correct_behavior": "Use cat:render-diff skill: git diff ${BASE_BRANCH}..HEAD | \"${CLAUDE_PLUGIN_ROOT}/scripts/render-diff.py\" and present verbatim output"
3093+
},
3094+
{
3095+
"id": "M233",
3096+
"timestamp": "2026-01-24T12:15:00Z",
3097+
"category": "git_operation_failure",
3098+
"description": "Task branch 2.0-license-validation-server-api deletes files added by v2.0 base branch after rebase",
3099+
"root_cause": "Rebase or squash operation resolved conflicts incorrectly, removing base branch additions instead of preserving them",
3100+
"rca_method": "C",
3101+
"rca_method_name": "causal-barrier",
3102+
"prevention_type": "skill",
3103+
"prevention_path": "${CLAUDE_PROJECT_DIR}/plugin/skills/git-merge-linear/SKILL.md",
3104+
"pattern_keywords": [
3105+
"rebase",
3106+
"file-deletion",
3107+
"conflict-resolution",
3108+
"base-branch"
3109+
],
3110+
"prevention_implemented": true,
3111+
"prevention_verified": false,
3112+
"recurrence_of": null,
3113+
"prevention_quality": {
3114+
"verification_type": "positive",
3115+
"fragility": "low",
3116+
"catches_variations": true
3117+
},
3118+
"correct_behavior": "Before merging, check for unexpected file deletions from base branch, especially in .claude/cat/ and plugin/ directories"
30933119
}
30943120
]
30953121
}

.claude/cat/retrospectives/retrospectives.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"last_retrospective": "2026-01-23T19:15:39-05:00",
3-
"mistake_count_since_last": 4,
3+
"mistake_count_since_last": 5,
44
"config": {
55
"mistake_count_threshold": 10,
66
"trigger_interval_days": 7

plugin/skills/git-merge-linear/SKILL.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,44 @@ fi
8787
echo "Base branch has not diverged - safe to proceed"
8888
```
8989

90+
### Step 2b: Check for Base File Deletions (MANDATORY - M233)
91+
92+
**CRITICAL: Even after rebase, incorrect conflict resolution can delete base branch files.**
93+
94+
```bash
95+
# Check if task branch deletes files that exist in base branch
96+
DELETED_FILES=$(git diff --name-status "${BASE_BRANCH}..HEAD" | grep "^D" | cut -f2)
97+
98+
if [[ -n "$DELETED_FILES" ]]; then
99+
echo "WARNING: Task branch deletes files from base branch:"
100+
echo "$DELETED_FILES"
101+
echo ""
102+
103+
# Check if these are intentional deletions or rebase artifacts
104+
# Files in .claude/cat/ or plugin/ directories are likely unintentional
105+
SUSPICIOUS=$(echo "$DELETED_FILES" | grep -E "^(\.claude/cat/|plugin/)" || true)
106+
107+
if [[ -n "$SUSPICIOUS" ]]; then
108+
echo "ERROR: Suspicious deletions detected in infrastructure paths:"
109+
echo "$SUSPICIOUS"
110+
echo ""
111+
echo "These deletions are likely from incorrect rebase conflict resolution."
112+
echo ""
113+
echo "Solution: Re-rebase with correct conflict resolution:"
114+
echo " git reset --hard origin/${TASK_BRANCH} # If remote has clean state"
115+
echo " # Or reset to merge-base and cherry-pick task commits"
116+
echo " git checkout ${BASE_BRANCH}"
117+
echo " git checkout -B ${TASK_BRANCH}"
118+
echo " # Then cherry-pick your actual task commits"
119+
exit 1
120+
fi
121+
122+
echo "Deletions appear intentional (not in infrastructure paths)"
123+
fi
124+
125+
echo "No suspicious file deletions - safe to proceed"
126+
```
127+
90128
### Step 3: Squash Commits (if needed)
91129

92130
```bash
@@ -205,6 +243,15 @@ if [[ "$DIVERGED" -gt 0 ]]; then
205243
exit 1
206244
fi
207245

246+
# Check for suspicious file deletions (M233)
247+
SUSPICIOUS_DELETIONS=$(git diff --name-status "${BASE_BRANCH}..HEAD" | grep "^D" | cut -f2 | grep -E "^(\.claude/cat/|plugin/)" || true)
248+
if [[ -n "$SUSPICIOUS_DELETIONS" ]]; then
249+
echo "ERROR: Task branch deletes infrastructure files from base:" >&2
250+
echo "$SUSPICIOUS_DELETIONS" >&2
251+
echo "Likely incorrect rebase conflict resolution. Re-rebase with correct resolution." >&2
252+
exit 1
253+
fi
254+
208255
# Squash if multiple commits
209256
COMMIT_COUNT=$(git rev-list --count "${BASE_BRANCH}..HEAD")
210257
if [[ "$COMMIT_COUNT" -gt 1 ]]; then

0 commit comments

Comments
 (0)