Sync plugin files (--github default, --env, --marketplace, --plugin-dev, --all, --uninstall)
/plugin marketplace add akaszubski/autonomous-dev/plugin install autonomous-dev@autonomous-devpython3 ~/.claude/lib/sync_dispatcher.py "$@"
Smart context-aware sync with automatic mode detection
The unified /sync command replaces /sync-dev and /update-plugin with intelligent context detection. It automatically detects whether you're syncing your development environment, updating from the marketplace, or working on plugin development.
# Auto-detect and sync (recommended)
/sync # Fetches latest from GitHub (default)
# Force specific mode
/sync --github # Fetch latest from GitHub (explicit)
/sync --env # Environment sync only
/sync --marketplace # Marketplace update only
/sync --plugin-dev # Plugin dev sync only
/sync --all # Execute all modes
/sync --uninstall # Preview uninstallation (safe)
/sync --uninstall --force # Execute uninstallation
Time: 10-90 seconds (depends on mode) Interactive: Shows detected mode, asks for confirmation Smart Detection: Auto-detects context - developers get plugin-dev, users get GitHub sync Post-Sync Validation: Automatic 4-phase validation with auto-fix
After every successful sync, automatic validation runs to ensure everything is working:
Settings Validation
settings.local.json exists and is valid JSONHook Integrity
chmod +x for non-executable hooksSemantic Scan
Health Check
Post-Sync Validation
========================================
Settings Validation
✅ All checks passed
Hooks Validation
⚠️ Hook not executable: my_hook.py
-> Auto-fixed: chmod +x my_hook.py
Semantic Validation
✅ No deprecated patterns detected
Health Validation
✅ All checks passed
========================================
Summary
========================================
✅ Sync validation PASSED
Auto-fixed: 1 issue
If validation finds issues that can't be auto-fixed, it provides step-by-step guidance:
❌ Sync validation FAILED (1 error)
HOW TO FIX
==========
1. Fix hooks/broken_hook.py syntax error:
Location: .claude/hooks/broken_hook.py:45
Error: Missing closing parenthesis
Action: Add ')' at end of line 45
The command automatically detects the appropriate sync mode:
Plugin Development → --plugin-dev
plugins/autonomous-dev/ directory exists.claude/ directoryGitHub Sync → --github (DEFAULT)
Simplified Logic: If you're in the autonomous-dev repo, you get plugin-dev mode. Otherwise, you get GitHub sync.
--github) - DEFAULTFetches the latest plugin files directly from GitHub:
What it does:
raw.githubusercontent.com/akaszubski/autonomous-dev/masterinstall_manifest.json to determine which files to fetch.claude/ directory structureWhen to use:
/sync in any projectExample:
/sync # Auto-detects and uses GitHub mode
/sync --github # Explicitly use GitHub mode
Output:
Fetching latest from GitHub (akaszubski/autonomous-dev)...
Downloading install_manifest.json...
Syncing 47 files...
✓ GitHub sync completed: 47 files updated from akaszubski/autonomous-dev
Requirements:
--env)Synchronizes your development environment using the sync-validator agent:
What it does:
When to use:
Example:
/sync --env
Output:
Detecting sync mode... Environment sync detected
Invoking sync-validator agent...
✓ Environment sync complete: 3 files updated, 0 conflicts
--marketplace)Updates plugin files from the Claude marketplace installation with intelligent version detection and orphan cleanup:
What it does:
~/.claude/plugins/marketplaces/autonomous-dev/.claude/local/When to use:
/plugin updateExample:
/sync --marketplace
Output:
Detecting sync mode... Marketplace update detected
Checking version...
Project version: 3.7.0
Marketplace version: 3.7.1
⬆ Update available: 3.7.0 → 3.7.1
Copying files from installed plugin...
✓ Marketplace sync complete: 47 files updated
- Commands: 18 updated
- Hooks: 12 updated
- Agents: 17 updated
Checking for orphaned files...
Found 2 orphaned files (marked for cleanup):
- .claude/commands/deprecated-sync-dev.md (no longer in v3.7.1)
- .claude/hooks/old-validation.py (consolidated into newer hook)
Dry-run mode: No files deleted (use --cleanup to remove)
✓ All marketplace sync operations complete
Version Detection (NEW in v3.7.1 - GitHub #50):
MAJOR.MINOR.PATCH[-PRERELEASE] from both marketplace and project plugin.jsonlib/version_detector.py (531 lines, 20 unit tests)
Version class: Semantic version object with comparison operatorsVersionComparison dataclass: Result with is_upgrade, is_downgrade, status, messagedetect_version_mismatch() function: High-level API for version comparison3.7.0, 3.8.0-beta.1, 3.8.0-rc.2 patternsOrphan Cleanup (NEW in v3.7.1 - GitHub #50):
.claude/ that aren't in the current plugin version.claude/commands/, .claude/hooks/, .claude/agents/ against plugin.json manifest--cleanup flag: Removes old files (requires confirmation unless -y flag)lib/orphan_file_cleaner.py (514 lines, 22 unit tests)
OrphanFile dataclass: Represents orphaned file with path and reasonCleanupResult dataclass: Result with orphans_detected, orphans_deleted, success, summaryOrphanFileCleaner class: Low-level API for fine-grained controldetect_orphans(): Detection without cleanupcleanup_orphans(): Cleanup with mode control (dry-run, confirm, auto)logs/orphan_cleanup_audit.log (JSON format)Implementation Integration (GitHub #51):
sync_dispatcher.pylib/sync_dispatcher.py for complete integration detailsSee lib/version_detector.py and lib/orphan_file_cleaner.py for implementation details.
--plugin-dev)Syncs plugin development files to local .claude/ directory:
What it does:
plugins/autonomous-dev/commands/ → .claude/commands/plugins/autonomous-dev/hooks/ → .claude/hooks/plugins/autonomous-dev/agents/ → .claude/agents/When to use:
Example:
/sync --plugin-dev
Output:
Detecting sync mode... Plugin development detected
Syncing plugin files to .claude/...
✓ Plugin dev sync complete: 52 files updated
- Commands: 18 synced
- Hooks: 29 synced
- Agents: 18 synced
--all)Executes all sync modes in sequence:
Execution order:
When to use:
Example:
/sync --all
Output:
Executing all sync modes...
[1/3] Environment sync...
✓ Environment: 3 files updated
[2/3] Marketplace sync...
✓ Marketplace: 47 files updated
[3/3] Plugin dev sync...
✓ Plugin dev: 52 files updated
✓ All sync modes complete: 102 total files updated
Rollback support: If any mode fails, changes are rolled back automatically.
--uninstall)Completely removes the autonomous-dev plugin from your project:
What it does:
--force).claude/ directoryModes:
--force flag for actual deletion--local-only to skip global ~/.claude/ filesWhen to use:
Examples:
# Preview what will be removed (safe, no deletion)
/sync --uninstall
# Execute actual uninstallation
/sync --uninstall --force
# Uninstall from project only (preserve global files)
/sync --uninstall --force --local-only
Preview output:
Uninstall Preview
========================================
Files to remove: 47
Total size: 1.2 MB
Backup will be created before deletion
Files:
.claude/commands/auto-implement.md
.claude/commands/sync.md
.claude/agents/planner.md
...
Protected files (will NOT be removed):
.claude/PROJECT.md
.claude/config/settings.local.json
.env
Run with --force to execute uninstallation
Execute output:
/sync --uninstall --force
Uninstalling autonomous-dev plugin...
Creating backup: .autonomous-dev/uninstall_backup_20251214_120000.tar.gz
Removing 47 files...
✓ Uninstall complete: 47 files removed (1.2 MB)
✓ Backup: .autonomous-dev/uninstall_backup_20251214_120000.tar.gz
To rollback:
python3 ~/.claude/lib/uninstall_orchestrator.py <project_root> --rollback .autonomous-dev/uninstall_backup_20251214_120000.tar.gz
Rollback: If you need to restore files after uninstallation:
from pathlib import Path
from uninstall_orchestrator import UninstallOrchestrator
orchestrator = UninstallOrchestrator(project_root=Path.cwd())
result = orchestrator.rollback(backup_path=Path(".autonomous-dev/uninstall_backup_20251214_120000.tar.gz"))
print(f"Restored {result.files_restored} files")
Security:
.claude/ and .autonomous-dev/)Protected files (never removed):
.claude/PROJECT.md (project goals and scope).claude/config/settings.local.json (user settings).env (environment variables and secrets)/sync-dev → /sync --envOld command:
/sync-dev
New equivalent:
/sync --env
Note: /sync-dev still works but shows deprecation warning. Update your workflows to use /sync --env.
/update-plugin → /sync --marketplaceOld command:
/update-plugin
New equivalent:
/sync --marketplace
Note: /update-plugin still works but shows deprecation warning. Update your workflows to use /sync --marketplace.
All sync operations include comprehensive security validation:
security_utilslogs/security_audit.logSecurity requirements:
See docs/SECURITY.md for comprehensive security documentation.
Cause: Network error or GitHub unavailable Fix: Check internet connection and try again
# Verify internet connection
curl -I https://raw.githubusercontent.com
# If working, try sync again
/sync --github
Cause: Invalid project path
Fix: Ensure you're running /sync from a valid project directory
cd /path/to/project
/sync
Cause: Not in a plugin development environment
Fix: Only use --plugin-dev when working on the plugin itself
# Check if plugin directory exists
ls plugins/autonomous-dev/
# If not present, you probably want environment sync instead
/sync --env
Cause: Multiple incompatible flags specified
Fix: Use only one flag (or --all)
# ❌ Wrong
/sync --env --marketplace
# ✓ Correct
/sync --env
# ✓ Or use --all
/sync --all
Cause: Mixing --all with specific mode flags
Fix: Choose either --all OR specific flags
# ❌ Wrong
/sync --all --env
# ✓ Correct
/sync --all
# ✓ Or specific mode
/sync --env
What it means: Your project plugin is older than the marketplace version Example: Project v3.7.0, Marketplace v3.7.1
What to do:
/sync --marketplace to apply updatesNote: This is just informational. Your current version still works fine, but updates may include security fixes, performance improvements, or bug fixes.
What it means: Files exist in your project that aren't in the current plugin version Examples:
sync-dev.md if upgrading from v3.6 to v3.7)What to do:
Option 1: Review before cleanup (RECOMMENDED)
/sync --marketplace # Shows orphans in dry-run mode
# Review the list of orphaned files
/sync --marketplace --cleanup # Prompts for each file
# Confirm deletion: y/n for each orphan
Option 2: Auto-cleanup (Non-interactive)
/sync --marketplace --cleanup -y
# Automatically deletes all orphans without prompting
Option 3: Keep files (Conservative)
# Just ignore the warning - old files won't hurt anything
# They'll still be there but won't interfere
When to be cautious:
Safe choice: Use --cleanup (with confirmation) - it's the best practice to keep your .claude/ directory clean and in sync with the current plugin version.
Cause: Permission denied or file locked Fix: Ensure the file isn't in use
# Close Claude Code completely
# (Press Cmd+Q on Mac or Ctrl+Q on Linux/Windows)
# Wait 5 seconds for process to exit
# Restart Claude Code
# Try sync again
/sync --marketplace --cleanup -y
If still fails:
# Check file permissions
ls -la .claude/commands/problematic-file.md
# Fix permissions if needed
chmod 644 .claude/commands/problematic-file.md
# Try cleanup again
/sync --marketplace --cleanup -y
# Morning: Sync environment before starting work
/sync
# Auto-detects environment mode
# Validates dependencies, config, migrations
# Step 1: Update plugin via marketplace
/plugin update autonomous-dev
# Step 2: FULL RESTART REQUIRED
# CRITICAL: /exit is NOT enough! Claude Code caches commands in memory.
# Press Cmd+Q (Mac) or Ctrl+Q (Windows/Linux) to fully quit
# Verify: ps aux | grep claude | grep -v grep (should return nothing)
# Wait 5 seconds, then restart Claude Code
# Step 3: Sync marketplace updates to project
/sync --marketplace
# Step 4: FULL RESTART AGAIN
# Commands won't reload until you fully restart Claude Code
# Press Cmd+Q again, wait 5 seconds, restart
# Step 1: Make changes to plugin files
vim plugins/autonomous-dev/commands/new-feature.md
# Step 2: Sync to .claude/ for testing
/sync --plugin-dev
# Step 3: FULL RESTART REQUIRED
# CRITICAL: /exit is NOT enough! You must fully quit Claude Code.
# Press Cmd+Q (Mac) or Ctrl+Q (Windows/Linux)
# Verify: ps aux | grep claude | grep -v grep (should return nothing)
# Wait 5 seconds, then restart Claude Code
# Step 4: Test the command
/new-feature
# Step 5: Repeat as needed (restart required each time!)
# Sync everything
/sync --all
# Ensures:
# - Environment is configured
# - Marketplace updates applied
# - Plugin dev files synced (if applicable)
The unified /sync command uses two core libraries:
sync_mode_detector.py: Intelligent context detection
sync_dispatcher.py: Mode-specific sync operations
Environment mode: 30-60 seconds
Marketplace mode: 5-10 seconds
Plugin dev mode: 5-10 seconds
All mode: 40-80 seconds
All sync operations create automatic backups:
$(mktemp -d)/claude_sync_backup_*/.claude/ directoryManual rollback (if needed):
# Find backup
ls -la /tmp/claude_sync_backup_*
# Restore manually
cp -r /tmp/claude_sync_backup_*/`.claude/` .claude/
/sync-dev command for detailed workflow/update-plugin command for update processdocs/SECURITY.md for comprehensive security documentationdocs/DEVELOPMENT.md for plugin development guideLast Updated: 2025-12-13
Issue: GitHub #44 - Unified /sync command, GitHub #124 - Default to GitHub sync
Replaces: /sync-dev, /update-plugin
Default Mode: GitHub sync (fetches latest from repository)