Skip to content

CLI reference

Binary: codehub. Source entry: packages/cli/src/index.ts. Published entry: packages/cli/dist/index.js. Default error contract: an unhandled throw writes codehub: <msg> to stderr and sets process.exitCode = 1.

Index a repository. Runs the full pipeline: parse, resolve, cluster, build BM25 + vector indexes, and write .codehub/.

usage
codehub analyze [path]
FlagDefaultPurpose
--forceoffIgnore the registry cache and re-run the pipeline.
--embeddingsoffCompute semantic vectors.
--embeddings-int8offUse the int8 embedder variant (~81 MB) instead of fp32 (~321 MB).
--granularity <csv>symbolAny subset of symbol,file,community.
--embeddings-workers <n|auto>autoSize of the ONNX worker pool.
--embeddings-batch-size <n>32Batch size per worker.
--offlineoffZero sockets.
--verboseoffPer-phase pipeline progress.
--skip-agents-mdoffSkip the AGENTS.md / CLAUDE.md stanza.
--sbom / --no-sbomonEmit sbom.cyclonedx.json + sbom.spdx.json from Dependency nodes. Use --no-sbom to suppress.
--scan / --no-scanonRun Priority-1 scanners, write .codehub/scan.sarif, and ingest findings into the graph. Network-backed scanners (osv-scanner, grype, npm/pip audit) self-skip under --offline. Use --no-scan to suppress.
--coverage / --no-coverageautoOverlay lcov / cobertura / jacoco / coverage.py reports onto File nodes. auto probes coverage/lcov.info, lcov.info, coverage.xml, build/reports/jacoco/test/jacocoTestReport.xml, coverage.json in that order and enables the phase when one exists (silent no-op otherwise). --coverage forces on and warns if nothing is found; --no-coverage forces off.
--skillsoffEmit one SKILL.md per Community (≥5 symbols) under .codehub/skills/.
--strict-detectorsoffDrop heuristic-only matches from route / ORM detectors (DET-O-001).
--allow-build-scripts <list>Comma-separated build-script opt-ins (e.g. proleap for the JVM COBOL deep-parse).

Exit codes: 0 success, 1 caught error.

Register an existing .codehub/ into ~/.codehub/registry.json without re-analysing.

usage
codehub index [paths...]
FlagDefaultPurpose
--forceoffStamp a minimal meta.json stub when missing.
--allow-non-gitoffPermit registering a directory with no .git.

Bootstrap a repo for OpenCodeHub. Copies the Claude Code plugin assets into .claude/ (project scope, with hook tokens rewritten from ${CLAUDE_PLUGIN_ROOT} to ${CLAUDE_PROJECT_DIR}/.claude), writes .mcp.json, appends .codehub/ to .gitignore, and seeds opencodehub.policy.yaml with every rule commented out.

usage
codehub init [path]
FlagDefaultPurpose
--forceoffOverwrite conflicting files under .claude/.
--skip-mcpoffSkip writing .mcp.json.
--skip-policyoffSkip seeding opencodehub.policy.yaml.

Wire MCP config into supported editors, install the Claude Code plugin, or download embedder weights.

usage
codehub setup
FlagDefaultPurpose
--editors <list>allclaude-code,cursor,codex,windsurf,opencode.
--forceoffOverwrite existing entries; re-download weights.
--undooffRestore the most recent .bak next to each config.
--embeddingsoffDownload F2LLM-v2-80M ONNX weights (SHA256-pinned GitHub release asset).
--int8offUse the int8 weight variant (~92 MB) instead of fp32 (~332 MB).
--model-dir <path>Override the target directory for embedder weights.
--pluginoffInstall the Claude Code plugin to ~/.claude/plugins/opencodehub/.
--scip <tool>Install an external SCIP adapter binary: clang, ruby, dotnet, kotlin, or all. SHA256-pinned; dotnet requires .NET SDK 8+ on PATH.
--cobol-proleapoffBuild the uwol/cobol-parser library from source (git clone + mvn install) and compile the bridge wrapper. Requires git, mvn, and JDK 17+ on PATH. Installs under ~/.codehub/vendor/proleap/.

Launch the stdio MCP server.

usage
codehub mcp

Signal handling: SIGINT → 130, SIGTERM → 143, stdin close → 0.

List repos indexed on this machine.

usage
codehub list

The output table includes a HEALTH column flagging dangling registry entries (missing path) and cleaned indexes (no graph artifact).

Report index metadata and staleness for one repo.

usage
codehub status [path]

Delete the index at [path].

