Skill: Finalize Documentation and Commit (Review, Consistency, Alignment)
Type: Execution
Purpose
Finalize documentation changes for production readiness in a documentation
project that coexists with the product source code in the same workspace.
Works with any documentation framework (Docusaurus, VitePress, MkDocs, Nextra,
plain Markdown, etc.).
Tasks:
- Discover conventions from existing documentation
- Verify code-documentation alignment when source code changed
- Review format, terminology, tone, and completeness consistency
- Validate framework-specific syntax and build integrity
- Verify current branch and dirty working tree match the intended documentation
task
- Prepare structured commits separated by change type
- Force an explicit cleanup decision after push, PR creation, or PR merge
When to Use
- Before committing documentation changes to a shared branch
- Before submitting a pull request that includes documentation updates
- After completing a documentation session that touched multiple pages
- When source code and documentation were both modified in the same session
- When preparing a clean commit history from messy documentation edits
- When continuing documentation work after another session may have used the
same repository
When NOT to Use
- Work-in-progress drafts still actively being written
- Trivial single-line typo fixes that need no consistency review
- Initial documentation scaffolding or exploratory writing phases
- Changes already reviewed and approved through another skill
- Standalone Markdown files outside a documentation project structure
Inputs Required
Do not run this skill without:
Optional but recommended:
Output Format
- Convention Reference (discovered patterns)
- Branch Context Verdict
- Code-Documentation Alignment Report
- Quality Review Findings
- Actions Taken (auto-fixes applied)
- Build Verification Results
- Commit Plan
- Final Commit Messages
- Post-Publish Cleanup Decision
Procedure
Gate -1 – Branch Context Check
Run branch-context-check before validating the working set. If that skill is
not installed, run the check inline: inspect git status --short --branch,
git branch --show-current, git log --oneline --decorate -5, and the
staged/dirty file lists, then classify the branch/worktree against the current
documentation task using the same four verdicts below.
Required outcome:
- Current documentation task intent is summarized.
- Current branch, upstream state, recent commits, staged files, and dirty files
are inspected.
- Branch/worktree verdict is one of
match, ambiguous, mismatch, or
blocked.
Proceed to Gate 0 only when:
- Verdict is
match, or
- Verdict is
ambiguous and the user explicitly confirms the branch/worktree
is correct for the current documentation task.
Stop before staging or committing when:
- Verdict is
mismatch or blocked.
- Staged files include changes outside the current documentation task.
- Dirty files from a previous session overlap with current-session
documentation files.
In a stopped state, recommend a concrete recovery path: create/switch to a
task-appropriate branch, create a separate worktree from the correct base, or
finish/commit the previous-session work first. Do not move, stash, reset, or
discard changes without explicit user approval.
Gate 0 – Working Set Validation
CRITICAL: The working tree may contain changes from other agent sessions
or manual edits. This gate must isolate only the current session's changes
without disturbing anything else.
Step 0-1: Identify current session scope
- Review the conversation history and edit history of this session.
- Build an explicit list of
.md/.mdx files that were created, modified,
or deleted by this session.
- Separately identify source code files changed in this session (needed for
Gate 2).
- If the user provided a scope list, use that as the authoritative source.
Step 0-2: Inspect full working tree state
- Run
git status and git diff --name-only to enumerate all uncommitted
changes in the working tree.
Step 0-3: Classify changes
- Doc-scope:
.md/.mdx files that appear in both the session scope
(Step 0-1) and the working tree (Step 0-2).
- Code-scope: Source code files changed by this session (input for Gate 2).
- Out-of-scope: Files in the working tree NOT modified by this session.
Step 0-4: Protect out-of-scope changes
- NEVER revert, restore, checkout, stash, or discard out-of-scope changes.
- Out-of-scope files must be left exactly as they are in the working tree.
- The only correct action is to exclude them from staging (
git add).
Step 0-5: Confirm with the user
- Present a summary:
- Documentation files to be reviewed and committed (doc-scope)
- Source code files to cross-reference (code-scope)
- Files left untouched (out-of-scope), if any
- Proceed only after the user confirms the target set.
Gate 1 – Convention Discovery
PURPOSE: Establish the review baseline. Use a provided style guide
first; infer conventions from existing documentation only where no
explicit guidance exists.
Step 1-0: Use a provided style guide first
- If the user provided a style guide or glossary (see Optional inputs), treat
it as the primary Convention Reference.
- Run Steps 1-1a–1-5 only to fill gaps the style guide does not cover (e.g.,
frontmatter fields, framework syntax), and never let inferred patterns
override explicit style-guide rules.
- If the style guide fully covers structure, terminology, and tone, skip
directly to Step 1-6.
Step 1-1a: Scan documentation headers
- Read frontmatter + first 30 lines of 10–15 representative
.md/.mdx files from the docs directory
(prioritize recently modified, high-traffic pages).
- If fewer than 10 documentation files exist, read all available files.
- Exclude files in the current session's change set to avoid circular
reference.
- From this scan, extract: frontmatter field names, heading structure,
first paragraph tone/speech level.
Step 1-1b: Deep read divergent samples
- Compare patterns extracted in Step 1-1a across all samples.
- Identify files where patterns diverge or are ambiguous
(e.g., inconsistent frontmatter fields, mixed heading levels).
- Full-read only the divergent files (typically 2–5 files) to resolve
ambiguity.
- If all samples show consistent patterns in Step 1-1a, skip this step.
Step 1-2: Extract structural patterns
- Frontmatter fields and their value patterns (title, sidebar_position,
sidebar_label, description, tags, etc.)
- Heading level conventions (e.g.,
# for page title only, ## for
top-level sections, ### for subsections)
- Common section ordering patterns (e.g., Overview → Usage → Configuration
→ Troubleshooting)
Step 1-3: Build terminology glossary
- Collect UI element names, feature names, and technical terms used
consistently across existing pages.
- Note the canonical form for each term (e.g., "저장" not "저장하기",
"Dashboard" not "대시보드" — or vice versa, depending on existing pattern).
- Record bilingual term pairs if the documentation uses a mixed-language
convention (e.g., Korean prose with English UI labels).
Step 1-4: Identify tone and style
- Determine the dominant speech level (e.g., 합쇼체
~합니다, 해요체
~해요, 하십시오체 ~하십시오).
- Identify person/voice conventions (e.g., "사용자는
합니다" vs
"하세요" imperative).
- Note active vs passive voice preference.
Step 1-5: Identify documentation framework and catalog its conventions
- Detect the documentation framework in use by examining configuration files
(e.g.,
docusaurus.config.js, .vitepress/config.*, mkdocs.yml,
next.config.* for Nextra, or none for plain Markdown).
- Catalog framework-specific syntax patterns found in existing documentation:
- Admonition/callout syntax (e.g.,
:::note in Docusaurus/VitePress,
!!! note in MkDocs, > [!NOTE] in GitHub-flavored Markdown).
- Component patterns (e.g.,
<Tabs>/<TabItem> in Docusaurus,
custom MDX components in Nextra).
- Code block language tags and annotation conventions.
- Custom component or shortcode usage patterns.
Step 1-6: Compile Convention Reference
- Produce a structured summary to use as the review baseline in Gates 2–3.
- Present the Convention Reference to the user for confirmation before
proceeding.
Gate 2 – Code-Documentation Alignment
ACTIVATION: This gate runs only if code-scope files were identified in
Gate 0. If no source code changed, skip to Gate 3.
Step 2-1: Analyze source code changes
- Run
git diff on code-scope files.
- Extract changed items: API endpoints, function signatures, component props,
configuration keys, CLI commands, environment variables.
Step 2-2: Map code changes to documentation
- Search across all documentation files (not just in-scope) for references to
the changed items using filename, import path, and keyword matching.
- Build a mapping:
changed code item → documentation section(s) referencing it.
Step 2-3: Identify alignment gaps
Produce an alignment report with three categories:
- Already updated: Documentation section was modified in this session and
reflects the code change.
- Needs update: Documentation references the changed code but was NOT
updated in this session.
- No documentation found: Code change has no corresponding documentation
(flag for user decision).
Present the report to the user. "Needs update" items must be resolved before
proceeding — resolution means either updating the documentation OR the user
explicitly acknowledging that no documentation change is needed (with reason).
Gate 3 – Documentation Quality Review
Apply the Convention Reference from Gate 1 to all doc-scope files.
3a) Structural consistency
- Heading levels follow the discovered convention.
- Frontmatter contains all expected fields with valid values.
- Section ordering matches the established pattern.
- No orphan headings (e.g., jumping from
## to ####).
3b) Terminology consistency
- Terms match the glossary from Gate 1.
- No mixed usage of the same concept (e.g., "저장" vs "저장하기", "Save"
vs "세이브").
- Proper nouns, product names, and feature names are cased consistently.
3c) Tone and style consistency
- Speech level matches the discovered convention (no mixing 합쇼체 and
해요체 within the same page).
- Person/voice is consistent (imperative vs descriptive).
- No abrupt tone shifts between sections.
3d) Content completeness
- No TODO, TBD, FIXME, placeholder, or Lorem ipsum markers.
- No empty sections (heading followed immediately by another heading or EOF).
- No untranslated placeholder text if the documentation is localized.
3e) Framework-specific syntax validity
- Admonitions/callouts properly opened and closed per the framework's syntax.
- Framework-specific components have matching open/close tags and required
attributes (if applicable).
- Code blocks have language tags and are properly fenced.
- MDX/component imports resolve to existing components (if applicable).
- Frontmatter YAML is valid (no syntax errors, no duplicate keys).
3f) Image and screenshot references
SKIP CONDITION: Skip if no image references ( or <img src="path">) points to a
file that exists in the repository.
- All images have non-empty alt text.
- No stale images (referenced file was deleted or moved).
3g) Link validity
- Internal document links (relative paths) resolve to existing files.
- Anchor links (
#section-name) match actual heading slugs in the target
document.
- No broken cross-references between documentation pages.
3h) Sidebar and navigation alignment
SKIP CONDITION: Skip if no files were added or deleted in this
session (only modifications). Sidebar/nav changes are only relevant
when the file set changes.
- Identify the sidebar/navigation configuration mechanism (e.g.,
sidebars.js in Docusaurus, _meta.json in Nextra, nav in
mkdocs.yml, auto-generated from directory structure in VitePress).
- New documentation files added in this session are registered in the
navigation configuration.
- Deleted documentation files are removed from the navigation configuration.
- Ordering metadata (e.g.,
sidebar_position in frontmatter, file ordering
in config) does not conflict with other pages in the same category.
Produce a Quality Review Report organized by severity:
- Error: Must fix before commit (broken syntax, missing images, dead links).
- Warning: Should fix (terminology inconsistency, tone drift, missing
alt text).
- Info: Optional improvement (section ordering, heading level suggestion).
Gate 4 – Auto-Fix
Step 4-1: Apply automatic fixes
Fix items that require no judgment:
- Terminology standardization (replace variant forms with canonical term)
- Heading level corrections
- Broken relative link path repair (if the correct target is deterministic)
- Missing frontmatter field population (using Convention Reference defaults)
- Admonition/code block syntax repair
- Remove TODO/placeholder markers in completed sections
Step 4-2: Present judgment-required items
Items that need user input:
- Content gaps identified in Gate 2 (code-doc alignment)
- Ambiguous terminology choices (when two forms are equally common)
- Tone corrections that alter meaning
- Missing images that need creation or replacement
Step 4-3: Summarize changes
- Present a before/after diff summary of all auto-fixes.
- Get user confirmation before proceeding.
Gate 5 – Build Verification
Step 5-1: Run documentation build
- Detect the build command from the project configuration (e.g.,
package.json scripts, Makefile, or framework CLI).
- Execute the build command from the documentation project root.
- Capture full output including warnings.
Step 5-2: Evaluate results
- Build succeeds with no warnings: Proceed to Gate 6.
- Build succeeds with warnings: Report warnings to user. Fix if they
relate to in-scope files; proceed if warnings are pre-existing.
- Build fails: Analyze error, apply fix, return to Gate 4 Step 4-1.
Step 5-3: Record evidence
- Build pass = final proof that documentation syntax and link references are
valid.
- Save build exit code and relevant output lines for the commit record.
Gate 6 – Commit Structuring
Staging rule: Stage only doc-scope files confirmed in Gate 0.
Use git add <specific-file> for each file individually.
Never use git add ., git add -A, or git add --all.
Step 6-1: Categorize changes
Group in-scope files by change type:
| Change Type |
Commit Prefix |
Description |
| Error fixes |
docs(fix): |
Broken links, syntax errors, missing images |
| Style/format |
docs(style): |
Terminology, tone, heading, frontmatter normalization |
| Content update |
docs(content): |
New sections, rewritten paragraphs, expanded explanations |
| Code-sync |
docs(sync): |
Documentation updates reflecting source code changes |
Step 6-2: Structure commits
- Create separate commits for each change type present.
- If a file has changes spanning multiple types, split by type where possible;
otherwise, assign to the dominant change type.
- Ordering:
docs(fix) → docs(style) → docs(content) → docs(sync).
Step 6-3: Write commit messages
Use Conventional Commits format. Each message must include:
- What changed (affected pages/sections)
- Why it changed (convention alignment, code-sync, error fix)
- Scope of review (mention Convention Discovery and build verification)
Gate 7 – Post-Publish Cleanup Handoff
After any commit, push, PR creation, or PR merge performed as part of this
workflow, run Gate 6 of branch-context-check.
Required behavior:
- If only local commits were created, state whether push/PR is pending and what
branch remains checked out.
- If a branch was pushed and the PR is still open, offer to keep the branch,
switch back to base, or leave cleanup for after merge.
- If a PR was merged, offer or perform approved cleanup: switch to base,
fast-forward pull, delete the local task branch, delete the remote task
branch, prune remote refs, and prune stale worktree metadata.
- If a separate worktree was used, offer or perform approved worktree removal
only after confirming that worktree is clean.
Do not end the workflow after push or merge without reporting the cleanup
decision. Deletion still requires the safety checks from branch-context-check
Gate 6 (inline fallback: delete only when the working tree is clean, the PR is
merged or the user confirms the branch is obsolete, the branch is not the
current checkout, and no other branch or worktree depends on it).
Guardrails
- Do not invent or fabricate documentation content not supported by the source
code or existing documentation.
- Do not silence or bypass documentation build errors.
- Do not modify documentation tone or style without Convention Reference
backing.
- Do not alter existing screenshots or images — only flag broken references.
- If context is insufficient to determine the correct term or phrasing, ask
for clarification.
- Respect existing project conventions for commit messages and structure.
- Do not commit until branch/worktree intent has passed
branch-context-check
or the user has explicitly accepted an ambiguous verdict.
- Do not end after commit/push/merge without running the post-publish cleanup
handoff.
- NEVER use
git checkout -- <file>, git restore, git stash,
git reset --hard, or any other command that discards or reverts uncommitted
changes to files outside the current session's scope.
- NEVER use
git add ., git add -A, or git add --all. Always stage
files individually with git add <specific-file>.
- Working tree changes from other sessions, agents, or manual edits must be
left completely untouched.
- Convention Discovery must sample from existing documentation only — never
use in-scope changed files as convention sources.
- Do not auto-fix items that require content judgment (ambiguous terminology,
meaning-altering tone changes) without user approval.
Failure Patterns
Common bad outputs:
- Applying conventions from only 1–2 sample files, producing biased standards
- Skipping Convention Discovery and inventing arbitrary style rules
- Ignoring code-documentation alignment when source code was also changed
- Lumping all documentation changes into a single undifferentiated commit
- Fixing terminology inconsistencies without checking which form is canonical
in the existing corpus
- Running build verification in the wrong directory (product root instead of
docs project root)
- Auto-fixing tone in a way that changes technical meaning
- Flagging pre-existing issues in files not modified by this session
- Reverting or discarding uncommitted changes that belong to other sessions
- Using
git add . which accidentally stages out-of-scope changes
- Treating "ensure no unintended changes" as "revert unrelated files" instead
of "exclude from staging"
- Continuing on a stale branch because documentation changes themselves look
clean
- Treating a dirty previous-session branch as safe just because only doc files
will be staged
- Pushing or merging successfully, then leaving stale local/remote branches or
worktrees without offering cleanup choices
- Deleting branches or worktrees after merge without verifying clean state and
merged/obsolete status
- Reporting Convention Reference without getting user confirmation, then
applying incorrect standards
Example 1 (Minimal Context)
Input:
2 documentation files changed: a new "Getting Started" page was added, and an
existing "Configuration" page had a section rewritten. No source code changes.
Output:
- Convention Reference: frontmatter requires
title, sidebar_position,
description; headings use ## for top-level sections; tone is 합쇼체
(~합니다); admonitions use :::note and :::tip
- Branch Context Verdict:
match — current branch and doc-scope files align
with the documentation task
- Code-Documentation Alignment Report: skipped (no source code changes)
- Quality Review Findings:
- Error: new page missing
sidebar_position in frontmatter
- Warning: "Configuration" page mixes "설정값" and "설정 값" (spacing)
- Info: "Getting Started" section order differs from convention
- Actions Taken: added
sidebar_position: 1 to frontmatter, standardized
"설정값" (no space, matching 80% of existing usage)
- Build Verification:
npm run build exit 0, no warnings
- Commit Plan: 2 commits — (a) style fix, (b) new content
- Final Commit Messages:
docs(style): standardize terminology and frontmatter in configuration page
docs(content): add getting started guide
- Post-Publish Cleanup Decision: not applicable yet — local commit only; push
or PR cleanup will be decided after publish
Example 2 (Realistic Scenario)
Input:
8 documentation files changed across 3 categories (guides, API reference,
troubleshooting). 4 source code files also changed, including a renamed API
endpoint and a new configuration option. Sidebar configuration was not updated.
Output:
- Convention Reference: frontmatter fields
title, sidebar_position,
sidebar_label, description, tags; 합쇼체 tone; features referenced
with English name first then Korean in parentheses (e.g., "Dashboard
(대시보드)"); :::warning for breaking changes, :::tip for best practices
- Branch Context Verdict:
match — branch name and dirty files align with
docs/API synchronization
- Code-Documentation Alignment Report:
- Already updated: API reference page for renamed endpoint
- Needs update: troubleshooting page still references old endpoint name;
configuration guide missing new
MAX_RETRY_COUNT option
- No documentation: new internal helper function (no user-facing docs needed)
- Quality Review Findings:
- Error: 2 broken internal links (target files were reorganized last sprint)
- Error: 1 image reference to deleted screenshot (
old-dashboard.png)
- Warning: API reference uses "대시보드" without English name (convention
violation)
- Warning: new guide page uses 해요체 ("~해요") while convention is 합쇼체
- Info: 3 pages missing
tags frontmatter field
- Actions Taken: fixed 2 broken links, updated old endpoint references,
added
MAX_RETRY_COUNT documentation, standardized bilingual term format,
corrected speech level to 합쇼체, added missing tags fields, registered
new pages in sidebars.js, flagged missing screenshot for user replacement
- Build Verification:
npm run build exit 0, 1 warning (pre-existing, out
of scope)
- Commit Plan: 4 commits
- Final Commit Messages:
docs(fix): repair broken links and remove stale image reference
docs(style): standardize terminology format and speech level across guides
docs(content): add MAX_RETRY_COUNT configuration documentation
docs(sync): update API reference and troubleshooting for endpoint rename
- Post-Publish Cleanup Decision: after PR merge, offer switch-to-base,
local/remote branch deletion, remote prune, and worktree prune; do not delete
while the PR is still open
Notes
FAST MODE (only if explicitly requested):
- Gate 1 Convention Discovery limited to 5 most recent files
- Gate 3 performs only 3a (structural) and 3d (completeness) checks
- Gate 5 build verification skipped
Relationship with finalize-and-commit:
When both source code and documentation changed in the same session, run
finalize-and-commit for source code first, then docs-finalize-and-commit
for documentation. Gate 2 of this skill reads source code diffs but does not
modify or commit source code files.
1---2name: docs-finalize-and-commit-23description: Finalize documentation changes for production readiness by discovering existing conventions, verifying code-doc alignment, reviewing format/terminology/tone consistency, verifying branch/worktree intent, and structuring clean commits with a post-publish branch/worktree cleanup decision. Counterpart of finalize-and-commit for documentation projects.4license: MIT5---67# Skill: Finalize Documentation and Commit (Review, Consistency, Alignment)89**Type:** Execution1011## Purpose1213Finalize documentation changes for production readiness in a documentation14project that coexists with the product source code in the same workspace.15Works with any documentation framework (Docusaurus, VitePress, MkDocs, Nextra,16plain Markdown, etc.).1718Tasks:1920- Discover conventions from existing documentation21- Verify code-documentation alignment when source code changed22- Review format, terminology, tone, and completeness consistency23- Validate framework-specific syntax and build integrity24- Verify current branch and dirty working tree match the intended documentation25 task26- Prepare structured commits separated by change type27- Force an explicit cleanup decision after push, PR creation, or PR merge2829---3031## When to Use3233- Before committing documentation changes to a shared branch34- Before submitting a pull request that includes documentation updates35- After completing a documentation session that touched multiple pages36- When source code and documentation were both modified in the same session37- When preparing a clean commit history from messy documentation edits38- When continuing documentation work after another session may have used the39 same repository4041---4243## When NOT to Use4445- Work-in-progress drafts still actively being written46- Trivial single-line typo fixes that need no consistency review47- Initial documentation scaffolding or exploratory writing phases48- Changes already reviewed and approved through another skill49- Standalone Markdown files outside a documentation project structure5051---5253## Inputs Required5455Do not run this skill without:5657- [ ] Working tree with uncommitted or staged `.md`/`.mdx` file changes58- [ ] Access to the documentation project build command (if the framework59 provides one)60- [ ] Existing documentation files to derive conventions from (at least 3 pages)6162Optional but recommended:6364- [ ] Target branch context (e.g., main, release)65- [ ] List of intended change scope (files or directories)66- [ ] Known glossary or style guide (if any)67- [ ] Current task intent or expected branch/worktree name6869---7071## Output Format72731. Convention Reference (discovered patterns)742. Branch Context Verdict753. Code-Documentation Alignment Report764. Quality Review Findings775. Actions Taken (auto-fixes applied)786. Build Verification Results797. Commit Plan808. Final Commit Messages819. Post-Publish Cleanup Decision8283---8485## Procedure8687### Gate -1 – Branch Context Check8889Run `branch-context-check` before validating the working set. If that skill is90not installed, run the check inline: inspect `git status --short --branch`,91`git branch --show-current`, `git log --oneline --decorate -5`, and the92staged/dirty file lists, then classify the branch/worktree against the current93documentation task using the same four verdicts below.9495Required outcome:9697- Current documentation task intent is summarized.98- Current branch, upstream state, recent commits, staged files, and dirty files99 are inspected.100- Branch/worktree verdict is one of `match`, `ambiguous`, `mismatch`, or101 `blocked`.102103Proceed to Gate 0 only when:104105- Verdict is `match`, or106- Verdict is `ambiguous` and the user explicitly confirms the branch/worktree107 is correct for the current documentation task.108109Stop before staging or committing when:110111- Verdict is `mismatch` or `blocked`.112- Staged files include changes outside the current documentation task.113- Dirty files from a previous session overlap with current-session114 documentation files.115116In a stopped state, recommend a concrete recovery path: create/switch to a117task-appropriate branch, create a separate worktree from the correct base, or118finish/commit the previous-session work first. Do not move, stash, reset, or119discard changes without explicit user approval.120121---122123### Gate 0 – Working Set Validation124125> **CRITICAL:** The working tree may contain changes from other agent sessions126> or manual edits. This gate must isolate *only* the current session's changes127> without disturbing anything else.128129**Step 0-1: Identify current session scope**130131- Review the conversation history and edit history of this session.132- Build an explicit list of `.md`/`.mdx` files that were created, modified,133 or deleted *by this session*.134- Separately identify source code files changed in this session (needed for135 Gate 2).136- If the user provided a scope list, use that as the authoritative source.137138**Step 0-2: Inspect full working tree state**139140- Run `git status` and `git diff --name-only` to enumerate all uncommitted141 changes in the working tree.142143**Step 0-3: Classify changes**144145- **Doc-scope:** `.md`/`.mdx` files that appear in both the session scope146 (Step 0-1) and the working tree (Step 0-2).147- **Code-scope:** Source code files changed by this session (input for Gate 2).148- **Out-of-scope:** Files in the working tree NOT modified by this session.149150**Step 0-4: Protect out-of-scope changes**151152- **NEVER** revert, restore, checkout, stash, or discard out-of-scope changes.153- Out-of-scope files must be left exactly as they are in the working tree.154- The only correct action is to *exclude* them from staging (`git add`).155156**Step 0-5: Confirm with the user**157158- Present a summary:159 - Documentation files to be reviewed and committed (doc-scope)160 - Source code files to cross-reference (code-scope)161 - Files left untouched (out-of-scope), if any162- Proceed only after the user confirms the target set.163164---165166### Gate 1 – Convention Discovery167168> **PURPOSE:** Establish the review baseline. Use a provided style guide169> first; infer conventions from existing documentation only where no170> explicit guidance exists.171172**Step 1-0: Use a provided style guide first**173174- If the user provided a style guide or glossary (see Optional inputs), treat175 it as the primary Convention Reference.176- Run Steps 1-1a–1-5 only to fill gaps the style guide does not cover (e.g.,177 frontmatter fields, framework syntax), and never let inferred patterns178 override explicit style-guide rules.179- If the style guide fully covers structure, terminology, and tone, skip180 directly to Step 1-6.181182**Step 1-1a: Scan documentation headers**183184- Read **frontmatter + first 30 lines** of 10–15 representative185 `.md`/`.mdx` files from the docs directory186 (prioritize recently modified, high-traffic pages).187- If fewer than 10 documentation files exist, read all available files.188- Exclude files in the current session's change set to avoid circular189 reference.190- From this scan, extract: frontmatter field names, heading structure,191 first paragraph tone/speech level.192193**Step 1-1b: Deep read divergent samples**194195- Compare patterns extracted in Step 1-1a across all samples.196- Identify files where patterns diverge or are ambiguous197 (e.g., inconsistent frontmatter fields, mixed heading levels).198- Full-read only the divergent files (typically 2–5 files) to resolve199 ambiguity.200- If all samples show consistent patterns in Step 1-1a, skip this step.201202**Step 1-2: Extract structural patterns**203204- Frontmatter fields and their value patterns (title, sidebar_position,205 sidebar_label, description, tags, etc.)206- Heading level conventions (e.g., `#` for page title only, `##` for207 top-level sections, `###` for subsections)208- Common section ordering patterns (e.g., Overview → Usage → Configuration209 → Troubleshooting)210211**Step 1-3: Build terminology glossary**212213- Collect UI element names, feature names, and technical terms used214 consistently across existing pages.215- Note the canonical form for each term (e.g., "저장" not "저장하기",216 "Dashboard" not "대시보드" — or vice versa, depending on existing pattern).217- Record bilingual term pairs if the documentation uses a mixed-language218 convention (e.g., Korean prose with English UI labels).219220**Step 1-4: Identify tone and style**221222- Determine the dominant speech level (e.g., 합쇼체 `~합니다`, 해요체223 `~해요`, 하십시오체 `~하십시오`).224- Identify person/voice conventions (e.g., "사용자는 ~합니다" vs225 "~하세요" imperative).226- Note active vs passive voice preference.227228**Step 1-5: Identify documentation framework and catalog its conventions**229230- Detect the documentation framework in use by examining configuration files231 (e.g., `docusaurus.config.js`, `.vitepress/config.*`, `mkdocs.yml`,232 `next.config.*` for Nextra, or none for plain Markdown).233- Catalog framework-specific syntax patterns found in existing documentation:234 - Admonition/callout syntax (e.g., `:::note` in Docusaurus/VitePress,235 `!!! note` in MkDocs, `> [!NOTE]` in GitHub-flavored Markdown).236 - Component patterns (e.g., `<Tabs>`/`<TabItem>` in Docusaurus,237 custom MDX components in Nextra).238 - Code block language tags and annotation conventions.239 - Custom component or shortcode usage patterns.240241**Step 1-6: Compile Convention Reference**242243- Produce a structured summary to use as the review baseline in Gates 2–3.244- Present the Convention Reference to the user for confirmation before245 proceeding.246247---248249### Gate 2 – Code-Documentation Alignment250251> **ACTIVATION:** This gate runs only if code-scope files were identified in252> Gate 0. If no source code changed, skip to Gate 3.253254**Step 2-1: Analyze source code changes**255256- Run `git diff` on code-scope files.257- Extract changed items: API endpoints, function signatures, component props,258 configuration keys, CLI commands, environment variables.259260**Step 2-2: Map code changes to documentation**261262- Search across all documentation files (not just in-scope) for references to263 the changed items using filename, import path, and keyword matching.264- Build a mapping: `changed code item → documentation section(s) referencing it`.265266**Step 2-3: Identify alignment gaps**267268Produce an alignment report with three categories:269270- **Already updated:** Documentation section was modified in this session and271 reflects the code change.272- **Needs update:** Documentation references the changed code but was NOT273 updated in this session.274- **No documentation found:** Code change has no corresponding documentation275 (flag for user decision).276277Present the report to the user. "Needs update" items must be resolved before278proceeding — resolution means either updating the documentation OR the user279explicitly acknowledging that no documentation change is needed (with reason).280281---282283### Gate 3 – Documentation Quality Review284285Apply the Convention Reference from Gate 1 to all doc-scope files.286287**3a) Structural consistency**288289- Heading levels follow the discovered convention.290- Frontmatter contains all expected fields with valid values.291- Section ordering matches the established pattern.292- No orphan headings (e.g., jumping from `##` to `####`).293294**3b) Terminology consistency**295296- Terms match the glossary from Gate 1.297- No mixed usage of the same concept (e.g., "저장" vs "저장하기", "Save"298 vs "세이브").299- Proper nouns, product names, and feature names are cased consistently.300301**3c) Tone and style consistency**302303- Speech level matches the discovered convention (no mixing 합쇼체 and304 해요체 within the same page).305- Person/voice is consistent (imperative vs descriptive).306- No abrupt tone shifts between sections.307308**3d) Content completeness**309310- No TODO, TBD, FIXME, placeholder, or Lorem ipsum markers.311- No empty sections (heading followed immediately by another heading or EOF).312- No untranslated placeholder text if the documentation is localized.313314**3e) Framework-specific syntax validity**315316- Admonitions/callouts properly opened and closed per the framework's syntax.317- Framework-specific components have matching open/close tags and required318 attributes (if applicable).319- Code blocks have language tags and are properly fenced.320- MDX/component imports resolve to existing components (if applicable).321- Frontmatter YAML is valid (no syntax errors, no duplicate keys).322323**3f) Image and screenshot references**324325> **SKIP CONDITION:** Skip if no image references (`` or `<img src="path">`) points to a329 file that exists in the repository.330- All images have non-empty alt text.331- No stale images (referenced file was deleted or moved).332333**3g) Link validity**334335- Internal document links (relative paths) resolve to existing files.336- Anchor links (`#section-name`) match actual heading slugs in the target337 document.338- No broken cross-references between documentation pages.339340**3h) Sidebar and navigation alignment**341342> **SKIP CONDITION:** Skip if no files were added or deleted in this343> session (only modifications). Sidebar/nav changes are only relevant344> when the file set changes.345346- Identify the sidebar/navigation configuration mechanism (e.g.,347 `sidebars.js` in Docusaurus, `_meta.json` in Nextra, `nav` in348 `mkdocs.yml`, auto-generated from directory structure in VitePress).349- New documentation files added in this session are registered in the350 navigation configuration.351- Deleted documentation files are removed from the navigation configuration.352- Ordering metadata (e.g., `sidebar_position` in frontmatter, file ordering353 in config) does not conflict with other pages in the same category.354355**Produce a Quality Review Report** organized by severity:356357- **Error:** Must fix before commit (broken syntax, missing images, dead links).358- **Warning:** Should fix (terminology inconsistency, tone drift, missing359 alt text).360- **Info:** Optional improvement (section ordering, heading level suggestion).361362---363364### Gate 4 – Auto-Fix365366**Step 4-1: Apply automatic fixes**367368Fix items that require no judgment:369370- Terminology standardization (replace variant forms with canonical term)371- Heading level corrections372- Broken relative link path repair (if the correct target is deterministic)373- Missing frontmatter field population (using Convention Reference defaults)374- Admonition/code block syntax repair375- Remove TODO/placeholder markers in completed sections376377**Step 4-2: Present judgment-required items**378379Items that need user input:380381- Content gaps identified in Gate 2 (code-doc alignment)382- Ambiguous terminology choices (when two forms are equally common)383- Tone corrections that alter meaning384- Missing images that need creation or replacement385386**Step 4-3: Summarize changes**387388- Present a before/after diff summary of all auto-fixes.389- Get user confirmation before proceeding.390391---392393### Gate 5 – Build Verification394395**Step 5-1: Run documentation build**396397- Detect the build command from the project configuration (e.g.,398 `package.json` scripts, `Makefile`, or framework CLI).399- Execute the build command from the documentation project root.400- Capture full output including warnings.401402**Step 5-2: Evaluate results**403404- **Build succeeds with no warnings:** Proceed to Gate 6.405- **Build succeeds with warnings:** Report warnings to user. Fix if they406 relate to in-scope files; proceed if warnings are pre-existing.407- **Build fails:** Analyze error, apply fix, return to Gate 4 Step 4-1.408409**Step 5-3: Record evidence**410411- Build pass = final proof that documentation syntax and link references are412 valid.413- Save build exit code and relevant output lines for the commit record.414415---416417### Gate 6 – Commit Structuring418419**Staging rule:** Stage only doc-scope files confirmed in Gate 0.420Use `git add <specific-file>` for each file individually.421Never use `git add .`, `git add -A`, or `git add --all`.422423**Step 6-1: Categorize changes**424425Group in-scope files by change type:426427| Change Type | Commit Prefix | Description |428|---|---|---|429| Error fixes | `docs(fix):` | Broken links, syntax errors, missing images |430| Style/format | `docs(style):` | Terminology, tone, heading, frontmatter normalization |431| Content update | `docs(content):` | New sections, rewritten paragraphs, expanded explanations |432| Code-sync | `docs(sync):` | Documentation updates reflecting source code changes |433434**Step 6-2: Structure commits**435436- Create separate commits for each change type present.437- If a file has changes spanning multiple types, split by type where possible;438 otherwise, assign to the dominant change type.439- Ordering: `docs(fix)` → `docs(style)` → `docs(content)` → `docs(sync)`.440441**Step 6-3: Write commit messages**442443Use Conventional Commits format. Each message must include:444445- What changed (affected pages/sections)446- Why it changed (convention alignment, code-sync, error fix)447- Scope of review (mention Convention Discovery and build verification)448449---450451### Gate 7 – Post-Publish Cleanup Handoff452453After any commit, push, PR creation, or PR merge performed as part of this454workflow, run Gate 6 of `branch-context-check`.455456Required behavior:457458- If only local commits were created, state whether push/PR is pending and what459 branch remains checked out.460- If a branch was pushed and the PR is still open, offer to keep the branch,461 switch back to base, or leave cleanup for after merge.462- If a PR was merged, offer or perform approved cleanup: switch to base,463 fast-forward pull, delete the local task branch, delete the remote task464 branch, prune remote refs, and prune stale worktree metadata.465- If a separate worktree was used, offer or perform approved worktree removal466 only after confirming that worktree is clean.467468Do not end the workflow after push or merge without reporting the cleanup469decision. Deletion still requires the safety checks from `branch-context-check`470Gate 6 (inline fallback: delete only when the working tree is clean, the PR is471merged or the user confirms the branch is obsolete, the branch is not the472current checkout, and no other branch or worktree depends on it).473474---475476## Guardrails477478- Do not invent or fabricate documentation content not supported by the source479 code or existing documentation.480- Do not silence or bypass documentation build errors.481- Do not modify documentation tone or style without Convention Reference482 backing.483- Do not alter existing screenshots or images — only flag broken references.484- If context is insufficient to determine the correct term or phrasing, ask485 for clarification.486- Respect existing project conventions for commit messages and structure.487- Do not commit until branch/worktree intent has passed `branch-context-check`488 or the user has explicitly accepted an `ambiguous` verdict.489- Do not end after commit/push/merge without running the post-publish cleanup490 handoff.491- **NEVER** use `git checkout -- <file>`, `git restore`, `git stash`,492 `git reset --hard`, or any other command that discards or reverts uncommitted493 changes to files outside the current session's scope.494- **NEVER** use `git add .`, `git add -A`, or `git add --all`. Always stage495 files individually with `git add <specific-file>`.496- Working tree changes from other sessions, agents, or manual edits must be497 left completely untouched.498- Convention Discovery must sample from existing documentation only — never499 use in-scope changed files as convention sources.500- Do not auto-fix items that require content judgment (ambiguous terminology,501 meaning-altering tone changes) without user approval.502503---504505## Failure Patterns506507Common bad outputs:508509- Applying conventions from only 1–2 sample files, producing biased standards510- Skipping Convention Discovery and inventing arbitrary style rules511- Ignoring code-documentation alignment when source code was also changed512- Lumping all documentation changes into a single undifferentiated commit513- Fixing terminology inconsistencies without checking which form is canonical514 in the existing corpus515- Running build verification in the wrong directory (product root instead of516 docs project root)517- Auto-fixing tone in a way that changes technical meaning518- Flagging pre-existing issues in files not modified by this session519- Reverting or discarding uncommitted changes that belong to other sessions520- Using `git add .` which accidentally stages out-of-scope changes521- Treating "ensure no unintended changes" as "revert unrelated files" instead522 of "exclude from staging"523- Continuing on a stale branch because documentation changes themselves look524 clean525- Treating a dirty previous-session branch as safe just because only doc files526 will be staged527- Pushing or merging successfully, then leaving stale local/remote branches or528 worktrees without offering cleanup choices529- Deleting branches or worktrees after merge without verifying clean state and530 merged/obsolete status531- Reporting Convention Reference without getting user confirmation, then532 applying incorrect standards533534---535536## Example 1 (Minimal Context)537538**Input:**5395402 documentation files changed: a new "Getting Started" page was added, and an541existing "Configuration" page had a section rewritten. No source code changes.542543**Output:**5445451. Convention Reference: frontmatter requires `title`, `sidebar_position`,546 `description`; headings use `##` for top-level sections; tone is 합쇼체547 (`~합니다`); admonitions use `:::note` and `:::tip`5482. Branch Context Verdict: `match` — current branch and doc-scope files align549 with the documentation task5503. Code-Documentation Alignment Report: skipped (no source code changes)5514. Quality Review Findings:552 - Error: new page missing `sidebar_position` in frontmatter553 - Warning: "Configuration" page mixes "설정값" and "설정 값" (spacing)554 - Info: "Getting Started" section order differs from convention5555. Actions Taken: added `sidebar_position: 1` to frontmatter, standardized556 "설정값" (no space, matching 80% of existing usage)5576. Build Verification: `npm run build` exit 0, no warnings5587. Commit Plan: 2 commits — (a) style fix, (b) new content5598. Final Commit Messages:560 - `docs(style): standardize terminology and frontmatter in configuration page`561 - `docs(content): add getting started guide`5629. Post-Publish Cleanup Decision: not applicable yet — local commit only; push563 or PR cleanup will be decided after publish564565---566567## Example 2 (Realistic Scenario)568569**Input:**5705718 documentation files changed across 3 categories (guides, API reference,572troubleshooting). 4 source code files also changed, including a renamed API573endpoint and a new configuration option. Sidebar configuration was not updated.574575**Output:**5765771. Convention Reference: frontmatter fields `title`, `sidebar_position`,578 `sidebar_label`, `description`, `tags`; 합쇼체 tone; features referenced579 with English name first then Korean in parentheses (e.g., "Dashboard580 (대시보드)"); `:::warning` for breaking changes, `:::tip` for best practices5812. Branch Context Verdict: `match` — branch name and dirty files align with582 docs/API synchronization5833. Code-Documentation Alignment Report:584 - Already updated: API reference page for renamed endpoint585 - Needs update: troubleshooting page still references old endpoint name;586 configuration guide missing new `MAX_RETRY_COUNT` option587 - No documentation: new internal helper function (no user-facing docs needed)5884. Quality Review Findings:589 - Error: 2 broken internal links (target files were reorganized last sprint)590 - Error: 1 image reference to deleted screenshot (`old-dashboard.png`)591 - Warning: API reference uses "대시보드" without English name (convention592 violation)593 - Warning: new guide page uses 해요체 ("~해요") while convention is 합쇼체594 - Info: 3 pages missing `tags` frontmatter field5955. Actions Taken: fixed 2 broken links, updated old endpoint references,596 added `MAX_RETRY_COUNT` documentation, standardized bilingual term format,597 corrected speech level to 합쇼체, added missing `tags` fields, registered598 new pages in `sidebars.js`, flagged missing screenshot for user replacement5996. Build Verification: `npm run build` exit 0, 1 warning (pre-existing, out600 of scope)6017. Commit Plan: 4 commits6028. Final Commit Messages:603 - `docs(fix): repair broken links and remove stale image reference`604 - `docs(style): standardize terminology format and speech level across guides`605 - `docs(content): add MAX_RETRY_COUNT configuration documentation`606 - `docs(sync): update API reference and troubleshooting for endpoint rename`6079. Post-Publish Cleanup Decision: after PR merge, offer switch-to-base,608 local/remote branch deletion, remote prune, and worktree prune; do not delete609 while the PR is still open610611---612613## Notes614615**FAST MODE** (only if explicitly requested):616617- Gate 1 Convention Discovery limited to 5 most recent files618- Gate 3 performs only 3a (structural) and 3d (completeness) checks619- Gate 5 build verification skipped620621**Relationship with `finalize-and-commit`:**622623When both source code and documentation changed in the same session, run624`finalize-and-commit` for source code first, then `docs-finalize-and-commit`625for documentation. Gate 2 of this skill reads source code diffs but does not626modify or commit source code files.