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 + HNSW indexes, and write .codehub/.

usage
codehub analyze [path]
FlagDefaultPurpose
--forceoffIgnore the registry cache and re-run the pipeline.
--embeddingsoffCompute semantic vectors.
--embeddings-int8offQuantise vectors to int8 (~23 MB weights).
--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.
--sbomoffEmit sbom.cyclonedx.json + sbom.spdx.json from Dependency nodes.
--coverageoffOverlay lcov / cobertura / jacoco / coverage.py reports onto File nodes.
--summaries / --no-summariesonLLM symbol summaries (Bedrock).
--max-summaries <n|auto>auto (10% of SCIP-confirmed callables, cap 500)Summary budget.
--summary-model <id>Override the Bedrock summary model id.
--skillsoffEmit one SKILL.md per Community (≥5 symbols) under .codehub/skills/.
--native-parseroffOpt into the native tree-sitter N-API addon (Node 22). Default is the WASM runtime.
--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 gte-modernbert-base ONNX weights (SHA256-pinned).
--int8offUse the int8 weight variant (~150 MB) instead of fp32 (~596 MB).
--model-dir <path>Override the target directory for embedder weights.
--pluginoffInstall the Claude Code plugin to ~/.claude/plugins/opencodehub/.

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 9-item code-pack BOM (manifest, skeleton, file-tree, dependency list, top symbols, processes, routes, tools, findings) sized to a token budget. This is the artifact attached to every release and signed with cosign.

usage
codehub code-pack [path]
FlagDefaultPurpose
--budget <n>100000AST-chunker token budget.

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.

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 checks that require native bindings (DuckDB / native tree-sitter addon).
--repoRoot <path>cwdRepo root to probe.

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.

usage
codehub wiki
FlagDefaultPurpose
--repo <name>currentTarget repo.
--jsonoffEmit a JSON summary on stdout.
--offlineoffAssert no network access (incompatible with --llm).
--llmoffRoute top-ranked modules through the summarizer.
--max-llm-calls <n>0 (dry-run)LLM call budget.
--llm-model <id>Override the Bedrock summary model id.

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 graph store. 5-second timeout by default.

usage
codehub sql <query>
FlagDefaultPurpose
--repo <name>currentTarget repo.
--timeout <ms>5000Statement timeout.
--jsonoffStructured envelope.