Skip to content

codehub-document

Primary artifact generator. Applies the proven four-phase /document pattern to OpenCodeHub’s graph and extends it with first-class group mode.

Writes a tree of cross-linked Markdown under .codehub/docs/ (single-repo) or .codehub/groups/<name>/docs/ (group mode) plus a .docmeta.json sidecar that drives --refresh.

name: codehub-document
argument-hint: "[output-dir] [--group <name>] [--committed] [--refresh] [--section <name>]"
color: indigo
model: sonnet
  1. mcp__opencodehub__list_repos returns the target. Otherwise: run codehub analyze.
  2. codehub status reports fresh. Otherwise: run codehub analyze.
  3. Group mode only: every member repo must be fresh per mcp__opencodehub__group_status. Stale members abort with named repos.

Inline, no subagent. Writes two shared-context files on disk:

  • <docs-root>/.context.md (hard 200-line cap) — repo profile, top communities, top processes, routes, MCP tools, owners summary, staleness envelope. Group mode adds the manifest + contracts matrix + freshness table.
  • <docs-root>/.prefetch.md — newline-delimited JSON ledger of tool calls with {tool, args, sha256, keys, cached_at, truncated}. Subagents read this instead of re-calling tools.

Prompt dedup via filesystem, not copy-paste.

FlagMeaning
[output-dir]Where to write. Default .codehub/docs/ (gitignored). With --committed, default flips to docs/codehub/.
--group <name>Enable group mode. Phase 0 calls group_list + group_status + group_contracts + group_query. Phase CD dispatches doc-cross-repo.
--committedWrite to a committed path instead of .codehub/docs/. Does not touch .gitignore.
--refreshRegenerate only sections whose sources[] mtimes are newer than the section’s mtime. Phase E always re-runs.
--section <name>Regenerate one named section (e.g., architecture/system-overview).
Terminal window
# Single-repo, default gitignored output
/codehub-document
# Group mode with an explicit output
/codehub-document docs/platform --group platform --committed
# Refresh stale sections only
/codehub-document --refresh
# One-section regenerate
/codehub-document --section architecture/system-overview

See ADR 0009 for the full contract.

  • No YAML frontmatter on outputs.
  • Every factual claim carries a backtick path:LOC citation (or repo:path:LOC in group mode).
  • Mermaid diagrams only (no SVG/PNG).
  • .docmeta.json is the source of truth for --refresh and staleness.