active/docs-refactor-v2/SKILL.md
Refactor an existing OpenClaw docs page with source-audited preservation, restructuring, and verification.
npx skillsauth add kevinslin/skills docs-refactor-v2Install this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use this skill when the user gives a target OpenClaw docs page and asks to rewrite, refactor, reorganize, split, shorten, or improve it.
This skill builds on docs-write-v2: use that skill for style, page types,
structure, examples, discoverability, and verification. This skill adds the
rewrite workflow needed to avoid losing accurate behavior during a major docs
refactor.
For major rewrites, moved-section audits, migration maps, or line-by-line
preservation requests, use docs-audit-v2 as the audit engine. Read
../docs-audit-v2/references/refactor-integration.md for the generic contract:
this skill owns the rewrite and semantic mapping decisions; docs-audit-v2
owns the schema, CLI implementation, hydration, validation, report rendering,
and viewer.
Required:
docs/plugins/codex-harness.md.Optional:
If the target page is missing or ambiguous, ask one concise question before editing. Otherwise, proceed.
Refactor the target page to be more useful, concise, and comprehensive within its stated scope.
Do not treat a rewrite as permission to discard behavior facts. Preserve, verify, move, or explicitly retire existing material. Incorrect docs are worse than verbose docs.
Before rewriting, lock the page's reader contract in one sentence:
Use that contract to reject scope creep. Maintainer-only architecture, implementation details, rare debugging, and exhaustive references do not belong in a happy-path guide unless the reader needs them to complete the page's stated workflow.
Prefer this split:
Use this loop for major doc rewrites, moved-section refactors, and any request that asks for audit-grade preservation:
pnpm docs:list when available so the target and related
pages are discoverable.docs-write-v2, then use docs-audit-v2 to scaffold the source and
destination set. Record the audit artifact paths, source base ref, source doc
order, destination doc order, and mapping-patch.json location before
rewriting.mapping-patch.json as material moves, merges, or becomes intentionally
removed. Do not wait until the end to reconstruct preservation from memory.map, hydrate, validate, and render. Inspect
the Markdown report and viewer, not just the command exit status.map, hydrate, validate,
and render until the mechanical audit is clean.Do not treat the first clean validation result as final semantic signoff. For a major rewrite, the workflow is complete only after the audit validates and the per-source-page line review has no actionable findings.
Read ../docs-write-v2/SKILL.md first. Apply its page-type, style,
examples, navigation, and verification guidance throughout the refactor.
Run pnpm docs:list when available, then read only the target page and the
likely entry points, references, or related pages needed for the refactor.
Before editing, decide the intended page type from docs-write-v2.
If the current page mixes page types, choose the main page type and plan where the other material belongs:
Create a working inventory from the old page before rewriting. For major
refactors, materialize this inventory with docs-audit-v2 scaffold so it can
become audit.json and mapping-patch.json, not just informal notes. Include:
For each fact, choose one outcome:
For each structured source block, choose one outcome:
Default to preserving useful source structure. Do not collapse numbered operational lists into prose, split paired tabs, rewrite clear checklists, or remove guided next-step cards unless there is a concrete reader benefit.
Do not infer defaults, permissions, policy, timeout behavior, or safety posture from names or intent. Verify them.
Use the nearest authoritative source for each behavior-sensitive claim:
If a page promises a reference, compare its tables against the schema, manifest, CLI help, generated docs, or exported types. Missing public fields, defaults, precedence rules, caps, or side effects are correctness bugs.
When moving detail out of the target page, record the destination before editing:
doc-schema-version: 1, and read_when hints.Avoid duplicate truth. If the same contract appears in multiple places, choose one canonical page and link to it.
Use docs-audit-v2 when the refactor needs audit-grade preservation proof.
This skill owns the refactor-side work:
scaffold before rewriting when possible.mapping-patch.json while editing.mapping[] row per material source line.add-dest when destination pages are created after scaffold.reindex-dest when destination pages are edited.map to produce audit.mapped.json.When continuing a mapped audit after rebasing, first verify that the audit base
still points at the pre-refactor source snapshot. Relative refs such as
HEAD~3 can drift when commits are added, dropped, or squashed. If the base has
drifted, rerun scaffold with the corrected base before reindex-dest, keep
the original source and destination doc order so stable IDs still match
mapping-patch.json, then rerun map, hydrate, validate, and render.
Do not map one source line to a broad destination section as
semantic-confirmed. If exact destination lines are not selected yet, use
block-fallback and keep the row non-final until tightened.
A preservation gap does not automatically belong back in the rewritten main page. First check whether the fact is already preserved in a canonical reference, troubleshooting, or generated page in the destination set. Prefer a short retrieval link from the main page over duplicating exhaustive detail, unless the fact is required for the 80/20 workflow on that page.
After audit.mapped.json exists, hand off to the audit phase:
hydrate produces audit.hydrated.json.validate --out produces audit.validated.json.render produces the Markdown report and HTML viewer.Do not claim the preservation audit is complete while validate reports
errors.
Rewrite in this order:
Add doc-schema-version: 1 to the YAML frontmatter of every docs page that the
refactor migrates, creates, or materially rewrites. Apply it only to docs page
files, not docs.json, glossary JSON, or other non-page metadata. If a
migrated page is generated, update the generator so regeneration preserves the
marker instead of hand-editing generated output.
Do not leave placeholders such as "TODO", "TBD", or "see docs" unless the user explicitly asks for a draft.
After editing, compare the old and new page:
If the refactor deliberately removes relevant material, say where it went or why it was removed in the final report.
When reviewer feedback changes the rewrite, update the docs and audit together:
Run the smallest reliable docs checks for the touched surface:
pnpm docs:listgit diff --check -- <touched-files>pnpm exec oxfmt --check --threads=1 <touched-files>pnpm docs:check-mdxpnpm docs:check-linkspnpm docs:check-i18n-glossary when link text, navigation, labels, or glossary
surfaces changedRun commands and examples from the page whenever feasible. If you cannot verify a behavior-sensitive claim, either remove the claim, mark the uncertainty in the work-in-progress report, or ask for the missing source.
Report:
mapping-patch.json and audit.mapped.json
artifacts produced by the refactor phase.Do not include a long rewrite diary. Lead with remaining risks only if there are any.
development
Resolve explicit shortcut triggers and usage. Always read this file at the start of a thread or when user mentions `trigger`.
testing
Improve skills from observed agent friction in sessions, PRs, or audits.
development
Generate incremental Slack digests for channels, topics, and categories.
testing
Audit an OpenClaw maturity-scorecard surface into an evidence-backed component score report. Use when given a surface from an OpenClaw maturity-scorecard.md and asked to score coverage, quality, readiness, or generate a detailed surface report plus per-component subreports.