Synced files: - Enhanced /sync command with behavioral elements - Added CODING_GUIDELINES.md sync - Added AGENT_COORDINATION_RULES.md sync - Added agent documentation sync Machine: ACG-M-L5090 Timestamp: 2026-01-21 16:38:37 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
9.8 KiB
/sync - Bidirectional ClaudeTools Sync
Synchronize ClaudeTools configuration, session data, and context bidirectionally with Gitea. Ensures all machines stay perfectly in sync for seamless cross-machine workflow.
What Gets Synced
FROM Local TO Gitea (PUSH):
- Session logs:
session-logs/*.md - Project session logs:
projects/*/session-logs/*.md - Credentials:
credentials.md(private repo - safe to sync) - Project state:
SESSION_STATE.md - Commands:
.claude/commands/*.md - Directives:
directives.md - File placement guide:
.claude/FILE_PLACEMENT_GUIDE.md - Behavioral guidelines:
.claude/CODING_GUIDELINES.md(NO EMOJIS, ASCII markers, standards).claude/AGENT_COORDINATION_RULES.md(delegation guidelines).claude/agents/*.md(agent-specific documentation).claude/CLAUDE.md(project context and instructions)- Any other
.claude/*.mdoperational files
- Any other tracked changes
FROM Gitea TO Local (PULL):
- All of the above from other machines
- Latest commands and configurations
- Updated session logs from other sessions
- Project-specific work and documentation
Execution Steps
Phase 1: Prepare Local Changes
-
Navigate to ClaudeTools repo:
cd ~/ClaudeTools # or D:\ClaudeTools on Windows -
Check repository status:
git statusReport number of changed/new files to user
-
Stage all changes:
git add -AThis includes:
- New/modified session logs
- Updated credentials.md
- SESSION_STATE.md changes
- Command updates
- Directive changes
- Behavioral guidelines (CODING_GUIDELINES.md, AGENT_COORDINATION_RULES.md, etc.)
- Agent documentation
- Project documentation
-
Auto-commit local changes with timestamp:
git commit -m "sync: Auto-sync from [machine-name] at [timestamp] Synced files: - Session logs updated - Latest context and credentials - Command/directive updates Machine: [hostname] Timestamp: [YYYY-MM-DD HH:MM:SS] Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>"Note: Only commit if there are changes. If working tree is clean, skip to Phase 2.
Phase 2: Sync with Gitea
-
Pull latest changes from Gitea:
git pull origin main --rebaseHandle conflicts if any:
- Session logs: Keep both versions (rename conflicting file with timestamp)
- credentials.md: Manual merge required - report to user
- Other files: Use standard git conflict resolution
Report what was pulled from remote
-
Push local changes to Gitea:
git push origin mainConfirm push succeeded
Phase 3: Apply Configuration Locally
-
Copy commands to global Claude directory:
mkdir -p ~/.claude/commands cp -r ~/ClaudeTools/.claude/commands/* ~/.claude/commands/These slash commands are now available globally
-
Apply global settings if available:
if [ -f ~/ClaudeTools/.claude/settings.json ]; then cp ~/ClaudeTools/.claude/settings.json ~/.claude/settings.json fi -
Sync project settings:
if [ -f ~/ClaudeTools/.claude/settings.local.json ]; then # Read and note any project-specific settings fi
Phase 4: Context Recovery
-
Find and read most recent session logs:
Check all locations:
~/ClaudeTools/session-logs/*.md(general)~/ClaudeTools/projects/*/session-logs/*.md(project-specific)
Report the 3 most recent logs found:
- File name and location
- Last modified date
- Brief summary of what was worked on (from first 5 lines)
-
Read behavioral guidelines and directives:
cat ~/ClaudeTools/directives.md cat ~/ClaudeTools/.claude/CODING_GUIDELINES.md cat ~/ClaudeTools/.claude/AGENT_COORDINATION_RULES.mdInternalize operational directives and behavioral rules to ensure:
- Proper coordination mode (delegate vs execute)
- NO EMOJIS rule enforcement
- Agent delegation patterns
- Coding standards compliance
Phase 5: Report Sync Status
-
Summarize what was synced:
## Sync Complete [OK] Local changes pushed to Gitea: - X session logs updated - credentials.md synced - SESSION_STATE.md updated - Y command files [OK] Remote changes pulled from Gitea: - Z files updated from other machines - Latest session: [most recent log] [OK] Configuration applied: - Commands available: /checkpoint, /context, /save, /sync, etc. - Directives internalized (coordination mode, delegation rules) - Behavioral guidelines internalized (NO EMOJIS, ASCII markers, coding standards) - Agent coordination rules applied - Global settings applied Recent work (last 3 sessions): 1. [date] - [project] - [brief summary] 2. [date] - [project] - [brief summary] 3. [date] - [project] - [brief summary] **Status:** All machines in sync. Ready to continue work.
Conflict Resolution
Session Log Conflicts
If both machines created session logs with same date:
- Keep both versions
- Rename to:
YYYY-MM-DD-session-[machine].md - Report conflict to user
credentials.md Conflicts
If credentials.md has conflicts:
- Do NOT auto-merge
- Report conflict to user
- Show conflicting sections
- Ask user which version to keep or how to merge
Other File Conflicts
Standard git conflict markers:
- Report files with conflicts
- Show conflict sections
- Ask user to resolve manually or provide guidance
Machine Detection
Automatically detect machine name for commit messages:
Windows:
$env:COMPUTERNAME
Mac/Linux:
hostname
Timestamp format:
date "+%Y-%m-%d %H:%M:%S"
Benefits
Seamless Multi-Machine Workflow
- Start work on one machine, continue on another
- All session context automatically synchronized
- Credentials available everywhere (private repo)
- Commands and directives stay consistent
- Behavioral rules enforced identically (NO EMOJIS, delegation patterns, coding standards)
Complete Context Preservation
- Never lose session data
- Full history across all machines
- Searchable via git log
- Rollback capability if needed
Zero Manual Sync
- One command syncs everything
- Auto-commit prevents forgotten changes
- Push/pull happens automatically
- Conflicts handled gracefully
Usage Examples
Standard Sync (Most Common)
User: /sync
Claude:
[Commits local changes]
[Pulls from Gitea]
[Pushes to Gitea]
[Applies configuration]
[Reports status]
Sync complete. 3 session logs pushed, 2 updates pulled.
Ready to continue work.
Sync Before Important Work
User: "I'm switching to my other machine. /sync"
Claude:
[Syncs everything]
Report: Latest work on Dataforth DOS dashboard pushed to Gitea.
All session logs and credentials synced.
You can now pull on the other machine to continue.
Daily Morning Sync
User: /sync
Claude:
[Pulls overnight changes from other machines]
Report: Found 2 new sessions from yesterday evening.
Latest: GuruRMM dashboard redesign completed.
Context recovered. Ready for today's work.
Error Handling
Network Issues
If git pull/push fails:
- Report connection error
- Show what was committed locally
- Suggest retry or manual sync
- Changes are safe (committed locally)
Authentication Issues
If Gitea authentication fails:
- Report auth error
- Check SSH keys or credentials
- Provide troubleshooting steps
- Manual push may be needed
Merge Conflicts
If automatic merge fails:
- Report which files have conflicts
- Show conflict markers
- Ask for user guidance
- Offer to abort merge if needed
Security Notes
credentials.md Syncing:
- Private repository on Gitea (https://git.azcomputerguru.com)
- Only accessible to authorized user
- Encrypted in transit (HTTPS/SSH)
- Safe to sync sensitive credentials
- Enables cross-machine access
What's NOT synced:
.envfiles (gitignored)- API virtual environment (api/venv/)
- Database files (local development)
- Temporary files (*.tmp, *.log)
- node_modules/ directories
Integration with Other Commands
After /checkpoint
User can run /sync after /checkpoint to push the checkpoint to Gitea:
User: /checkpoint
Claude: [Creates git commit]
User: /sync
Claude: [Pushes checkpoint to Gitea]
Before /save
User can sync first to see latest context:
User: /sync
Claude: [Shows latest session logs]
User: /save
Claude: [Creates session log with full context]
With /context
Syncing ensures /context has complete history:
User: /sync
Claude: [Syncs all session logs]
User: /context Dataforth
Claude: [Searches complete session log history including other machines]
Frequency Recommendations
Daily: Start of work day
- Pull overnight changes
- See what was done on other machines
- Recover latest context
After Major Work: End of coding session
- Push session logs
- Share context across machines
- Backup to Gitea
Before Switching Machines:
- Push all local changes
- Ensure other machine can pull
- Seamless transition
Weekly: General maintenance
- Keep repos in sync
- Review session log history
- Clean up if needed
Troubleshooting
"Already up to date" but files seem out of sync
# Force status check
cd ~/ClaudeTools
git fetch origin
git status
"Divergent branches" error
# Rebase local changes on top of remote
git pull origin main --rebase
Lost uncommitted changes
# Check stash
git stash list
# Recover if needed
git stash pop
Created: 2026-01-21 Purpose: Bidirectional sync for seamless multi-machine ClaudeTools workflow Repository: https://git.azcomputerguru.com/azcomputerguru/claudetools.git Status: Active - comprehensive sync with context preservation