From cd9f5b76cfbb2fcc1f7d3eee0310fef617b6e760 Mon Sep 17 00:00:00 2001 From: cabana8471 Date: Mon, 26 Jan 2026 20:49:35 +0100 Subject: [PATCH] fix: Address Leon's review - safer process killing and cross-platform support Changes: - Replace pkill -f "node" with port-based killing (lsof -ti :PORT) - Safer: only kills dev server, not VS Code/Claude Code/other Node apps - More specific: targets exact port instead of all Node processes - Add Windows alternative commands (commented, for reference) - Use ${PORT:-3000} variable instead of hardcoded port 3000 - Update health check and API verification to use PORT variable Co-Authored-By: Claude Opus 4.5 --- .claude/templates/coding_prompt.template.md | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/.claude/templates/coding_prompt.template.md b/.claude/templates/coding_prompt.template.md index e7f1c2f..360c210 100644 --- a/.claude/templates/coding_prompt.template.md +++ b/.claude/templates/coding_prompt.template.md @@ -217,14 +217,20 @@ grep -r "new Map\(\)\|new Set\(\)" --include="*.ts" --include="*.tsx" --include= 3. **STOP the server completely:** ```bash - # Send SIGTERM first, then SIGKILL if needed - pkill -f "node" || pkill -f "npm" || pkill -f "next" + # Kill by port (safer - only kills the dev server, not VS Code/Claude Code/etc.) + # Unix/macOS: + lsof -ti :${PORT:-3000} | xargs kill -TERM 2>/dev/null || true sleep 3 - pkill -9 -f "node" 2>/dev/null || true + lsof -ti :${PORT:-3000} | xargs kill -9 2>/dev/null || true sleep 2 + + # Windows alternative (use if lsof not available): + # netstat -ano | findstr :${PORT:-3000} | findstr LISTENING + # taskkill /F /PID 2>nul + # Verify server is stopped - if pgrep -f "node" > /dev/null; then - echo "ERROR: Server still running!" + if lsof -ti :${PORT:-3000} > /dev/null 2>&1; then + echo "ERROR: Server still running on port ${PORT:-3000}!" exit 1 fi ``` @@ -234,7 +240,7 @@ grep -r "new Map\(\)\|new Set\(\)" --include="*.ts" --include="*.tsx" --include= ./init.sh & sleep 15 # Allow server to fully start # Verify server is responding - if ! curl -f http://localhost:3000/api/health && ! curl -f http://localhost:3000; then + if ! curl -f http://localhost:${PORT:-3000}/api/health && ! curl -f http://localhost:${PORT:-3000}; then echo "ERROR: Server failed to start after restart" exit 1 fi @@ -242,7 +248,7 @@ grep -r "new Map\(\)\|new Set\(\)" --include="*.ts" --include="*.tsx" --include= 5. **Query for test data - it MUST still exist** - Via UI: Navigate to data location, verify data appears - - Via API: `curl http://localhost:PORT/api/items` - verify data in response + - Via API: `curl http://localhost:${PORT:-3000}/api/items` - verify data in response 6. **If data is GONE:** Implementation uses in-memory storage → CRITICAL FAIL - Run all grep commands from STEP 5.6 to identify the mock pattern