CLI Reference

July 21, 2026 ยท View on GitHub

The cgr command is the main entry point for Code-Graph-RAG.

Built-in Help

List commands by workflow or show the detailed page for a command:

cgr help
cgr help start
cgr help daemon logs

cgr COMMAND --help displays the same command-specific information.

Core Commands

cgr start

Parse a repository and/or start the interactive query CLI.

cgr start --repo-path /path/to/repo [OPTIONS]
OptionDescription
--repo-pathPath to repository (defaults to current directory)
--update-graphParse and ingest the repository into the knowledge graph
--cleanDelete every project from the shared graph and clear the selected repository's sync cache. With --update-graph, rebuild after deletion.
--batch-sizeOverride Memgraph flush batch size
--orchestratorSpecify provider:model for main operations (e.g., google:gemini-2.5-pro, ollama:llama3.2)
--cypherSpecify provider:model for graph queries (e.g., google:gemini-2.5-flash, ollama:codellama)
-o, --outputWrite the updated graph to a JSON path. Requires --update-graph.

cgr export

Export the knowledge graph to JSON.

cgr export -o my_graph.json

cgr optimize

AI-powered codebase optimisation.

cgr optimize <language> --repo-path /path/to/repo [OPTIONS]
OptionDescription
--repo-pathPath to repository
--orchestratorSpecify provider:model for operations
--batch-sizeOverride Memgraph flush batch size
--reference-documentPath to reference documentation for guided optimisation

Supported languages: python, javascript, typescript, rust, go, java, scala, c, cpp

cgr dead-code

Report functions and methods unreachable from any entry point (candidates for review, not a guaranteed delete list). See Dead Code Detection.

cgr dead-code [OPTIONS]
OptionDescription
--project-name, -nProject to scan. Defaults to the sole indexed project.
--entry-point, -eTreat symbols whose qualified name ends with this value as reachable roots. Repeatable.
--decorator-rootTreat symbols carrying this decorator as roots. Repeatable.
--excludeGlob matched against a symbol's file path to exclude. Repeatable.
--include-tests / --no-include-testsTreat test code as reachable roots. On by default.
--classes / --no-classesAlso report unreachable classes. Off by default.
--formatOutput format: table (default) or json.
--output, -oWrite the report to a file instead of stdout.
--fail-on-foundExit with code 1 when any candidate is found (useful in CI).

cgr mcp-server

Serve cgr tools to MCP clients over stdio or HTTP.

cgr mcp-server

cgr index

Index a repository to protobuf for offline use.

cgr index -o ./index-output --repo-path ./my-project

cgr doctor

Check that all required dependencies and services are available.

cgr doctor

cgr language

Manage language support.

cgr language add-grammar <language-name>
cgr language add-grammar --grammar-url <url>
cgr language list-languages
cgr language remove-language <language-name>

Makefile Commands

CommandDescription
make helpShow help message
make allInstall everything for full development environment
make installInstall project dependencies with full language support
make pythonInstall project dependencies for Python only
make devSetup development environment (install deps + pre-commit hooks)
make testRun unit tests only (fast, no Docker)
make test-parallelRun unit tests in parallel (fast, no Docker)
make test-integrationRun integration tests (requires Docker)
make test-allRun all tests including integration and e2e (requires Docker)
make test-parallel-allRun all tests in parallel (requires Docker)
make cleanClean up build artifacts and cache
make build-grammarsBuild grammar submodules
make watchWatch repository for changes and update graph in real-time
make readmeRegenerate README.md from codebase
make lintRun ruff check
make formatRun ruff format
make typecheckRun type checking with ty
make checkRun all checks: lint, typecheck, test
make pre-commitRun all pre-commit checks locally