mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-05 01:50:27 +08:00
fix: Add safety checks and auto-recovery to update-memory commands
- Fix execution order in update-memory-related: detect changes before staging - Add safety checks to prevent unintended source code modifications - Implement automatic staging recovery if non-CLAUDE.md files are modified - Ensure both update commands have consistent safety mechanisms 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -83,7 +83,17 @@ FOR depth FROM max_depth DOWN TO 0:
|
||||
Bash(~/.claude/scripts/update_module_claude.sh "$module" "full" &)
|
||||
wait_all_jobs()
|
||||
|
||||
# Step 6: Display changes → Final status
|
||||
# Step 6: Safety check and restore staging state
|
||||
non_claude=$(Bash(git diff --cached --name-only | grep -v "CLAUDE.md" || true))
|
||||
if [ -n "$non_claude" ]; then
|
||||
Bash(git restore --staged .)
|
||||
echo "⚠️ Warning: Non-CLAUDE.md files were modified, staging reverted"
|
||||
echo "Modified files: $non_claude"
|
||||
else
|
||||
echo "✅ Only CLAUDE.md files modified, staging preserved"
|
||||
fi
|
||||
|
||||
# Step 7: Display changes → Final status
|
||||
Bash(git status --short)
|
||||
```
|
||||
|
||||
@@ -111,7 +121,8 @@ subagent_type: "memory-gemini-bridge"
|
||||
- **Separated Commands**: Each bash operation is a discrete, trackable step
|
||||
- **Intelligent Complexity Detection**: Model analyzes project context for optimal strategy
|
||||
- **Depth-Parallel Execution**: Same depth modules run in parallel, depths run sequentially
|
||||
- **Git Integration**: Auto-cache changes before, show status after
|
||||
- **Git Integration**: Auto-cache changes before, safety check and show status after
|
||||
- **Safety Protection**: Automatic detection and revert of unintended source code modifications
|
||||
- **Module Detection**: Uses get_modules_by_depth.sh for structure discovery
|
||||
- **User Confirmation**: Clear plan presentation with approval step
|
||||
- **CLAUDE.md Only**: Only updates documentation, never source code
|
||||
@@ -17,17 +17,19 @@ Context-aware documentation update for modules affected by recent changes.
|
||||
#!/bin/bash
|
||||
# Context-aware CLAUDE.md documentation update
|
||||
|
||||
# Step 1: Cache git changes
|
||||
# Step 1: Detect changed modules (before staging)
|
||||
changed=$(Bash(~/.claude/scripts/detect_changed_modules.sh list))
|
||||
|
||||
# Step 2: Cache git changes (protect current state)
|
||||
Bash(git add -A 2>/dev/null || true)
|
||||
|
||||
# Step 2: Detect changed modules
|
||||
changed=$(Bash(~/.claude/scripts/detect_changed_modules.sh list))
|
||||
# Step 3: Use detected changes or fallback
|
||||
if [ -z "$changed" ]; then
|
||||
changed=$(Bash(~/.claude/scripts/get_modules_by_depth.sh list | head -10))
|
||||
fi
|
||||
count=$(echo "$changed" | wc -l)
|
||||
|
||||
# Step 3: Analysis handover → Model takes control
|
||||
# Step 4: Analysis handover → Model takes control
|
||||
# BASH_EXECUTION_STOPS → MODEL_ANALYSIS_BEGINS
|
||||
|
||||
# Pseudocode flow:
|
||||
@@ -88,7 +90,17 @@ FOR depth FROM max_depth DOWN TO 0:
|
||||
Bash(~/.claude/scripts/update_module_claude.sh "$module" "related" &)
|
||||
wait_all_jobs()
|
||||
|
||||
# Step 6: Display changes → Final status
|
||||
# Step 6: Safety check and restore staging state
|
||||
non_claude=$(Bash(git diff --cached --name-only | grep -v "CLAUDE.md" || true))
|
||||
if [ -n "$non_claude" ]; then
|
||||
Bash(git restore --staged .)
|
||||
echo "⚠️ Warning: Non-CLAUDE.md files were modified, staging reverted"
|
||||
echo "Modified files: $non_claude"
|
||||
else
|
||||
echo "✅ Only CLAUDE.md files modified, staging preserved"
|
||||
fi
|
||||
|
||||
# Step 7: Display changes → Final status
|
||||
Bash(git diff --stat)
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user