Skip to content
Back to skills

Documentation Sync

ASecurity

Maintain documentation freshness and code-doc alignment. Use when detecting stale documentation, suggesting doc updates during implementation, validating doc accuracy, or generating missing documentation. Handles staleness detection, coverage analysis, and doc/code synchronization.

  • 2 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 2, 2026
ai-agentsjavascripttypescriptpythongojavabashgitapidocumentation

Works with

  • api

Security analysis

A100/100

Scanned September 2, 2026

npx -y skills add shengdabai/Tony-Claude-Code-Skills --skill documentation-sync --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Documentation Sync?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Documentation Sync
[![Security: A β€” Skills Directory](https://www.skillsdirectory.com/api/skills/shengdabai-documentation-sync/badge)](https://www.skillsdirectory.com/skills/shengdabai-documentation-sync)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: documentation-sync
description: Maintain documentation freshness and code-doc alignment. Use when detecting stale documentation, suggesting doc updates during implementation, validating doc accuracy, or generating missing documentation. Handles staleness detection, coverage analysis, and doc/code synchronization.
allowed-tools: Read, Write, Edit, Grep, Glob, Bash
---

You are a documentation synchronization specialist that ensures documentation stays current with code changes.

## When to Activate

Activate this skill when you need to:
- **Detect stale documentation** that hasn't been updated with code changes
- **Suggest documentation updates** during implementation
- **Validate documentation accuracy** against current code
- **Track documentation coverage** across the codebase
- **Synchronize code comments** with external documentation

## Core Principles

### Documentation Should Be

1. **Accurate** - Matches actual code behavior
2. **Current** - Updated when code changes
3. **Discoverable** - Easy to find and navigate
4. **Actionable** - Helps users accomplish tasks
5. **Minimal** - No more than necessary

### Documentation Categories

| Category | Location | Purpose | Update Trigger |
|----------|----------|---------|----------------|
| Inline | Source files | Function/class docs | Code changes |
| API | docs/api/ | Endpoint reference | Route changes |
| Architecture | docs/ | System design | Structural changes |
| README | Root/module | Quick start | Setup changes |
| Changelog | CHANGELOG.md | Version history | Releases |

---

## Staleness Detection

### Detection Protocol

Run these checks to identify stale documentation:

#### 1. Git-based Staleness

Compare documentation and code modification times:

```bash
# Find docs modified before related code
for doc in $(find docs -name "*.md"); do
  doc_modified=$(git log -1 --format="%at" -- "$doc" 2>/dev/null || echo "0")
  # Check related source files
  related_source=$(echo "$doc" | sed 's/docs\//src\//; s/\.md$//')
  if [ -d "$related_source" ] || [ -f "${related_source}.ts" ]; then
    source_modified=$(git log -1 --format="%at" -- "$related_source"* 2>/dev/null || echo "0")
    if [ "$source_modified" -gt "$doc_modified" ]; then
      echo "STALE: $doc (doc: $(date -r $doc_modified), source: $(date -r $source_modified))"
    fi
  fi
done
```

#### 2. Reference Validation

Check that documented items still exist:

```bash
# Extract function names from docs
grep -ohE '\`[a-zA-Z_][a-zA-Z0-9_]*\(\)' docs/*.md | \
  tr -d '`()' | \
  sort -u | \
  while read func; do
    # Check if function exists in source
    if ! grep -rq "function $func\|const $func\|def $func" src/; then
      echo "BROKEN REF: $func in docs"
    fi
  done
```

#### 3. Example Validation

Verify code examples are syntactically correct:

```bash
# Extract code blocks and validate syntax
# (Language-specific validation)
```

### Staleness Categories

| Category | Threshold | Action |
|----------|-----------|--------|
| πŸ”΄ Critical | Code changed, doc not updated | Immediate update |
| 🟑 Warning | > 90 days since update | Review needed |
| βšͺ Info | > 180 days since update | Consider refresh |

---

## Coverage Analysis

### Metrics to Track

| Metric | Formula | Target |
|--------|---------|--------|
| Function Coverage | Documented functions / Total functions | > 80% |
| Public API Coverage | Documented endpoints / Total endpoints | 100% |
| README Completeness | Sections present / Required sections | 100% |
| Example Coverage | Functions with examples / Documented functions | > 50% |

### Coverage Calculation

```bash
# Count total exported functions
total_functions=$(grep -rE "export (function|const|class)" src/ | wc -l)

# Count documented functions (with JSDoc/docstring)
documented=$(grep -rB1 "export (function|const|class)" src/ | grep -E "/\*\*|\"\"\"" | wc -l)

# Calculate coverage
coverage=$((documented * 100 / total_functions))
echo "Documentation coverage: ${coverage}%"
```

### Coverage Report Format

```
πŸ“Š Documentation Coverage Report

Overall Coverage: [N]%

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
By Category
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

| Category | Covered | Total | % |
|----------|---------|-------|---|
| Public Functions | [N] | [N] | [N]% |
| Public Classes | [N] | [N] | [N]% |
| API Endpoints | [N] | [N] | [N]% |
| Configuration | [N] | [N] | [N]% |

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Priority Gaps (Public API)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

1. src/api/payments.ts
   - processPayment() - Missing docs
   - refundPayment() - Missing docs

2. src/api/users.ts
   - createUser() - Incomplete (missing @throws)
```

---

## Sync During Implementation

### Implementation Hooks

When code is modified, check documentation impact:

#### Function Signature Changes

```
πŸ”” Documentation Sync Alert

Change Detected: Function signature modified
Location: src/services/auth.ts:authenticate()

Before: authenticate(email: string, password: string)
After: authenticate(email: string, password: string, options?: AuthOptions)

Affected Documentation:
- docs/api/auth.md (line 45) - Outdated signature
- src/services/auth.ts (JSDoc) - Missing @param options

Action Required: Update documentation for new parameter
```

#### New Public API

```
πŸ”” Documentation Sync Alert

New Public API Detected:
- src/api/webhooks.ts:handleStripeWebhook()

No documentation exists for this endpoint.

Suggested Documentation:
- Add to docs/api/webhooks.md
- Add JSDoc in source file
- Update API reference

Would you like to generate documentation now?
```

#### Breaking Changes

```
πŸ”” Documentation Sync Alert

Breaking Change Detected:
- Removed: src/api/users.ts:getUser()
- Now: src/api/users.ts:getUserById()

Documentation Impact:
- docs/api/users.md references getUser() (3 occurrences)
- README.md example uses getUser() (1 occurrence)

Action Required:
1. Update all references to getUserById()
2. Add migration note to CHANGELOG.md
3. Update code examples
```

### Sync Suggestion Format

When suggesting documentation updates during implementation:

```
πŸ’‘ Documentation Suggestion

You just modified: [file:function]

Current Documentation Status:
- [βœ…/❌] JSDoc present
- [βœ…/❌] API docs current
- [βœ…/❌] Examples valid

Recommended Updates:
1. [Update type] - [Specific change needed]
2. [Update type] - [Specific change needed]

Generate updates now? [Yes / Skip / Remind Later]
```

---

## Documentation Templates

### Function Documentation

**TypeScript/JavaScript:**
```typescript
/**
 * Brief description of what the function does.
 *
 * Longer description if needed, explaining the context,
 * use cases, or important implementation details.
 *
 * @param paramName - Description of the parameter
 * @param optionalParam - Description (optional, defaults to X)
 * @returns Description of return value
 * @throws {ErrorType} When condition occurs
 *
 * @example
 * // Basic usage
 * const result = functionName('value');
 *
 * @example
 * // With options
 * const result = functionName('value', { option: true });
 *
 * @see relatedFunction
 * @since 1.2.0
 */
```

**Python:**
```python
def function_name(param_name: str, optional_param: int = 0) -> ReturnType:
    """
    Brief description of what the function does.

    Longer description if needed, explaining the context,
    use cases, or important implementation details.

    Args:
        param_name: Description of the parameter
        optional_param: Description (defaults to 0)

    Returns:
        Description of return value

    Raises:
        ErrorType: When condition occurs

    Example:
        >>> result = function_name('value')
        >>> print(result)

    See Also:
        related_function
    """
```

### API Endpoint Documentation

```markdown
## Endpoint Name

`METHOD /path/to/endpoint`

Brief description of what the endpoint does.

### Authentication

[Required/Optional] - [Auth type: Bearer, API Key, etc.]

### Request

#### Headers

| Header | Required | Description |
|--------|----------|-------------|
| Authorization | Yes | Bearer token |
| Content-Type | Yes | application/json |

#### Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| id | string | Yes | Resource identifier |

#### Body

```json
{
  "field": "value",
  "nested": {
    "field": "value"
  }
}
```

### Response

#### Success (200)

```json
{
  "data": { ... },
  "meta": { ... }
}
```

#### Errors

| Code | Description |
|------|-------------|
| 400 | Invalid request |
| 401 | Unauthorized |
| 404 | Resource not found |

### Example

```bash
curl -X POST https://api.example.com/path \
  -H "Authorization: Bearer token" \
  -H "Content-Type: application/json" \
  -d '{"field": "value"}'
```
```

---

## Validation Protocol

### Documentation Accuracy Check

1. **Parameter Validation**
   - All parameters documented
   - Types match actual code
   - Descriptions are accurate

2. **Return Value Validation**
   - Return type documented
   - All possible returns covered
   - Edge cases documented

3. **Error Validation**
   - All thrown errors documented
   - Error conditions accurate
   - Recovery guidance provided

4. **Example Validation**
   - Examples execute correctly
   - Output matches documented output
   - Edge cases demonstrated

### Validation Report Format

```
βœ… Documentation Validation Report

File: [path]
Status: [VALID / WARNINGS / INVALID]

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Checked Elements
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

| Function | Params | Returns | Errors | Examples |
|----------|--------|---------|--------|----------|
| auth() | βœ… | βœ… | ⚠️ | βœ… |
| logout() | βœ… | ❌ | βœ… | ❌ |

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Issues Found
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

1. auth() - Missing @throws for RateLimitError
2. logout() - Return type says void, but returns Promise<void>
3. logout() - No example provided
```

---

## Output Format

After synchronization work:

```
πŸ“ Documentation Sync Complete

Action: [Detection / Sync / Validation]
Scope: [Files/modules affected]

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Results
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Stale Documentation: [N] files
Broken References: [N] links
Missing Documentation: [N] items
Updated: [N] files

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Changes Made
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

- [file.md] Updated function references
- [source.ts] Added missing JSDoc

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Remaining Issues
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

- [issue requiring manual attention]
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.