Re-analyze the codebase and intelligently update documentation while preserving manual customizations.
Re-analyzes your codebase and updates documentation while preserving manual customizations. Use this when code structure has changed significantly or multiple domains have drifted, but you want to keep your custom notes and sections intact.
/plugin marketplace add olioapps/claude-code-plugins/plugin install codebase-documentation@olio-pluginsRe-analyze the codebase and intelligently update documentation while preserving manual customizations.
Arguments: /codebase-documentation:update-docs [FLAGS]
Analysis Control:
Update Behavior:
Output Control:
Use /codebase-documentation:update-docs when:
Don't use when:
/codebase-documentation:audit-docs instead/codebase-documentation:map-domain <name> instead/codebase-documentation:document-codebaseCheck for required files:
.claude/docs/codebase-schema.yaml.claude/docs/INDEX.mdIf missing:
/codebase-documentation:document-codebase first."Read existing domain docs from .claude/docs/domains/*.md
For each domain doc, identify custom sections (not from template):
Template sections (can safely regenerate):
Custom sections (must preserve):
> ...)Store customization map: { domain: [custom_sections] }
--skip-audit)Execute internal audit logic (same as /codebase-documentation:audit-docs --threshold minor):
Show summary:
## Pre-flight Audit
**Domains with drift:**
- ⚠️ {X} domains with trivial drift
- 🔍 {X} domains with minor drift
- ❌ {X} domains with significant drift
**Customizations detected:**
- {X} domains have custom content that will be preserved
Use AskUserQuestion:
If "View details", show drift breakdown then re-prompt.
Use Task tool to invoke codebase-analyzer agent:
Re-analyze this codebase to detect changes since last documentation.
Previous analysis context:
---PREVIOUS_ANALYSIS---
{paste current codebase-schema.yaml content}
---END---
Focus on:
- New domains or structural changes
- Changed file counts and patterns
- New patterns or conventions
- Removed or moved domains
User context (preserve from original):
- Application type: {from previous metadata.type}
- Architecture: {from previous metadata.architecture}
Return updated analysis in your standard ---ANALYSIS--- format.
Parse response expecting ---ANALYSIS---...---END--- format.
Compare old schema with new analysis:
# Analysis Diff Structure
domains:
added:
- {domain_name}: {location, purpose, count}
removed:
- {domain_name}: {last known location}
changed:
{domain_name}:
count: {old} → {new}
location: {old} → {new} # if moved
purpose: {old} → {new} # if changed
key_files:
added: [files]
removed: [files]
file_patterns:
added: [{pattern_name}: {details}]
removed: [{pattern_name}]
changed:
{pattern_name}:
count: {old} → {new}
example: {old} → {new} # if changed
For each domain, determine update strategy:
Criteria:
Action: Update counts/stats only, minimal changes
Criteria:
Action: Regenerate template sections, preserve custom sections
Criteria:
Action: Archive old (unless --no-archive), generate fresh
Criteria:
Action: Create new documentation
Criteria:
Action: Archive documentation (not delete, unless --no-archive)
--interactive)For each MERGE or RECREATE change:
Use AskUserQuestion:
metadata.documentation.generated_at timestamp.claude/docs/codebase-schema.yamlFor each domain, apply determined strategy:
REFRESH:
1. Read existing doc
2. Update file counts in tables
3. Update directory structure tree
4. Update "Last Updated" timestamp
5. Keep all other content unchanged
6. Write back
MERGE:
1. Read existing doc
2. Parse into sections (template vs custom)
3. Regenerate template sections with new analysis data:
- Overview (first paragraph)
- Directory Structure
- Key Files table
- Dependencies
- Related Documentation links
4. Preserve custom sections in their original positions
5. Add "Updated: {date}" note if significant changes
6. Flag conflicts (custom content references deleted files)
7. Write merged doc
RECREATE:
1. If --no-archive NOT set:
- Create archive: .claude/docs/domains/_archive/{domain}-{date}.md
- Copy existing doc to archive
2. Generate new doc from template using new analysis
3. Add note: "Previous version archived at {path}" (if archived)
4. Write new doc
ADD:
1. Generate new doc from template
2. Use analysis data for this domain
3. Write to .claude/docs/domains/{domain}.md
REMOVE:
1. If --no-archive NOT set:
- Create archive: .claude/docs/domains/_archive/{domain}-{date}.md
- Move existing doc to archive
2. Remove from schema
3. Remove from INDEX.md table
4. Add note in update summary
Apply same strategy logic to pattern guides:
Run internal validation checks:
Schema Validation:
Documentation Validation:
Report issues if validation fails but don't abort.
Present comprehensive report:
## Documentation Updated Successfully
**Re-analysis Date**: {ISO 8601 timestamp}
**Update Strategy**: {Interactive|Automatic}
**Customizations**: {Preserved|None found|Lost (if --force-recreate)}
---
## Changes Applied
### Schema Updates
- **Domains**: {X} updated, {Y} added, {Z} removed
- **Patterns**: {X} updated, {Y} added, {Z} removed
- **File Count Drift**: {total files changed across all domains}
### Documentation Updates
#### Domains Updated ({count})
| Domain | Strategy | Changes |
|--------|----------|---------|
| {domain} | REFRESH | File count: {old} → {new} |
| {domain} | MERGE | Added subdomain, preserved {X} custom sections |
| {domain} | RECREATE | Structure completely changed, archived previous |
#### New Domains ({count})
| Domain | Location | Purpose |
|--------|----------|---------|
| {new_domain} | `{path}` | {purpose} |
#### Removed Domains ({count})
| Domain | Archived To | Reason |
|--------|-------------|--------|
| {old_domain} | `_archive/{file}` | No longer exists in codebase |
#### Patterns Updated ({count})
| Pattern | Change | Impact |
|---------|--------|--------|
| {pattern} | Count: {old} → {new} | REFRESH |
| {pattern} | NEW | Added guide |
---
## Preserved Customizations
{If custom sections found and preserved:}
**Domains with custom content preserved:**
- `{domain}.md` - {X} custom sections merged
- `{domain}.md` - {Y} custom examples preserved
**Custom INDEX.md sections preserved:**
- {Section name}
---
## Conflicts & Manual Review Needed
{If issues detected during merge:}
⚠️ **{Domain name}**
- Issue: Custom content references deleted file `{filename}`
- Action needed: Review and update custom section
- Location: `.claude/docs/domains/{domain}.md`
---
## Archived Files
{If domains/patterns removed:}
The following files were archived (not deleted):
- `.claude/docs/domains/_archive/{domain}-{date}.md`
- `.claude/docs/patterns/_archive/{pattern}-{date}.md`
Review archived content before permanent deletion.
---
## Validation Results
✅ Schema syntax valid
✅ All domains documented
✅ All patterns have homes
✅ INDEX table complete
✅ No broken links detected
{Or list issues if validation failed}
---
## Next Steps
1. **Review changes**: Check updated domain docs for accuracy
2. **Resolve conflicts**: Address any flagged issues above
3. **Test discovery**: Run `/prime` to verify updated docs work
4. **Audit periodically**: Schedule `/codebase-documentation:audit-docs` to catch future drift
{If conflicts exist:}
⚠️ **Manual review required for {X} conflicts** - See "Conflicts" section above
--dry-run)Execute all phases EXCEPT Phase 5 (Apply Updates).
Instead of writing files, show:
## Dry Run Preview
**The following changes WOULD be applied:**
### Schema Changes
{Show YAML diff}
### Domain Doc Changes
{For each domain, show strategy + summary of changes}
### Files to Create
- {new files}
### Files to Archive
- {files to archive}
**No files were modified.**
To apply these changes, run:
`/codebase-documentation:update-docs` (without --dry-run)
/codebase-documentation:document-codebase first."/codebase-documentation:audit-docs instead# Standard update (interactive, preserve customizations)
/codebase-documentation:update-docs
# Update specific domains only
/codebase-documentation:update-docs --domains components,services,models
# Dry run to preview changes
/codebase-documentation:update-docs --dry-run
# Force complete recreation (lose customizations)
/codebase-documentation:update-docs --force-recreate
# Non-interactive, preserve everything possible
/codebase-documentation:update-docs --preserve-custom
# Update with full reanalysis and verbose output
/codebase-documentation:update-docs --full-reanalysis --verbose
# Quick update, skip audit, no prompts
/codebase-documentation:update-docs --skip-audit
# Update without archiving removed docs
/codebase-documentation:update-docs --no-archive
A successful update should:
/update-docsUpdate and maintain project documentation for local code changes using multi-agent workflow with tech-writer agents. Covers docs/, READMEs, JSDoc, and API documentation.