@claude-tools-i-use/ai-conflict-sync
v0.1.1
Published
Prevent AI coding tools from editing files with unsaved changes in your IDE
Maintainers
Readme
ai-conflict-sync
Prevent AI coding tools from editing files with unsaved changes in your IDE.
The Problem
AI coding tools like Claude Code operate in the terminal, unaware of your IDE state. They frequently edit files you have open with unsaved changes, causing conflicts and lost work.
The Solution
ai-conflict-sync creates a bridge between your IDE and AI tools:
- Watch Mode: Monitors files you're editing and creates lock markers
- Check Mode: AI tools can check if a file is safe to edit
- Hook Mode: Integrates with git pre-commit and AI tool hooks
Installation
npm install -g ai-conflict-syncUsage
Start the Watcher Daemon
# Watch current directory for file changes
acs watch
# Watch specific directories
acs watch src/ lib/
# Run in background
acs watch --daemonCheck if Files are Safe to Edit
# Check a single file
acs check src/index.ts
# Check multiple files
acs check src/*.ts
# Exit codes: 0 = safe, 1 = conflicts foundManual Lock/Unlock
# Mark a file as being edited
acs lock src/important.ts
# Release the lock
acs unlock src/important.ts
# List all locked files
acs listIntegration with Claude Code
Add to your CLAUDE.md:
Before editing any file, run: acs check <filepath>
If the check fails, ask the user to save their changes first.Or use the Claude Code hook (in ~/.claude/hooks.json):
{
"pre_edit": {
"command": "acs check $FILE",
"on_fail": "abort"
}
}How It Works
- File Watching: Uses chokidar to detect file modifications
- Lock Files: Creates
.acs-lockmarkers in a temp directory - Staleness Detection: Compares file mtime with last known state
- IDE Integration: Can read VS Code's workspace state (optional)
Lock File Format
Locks are stored in ~/.ai-conflict-sync/locks/:
{
"file": "/path/to/file.ts",
"lockedAt": "2026-01-04T12:00:00Z",
"lastMtime": 1704369600000,
"reason": "file_modified"
}Configuration
Create ~/.ai-conflict-sync/config.json:
{
"watchPaths": ["~/projects"],
"ignorePaths": ["node_modules", ".git", "dist"],
"lockTimeout": 300,
"daemon": false
}Commands
| Command | Description |
| ---------------------- | ------------------------------- |
| acs watch [paths...] | Start watching for file changes |
| acs check <file> | Check if file is safe to edit |
| acs lock <file> | Manually lock a file |
| acs unlock <file> | Release a lock |
| acs list | List all active locks |
| acs clear | Clear all locks |
| acs status | Show daemon status |
License
MIT
