fix(hooks): remove all venv auto-repair code that deleted .venv directories
BREAKING: Removes automatic venv management that was causing session failures Changes: - Delete scripts/venv-repair.sh (was deleting and recreating venvs) - Remove auto-repair code from projman/hooks/startup-check.sh - Remove venv-repair call from scripts/post-update.sh - Remove rm -rf .venv instructions from docs/UPDATING.md and CONFIGURATION.md - Update docs/CANONICAL-PATHS.md to remove venv-repair.sh reference Additionally: - Add Pre-Change Protocol to CLAUDE.md (mandatory dependency check before edits) - Add Pre-Change Protocol enforcement to claude-config-maintainer plugin - Add Development Context section to CLAUDE.md clarifying which plugins are used in this project vs only being developed - Reorganize commands table to separate relevant vs non-relevant commands The venv auto-repair was the root cause of repeated MCP server failures, requiring manual setup.sh runs after every session start. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -277,6 +277,39 @@ Every CLAUDE.md should have:
|
||||
1. **Project Overview** - What is this?
|
||||
2. **Quick Start** - How do I build/test/run?
|
||||
3. **Important Rules** - What must I NOT do?
|
||||
4. **Pre-Change Protocol** - Mandatory dependency check before code changes
|
||||
|
||||
### Pre-Change Protocol Section (MANDATORY)
|
||||
|
||||
**This section is REQUIRED in every CLAUDE.md.** It ensures Claude performs comprehensive dependency analysis before making any code changes.
|
||||
|
||||
```markdown
|
||||
## ⛔ MANDATORY: Before Any Code Change
|
||||
|
||||
**Claude MUST show this checklist BEFORE editing any file:**
|
||||
|
||||
### 1. Impact Search Results
|
||||
Run and show output of:
|
||||
```bash
|
||||
grep -rn "PATTERN" --include="*.sh" --include="*.md" --include="*.json" --include="*.py" | grep -v ".git"
|
||||
```
|
||||
|
||||
### 2. Files That Will Be Affected
|
||||
Numbered list of every file to be modified, with the specific change for each.
|
||||
|
||||
### 3. Files Searched But Not Changed (and why)
|
||||
Proof that related files were checked and determined unchanged.
|
||||
|
||||
### 4. Documentation That References This
|
||||
List of docs that mention this feature/script/function.
|
||||
|
||||
**User verifies this list before Claude proceeds. If Claude skips this, stop immediately.**
|
||||
|
||||
### After Changes
|
||||
Run the same grep and show results proving no references remain unaddressed.
|
||||
```
|
||||
|
||||
**When analyzing a CLAUDE.md, flag as HIGH priority issue if this section is missing.**
|
||||
|
||||
### Optional Sections (as needed)
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ Analyze the CLAUDE.md file in this project
|
||||
- Quick start commands documented
|
||||
- Critical rules highlighted
|
||||
- Key workflows covered
|
||||
- **Pre-Change Protocol section present** (MANDATORY - see below)
|
||||
|
||||
### Conciseness (25 points)
|
||||
- No unnecessary repetition
|
||||
@@ -66,6 +67,42 @@ Analyze the CLAUDE.md file in this project
|
||||
- Appropriate length for project size
|
||||
- No generic filler content
|
||||
|
||||
## Pre-Change Protocol Check (MANDATORY)
|
||||
|
||||
**This check is CRITICAL.** The Pre-Change Protocol section ensures Claude performs comprehensive dependency analysis before making any code changes, preventing missed references and incomplete updates.
|
||||
|
||||
### What to Check
|
||||
|
||||
Search CLAUDE.md for:
|
||||
- Section header containing "Pre-Change" or "Before Any Code Change"
|
||||
- References to `grep -rn` or impact search
|
||||
- Checklist with "Files That Will Be Affected"
|
||||
- Requirement for user verification before proceeding
|
||||
|
||||
### If Missing
|
||||
|
||||
**Flag as HIGH PRIORITY issue:**
|
||||
|
||||
```
|
||||
1. [HIGH] Missing Pre-Change Protocol section
|
||||
CLAUDE.md lacks mandatory dependency-check protocol.
|
||||
Impact: Claude may miss file references when making changes,
|
||||
leading to broken dependencies and incomplete updates.
|
||||
|
||||
Recommendation: Add Pre-Change Protocol section immediately.
|
||||
This is the #1 cause of cascading bugs from incomplete changes.
|
||||
```
|
||||
|
||||
### Required Section Content
|
||||
|
||||
The Pre-Change Protocol section must include:
|
||||
1. Requirement to run grep search and show results
|
||||
2. List of files that will be affected
|
||||
3. List of files searched but not changed (with reasoning)
|
||||
4. Documentation that references the change target
|
||||
5. User verification checkpoint before proceeding
|
||||
6. Post-change verification step
|
||||
|
||||
## Plugin Integration Analysis
|
||||
|
||||
After the content analysis, the command detects and analyzes marketplace plugin integration:
|
||||
|
||||
@@ -139,6 +139,7 @@ For small projects or when starting fresh:
|
||||
- Project Overview (required)
|
||||
- Quick Start (required)
|
||||
- Critical Rules (required)
|
||||
- **Pre-Change Protocol (required)**
|
||||
|
||||
### Standard Template (default)
|
||||
For typical projects:
|
||||
@@ -146,6 +147,7 @@ For typical projects:
|
||||
- Quick Start
|
||||
- Architecture
|
||||
- Critical Rules
|
||||
- **Pre-Change Protocol**
|
||||
- Common Operations
|
||||
- File Structure
|
||||
|
||||
@@ -153,11 +155,44 @@ For typical projects:
|
||||
For large or complex projects:
|
||||
- All standard sections plus:
|
||||
- Detailed Architecture
|
||||
- **Pre-Change Protocol**
|
||||
- Troubleshooting
|
||||
- Integration Points
|
||||
- Development Workflow
|
||||
- Deployment Notes
|
||||
|
||||
### Pre-Change Protocol Section (MANDATORY in ALL templates)
|
||||
|
||||
**This section MUST be included in every generated CLAUDE.md:**
|
||||
|
||||
```markdown
|
||||
## ⛔ MANDATORY: Before Any Code Change
|
||||
|
||||
**Claude MUST show this checklist BEFORE editing any file:**
|
||||
|
||||
### 1. Impact Search Results
|
||||
Run and show output of:
|
||||
\`\`\`bash
|
||||
grep -rn "PATTERN" --include="*.sh" --include="*.md" --include="*.json" --include="*.py" | grep -v ".git"
|
||||
\`\`\`
|
||||
|
||||
### 2. Files That Will Be Affected
|
||||
Numbered list of every file to be modified, with the specific change for each.
|
||||
|
||||
### 3. Files Searched But Not Changed (and why)
|
||||
Proof that related files were checked and determined unchanged.
|
||||
|
||||
### 4. Documentation That References This
|
||||
List of docs that mention this feature/script/function.
|
||||
|
||||
**User verifies this list before Claude proceeds. If Claude skips this, stop immediately.**
|
||||
|
||||
### After Changes
|
||||
Run the same grep and show results proving no references remain unaddressed.
|
||||
```
|
||||
|
||||
**Rationale:** This protocol prevents incomplete changes where Claude modifies some files but misses others that reference the same code, causing cascading bugs.
|
||||
|
||||
## Auto-Detection
|
||||
|
||||
The command automatically detects:
|
||||
|
||||
@@ -56,6 +56,7 @@ Or specify specific optimizations:
|
||||
|
||||
### Enhance
|
||||
- Add missing essential sections
|
||||
- **Add Pre-Change Protocol if missing (HIGH PRIORITY)**
|
||||
- Improve unclear instructions
|
||||
- Add helpful examples
|
||||
- Highlight critical rules
|
||||
@@ -158,6 +159,49 @@ Backup saved to: .claude/backups/CLAUDE.md.2025-01-18
|
||||
| `--preserve-comments` | Keep all existing comments |
|
||||
| `--section=NAME` | Optimize specific section only |
|
||||
|
||||
## Pre-Change Protocol (Mandatory Addition)
|
||||
|
||||
**If CLAUDE.md is missing the Pre-Change Protocol section, optimization MUST add it.**
|
||||
|
||||
This is the highest priority enhancement because it prevents cascading bugs from incomplete code changes.
|
||||
|
||||
### Detection
|
||||
|
||||
Search CLAUDE.md for:
|
||||
- "Pre-Change" or "Before Any Code Change" in headers
|
||||
- References to impact search or grep verification
|
||||
- User verification checkpoint
|
||||
|
||||
### If Missing
|
||||
|
||||
Add this section (position: after Critical Rules, before Common Operations):
|
||||
|
||||
```markdown
|
||||
## ⛔ MANDATORY: Before Any Code Change
|
||||
|
||||
**Claude MUST show this checklist BEFORE editing any file:**
|
||||
|
||||
### 1. Impact Search Results
|
||||
Run and show output of:
|
||||
\`\`\`bash
|
||||
grep -rn "PATTERN" --include="*.sh" --include="*.md" --include="*.json" --include="*.py" | grep -v ".git"
|
||||
\`\`\`
|
||||
|
||||
### 2. Files That Will Be Affected
|
||||
Numbered list of every file to be modified, with the specific change for each.
|
||||
|
||||
### 3. Files Searched But Not Changed (and why)
|
||||
Proof that related files were checked and determined unchanged.
|
||||
|
||||
### 4. Documentation That References This
|
||||
List of docs that mention this feature/script/function.
|
||||
|
||||
**User verifies this list before Claude proceeds. If Claude skips this, stop immediately.**
|
||||
|
||||
### After Changes
|
||||
Run the same grep and show results proving no references remain unaddressed.
|
||||
```
|
||||
|
||||
## When to Use
|
||||
|
||||
Run `/config-optimize` when:
|
||||
|
||||
@@ -7,29 +7,6 @@ PREFIX="[projman]"
|
||||
|
||||
# Calculate paths
|
||||
PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-$(dirname "$(dirname "$(realpath "$0")")")}"
|
||||
# Marketplace root is 2 levels up from plugin root (plugins/projman -> .)
|
||||
MARKETPLACE_ROOT="$(dirname "$(dirname "$PLUGIN_ROOT")")"
|
||||
VENV_REPAIR_SCRIPT="$MARKETPLACE_ROOT/scripts/venv-repair.sh"
|
||||
|
||||
# ============================================================================
|
||||
# Auto-repair MCP venvs (runs before other checks)
|
||||
# ============================================================================
|
||||
|
||||
if [[ -x "$VENV_REPAIR_SCRIPT" ]]; then
|
||||
# Run venv repair - this creates symlinks to cached venvs
|
||||
# Only outputs messages if something needed fixing
|
||||
"$VENV_REPAIR_SCRIPT" 2>/dev/null || {
|
||||
echo "$PREFIX MCP venv setup failed - run: cd $MARKETPLACE_ROOT && ./scripts/setup-venvs.sh"
|
||||
exit 0
|
||||
}
|
||||
else
|
||||
# Fallback: just check if venv exists
|
||||
VENV_PATH="$PLUGIN_ROOT/mcp-servers/gitea/.venv/bin/python"
|
||||
if [[ ! -f "$VENV_PATH" ]]; then
|
||||
echo "$PREFIX MCP venvs missing - run setup.sh from installed marketplace"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check git remote vs .env config (only if .env exists)
|
||||
if [[ -f ".env" ]]; then
|
||||
|
||||
Reference in New Issue
Block a user