/docs-sync
Synchronize your documentation with codebase changes by detecting new code and ensuring corresponding documentation exists.
Quick Start
/agileflow:docs-syncTo compare against a specific branch:
/agileflow:docs-sync BRANCH=feature-auth BASE=mainParameters
| Parameter | Required | Default | Description |
|---|---|---|---|
BRANCH | No | Current branch | Branch to analyze for changes |
BASE | No | main/master | Base branch to compare against |
AUTO_CREATE | No | no | Automatically create missing documentation (yes/no) |
Examples
Analyze Current Branch
/agileflow:docs-syncAnalyzes your current branch against main and reports:
- New API endpoints without documentation
- New UI components without documentation
- Configuration changes not documented
- Outdated documentation
Compare Feature Branch
/agileflow:docs-sync BRANCH=feature-oauth BASE=mainCompares feature-oauth against main to find all documentation gaps.
Auto-Create Missing Docs
/agileflow:docs-sync BRANCH=feature-payments AUTO_CREATE=yesAutomatically generates stub documentation for all missing items and commits with message docs: sync with codebase changes.
Output
The command generates a comprehensive report:
# Documentation Sync Report
**Branch**: feature-auth | **Base**: main | **Generated**: 2025-12-24T10:30:00Z
## Missing Documentation
### API Endpoints (3)
- ❌ POST /api/auth/login (src/api/auth/login.ts)
- ❌ POST /api/auth/logout (src/api/auth/logout.ts)
- ❌ GET /api/auth/verify (src/api/auth/verify.ts)
### UI Components (2)
- ❌ LoginForm (src/components/LoginForm.tsx)
- ⚠️ UserProfile (src/components/UserProfile.tsx) - stub exists, needs details
### Configuration (1)
- ❌ New env var: JWT_SECRET (.env.example)
## Outdated Documentation
### Deprecated
- 📄 docs/04-architecture/api.md mentions /api/v1/login (removed in this branch)
## Up-to-Date
- ✅ UserAvatar component documented
- ✅ Database schema up-to-dateHow It Works
Change Detection
The command:
- Compares branches using
git diffto identify all code changes - Categorizes changes into API endpoints, UI components, services, configuration, and database schemas
- Maps to documentation locations where docs should exist
Smart Inference
Documentation is inferred from:
- TypeScript types and interfaces - Function signatures and return types
- JSDoc comments - Existing code documentation
- Test files - Usage examples
- OpenAPI decorators - API specifications
Gap Analysis
For each changed file, the command checks:
- Missing documentation: Newly added code with no docs
- Outdated documentation: References to removed or changed code
- Incomplete documentation: Stubs that need details
Documentation Mapping
Code changes are mapped to expected documentation:
| Code Location | Expected Documentation |
|---|---|
src/api/ or src/routes/ | docs/04-architecture/api.md or OpenAPI spec |
src/components/ or src/pages/ | docs/04-architecture/components.md or Storybook |
src/services/ or src/utils/ | docs/04-architecture/services.md |
*.config.js, .env.example | docs/02-practices/configuration.md |
migrations/ or schema/ | docs/04-architecture/database.md |
Best Practices
Before Committing Code
Run docs-sync to identify documentation gaps early:
/agileflow:docs-sync BRANCH=your-feature BASE=mainWhen Adding New Endpoints
The command will flag them automatically, making it easy to remember documentation:
/agileflow:docs-sync AUTO_CREATE=yesThis creates stubs marked with "TODO: Add details" for manual review.
Documentation Sections to Maintain
Keep these synchronized with code:
- API request/response examples
- Component prop definitions
- Configuration options
- Database schema changes
- Deprecated API endpoints
Related Commands
/context- Generate comprehensive context brief/readme-sync- Synchronize README files with folder contents/adr- Document architectural decisions
On This Page
/docs-syncQuick StartParametersExamplesAnalyze Current BranchCompare Feature BranchAuto-Create Missing DocsOutputHow It WorksChange DetectionSmart InferenceGap AnalysisDocumentation MappingBest PracticesBefore Committing CodeWhen Adding New EndpointsDocumentation Sections to MaintainRelated Commands