This guide explains the command line in plain language.
Use CLI when you want:
- imports and refresh jobs;
- scripts and automation;
- checks in
CI; - direct access without the OpenCode plugin.
What the CLI Is For¶
The CLI is not the main daily interface for most people anymore.
That role belongs to OpenCode.
The CLI is now best for:
- preparing projects;
- checking system state;
- running reviews and reports;
- automating repeatable work.
The Three Things You Usually Need¶
1. Import a project¶
codegraph import --path /path/to/repo
Use this when you first bring a repository into CodeGraph.
What happens:
- the code graph is built with
GoCPG; - project context is prepared for
OpenViking; - the project becomes available to the API and plugin flows.
2. List projects¶
codegraph projects list
Use this when you want to confirm that the project exists and is ready.
3. Start the API¶
python -m src.api.cli run
Use this when OpenCode, MCP, or another tool needs the backend.
Common Everyday CLI Jobs¶
Review changes from CLI¶
python -m src.cli review --base-ref HEAD~3
Use this when you want review findings without opening the plugin.
Run project-level checks¶
python -m src.cli audit --db data/projects/codegraph.duckdb --language en --format json
Use this when you want a broad quality or risk pass.
Refresh project state¶
codegraph import --path /path/to/repo
Use the same import path again when the repository changed enough that you want a clean refresh.
Manage service accounts¶
python -m src.cli auth service-account create --name ci-bot
python -m src.cli auth service-account list
python -m src.cli auth service-account inspect --service-account-id sa_123
python -m src.cli auth service-account rotate --service-account-id sa_123
python -m src.cli auth service-account revoke --service-account-id sa_123 --credential-id cred_456
python -m src.cli auth service-account deactivate --service-account-id sa_123
Use these commands when automation needs an explicit machine identity and you want to control its full lifecycle from the CLI.
Inspect snapshots and governance policy¶
python -m src.cli dashboard snapshot show --snapshot-id snap_123
python -m src.cli dashboard snapshot policy
Use dashboard snapshot show when you need to inspect one stored baseline, and dashboard snapshot policy when you need to confirm the current governance rules before compare or export.
How CLI Fits the New Architecture¶
Even when you use CLI, the same system model still applies:
GoCPGgives the live graph;OpenVikinggives reusable project memory;PostgreSQLkeeps governance and ownership rules.
So CLI work still affects the same sessions, memory, and project state that OpenCode uses later.
When to Use CLI Instead of OpenCode¶
| Use CLI when… | Use OpenCode when… |
|---|---|
| You need repeatable scripts | You are doing interactive daily work |
| You are preparing or refreshing a repo | You are exploring or reviewing code live |
You want a backend check in CI |
You want guided commands like /onboard or /review |
| You want raw operational control | You want the shortest path to an answer |
Fast Command List¶
# Import a repository
codegraph import --path /path/to/repo
# Show projects
codegraph projects list
# Start API
python -m src.api.cli run
# Review changes
python -m src.cli review --base-ref HEAD~3
# Run an audit
python -m src.cli audit --db data/projects/codegraph.duckdb --language en --format json
# Service-account lifecycle
python -m src.cli auth service-account create --name ci-bot
python -m src.cli auth service-account list
python -m src.cli auth service-account inspect --service-account-id sa_123
python -m src.cli auth service-account rotate --service-account-id sa_123
python -m src.cli auth service-account revoke --service-account-id sa_123 --credential-id cred_456
python -m src.cli auth service-account deactivate --service-account-id sa_123
# Snapshot inspection and policy
python -m src.cli dashboard snapshot show --snapshot-id snap_123
python -m src.cli dashboard snapshot policy
If Something Breaks¶
First check:
- Is the project imported?
- Is the API running?
- Is
OpenVikinghealthy? - Is
PostgreSQLreachable? - Is
GoCPGhealthy?
Then read: Troubleshooting