usage
codehub clean [path]
FlagDefaultPurpose
--alloffDelete every registered index.

Emit a single-file LLM-ready snapshot of the repo via repomix (AST-compressed by default).

usage
codehub pack [path]
FlagDefaultPurpose
--style <xml|markdown|json|plain>xmlOutput format.
--no-compressoffDisable AST compression.
--remove-commentsoffStrip comments.
--out <path><repo>/.codehub/pack/repo.<ext>Output file.

Produce the deterministic 8-item code-pack BOM sized to a token budget. The BOM is manifest.json plus seven body items: skeleton, file-tree, dependency list, ast-chunks, xrefs, findings, and licenses. A consumer-facing readme.md ships alongside the BOM but is not part of the manifest hash preimage. The pack is byte-identical given the same (commit, tokenizer, budget), and packHash names its on-disk directory (<repo>/.codehub/packs/<packHash>/).

The default engine is pack (the @opencodehub/pack BOM). --engine repomix opts into the legacy single-file snapshot (a single output file, bomItemCount of 1, no manifest).

usage
codehub code-pack [path]
FlagDefaultPurpose
--budget <n>100000AST-chunker token budget.
--tokenizer <id>openai:o200k_base@tiktoken-0.8.0Tokenizer pin <vendor>:<name>@<pin>.
--out-dir <dir><repo>/.codehub/packs/<packHash>/Override the default output directory.
--engine <pack|repomix>packpack emits the 8-item BOM; repomix emits the legacy single-file snapshot.
--explain-contextoffAfter packing, print the context read-receipt (files indexed, lines, hash coverage, per-language breakdown) from context-bom.json.
--jsonoffWith --explain-context or --variance-probe, emit the result as JSON on stdout.
--variance-probe <task-file>Measure the run-to-run answer variance an OCH pack removes from a coding agent. Loads the task file, generates the pack, runs the agent N times with vs. without the pack, and reports the dispersion delta plus token overhead. Agents run on Amazon Bedrock. On-demand only.
--runs <n>10With --variance-probe: runs per arm.
--harness <claude|codex>bothWith --variance-probe: restrict to one agent.
--aws-region <region>inherited AWS_REGIONWith --variance-probe: AWS region for Bedrock inference.
--model-claude <id>us.anthropic.claude-sonnet-4-6With --variance-probe: Claude Code Bedrock model / inference-profile id.
--model-codex <id>openai.gpt-5.5With --variance-probe: Codex Bedrock model id.
example
codehub code-pack . --budget 80000 --explain-context

Assert two code-packs are decision-equivalent (spec 011 / ADR 0020): the same files and byte ranges selected under the same budget, regardless of incidental drift in tokenCount, pins, or chunk text. packHash equality is the cheap witness; a decisionHash projection is the contract. The verdict is one of EQUIVALENT, DIVERGED, BUDGET_MISMATCH, or CORRUPT. On-demand, never a CI gate.

usage
codehub replay --compare <pack-a> <pack-b>
FlagDefaultPurpose
--compare <packs...>Required. Exactly two pack directories (.codehub/packs/<packHash>/) to compare.
--jsonoffEmit the full replay record (verdict, decisionHashes, diff) as JSON on stdout.
--budget-strictoffTreat a BUDGET_MISMATCH (different --budget between the packs) as a failure exit.

Exit codes: EQUIVALENT → 0, BUDGET_MISMATCH → 0 (or 1 with --budget-strict), DIVERGED → 1, CORRUPT → 1.

example
codehub replay --compare .codehub/packs/abc123 .codehub/packs/def456 --json

Hybrid BM25 + embedding search.

usage
codehub query <text>
FlagDefaultPurpose
--limit <n>10Max results.
--repo <name>currentTarget repo (required when >1 indexed and no cwd match).
--jsonoffStructured envelope.
--contentoffInclude source content per result.
--context <text>Extra context string for re-ranking.
--goal <text>Goal string for re-ranking.
--max-symbols <n>50Cap on candidate symbols.
--bm25-onlyoffSkip vector search.
--rerank-top-k <n>50Candidates fed into the re-ranker.
--zoomoffZoom into processes.
--fanout <n>Fan-out per process.
--granularity <symbol|file|community>symbolResult granularity.

Callers, callees, and processes for one symbol.

usage
codehub context <symbol>
FlagDefaultPurpose
--repo <name>currentTarget repo.
--jsonoffStructured envelope.
--target-uid <id>Disambiguate by graph UID.
--file-path <hint>Disambiguate by file path suffix.
--kind <kind>Disambiguate by kind (Function / Method / Class / Interface / …).

