Update existing documentation by searching codebase for current implementation.
When user wants to update documentation:
Read .devdoc/context.json if it exists:
product.name for product referencesterminology.glossary for correct termsterminology.avoidTermsdocumentation.voice for writing styleAsk the user:
"What would you like to update?
Based on their choice:
guides/authentication.mdx)"Step 2a: Search for source files related to documented topics:
# Find all exported functions/classes
rg "export (function|class|const|interface|type)" --type ts -l
# Find specific topic files
git ls-files | grep -iE "(auth|user|api)"
Step 2b: Read both doc files AND source files:
Step 2c: Generate comparison:
DOCUMENTED (from docs/api/users.mdx):
- createUser(name: string, email: string)
ACTUAL (from src/lib/users.ts):
- createUser(options: CreateUserInput)
→ SIGNATURE MISMATCH - needs update
Compare documentation against actual source:
docs.jsonSearch for feature flags in source:
rg -l "featureFlag|feature_flag|isEnabled|FF_" --type ts
rg "if.*\(.*feature|process\.env\.FEATURE" --type ts
Search for duplicate/similar features:
rg "export.*(login|authenticate|signIn)" --type ts -l
Include in sync report:
Compare docs against actual source files:
## Documentation Sync Report
### Signature Changes (from source files)
- `docs/api/users.mdx` vs `src/lib/users.ts`:
- Documented: `createUser(name, email)`
- Source file: `createUser(options: CreateUserInput)`
- Action: Update signature and params
### New Exports (in source, not in docs)
- `src/lib/auth.ts`: `refreshToken()` - Not documented
- `src/lib/users.ts`: `deleteUser()` - Not documented
### Removed (in docs, not in source)
- `legacyAuth()` - Not found in any source file
### Up to Date ✓
- `docs/guides/authentication.mdx` matches `src/lib/auth/`
### Unable to Verify (source not found)
⚠️ `docs/legacy/old-api.mdx` - No matching source file
═══════════════════════════════════════════════════════════
FEATURE FLAGS DETECTED
═══════════════════════════════════════════════════════════
⚠️ src/lib/auth/index.ts:45 - newAuthFlow
Current docs: OLD implementation
Feature flag: NEW implementation available
Question: Update docs to which version?
1. Keep current (old)
2. Update to new (feature-flagged)
3. Document both with toggle notice
═══════════════════════════════════════════════════════════
DUPLICATE FEATURES
═══════════════════════════════════════════════════════════
🔄 Similar functions found:
- src/lib/auth/login.ts → login()
- src/lib/auth/v2/authenticate.ts → authenticate()
Question: How to handle?
1. Document primary only
2. Document all with comparison
3. Mark duplicates as deprecated
Ask: "How would you like to proceed?
For EACH file being updated, show before/after:
═══════════════════════════════════════════════════════════
CHANGE REVIEW: docs/api/users.mdx
═══════════════════════════════════════════════════════════
📄 BEFORE (current):
───────────────────────────────────────────────────────────
## createUser(name, email)
Creates a new user account.
| Parameter | Type |
|-----------|------|
| name | string |
| email | string |
───────────────────────────────────────────────────────────
📄 AFTER (proposed):
───────────────────────────────────────────────────────────
## createUser(options)
Creates a new user account.
| Parameter | Type | Description |
|-----------|------|-------------|
| options | CreateUserInput | User creation options |
### CreateUserInput
| Property | Type | Required |
|----------|------|----------|
| name | string | Yes |
| email | string | Yes |
| role | 'admin' \| 'user' | No |
───────────────────────────────────────────────────────────
⚠️ NOTICES:
- Source: src/lib/users.ts:23
- Feature flag: None
- Duplicates: None
OPTIONS:
1. ✅ **Approve** - Apply this change
2. ✏️ **Edit** - Modify the proposed content
3. ⏭️ **Skip** - Don't update this file
4. ❌ **Cancel all** - Stop updating
Choose an option:
Only after user approves each change:
<Warning>
**Deprecated in v2.0**: This feature was removed.
See [migration guide](/guides/v2-migration).
</Warning>
<Note>
**Feature Flag**: This feature requires `newAuthFlow` to be enabled.
</Note>
{/* TODO: Document this new feature */}
## New Feature
Coming soon...
If pages were added/removed/moved:
docs.json"Updated:
docs/api/users.mdx - Updated function signaturesdocs/quickstart.mdx - Updated to v2.0.0docs.json - Added webhooks pageChanges ready for review. Run npm run dev to preview.
Want me to commit these changes? Use /commit when ready."
// Before
`createUser(name: string, email: string)`
// After
`createUser(options: CreateUserInput)`
Where `CreateUserInput`:
```typescript
interface CreateUserInput {
name: string;
email: string;
role?: 'admin' | 'user';
}
### Removed Feature
```mdx
<Warning>
**Removed in v2.0**: The `legacyAuth` method was removed.
Use `authenticate()` instead. See [migration guide](/migrate-v2).
</Warning>
---
title: "Webhooks"
description: "Receive real-time notifications"
---
{/* TODO: Complete this documentation */}
## Overview
Documentation coming soon.
## Quick Start
```typescript
// Example placeholder
---
## Key Principles
| Principle | Description |
|-----------|-------------|
| **Search before update** | ALWAYS read source files before changing docs |
| **No hallucination** | Only update based on actual file contents |
| **Review before write** | ALWAYS show before/after for user approval |
| **Flag feature flags** | Detect and highlight conditional features |
| **Flag duplicates** | Identify similar/related features |
| **Verify changes** | Read source to confirm what changed |
## Quality Guidelines
- **SEARCH FIRST** - Read source files before making any update
- **REVIEW WITH USER** - Show before/after for each change
- **DETECT FEATURE FLAGS** - Search for conditional features
- **DETECT DUPLICATES** - Find similar functions/features
- Always show changes before applying
- Preserve existing prose and explanations
- Update only technical details (code, versions, signatures)
- Flag when source file not found - offer auto-correct options
- Add TODO markers for human review
- Apply terminology from context.json
- Create stubs rather than skip new features