Skip to main content
CodeGraph provides a command-line interface for analyzing codebases and managing the graph.

Global Options

These options apply to all commands:
OptionDescription
--help, -hShow help information
--version, -vShow version
--verboseEnable verbose output
--quiet, -qSuppress non-error output

analyze

Analyze a .NET solution or project and save the graph to Neo4j.
codegraph analyze <path> [options]

Arguments

ArgumentDescription
pathPath to .sln or .csproj file

Options

OptionDefaultDescription
--depthclassAnalysis depth: namespace, class, or method
--include*Glob pattern for projects to include
--excludeGlob pattern for projects to exclude
--incrementalOnly analyze changed files
--clearClear existing graph before analysis
--neo4j-urienvNeo4j connection URI
--neo4j-userenvNeo4j username
--neo4j-passwordenvNeo4j password

Examples

# Basic analysis
codegraph analyze ./MyProject.sln

# With environment variables (recommended)
npx @dotenvx/dotenvx run -- sh -c 'codegraph analyze ./MyProject.sln'

# Exclude test projects
codegraph analyze ./MyProject.sln --exclude "*Tests*"

# Method-level analysis
codegraph analyze ./MyProject.sln --depth method

# Incremental update
codegraph analyze ./MyProject.sln --incremental

# Clear and re-analyze
codegraph analyze ./MyProject.sln --clear

serve

Start the API server and web frontend.
codegraph serve [options]

Options

OptionDefaultDescription
--api-port5050API server port
--web-port5173Web frontend port
--no-webDon’t start web frontend
--no-gpuDon’t start GPU server

Examples

# Start everything
codegraph serve

# API only
codegraph serve --no-web

# Custom ports
codegraph serve --api-port 8080 --web-port 3000

layout

Manage graph layout positions.

layout compute

Compute layout using GPU or CPU.
codegraph layout compute [options]
OptionDefaultDescription
--gpuForce GPU computation
--cpuForce CPU computation
--iterations1000Number of iterations
--gravity1.0Gravity strength
# GPU layout
codegraph layout compute --gpu

# Custom parameters
codegraph layout compute --iterations 2000 --gravity 1.5

layout clear

Clear all layout positions.
codegraph layout clear

layout status

Check layout status.
codegraph layout status

overlay

Manage overlay plugins.

overlay list

List available overlays.
codegraph overlay list

overlay apply

Apply an overlay.
codegraph overlay apply <plugin-id> [options]
# Apply git activity
codegraph overlay apply git-activity

# Apply with options
codegraph overlay apply git-activity --since "2024-01-01"

# Apply test coverage
codegraph overlay apply test-coverage --report coverage.xml

overlay remove

Remove an overlay.
codegraph overlay remove <plugin-id>

overlay status

Check overlay status.
codegraph overlay status <plugin-id>

gpu

Manage GPU layout server.

gpu status

Check GPU availability.
codegraph gpu status
Output:
GPU Status: Available
Backend: Metal
Device: Apple M1 Pro
Server: ws://localhost:9002 (connected)

gpu start

Start the GPU server.
codegraph gpu start

gpu stop

Stop the GPU server.
codegraph gpu stop

query

Run Cypher queries against Neo4j.
codegraph query <cypher>

Examples

# Count nodes
codegraph query "MATCH (n:CodeNode) RETURN count(n)"

# Find dependencies
codegraph query "MATCH (n)-[:DEPENDS_ON]->(m) WHERE n.name = 'UserService' RETURN m.name"

# Interactive mode
codegraph query --interactive

export

Export graph data.
codegraph export <format> <output> [options]

Formats

FormatDescription
jsonJSON format
graphmlGraphML format
dotGraphviz DOT format
csvCSV (nodes and edges)

Examples

# Export to JSON
codegraph export json graph.json

# Export to GraphML
codegraph export graphml graph.graphml

# Export only specific node types
codegraph export json graph.json --types "Class,Interface"

Environment Variables

The CLI reads these environment variables:
VariableDescription
Neo4j__UriNeo4j connection URI
Neo4j__UsernameNeo4j username
Neo4j__PasswordNeo4j password
Neo4j__DatabaseNeo4j database name
GRAPHPU_URIGPU server WebSocket URI
Use npx @dotenvx/dotenvx run to load from .env:
npx @dotenvx/dotenvx run -- codegraph analyze ./MyProject.sln