codehub init — bootstrap a repo
codehub init is the one-command on-ramp. Run it inside any repo you
want OpenCodeHub to cover. It installs a project-scope Claude Code
plugin, writes the .mcp.json entry, appends .codehub/ to
.gitignore, and seeds a policy starter.
Project scope on purpose. Everything lands under the repo root
(not ~/.claude/). Check .claude/, .mcp.json, and
opencodehub.policy.yaml into git and every teammate who clones gets
the plugin automatically.
What it does
Section titled “What it does”$ codehub initcodehub init: installed plugin assets under .claude/codehub init: wrote hooks to /path/to/repo/.claude/settings.jsoncodehub setup (claude-code): wrote MCP entry to /path/to/repo/.mcp.jsoncodehub init: appended ".codehub/" to .gitignorecodehub init: seeded opencodehub.policy.yaml (all rules commented out)Next: run 'codehub analyze' to build the graph, then restart Claude Code.What ships in .claude/
Section titled “What ships in .claude/”.claude/├── agents/│ └── code-analyst.md # graph-grounded analysis subagent├── commands/ # 5 slash commands│ ├── probe.md│ ├── verdict.md│ ├── owners.md│ ├── audit-deps.md│ └── rename.md├── hooks/ # PostToolUse / Stop scripts│ ├── augment.sh # enriches Bash/Grep/Glob with graph context│ └── docs-staleness.sh # non-blocking "/codehub-document --refresh" hint├── settings.json # project-scope hooks config└── skills/ # 11 skills ├── codehub-document/ # artifact factory skills ├── codehub-pr-description/ ├── codehub-onboarding/ ├── codehub-contract-map/ ├── codehub-code-pack/ ├── opencodehub-guide/ # analysis skills ├── opencodehub-exploring/ ├── opencodehub-impact-analysis/ ├── opencodehub-debugging/ ├── opencodehub-refactoring/ └── opencodehub-pr-review/Other files seeded
Section titled “Other files seeded”.mcp.json—mcpServers.codehubentry so Claude Code launches the MCP server automatically..gitignore—.codehub/appended (local graph state stays out of git by default).opencodehub.policy.yaml— starter file with every rule commented out. Uncomment when the CI verdict actions ship (spec 002 P1).
Options
Section titled “Options”| Flag | Default | Purpose |
|---|---|---|
--force | off | Overwrite conflicting files under .claude/. Without it, a re-run with any existing .claude/ contents refuses and lists every conflict. |
--skip-mcp | off | Skip the .mcp.json write. Useful when MCP config is managed at user scope (~/.claude.json). |
--skip-policy | off | Skip the opencodehub.policy.yaml seed. |
[path] | process.cwd() | Positional target directory. |
Idempotence
Section titled “Idempotence”Re-running with the same args produces byte-identical output for
settings.json, .mcp.json, .gitignore, and the policy file. The
policy file is not re-seeded if it already exists — init only
creates it, never overwrites it, even under --force.
Conflicts under .claude/ (e.g., a skill file you’ve locally modified)
abort the run without --force. The error names every conflict so you
can decide file-by-file.
Next step
Section titled “Next step”Run codehub analyze to build the graph, then restart Claude Code so
it picks up the new project-scope plugin.
codehub analyze .See Your first query for what to do once the graph is built.