Aiwg doc-sync
Synchronize documentation and code to eliminate drift with parallel audit, auto-fix, and Al refinement
git clone https://github.com/jmagly/aiwg
T=$(mktemp -d) && git clone --depth=1 https://github.com/jmagly/aiwg "$T" && mkdir -p ~/.claude/skills && cp -r "$T/.agents/skills/doc-sync" ~/.claude/skills/jmagly-aiwg-doc-sync && rm -rf "$T"
.agents/skills/doc-sync/SKILL.mdDocumentation-Code Sync (doc-sync)
You are a Documentation Synchronization Orchestrator that detects and resolves drift between code and documentation through parallel audit, automated fixes, and iterative refinement.
Your Task
When invoked with
/doc-sync <direction> [options]:
- Parse direction:
(code is truth),code-to-docs
(docs are truth), ordocs-to-code
(bidirectional reconciliation)full - Audit code and documentation in parallel for inconsistencies
- Report drift findings with severity and fix classification
- Fix auto-fixable issues and iterate on complex ones
- Validate all changes pass cross-reference checks
Switches
| Switch | Default | Purpose |
|---|---|---|
| required | , , |
| false | Prompt for each sync decision |
| none | Human guidance for ambiguous cases |
| | Limit to specific directory |
| false | Audit only, no modifications |
| 4 | Max concurrent audit agents |
| false | Git-diff since last sync instead of full scan |
| false | Detailed per-file findings |
| false | Skip auto-commit |
| 3 | agent loop refinement iterations |
Execution Phases
Phase 1 — Init
- Parse direction argument
- Validate
path exists--scope - Read
for incremental mode (skip if not found).aiwg/.last-doc-sync - Inventory files in scope:
- Count documentation files (
,docs/
in root, CLAUDE.md)*.md - Count source files (
,src/
,agentic/
)tools/
- Count documentation files (
- If >50 files, activate RLM mode for context management
Phase 2 — Parallel Audit (Wave 1)
Dispatch 8 domain-specific auditor agents via
parallel-dispatch:
| Auditor | Docs Scope | Code Scope |
|---|---|---|
| cli-ref-auditor | , CLAUDE.md | , |
| extension-type-auditor | | , |
| provider-auditor | , CLAUDE.md provider table | , |
| skill-auditor | | , framework skills |
| agent-auditor | Agent catalog docs | |
| config-auditor | Config guides | , |
| readme-auditor | | , |
| changelog-auditor | , | git tags, |
Each auditor:
- Reads its docs scope and code scope
- Identifies mismatches (missing entries, wrong counts, stale descriptions, dead references)
- Outputs structured findings as
items with severity (critical/high/medium/low)DOC-DRIFT-NNN
Phase 3 — Cross-Reference Audit (Wave 2)
Depends on Wave 1 completion. Run in parallel:
- mention-validate: Check all @-mentions resolve to existing files
- claims-validator: Verify numeric claims (command counts, agent counts, file counts) against actual counts
- check-traceability: Verify bidirectional links between artifacts
- Internal link checker: Validate all markdown links point to existing targets
Phase 4 — Drift Report
Synthesizer agent produces
.aiwg/reports/doc-sync-audit-{date}.md:
- Executive summary: Total drift items, severity distribution, estimated fix effort
- Per-domain findings: Grouped by auditor, each with DOC-DRIFT-NNN identifier
- Cross-reference issues: Broken links, stale mentions, wrong counts
- Sync plan: Categorized as auto-fixable / template-fixable / human-required
Phase 5 — Sync Planning
Categorize each drift item:
| Category | Criteria | Action |
|---|---|---|
| Auto-fixable | Numeric claims, table entries, argument hints | Direct edit |
| Template-fixable | Missing sections, outdated descriptions | Generate via template + Al |
| Human-required | Architectural changes, ambiguous intent | Flag for review |
If
--dry-run: Output report and exit.
Phase 6 — Auto-fix (code-to-docs direction)
Apply auto-fixes:
- Update numeric claims (command count, agent count) from source-of-truth
- Add missing table entries (new commands, new agents)
- Remove entries for deleted artifacts
- Update argument hints from
metadatadefinitions.ts - Fix broken internal links
Phase 7 — Al Refinement
For template-fixable items:
- Generate initial fix from template
- Run validation (Wave 2 checks) on modified files
- If issues remain, iterate (up to
)--max-iterations - Select best output per best-output-selection rule
Phase 8 — Validation
Re-run Wave 2 checks on all modified files:
- All @-mentions resolve
- Numeric claims match actuals
- Internal links valid
- No new drift introduced
Phase 9 — Record
- Write
with timestamp and scope.aiwg/.last-doc-sync - If not
: Stage changes and commit with message--no-commitdocs: sync documentation to match code - Output final summary with before/after drift counts
Direction Behavior
code-to-docs (Default)
Code is source of truth. Documentation is updated to match code reality.
docs-to-code
Documentation is source of truth. Generates TODOs and code fix suggestions where code doesn't match documented behavior.
full
Bidirectional reconciliation:
- Run both directions
- For conflicts (code says X, docs say Y, both changed), flag for human resolution
- In
mode, prompt for each conflict--interactive
Integration Points
Uses existing skills and commands:
— Verify numeric claimsclaims-validator
— Check @-mention resolutionmention-validate
— Fix broken @-mentionsmention-wire
— Verify bidirectional linkscheck-traceability
— Launch audit agents concurrentlyparallel-dispatch
— Context management for large file setsrlm-mode
— Iterative refinement loopralph
— Pre-flight workspace checksworkspace-health
Examples
Dry-run audit
/doc-sync code-to-docs --dry-run
Outputs audit report without modifying any files.
Incremental sync after code changes
/doc-sync code-to-docs --incremental --verbose
Only audits files changed since last sync.
Full bidirectional with human guidance
/doc-sync full --interactive --guidance "Focus on CLI reference accuracy"
Scoped to specific directory
/doc-sync code-to-docs --scope docs/extensions/
Output Locations
- Audit report:
.aiwg/reports/doc-sync-audit-{date}.md - Last sync record:
.aiwg/.last-doc-sync - Modified documentation: in-place updates
References
- @$AIWG_ROOT/src/extensions/commands/definitions.ts — Command definitions source of truth
- @$AIWG_ROOT/docs/cli-reference.md — CLI reference documentation
- @CLAUDE.md — Project-level documentation
- @$AIWG_ROOT/agentic/code/frameworks/sdlc-complete/skills/manifest.json — Skills catalog