# Command: sync
> **π€ Agent Directive**: If you are reading this file, the command `@acp.sync` has been invoked. Follow the steps below to execute this command.
**Namespace**: acp
**Version**: 1.0.0
**Created**: 2026-02-16
**Last Updated**: 2026-02-16
**Status**: Active
---
**Purpose**: Synchronize documentation with source code by identifying and updating stale documentation
**Category**: Documentation
**Frequency**: As Needed
---
## What This Command Does
This command synchronizes ACP documentation with the actual source code implementation. It reads source files, compares them with design documents and patterns, identifies documentation drift, and updates stale documentation to match reality.
Use this command after making significant code changes, when you suspect documentation is outdated, or periodically to ensure documentation stays current. It's particularly useful after implementing features, refactoring code, or completing milestones.
Unlike `@acp.update` which updates progress tracking, `@acp.sync` focuses on keeping design documents, patterns, and technical documentation aligned with the actual codebase.
---
## Prerequisites
- [ ] ACP installed in project
- [ ] Source code exists to compare against
- [ ] Design documents exist in `agent/design/`
- [ ] You have understanding of what changed in code
---
## Steps
### 1. Read Design Documents
Load all design documents to understand documented architecture.
**Actions**:
- Read all files in `agent/design/`
- Note documented features, patterns, and architecture
- Understand documented API contracts
- Identify documented dependencies
- List documented file structures
**Expected Outcome**: Documented architecture understood
### 2. Read Source Code
Review actual implementation in source files.
**Actions**:
- Identify main source directories (src/, lib/, etc.)
- Read key implementation files
- Note actual features implemented
- Understand actual architecture
- Identify actual dependencies
- Document actual file structures
**Expected Outcome**: Actual implementation understood
### 3. Compare Documentation vs Reality
Identify discrepancies between docs and code.
**Actions**:
- Compare documented features with implemented features
- Check if documented patterns match actual patterns
- Verify API contracts match implementation
- Compare file structures
- Note undocumented features in code
- Identify documented features not yet implemented
**Expected Outcome**: Documentation drift identified
### 4. Identify Stale Documentation
Determine which documents need updates.
**Actions**:
- List design docs that are outdated
- Note patterns that don't match code
- Identify missing documentation for new features
- Flag incorrect technical specifications
- Prioritize updates by importance
**Expected Outcome**: Update priorities established
### 5. Update Design Documents
Refresh design documents to match reality.
**Actions**:
- Update feature descriptions
- Correct technical specifications
- Update code examples to match actual code
- Add notes about implementation differences
- Update status fields (Proposal β Implemented)
- Add "Last Updated" dates
**Expected Outcome**: Design docs reflect reality
### 6. Update Pattern Documents
Refresh patterns to match actual usage.
**Actions**:
- Update pattern examples with real code
- Correct pattern descriptions
- Add new patterns discovered in code
- Update anti-patterns based on lessons learned
- Ensure code examples compile/work
**Expected Outcome**: Patterns match actual usage
### 7. Document New Features
Add documentation for undocumented features.
**Actions**:
- Create design docs for undocumented features
- Document new patterns found in code
- Add technical specifications
- Include code examples
- Link related documents
**Expected Outcome**: All features documented
### 8. Update Progress Tracking
Update progress.yaml to reflect sync activity.
**Actions**:
- Add recent work entry for sync
- Note what was updated
- Update documentation counts if needed
- Add notes about documentation status
**Expected Outcome**: Sync activity tracked
---
## Verification
- [ ] All design documents reviewed
- [ ] Source code reviewed and compared
- [ ] Documentation drift identified
- [ ] Stale documents updated
- [ ] New features documented
- [ ] Pattern documents current
- [ ] Code examples work correctly
- [ ] progress.yaml updated with sync notes
---
## Expected Output
### Files Modified
- `agent/design/*.md` - Updated design documents
- `agent/patterns/*.md` - Updated pattern documents
- `agent/progress.yaml` - Sync activity logged
- Potentially new design/pattern documents created
### Console Output
```
π Synchronizing Documentation with Code
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
Reading design documents...
β Read 5 design documents
β Read 3 pattern documents
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
Reviewing source code...
β Reviewed src/services/
β Reviewed src/models/
β Reviewed src/utils/
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
Comparing documentation vs reality...
β οΈ Found 3 discrepancies:
1. auth-design.md: Documented OAuth, implemented API keys
2. data-pattern.md: Example code outdated
3. api-design.md: Missing /health endpoint documentation
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
Updating documentation...
β Updated auth-design.md (OAuth β API keys)
β Updated data-pattern.md (refreshed examples)
β Updated api-design.md (added /health endpoint)
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
Sync Complete!
Summary:
- Documents reviewed: 8
- Discrepancies found: 3
- Documents updated: 3
- New documents created: 0
- Documentation is now current
```
### Status Update
- Design documents synchronized
- Patterns updated
- New features documented
- Sync logged in progress.yaml
---
## Examples
### Example 1: After Major Refactoring
**Context**: Refactored authentication system, docs are outdated
**Invocation**: `@acp.sync`
**Result**: Identifies auth-design.md is stale, updates it to reflect new implementation, updates related patterns
### Example 2: After Adding Features
**Context**: Added 3 new API endpoints, not yet documented
**Invocation**: `@acp.sync`
**Result**: Identifies undocumented endpoints, updates api-design.md with new endpoints, adds code examples
### Example 3: Periodic Maintenance
**Context**: Monthly documentation review
**Invocation**: `@acp.sync`
**Result**: Reviews all docs, finds minor drift in 2 files, updates them, confirms rest is current
---
## Related Commands
- [`@acp.update`](acp.update.md) - Update progress tracking (not documentation)
- [`@acp.validate`](acp.validate.md) - Validate documentation structure and consistency
- [`@acp.init`](acp.init.md) - Includes sync as part of initialization
- [`@acp.report`](acp.report.md) - Generate report including documentation status
---
## Troubleshooting
### Issue 1: Can't determine what changed
**Symptom**: Unclear what documentation needs updating
**Cause**: Too many changes or unclear code
**Solution**: Review git commits since last sync, focus on major changes first, update incrementally
### Issue 2: Documentation and code both seem wrong
**Symptom**: Neither docs nor code match expected behavior
**Cause**: Requirements changed or misunderstood
**Solution**: Clarify requirements first, then update both code and docs to match correct requirements
### Issue 3: Too many discrepancies to fix
**Symptom**: Overwhelming number of outdated docs
**Cause**: Long time since last sync
**Solution**: Prioritize by importance, fix critical docs first, schedule time for rest, sync more frequently going forward
---
## Security Considerations
### File Access
- **Reads**: All files in `agent/design/`, `agent/patterns/`, source code directories
- **Writes**: `agent/design/*.md`, `agent/patterns/*.md`, `agent/progress.yaml`
- **Executes**: None
### Network Access
- **APIs**: None
- **Repositories**: None
### Sensitive Data
- **Secrets**: Does not access secrets or credentials
- **Credentials**: Does not access credentials files
---
## Notes
- This command can be time-consuming for large projects
- Focus on high-priority documentation first
- Sync regularly to avoid large drift
- Use git diff to see what changed in code
- Document the "why" not just the "what"
- Keep code examples working and tested
- Update "Last Updated" dates in documents
- Consider running after each milestone completion
---
**Namespace**: acp
**Command**: sync
**Version**: 1.0.0
**Created**: 2026-02-16
**Last Updated**: 2026-02-16
**Status**: Active
**Compatibility**: ACP 1.1.0+
**Author**: ACP Project