Files
claude-mem/plugin/skills/troubleshoot/operations/automated-fixes.md
T
Alex Newman db3794762f chore: remove all better-sqlite3 references from codebase (#357)
* fix: export/import scripts now use API instead of direct DB access

Export script fix:
- Add format=json parameter to SearchManager for raw data output
- Add getSdkSessionsBySessionIds method to SessionStore
- Add POST /api/sdk-sessions/batch endpoint to DataRoutes
- Refactor export-memories.ts to use HTTP API

Import script fix:
- Add import methods to SessionStore with duplicate detection
- Add POST /api/import endpoint to DataRoutes
- Refactor import-memories.ts to use HTTP API

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: update analyze-transformations-smart.js to use bun:sqlite

Replace better-sqlite3 import with bun:sqlite to align with v7.1.0 migration.

* chore: remove all better-sqlite3 references from codebase

- Updated scripts/analyze-transformations-smart.js to use bun:sqlite
- Merged PR #332: Refactored import/export scripts to use worker API instead of direct DB access
- Updated PM2-to-Bun migration documentation

All better-sqlite3 references have been removed from source code.
Documentation references remain as appropriate historical context.

* build: update plugin artifacts with merged changes

Include built artifacts from PR #332 merge and analyze-transformations-smart.js update.

---------

Co-authored-by: lee <loyalpartner@163.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 17:57:40 -05:00

5.0 KiB

Automated Fix Sequences

One-command fix sequences for common claude-mem issues.

Quick Fix: Complete Reset and Restart

Use when: General issues, worker not responding, after updates

cd ~/.claude/plugins/marketplaces/thedotmack/ && \
npm run worker:stop; \
npm install && \
npm run worker:start && \
sleep 3 && \
curl -s http://127.0.0.1:37777/health

Expected output: {"status":"ok"}

What it does:

  1. Stops the worker (if running)
  2. Ensures dependencies are installed
  3. Starts worker
  4. Waits for startup
  5. Verifies health

Fix: Worker Not Running

Use when: Worker status shows it's not running

cd ~/.claude/plugins/marketplaces/thedotmack/ && \
npm run worker:start && \
sleep 2 && \
npm run worker:status

Expected output: Worker running with PID and health OK

Fix: Dependencies Missing

Use when: Worker won't start due to missing packages

cd ~/.claude/plugins/marketplaces/thedotmack/ && \
npm install && \
npm run worker:restart

Fix: Stale PID File

Use when: Worker reports running but health check fails

rm -f ~/.claude-mem/worker.pid && \
cd ~/.claude/plugins/marketplaces/thedotmack/ && \
npm run worker:start && \
sleep 2 && \
curl -s http://127.0.0.1:37777/health

Expected output: {"status":"ok"}

Fix: Port Conflict

Use when: Error shows port already in use

# Change to port 37778
mkdir -p ~/.claude-mem && \
echo '{"CLAUDE_MEM_WORKER_PORT":"37778"}' > ~/.claude-mem/settings.json && \
cd ~/.claude/plugins/marketplaces/thedotmack/ && \
npm run worker:restart && \
sleep 2 && \
curl -s http://127.0.0.1:37778/health

Expected output: {"status":"ok"}

Fix: Database Issues

Use when: Database appears corrupted or out of sync

# Backup and test integrity
cp ~/.claude-mem/claude-mem.db ~/.claude-mem/claude-mem.db.backup && \
sqlite3 ~/.claude-mem/claude-mem.db "PRAGMA integrity_check;" && \
cd ~/.claude/plugins/marketplaces/thedotmack/ && \
npm run worker:restart

If integrity check fails, recreate database:

# WARNING: This deletes all memory data
mv ~/.claude-mem/claude-mem.db ~/.claude-mem/claude-mem.db.old && \
cd ~/.claude/plugins/marketplaces/thedotmack/ && \
npm run worker:restart

Fix: Clean Reinstall

Use when: All else fails, nuclear option

# Backup data first
cp ~/.claude-mem/claude-mem.db ~/.claude-mem/claude-mem.db.backup 2>/dev/null

# Stop worker
cd ~/.claude/plugins/marketplaces/thedotmack/
npm run worker:stop

# Clean PID file
rm -f ~/.claude-mem/worker.pid

# Reinstall dependencies
rm -rf node_modules && \
npm install

# Start worker
npm run worker:start && \
sleep 3 && \
curl -s http://127.0.0.1:37777/health

Fix: Clear Old Logs

Use when: Want to start with fresh logs

# Archive old logs
tar -czf ~/.claude-mem/logs-archive-$(date +%Y-%m-%d).tar.gz ~/.claude-mem/logs/*.log 2>/dev/null

# Remove logs older than 7 days
find ~/.claude-mem/logs/ -name "worker-*.log" -mtime +7 -delete

# Restart worker for fresh log
cd ~/.claude/plugins/marketplaces/thedotmack/
npm run worker:restart

Note: Logs auto-rotate daily, manual cleanup rarely needed.

Verification Commands

After running any fix, verify with these:

# Check worker status
cd ~/.claude/plugins/marketplaces/thedotmack/
npm run worker:status

# Check health
curl -s http://127.0.0.1:37777/health

# Check database
sqlite3 ~/.claude-mem/claude-mem.db "SELECT COUNT(*) FROM observations;"

# Check viewer
curl -s http://127.0.0.1:37777/api/stats

# Check logs for errors
grep -i "error" ~/.claude-mem/logs/worker-$(date +%Y-%m-%d).log | tail -20

All checks should pass:

  • Worker status: Shows PID and "Health: OK"
  • Health endpoint: {"status":"ok"}
  • Database: Shows count (may be 0 if new)
  • Stats: Returns JSON with counts
  • Logs: No recent errors

One-Line Complete Diagnostic

Quick health check:

cd ~/.claude/plugins/marketplaces/thedotmack/ && npm run worker:status && curl -s http://127.0.0.1:37777/health && echo " ✓ All systems OK"

Troubleshooting the Fixes

If automated fix fails:

  1. Run the diagnostic script from diagnostics.md
  2. Check specific error in worker logs:
    tail -50 ~/.claude-mem/logs/worker-$(date +%Y-%m-%d).log
    
  3. Try manual worker start to see detailed error:
    cd ~/.claude/plugins/marketplaces/thedotmack/
    bun plugin/scripts/worker-service.js
    
  4. Use the bug report tool:
    npm run bug-report
    

Common Error Patterns and Fixes

Error Pattern Likely Cause Quick Fix
EADDRINUSE Port conflict Change port in settings.json
SQLITE_ERROR Database corruption Run integrity check, recreate if needed
ENOENT Missing files Run npm install
Module not found Dependency issue Clean reinstall
Connection refused Worker not running npm run worker:start
Stale PID Old PID file Remove ~/.claude-mem/worker.pid