Oma docs

From gracefullight/docusaurus-plugins · View interactive version

Oma docs is an AI agent skill from the GitHub repository gracefullight/docusaurus-plugins. Verify documentation references against the current codebase and propose updates for diff-affected docs. Use to check if docs still match reality (broken file paths, CLI commands, config keys, env vars, scripts) and to surface docs that may need updating after code changes.

How to use this skill

Skill file

oma-docs - Documentation Drift Detector

Scheduling

Goal

Detect broken references in docs/**/*.md (verify mode) and propose LLM-generated patch proposals for docs affected by recent code changes (sync mode). Both modes run on-demand; sync is always interactive.

Intent signature

When to use

When NOT to use

Expected inputs

verify mode: Optional glob path (default **/*.md), optional --json flag, optional --report-file <path>.

sync mode: Optional git diff range (default --cached, fallback HEAD~1..HEAD).

Expected outputs

verify mode:

sync mode:

Dependencies

Control-flow features

Structural Flow

Entry

  1. Read first argument to select mode (verify | sync). If absent, print help and exit.
  2. Load oma-config.yaml to check docs.auto_verify when invoked from a workflow hook.
  3. Confirm required CLI dependencies (oma docs verify, oma docs sync) are on PATH.

Scenes

  1. PREPARE: Determine mode, resolve path/diff-range arguments, confirm tool availability.
  2. ACQUIRE: Run extractor (extract.ts) to regenerate doc-refs.json from docs/**/*.md (verify) or build in-memory reverse index from existing doc-refs.json (sync).
  3. REASON: Resolve each reference deterministically (verify) or correlate changed files to candidate docs via reverse lookup (sync).
  4. ACT: Render the deterministic drift report (verify) or list candidate docs with matched refs (sync). Host LLM does any natural-language synthesis or patch drafting on top of this output.
  5. VERIFY: Confirm output shape is valid (JSON schema check for --json; structured candidate list for sync).
  6. FINALIZE: Print to stdout, write report file if requested, emit exit code.

Transitions

Failure and recovery

Exit

Logical Operations

Actions

| Action | SSL primitive | Notes |

|--------|---------------|-------|

| Parse CLI args and mode | READ | First arg selects verify or sync |

| Extract refs from docs | CALL_TOOL | extract.ts: remark AST + L2 patterns → doc-refs.json |

| Check broken refs | RESOLVE | resolve.ts: file, url, cli, script, env, config checks |

| Build reverse index | INFER | sync-propose.ts: in-memory map from doc-refs.json |

| Match diff to candidate docs | RESOLVE | sync-propose.ts: git diff + reverse lookup |

| Redact secrets from diff | VALIDATE | Exclude .env*, *.pem, *.key, id_rsa*; sanitize content |

| Generate patch proposals | INFER | Host LLM drafts patches from sync-propose.ts candidate output (no CLI LLM call) |

| Render drift report | RENDER | reporter.ts: markdown (default), JSON (--json), file (--report-file) |

| Apply approved patches | WRITE | git apply on user-confirmed patches only |

| Notify hook summary | NOTIFY | 1-3 line stdout summary for workflow hooks |

Tools and instruments

Host-LLM contract

This skill follows the OMA pattern (mirroring oma-scholar): the CLI emits structured data; the host LLM (the agent runtime that invoked the skill) does any natural-language synthesis or judgment.

After oma docs verify --json:

  1. Read the JSON drift report.
  2. Group findings by severity / urgency (host-LLM judgment).
  3. Suggest fixes per finding, prioritizing files most central to the project.
  4. If the user asks for natural-language summary, host LLM produces it from the JSON, never from cached prose.

After oma docs sync <range> --json:

  1. Read the candidate doc list (each entry: { doc, changedFiles, matchedRefs }).
  2. For each candidate doc: read the doc itself, read git diff for changedFiles, draft a unified-diff patch reflecting the code change.
  3. Present patches to the user for review. Never auto-apply.
  4. On user approval, apply via git apply or by writing the doc directly.

Canonical command path

verify mode runs a drift check against the current codebase:

# Default: scan all docs/**/*.md, render markdown to stdout.
# URL link checking is delegated to lychee in the background
# (install: `brew install lychee`). Core check ~8s on a 1k-doc repo.
oma docs verify

# Narrow to a path or glob (uses minimatch)
oma docs verify "docs/**/*.md"
oma docs verify cli/README.md

# Machine-readable output for CI / hooks
oma docs verify --json

# Persist full markdown report to a file
oma docs verify --report-file ./drift-report.md

# Skip URL checking entirely (when lychee is run separately, or as a
# one-off override of docs.check_urls=true in oma-config.yaml)
oma docs verify --no-urls

# Block until lychee finishes (CI scenarios needing complete URL data)
oma docs verify --urls-sync

# Exit code: 0 = clean, 1 = broken refs found in core check.
# URL drift, if any, is reported separately at docs/generated/url-drift.json
# and does NOT affect this exit code.

sync mode proposes patches for docs affected by a git diff (always interactive, never auto-applies):

# Default: staged changes (--cached), fallback HEAD~1..HEAD
oma docs sync

# Explicit range
oma docs sync HEAD~5..HEAD
oma docs sync main..feature-branch

# The CLI emits the candidate-doc list; the host LLM drafts patches and
# confirms per doc ([y] apply / [n] skip / [d] diff / [s] full proposal).
# Sync regenerates docs/generated/doc-refs.json after applying any patches.

Workflow hook (opt-in) runs verify automatically at workflow completion when docs.auto_verify: true in oma-config.yaml:

# Hook command emitted by /scm, /work, /ultrawork
oma docs verify --json
# Hook policy: warn-only in v1; non-zero exit does NOT block workflow completion

Resource scope

| Scope | Resource target |

|-------|-----------------|

| LOCAL_FS read | docs/**/*.md (extractor input), docs/generated/doc-refs.json (index), .env.example, package.json, .agents/oma-config.yaml |

| LOCAL_FS write | docs/generated/doc-refs.json (regenerated each verify run), approved sync patches |

| CODEBASE read-only | Existence checks for file/cli/script/env/config refs; git diff intake |

| PROCESS | git diff, git apply, which, background lychee spawn |

| NETWORK | URL checking delegated to lychee (no internal HEAD fallback; see Guardrail 6) |

Preconditions

Effects and side effects

Guardrails

  1. Never modify .agents/: CLAUDE.md SSOT protection applies in all modes.
  2. Never auto-apply sync patches: sync is always interactive; [y] confirm required per doc.
  3. LLM unavailable → graceful degradation: verify falls back to raw JSON; sync falls back to candidate-list-only (no proposals). Neither mode blocks on LLM availability.
  4. Response language follows oma-config.yaml language: user-facing report text is localized; code, paths, JSON keys, and CLI commands stay in English.
  5. Secret-bearing files excluded from sync output: .env*, *.pem, *.key, id_rsa*, and gitignored files never appear in candidate changedFiles lists. Host LLM never sees secret file paths.
  6. URL link checking delegated to lychee: when docs.check_urls=true (default), URL refs are checked by lychee running in the background; results land in docs/generated/url-drift.json. If lychee is missing, an install hint is printed and URL checking is skipped (no internal HEAD fallback).
  7. No direct LLM API calls from the CLI: the CLI never imports vendor SDKs, never reads API keys, never makes outbound LLM requests. All synthesis, patch drafting, and natural-language framing is the host LLM's responsibility (mirrors oma-scholar's pattern). This makes oma-docs vendor-agnostic: works identically under Claude Code / Codex / Gemini / Qwen / Antigravity.
  8. Hook is warn-only in v1: broken refs never block workflow completion; docs.auto_verify: false by default (explicit opt-in required).
  9. Escape hatch respected: <!-- oma-docs:ignore-start --> / <!-- oma-docs:ignore-end --> blocks and frontmatter oma-docs: skip are honored; no ref extraction from ignored regions.

v1 scope note

v1 covers verify and sync (broken-only classification, L2 ref extraction). The following are explicitly deferred to v2: create mode (generate missing docs), multilingual sync (deeper oma-translator integration), L3 symbol-level extraction (Tree-sitter/LSP), GitHub Action wrapper, block hook mode.

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.