<!-- AUTO-GENERATED by scripts/gen-adapters.js - DO NOT EDIT -->
---
description: Use when user asks to "update docs", "sync documentation", "fix outdated docs", "update changelog", "docs are stale", or after completing code changes that might affect documentation.
agent: general
---

> **OpenCode Note**: Invoke agents using `@agent-name` syntax.
> Available agents: task-discoverer, exploration-agent, planning-agent,
> implementation-agent, deslop-agent, delivery-validator, sync-docs-agent, consult-agent
> Example: `@exploration-agent analyze the codebase`


# /sync-docs - Documentation Sync

Sync documentation with actual code state. Finds docs that reference changed files, updates CHANGELOG, and flags outdated examples.

## Architecture

```
/sync-docs command (you are here)
    |
    v
sync-docs-agent (sonnet)
    |-- Invoke sync-docs skill
    |-- Return structured results
    |
    v
Command processes results
    |-- If apply mode + fixes: spawn simple-fixer
    |-- Present final results
```

## Constraints

1. **Preserve existing content** - Update references, don't rewrite sections
2. **Minimal changes** - Only fix what's actually outdated
3. **Evidence-based** - Every change linked to a specific code change
4. **Safe defaults** - Report mode by default

## Arguments

Parse from $ARGUMENTS:

- **Mode**: `report` (default) or `apply`
- **Scope**:
  - `--scope=recent` (default): Files changed since last commit to main
  - `--scope=all`: Scan all docs against all code
  - `--scope=before-pr`: Files in current branch (for /next-task integration)
  - `path`: Specific file or directory

## Execution

### Step 1: Parse Arguments

*(JavaScript reference - not executable in OpenCode)*

### Step 2: Spawn sync-docs-agent

*(JavaScript reference - not executable in OpenCode)*

### Step 3: Process Results

Parse the structured JSON from between `=== SYNC_DOCS_RESULT ===` markers:

*(JavaScript reference - not executable in OpenCode)*

### Step 4: Apply Fixes (if apply mode)

If mode is `apply` and fixes array is non-empty:

*(JavaScript reference - not executable in OpenCode)*

### Step 5: Present Results

*(JavaScript reference - not executable in OpenCode)*

## Examples

```bash
# Check what docs might need updates (safe, no changes)
/sync-docs

# Check docs related to specific path
/sync-docs report src/auth/

# Apply safe fixes
/sync-docs apply

# Full codebase scan
/sync-docs report --scope=all

# For PR preparation
/sync-docs apply --scope=before-pr
```

## Integration

This command is also used by `/next-task` Phase 11:

- Invoke `@sync-docs-agent` agent


## Error Handling

- **No git**: Exit with "Git required for change detection"
- **No changed files**: "No changes detected. Use --scope=all to scan entire codebase"
- **No docs found**: "No documentation files found"
- **Agent failure**: Report error, suggest manual review
