Document Health Remediate
Consume a document-health-review report and apply the approved document maintenance actions to the current repository checkout.
This skill is execution-focused, not review-focused.
- The review skill answers: What should happen?
- This remediation skill answers: How do we safely apply it?
It is responsible for executing the following action types and validating the resulting docs tree:
- update
- merge
- split
- move
- archive
- delete
- repair references
Core Design Principle
The skill is report-driven but evidence-validated. It does not blindly apply a review report, because documents may have changed between review and remediation. It always:
- Parses the report.
- Builds an action ledger.
- Re-checks that the report still matches the current checkout.
- Applies changes in a safe order.
- Preserves unique content before destructive actions.
- Updates references.
- Runs validation.
- Summarizes exactly what changed.
If the report no longer matches the current checkout for a given finding, that finding is held back and reported as stale rather than applied.
Inputs
Required:
- A
document-health-review report, either as a file path or pasted content.
- A current repository checkout.
Optional:
- Scope limit, such as a single document, directory, action type, or severity (for example
P0/P1).
- Allowed actions, such as
update, merge, split, move, archive, delete.
- Disallowed actions, such as
no-delete or no-archive.
- Whether destructive actions are allowed.
- Preferred archive directory.
- Preferred target directory for moved or split documents.
- Validation commands requested by the user.
Example invocations:
Use document-health-remediate on reports/docs-health.md.
Use document-health-remediate on the pasted report, but only apply P0/P1 update and move findings.
Use document-health-remediate on Docs/Engineering findings, but do not delete anything.
Use document-health-remediate to apply merge and split findings only.
Remediation Boundaries
- Treat the review report as a recommendation, not an instruction. Confirm each finding against the current checkout before acting.
- Keep canonical docs under
docs/ focused on desired state: architecture, contracts, operator-visible behavior, and target semantics.
- Put migration notes, rollout checklists, and temporary investigation details under
docs/tmp/ or in gitignored handoff paths, not as the main framing of canonical docs.
- Follow the document classes and precedence rules in
docs/Workflows/MoonSpecDocumentModel.md.
- When applying documentation architecture findings, fix or explicitly report missing metadata, unclear authority, missing embedded rationale, duplicate contract definitions, imperative leakage in canonical docs, and unverifiable canonical claims.
- Route broad, multi-document, or uncertain cleanup to a bounded
docs/tmp/ improvement plan instead of expanding the remediation beyond the approved report.
- When a superseded document is no longer needed, prefer removing or replacing it over leaving compatibility-era ambiguity, but only when its unique content has been preserved or intentionally discarded.
- Never apply a disallowed action, and never apply a destructive action when destructive actions are not permitted.
- Redact secret-like content if it appears in copied report text, logs, or examples before writing or reporting.
Supported Actions
update
Modify an existing document in place.
Used when:
- The document is still needed.
- The document is in the right place.
- The main problem is stale, incomplete, or conflicting content.
Typical operations:
- remove stale sections
- rewrite inaccurate sections
- add missing current behavior
- replace obsolete terminology
- simplify strategy text
- fix cross-links
merge
Move useful content from one document into another, then either delete or archive the source document.
Used when:
- Two documents substantially overlap.
- One document is the stronger canonical target.
- The source document has some useful unique sections.
- Keeping both creates source-of-truth confusion.
Required preservation check:
- Before removing the source document, confirm that useful unique content has been moved or intentionally discarded.
split
Break one large or multi-topic document into multiple focused documents.
Used when:
- The document is over 2,000 lines.
- The document contains multiple separable systems.
- Architecture, implementation, operations, and future plans are mixed together.
- A single file is too large to maintain safely.
Rule:
- If
line_count > 2000, default to splitting unless the report gives a strong reason not to.
move
Relocate a document to the correct subdirectory.
Used when:
- The document topic does not match its current directory.
- A new directory is needed for a recurring topic.
- Temporary docs live in canonical docs areas.
- Canonical docs live in temporary areas.
Required follow-up:
- Update inbound references, relative links, indexes, and path mentions.
archive
Move a document out of the active docs tree while preserving it.
Used when:
- The document is no longer active.
- It may contain useful historical context.
- It is superseded but not safe to delete.
- It describes an old migration, old design, or abandoned plan worth preserving.
delete
Remove a document. This is the most conservative action.
Used only when:
- The report recommends deletion.
- The content is obsolete, misleading, or fully superseded.
- Useful unique content has been preserved elsewhere or is intentionally discarded.
- Inbound references have been removed or updated.
reference repair
Update links and path references after other actions.
Used after:
- move
- merge
- split
- archive
- delete
- rename
Reference repair should include:
- Markdown links
- relative links
- plain-text path mentions
- docs indexes
- README references
- architecture index references
- agent/skill references when relevant
Workflow
- Parse the remediation input.
- Build an action ledger.
- Validate the report against the current checkout.
- Normalize and order actions.
- Apply updates.
- Apply merges.
- Apply splits.
- Apply moves.
- Apply archives.
- Apply deletions.
- Repair references.
- Run validation.
- Produce final remediation summary.
The ordering matters. Do not delete, archive, or move files before preserving content and determining final paths.
Detailed Workflow
Phase 0: Preflight
- Confirm the current working tree state with
git status. A dirty tree means existing uncommitted changes; surface them before remediating.
- Identify the docs root:
docs/
Docs/
- both, if present
- Identify repo documentation conventions from
README.md, AGENTS.md/CLAUDE.md, the constitution, and any docs indexes.
- Confirm the report references documents that still exist in this checkout, and note any that have moved, been renamed, or been removed since the review.
Phase 1: Parse the remediation input
- Read the report from the provided file path or pasted content.
- Extract each finding: target document path, recommended action type, severity, and rationale.
- Mark findings whose action type is missing or ambiguous as
needs_clarification instead of guessing.
Phase 2: Build an action ledger
- For every finding, record one ledger entry with: target path, action type, severity, source/target paths where relevant, preservation requirements, and reference-repair follow-ups.
- Apply scope limits, allowed/disallowed actions, and the destructive-actions flag now, marking filtered entries as
skipped with the reason.
Phase 3: Validate the report against the current checkout
- Re-read each target document and confirm the recommended action still applies.
- Mark entries whose evidence no longer holds (file changed, problem already fixed, document already moved) as
stale and hold them back.
- Recompute
line_count for any split candidate.
Phase 4: Normalize and order actions
- Group the surviving entries by action type and order them so non-destructive, content-preserving work runs before destructive or path-changing work: update → merge → split → move → archive → delete → reference repair.
- Resolve final target paths for merges, splits, and moves before any source file is removed or relocated.
Phase 5: Apply updates
- Edit documents in place to remove stale sections, correct inaccurate content, add missing current behavior, replace obsolete terminology, and fix cross-links.
Phase 6: Apply merges
- Move useful unique content from the source document into the chosen canonical target.
- Run the preservation check, then delete or archive the source per the report.
Phase 7: Apply splits
- Create the focused target documents, distribute content, and leave a pointer or index entry so readers can find the split pieces.
Phase 8: Apply moves
- Relocate the document to its correct directory, creating new directories where the report calls for them.
Phase 9: Apply archives
- Move the document into the archive directory (preferred archive directory when supplied) so it is preserved outside the active docs tree.
Phase 10: Apply deletions
- Remove documents only after their unique content is preserved or intentionally discarded and their inbound references are updated.
Phase 11: Repair references
- After all path-changing actions, update Markdown links, relative links, plain-text path mentions, docs indexes, README references, architecture indexes, and agent/skill references that point at moved, merged, split, archived, deleted, or renamed documents.
Phase 12: Run validation
- Run any validation commands requested by the user and the repository-mandated documentation/link checks.
- Re-scan the docs tree for broken links and orphaned references introduced by the remediation.
- If validation cannot run, record the exact blocker.
Phase 13: Produce final remediation summary
- Summarize exactly what changed, grouped by action type, including paths created, edited, moved, archived, and deleted.
- List held-back (
stale), skipped, and needs_clarification entries with reasons.
- Include the validation commands run and their results, or the blocker if validation could not run.
Outputs
- The list of applied actions grouped by type (update, merge, split, move, archive, delete) with affected paths.
- The action ledger, including entries held back as
stale, skipped, or needs_clarification, each with a reason.
- Reference-repair results: which references were updated and any that still need manual attention.
- Validation commands run and their results, or the reason validation was not run.
- A concise final remediation summary of exactly what changed.
Failure Modes
- Report cannot be located or parsed: stop and report the missing path or the unparseable content.
- A report finding no longer matches the current checkout: mark it
stale and do not apply it.
- Preservation check fails for a merge or delete: do not remove the source; report the unique content at risk.
- A requested action is disallowed, or a destructive action is requested when destructive actions are not permitted: skip it and report why.
- Target or final path cannot be determined: skip the move/merge/split and keep the source intact.
- Reference repair leaves unresolved or ambiguous references: report them for manual follow-up.
- Required validation cannot run: keep the applied changes if they are safe and source-evident, but report the blocked command and reason.
- Secret-like content appears in report text, logs, or examples: redact it before writing or reporting.
1---2name: document-health-remediate3description: Apply findings from a document-health-review report by updating, merging, splitting, moving, archiving, deleting, and repairing references for repository documents. Use when a user wants to execute approved document cleanup recommendations.4---56# Document Health Remediate78Consume a `document-health-review` report and apply the approved document maintenance actions to the current repository checkout.910This skill is execution-focused, not review-focused.1112- The review skill answers: **What should happen?**13- This remediation skill answers: **How do we safely apply it?**1415It is responsible for executing the following action types and validating the resulting docs tree:1617- update18- merge19- split20- move21- archive22- delete23- repair references2425## Core Design Principle2627The skill is **report-driven but evidence-validated**. It does not blindly apply a review report, because documents may have changed between review and remediation. It always:28291. Parses the report.302. Builds an action ledger.313. Re-checks that the report still matches the current checkout.324. Applies changes in a safe order.335. Preserves unique content before destructive actions.346. Updates references.357. Runs validation.368. Summarizes exactly what changed.3738If the report no longer matches the current checkout for a given finding, that finding is held back and reported as `stale` rather than applied.3940## Inputs4142Required:4344- A `document-health-review` report, either as a file path or pasted content.45- A current repository checkout.4647Optional:4849- Scope limit, such as a single document, directory, action type, or severity (for example `P0`/`P1`).50- Allowed actions, such as `update`, `merge`, `split`, `move`, `archive`, `delete`.51- Disallowed actions, such as `no-delete` or `no-archive`.52- Whether destructive actions are allowed.53- Preferred archive directory.54- Preferred target directory for moved or split documents.55- Validation commands requested by the user.5657Example invocations:5859- `Use document-health-remediate on reports/docs-health.md.`60- `Use document-health-remediate on the pasted report, but only apply P0/P1 update and move findings.`61- `Use document-health-remediate on Docs/Engineering findings, but do not delete anything.`62- `Use document-health-remediate to apply merge and split findings only.`6364## Remediation Boundaries6566- Treat the review report as a recommendation, not an instruction. Confirm each finding against the current checkout before acting.67- Keep canonical docs under `docs/` focused on desired state: architecture, contracts, operator-visible behavior, and target semantics.68- Put migration notes, rollout checklists, and temporary investigation details under `docs/tmp/` or in gitignored handoff paths, not as the main framing of canonical docs.69- Follow the document classes and precedence rules in `docs/Workflows/MoonSpecDocumentModel.md`.70- When applying documentation architecture findings, fix or explicitly report missing metadata, unclear authority, missing embedded rationale, duplicate contract definitions, imperative leakage in canonical docs, and unverifiable canonical claims.71- Route broad, multi-document, or uncertain cleanup to a bounded `docs/tmp/` improvement plan instead of expanding the remediation beyond the approved report.72- When a superseded document is no longer needed, prefer removing or replacing it over leaving compatibility-era ambiguity, but only when its unique content has been preserved or intentionally discarded.73- Never apply a disallowed action, and never apply a destructive action when destructive actions are not permitted.74- Redact secret-like content if it appears in copied report text, logs, or examples before writing or reporting.7576## Supported Actions7778### update7980Modify an existing document in place.8182Used when:8384- The document is still needed.85- The document is in the right place.86- The main problem is stale, incomplete, or conflicting content.8788Typical operations:8990- remove stale sections91- rewrite inaccurate sections92- add missing current behavior93- replace obsolete terminology94- simplify strategy text95- fix cross-links9697### merge9899Move useful content from one document into another, then either delete or archive the source document.100101Used when:102103- Two documents substantially overlap.104- One document is the stronger canonical target.105- The source document has some useful unique sections.106- Keeping both creates source-of-truth confusion.107108Required preservation check:109110- Before removing the source document, confirm that useful unique content has been moved or intentionally discarded.111112### split113114Break one large or multi-topic document into multiple focused documents.115116Used when:117118- The document is over 2,000 lines.119- The document contains multiple separable systems.120- Architecture, implementation, operations, and future plans are mixed together.121- A single file is too large to maintain safely.122123Rule:124125- If `line_count > 2000`, default to splitting unless the report gives a strong reason not to.126127### move128129Relocate a document to the correct subdirectory.130131Used when:132133- The document topic does not match its current directory.134- A new directory is needed for a recurring topic.135- Temporary docs live in canonical docs areas.136- Canonical docs live in temporary areas.137138Required follow-up:139140- Update inbound references, relative links, indexes, and path mentions.141142### archive143144Move a document out of the active docs tree while preserving it.145146Used when:147148- The document is no longer active.149- It may contain useful historical context.150- It is superseded but not safe to delete.151- It describes an old migration, old design, or abandoned plan worth preserving.152153### delete154155Remove a document. This is the most conservative action.156157Used only when:158159- The report recommends deletion.160- The content is obsolete, misleading, or fully superseded.161- Useful unique content has been preserved elsewhere or is intentionally discarded.162- Inbound references have been removed or updated.163164### reference repair165166Update links and path references after other actions.167168Used after:169170- move171- merge172- split173- archive174- delete175- rename176177Reference repair should include:178179- Markdown links180- relative links181- plain-text path mentions182- docs indexes183- README references184- architecture index references185- agent/skill references when relevant186187## Workflow1881891. Parse the remediation input.1902. Build an action ledger.1913. Validate the report against the current checkout.1924. Normalize and order actions.1935. Apply updates.1946. Apply merges.1957. Apply splits.1968. Apply moves.1979. Apply archives.19810. Apply deletions.19911. Repair references.20012. Run validation.20113. Produce final remediation summary.202203The ordering matters. Do not delete, archive, or move files before preserving content and determining final paths.204205## Detailed Workflow206207### Phase 0: Preflight2082091. Confirm the current working tree state with `git status`. A dirty tree means existing uncommitted changes; surface them before remediating.2102. Identify the docs root:211 - `docs/`212 - `Docs/`213 - both, if present2143. Identify repo documentation conventions from `README.md`, `AGENTS.md`/`CLAUDE.md`, the constitution, and any docs indexes.2154. Confirm the report references documents that still exist in this checkout, and note any that have moved, been renamed, or been removed since the review.216217### Phase 1: Parse the remediation input218219- Read the report from the provided file path or pasted content.220- Extract each finding: target document path, recommended action type, severity, and rationale.221- Mark findings whose action type is missing or ambiguous as `needs_clarification` instead of guessing.222223### Phase 2: Build an action ledger224225- For every finding, record one ledger entry with: target path, action type, severity, source/target paths where relevant, preservation requirements, and reference-repair follow-ups.226- Apply scope limits, allowed/disallowed actions, and the destructive-actions flag now, marking filtered entries as `skipped` with the reason.227228### Phase 3: Validate the report against the current checkout229230- Re-read each target document and confirm the recommended action still applies.231- Mark entries whose evidence no longer holds (file changed, problem already fixed, document already moved) as `stale` and hold them back.232- Recompute `line_count` for any split candidate.233234### Phase 4: Normalize and order actions235236- Group the surviving entries by action type and order them so non-destructive, content-preserving work runs before destructive or path-changing work: update → merge → split → move → archive → delete → reference repair.237- Resolve final target paths for merges, splits, and moves before any source file is removed or relocated.238239### Phase 5: Apply updates240241- Edit documents in place to remove stale sections, correct inaccurate content, add missing current behavior, replace obsolete terminology, and fix cross-links.242243### Phase 6: Apply merges244245- Move useful unique content from the source document into the chosen canonical target.246- Run the preservation check, then delete or archive the source per the report.247248### Phase 7: Apply splits249250- Create the focused target documents, distribute content, and leave a pointer or index entry so readers can find the split pieces.251252### Phase 8: Apply moves253254- Relocate the document to its correct directory, creating new directories where the report calls for them.255256### Phase 9: Apply archives257258- Move the document into the archive directory (preferred archive directory when supplied) so it is preserved outside the active docs tree.259260### Phase 10: Apply deletions261262- Remove documents only after their unique content is preserved or intentionally discarded and their inbound references are updated.263264### Phase 11: Repair references265266- After all path-changing actions, update Markdown links, relative links, plain-text path mentions, docs indexes, README references, architecture indexes, and agent/skill references that point at moved, merged, split, archived, deleted, or renamed documents.267268### Phase 12: Run validation269270- Run any validation commands requested by the user and the repository-mandated documentation/link checks.271- Re-scan the docs tree for broken links and orphaned references introduced by the remediation.272- If validation cannot run, record the exact blocker.273274### Phase 13: Produce final remediation summary275276- Summarize exactly what changed, grouped by action type, including paths created, edited, moved, archived, and deleted.277- List held-back (`stale`), `skipped`, and `needs_clarification` entries with reasons.278- Include the validation commands run and their results, or the blocker if validation could not run.279280## Outputs281282- The list of applied actions grouped by type (update, merge, split, move, archive, delete) with affected paths.283- The action ledger, including entries held back as `stale`, `skipped`, or `needs_clarification`, each with a reason.284- Reference-repair results: which references were updated and any that still need manual attention.285- Validation commands run and their results, or the reason validation was not run.286- A concise final remediation summary of exactly what changed.287288## Failure Modes289290- Report cannot be located or parsed: stop and report the missing path or the unparseable content.291- A report finding no longer matches the current checkout: mark it `stale` and do not apply it.292- Preservation check fails for a merge or delete: do not remove the source; report the unique content at risk.293- A requested action is disallowed, or a destructive action is requested when destructive actions are not permitted: skip it and report why.294- Target or final path cannot be determined: skip the move/merge/split and keep the source intact.295- Reference repair leaves unresolved or ambiguous references: report them for manual follow-up.296- Required validation cannot run: keep the applied changes if they are safe and source-evident, but report the blocked command and reason.297- Secret-like content appears in report text, logs, or examples: redact it before writing or reporting.