Resolving conflicts
Conflicts occur when multiple agent files (or your primary agent and other agents) have been modified since the last sync. This guide helps you understand and resolve them effectively.
Understanding conflicts
What triggers a conflict
A conflict is detected when:
- You run
aligntrue sync - Auto-pull is enabled
- Both files have been modified since
.aligntrue/.last-synctimestamp - AlignTrue doesn’t know which change to keep
What conflicts look like
⚠ Conflict detected:
- You edited AGENTS.md (primary agent)
- Changes also found in .cursor/rules/aligntrue.mdc
? How would you like to resolve this conflict?
> Accept changes from primary agent
Keep other agent changes (skip auto-pull)
Abort sync and review manuallyResolution strategies
1. Accept primary agent (auto-pull)
When to use:
- You edited your primary agent (e.g., AGENTS.md)
- Your primary agent changes are more important
- You want to sync to all other agents
What happens:
- Auto-pull pulls from primary agent
- Your primary agent edits are kept
- Sync proceeds with primary agent as source (pushes to all agents)
# Or use flag to skip auto-pull entirely
aligntrue sync --no-auto-pull2. Keep non-primary agent changes (skip auto-pull)
When to use:
- You edited a non-primary agent (e.g., Cursor) and it’s more important
- You want to pull those changes to the IR
- You’re okay with primary agent being overwritten
What happens:
- Auto-pull is skipped
- Non-primary agent changes are preserved
- Manual resolution needed before next sync
Note: Consider backing up first if your agent changes matter.
3. Abort and review manually
When to use:
- You’re unsure which changes to keep
- You want to merge changes manually
- You need to back up current state first
What happens:
- Sync exits without making changes
- You can review both files
- You can manually merge or choose a resolution
Manual conflict resolution
Step 1: Back up current state
aligntrue backup create --notes "Before manual conflict resolution"Step 2: Review changes
Compare the files:
# View primary agent (AGENTS.md)
cat AGENTS.md
# View agent file (example: Cursor)
cat .cursor/rules/aligntrue.mdc
# Or use dry-run to preview
aligntrue sync --dry-runStep 3: Choose resolution
Option A: Keep primary agent, discard other agent changes
aligntrue sync --no-auto-pullOption B: Keep other agent changes, pull to IR
aligntrue sync --accept-agent cursorOption C: Merge manually
- Edit AGENTS.md or agent file to include both changes
- Run sync without auto-pull:
aligntrue sync --no-auto-pull
Step 4: Verify
# Check that sync completed
aligntrue check
# Review exported files
cat .cursor/rules/aligntrue.mdcPreventing conflicts
1. Choose a workflow mode
The best way to prevent conflicts is to set a workflow mode:
# .aligntrue/config.yaml
sync:
workflow_mode: "native_format" # or "ir_source"See Workflows guide for details.
2. Edit only one source
Manual Review workflow:
- Edit: AGENTS.md or your chosen agent format
- Auto-pull: Disabled for explicit control
- Sync: Use
aligntrue sync --dry-runto preview
AGENTS.md (Primary) workflow:
- Edit: AGENTS.md or any agent file
- Auto-pull: Enabled for automatic syncing
- Sync: Automatic resolution by primary_agent setting
3. Sync frequently
Run aligntrue sync often to keep files in sync:
# After editing AGENTS.md
vim AGENTS.md
aligntrue sync
# After editing agent files (AGENTS.md Primary workflow)
# Edit in Cursor...
aligntrue sync # auto-pull handles it4. Use file watchers (advanced)
See File watcher setup for automatic sync on file changes.
Common conflict scenarios
Scenario 1: Accidentally edited both files
Problem: You edited AGENTS.md, then forgot and also edited Cursor rules.
Solution:
- Check timestamps to see which is more recent
- Choose the more recent edit
- Enable bidirectional sync to prevent future conflicts
ls -la AGENTS.md
ls -la .cursor/rules/aligntrue.mdc
# Keep newer file's changes
aligntrue sync --accept-agent cursor # if agent is newer
aligntrue sync --no-auto-pull # if AGENTS.md is newerScenario 2: Team member pushed AGENTS.md changes
Problem: You pulled from git, AGENTS.md changed, but your agent file is different.
Solution: Accept the team’s AGENTS.md changes:
git pull
aligntrue sync --no-auto-pull # Push AGENTS.md to agentsScenario 3: Experimented in agent, want to keep some changes
Problem: You tested multiple rule variations in Cursor, want to keep some but not all.
Solution:
- Back up current state
- Manually edit AGENTS.md to include desired changes
- Sync without auto-pull
aligntrue backup create
vim AGENTS.md # Add desired rules from agent
aligntrue sync --no-auto-pullScenario 4: Conflict after long gap between syncs
Problem: Haven’t synced in days, both files diverged significantly.
Solution:
- Review both files carefully
- Back up before resolving
- Consider manual merge
- Sync more frequently going forward
aligntrue backup create
diff AGENTS.md .cursor/rules/aligntrue.mdc
# Manually merge in your editor
aligntrue sync --no-auto-pullAdvanced resolution
Three-way merge (manual)
For complex conflicts, use git-style three-way merge:
- Get the last synced version (from backup)
- Compare all three versions
- Merge changes manually
# Get last clean state
aligntrue backup list
aligntrue backup restore --to <timestamp> --destination /tmp/last-clean
# Compare
diff3 AGENTS.md /tmp/last-clean/AGENTS.md .cursor/rules/aligntrue.mdc
# Manually resolve in editor
vim AGENTS.md
# Sync
aligntrue sync --no-auto-pullScripted resolution
For teams with specific conflict policies:
#!/bin/bash
# always-prefer-agents-md.sh
# Always keep AGENTS.md changes, never auto-pull
aligntrue sync --no-auto-pullAdd to git hooks or CI to enforce policy.
Conflict logs
Check sync history
# View last sync timestamp
cat .aligntrue/.last-sync
# View backup history
aligntrue backup list
# View config
cat .aligntrue/config.yamlDebug mode
Get detailed sync information:
ALIGNTRUE_DEBUG=1 aligntrue sync --dry-runRecovery from bad resolution
If you chose wrong option
-
Restore from backup:
aligntrue backup list aligntrue backup restore --to <timestamp> -
Try again:
aligntrue sync # Choose correct option this time
If auto-backup disabled
If you didn’t have backups enabled:
-
Check git history:
git log -p AGENTS.md git checkout HEAD~1 AGENTS.md -
If agent file matters: Some agents keep history (check
.cursor/directory) -
Manual reconstruction from memory
Best practices
-
Enable auto-backup:
backup: auto_backup: true backup_on: ["sync"] -
Use version control: Commit AGENTS.md regularly
-
Set workflow mode: Avoid conflicts by choosing one editing location
-
Sync frequently: Small, frequent syncs are easier than big merges
-
Review diffs: Use
--show-auto-pull-diffto see what changed -
Test in dry-run: Use
--dry-runbefore actual sync
Related pages
- Auto-pull behavior - Understanding auto-pull
- Workflows guide - Choosing your workflow
- Backup and restore - Using backups
- Sync behavior - How sync works