Blast radius for one symbol.

usage
codehub impact <symbol>
FlagDefaultPurpose
--depth <n>3BFS depth.
--direction <up|down|both>bothTraversal direction.
--repo <name>currentTarget repo.
--jsonoffStructured envelope.
--target-uid <id>Disambiguate by graph UID.
--file-path <hint>Disambiguate by file path.
--kind <kind>Disambiguate by kind.

Map a diff to symbols and processes.

usage
codehub detect-changes
FlagDefaultPurpose
--scope <unstaged|staged|all|compare>allDiff scope.
--compare-ref <ref>Ref for --scope compare.
--repo <name>currentTarget repo.
--jsonoffStructured envelope.
--strictoffExit 1 on MEDIUM as well.

Exit codes: 0 OK, 1 HIGH/CRITICAL (or MEDIUM+ with --strict), 2 caught error.

5-tier PR verdict.

usage
codehub verdict
FlagDefaultPurpose
--base <ref>mainBase ref.
--head <ref>HEADHead ref.
--repo <name>currentTarget repo.
--jsonoffEmit JSON instead of Markdown.

Exit codes: auto_merge=0, single_review=1, dual_review=1, expert_review=2, block=3.

Diff-scoped change-pack: the impacted subgraph, a PR verdict, affected tests, and a cost estimate for one diff. CLI sibling of the change_pack MCP tool, usable in CI without launching the MCP server.

usage
codehub change-pack
FlagDefaultPurpose
--repo <name>currentTarget repo.
--base <ref>mainBase git ref.
--head <ref>HEADHead git ref.
--depth <n>4Upstream traversal depth.
--min-confidence <f>0.7Traversal confidence floor, 0 to 1.
--budget <n>100000Context budget in heuristic tokens.
--include-tests-in-subgraphoffRetain test nodes in the impacted subgraph.
--jsonoffStructured envelope.

Exit codes mirror verdict: auto_merge / single_review → 0, dual_review → 1, expert_review / block → 2.

Cross-repo group management.

usage
codehub group create <name> <repos...> [--description <text>]
codehub group list
codehub group delete <name>
codehub group status <name>
codehub group query <name> <text> [--limit <n>] [--json]
codehub group sync <name> [--json]

--limit defaults to 20 for group query.

Ingest a SARIF 2.1.0 file into the graph as Finding nodes plus FOUND_IN edges.

usage
codehub ingest-sarif <sarifFile>
FlagDefaultPurpose
--repo <name>currentTarget repo.

Run scanners and ingest findings.

usage
codehub scan [path]
FlagDefaultPurpose
--scanners <list>profile-gatedComma-separated scanner ids.
--with <list>Additional scanner ids to include.
--output <file><repo>/.codehub/scan.sarifSARIF output path.
--severity <list>HIGH,CRITICALSeverity levels that fail the run.
--repo <name>currentTarget repo.
--concurrency <n>Max parallel scanners.
--timeout <ms>Per-scanner timeout.

Exit codes: 0 clean, 1 findings at severity, 2 scanner crashed.

Probe the environment.

usage
codehub doctor
FlagDefaultPurpose
--skip-nativeoffSkip the two probes that load a runtime module: the node:sqlite built-in WAL round-trip and the optional onnxruntime-web embedder (prebuilt WASM). The store has no native bindings, so this flag retains only these two checks; it is kept for compatibility with CI sandboxes. Parsing is WASM-only (web-tree-sitter) and is never skipped.
--strictoffTreat a missing SCIP indexer as a failure (exit 2), not a warning. For release / CI gates. Vendored WASM grammars fail in both modes.
--repoRoot <path>cwdRepo root to probe.

Exit codes: 0 all checks OK, 1 at least one warning, 2 at least one failure.

Run the acceptance-gate bench suite and emit a dashboard.

usage
codehub bench
FlagDefaultPurpose
--acceptance <path>Override the path to scripts/acceptance.sh.
--silentoffSuppress the listr2 progress renderer.

Emit a Markdown wiki for the repo under --output. Deterministic: every page is rendered from the graph, so the same commit produces the same wiki.

usage
codehub wiki --output <dir>
FlagDefaultPurpose
--output <dir>Required. Target directory for rendered pages.
--repo <name>currentTarget repo.
--jsonoffEmit a JSON summary on stdout.
--offlineoffAssert no network access.
example
codehub wiki --output docs/wiki

Emit opinionated CI workflows.

usage
codehub ci-init
FlagDefaultPurpose
--platform <github|gitlab|both>auto-detectTarget CI.
--main-branch <b>mainBase branch.
--repo <path>cwdRepo root.
--forceoffOverwrite existing workflows.

Fast BM25 enrichment for editor PreToolUse hooks. Writes to stderr so the hook can pipe it to the agent.

usage
codehub augment <pattern>
FlagDefaultPurpose
--limit <n>5Max hits.

Read-only SQL against the single-file store, <repo>/.codehub/store.sqlite (WAL, via Node’s built-in node:sqlite, ADR 0019). Every table lives in this one file and is directly queryable: nodes, edges, embeddings, cochanges, and store_meta. Reach kind-specific fields on nodes via SQLite JSON1, e.g. payload->>'$.field'. The guard rejects any mutation. 5-second timeout by default.

The typed tools (query / context / impact) remain the high-level path for graph traversal. A cypher query path exists only as a reserved escape hatch for community-fork graph adapters (AGE / Memgraph / Neo4j / Neptune) and is not supported by the default backend.

usage
codehub sql <query>
FlagDefaultPurpose
--repo <name>currentTarget repo.
--timeout <ms>5000Statement timeout.
--jsonoffStructured envelope.
example
codehub sql "SELECT id, name FROM nodes WHERE kind = 'Function' LIMIT 10"

Each command below is a CLI sibling of an MCP tool, reusing the same underlying reader against the single-file store. They run in CI without launching the MCP server.

List SARIF Finding nodes (sibling of the MCP list_findings tool).

usage
codehub findings
FlagDefaultPurpose
--repo <name>currentTarget repo.
--severity <level>Restrict to one SARIF severity: error, warning, note, or none.
--scanner <id>Restrict to a single scanner id (e.g. semgrep).
--rule-id <id>Restrict to a single rule id.
--file-path <hint>Substring filter on the finding’s file path.
--limit <n>500Maximum findings to return.
--jsonoffStructured envelope.
example
codehub findings --severity error --scanner semgrep

List dead and unreachable-export symbols (sibling of the MCP list_dead_code tool).

usage
codehub dead-code
FlagDefaultPurpose
--repo <name>currentTarget repo.
--file-path-pattern <hint>Substring filter on each symbol’s file path.
--include-unreachable-exportsoffAlso include exported-but-unreferenced symbols.
--limit <n>100Maximum symbols to return.
--jsonoffStructured envelope.
example
codehub dead-code --include-unreachable-exports

Classify Dependency nodes by license risk tier (sibling of the MCP license_audit tool).

usage
codehub license-audit
FlagDefaultPurpose
--repo <name>currentTarget repo.
--jsonoffStructured envelope.
example
codehub license-audit --json

Show the detected project profile (sibling of the MCP project_profile tool).

usage
codehub project-profile
FlagDefaultPurpose
--repo <name>currentTarget repo.
--jsonoffStructured envelope.
example
codehub project-profile

Per-community risk trend plus a 30-day projection (sibling of the MCP risk_trends tool).

usage
codehub risk-trends
FlagDefaultPurpose
--repo <name>currentTarget repo.
--jsonoffStructured envelope.
example
codehub risk-trends --json

List ranked OWNED_BY contributors for a node (sibling of the MCP owners tool).

usage
codehub owners <target>
FlagDefaultPurpose
--repo <name>currentTarget repo.
--limit <n>20Maximum contributors to return.
--jsonoffStructured envelope.
example
codehub owners src/auth/session.ts

Map HTTP routes to handlers and consumers (sibling of the MCP route_map tool).

usage
codehub route-map
FlagDefaultPurpose
--repo <name>currentTarget repo.
--route <hint>Substring match against Route.url (e.g. /api/users).
--method <verb>Exact match against Route.method (e.g. GET).
--jsonoffStructured envelope.
example
codehub route-map --route /api/users --method GET

Score the blast radius of changing a Route’s contract (sibling of the MCP api_impact tool).

usage
codehub api-impact
FlagDefaultPurpose
--repo <name>currentTarget repo.
--route <hint>Substring match against Route.url.
--file <hint>Substring match against Route.filePath.
--jsonoffStructured envelope.
example
codehub api-impact --route /api/users

List external dependencies (sibling of the MCP dependencies tool).

usage
codehub dependencies
FlagDefaultPurpose
--repo <name>currentTarget repo.
--ecosystem <id>Restrict to one ecosystem: npm, pypi, go, cargo, maven, or nuget.
--file-path <hint>Substring filter on the manifest / lockfile path.
--limit <n>500Maximum dependencies to return.
--jsonoffStructured envelope.
example
codehub dependencies --ecosystem npm