Skip to content

rai graph

Build, query, and manage the knowledge graph. The graph is a unified index of all context sources: governance, memory (patterns, calibration, sessions), skills, work tracking, and discovered components.

Build the graph index from all sources. By default, diffs against the previous build and saves the diff to .raise/rai/personal/last-diff.json.

FlagShortDescription
--output-oPath to save index JSON
--no-diffSkip diff computation
Terminal window
# Build index to default location
rai graph build
# Build without diff
rai graph build --no-diff
# Save to custom location
rai graph build --output custom_index.json

Exit codes: 0 success.


Search the knowledge graph for relevant concepts.

ArgumentDescription
QUERY_STRQuery string — keywords or concept ID (required)
FlagShortDescription
--format-fOutput format: human, json. Default: human
--output-oOutput file path (default: stdout)
--strategy-sQuery strategy: keyword_search, concept_lookup
--types-tFilter by types (comma-separated: pattern, calibration, principle, etc.)
--edge-typesFilter by edge types (comma-separated: constrained_by, depends_on, etc.)
--limit-lMaximum number of results. Default: 10
--index-iGraph index path
Terminal window
# Search by keywords
rai graph query "planning estimation"
# Filter to patterns only
rai graph query "testing" --types pattern,calibration
# Lookup specific concept by ID
rai graph query "PAT-001" --strategy concept_lookup
# Compact JSON output
rai graph query "velocity" --format json

Show full architectural context for a module. Returns bounded context (domain), architectural layer, guardrails, and dependencies.

ArgumentDescription
MODULE_IDModule ID, e.g. mod-memory (required)
FlagShortDescription
--format-fOutput format: human, json. Default: human
--index-iGraph index path
Terminal window
# Show context for memory module
rai graph context mod-memory
# JSON output
rai graph context mod-memory --format json

Validate graph index structure and relationships. Checks for cycles in depends_on relationships, valid relationship types, and that all edge targets exist as nodes.

FlagShortDescription
--index-iPath to index JSON file
Terminal window
# Validate default index
rai graph validate
# Validate specific index file
rai graph validate --index custom_index.json

Exit codes: 0 valid, 1 validation errors found.


Extract concepts from governance markdown files. Without arguments, extracts from all standard governance locations (governance/prd.md, governance/vision.md, framework/reference/constitution.md).

ArgumentDescription
FILE_PATHPath to governance file (optional — extracts all if omitted)
FlagShortDescription
--format-fOutput format: human, json. Default: human
Terminal window
# Extract from all governance files
rai graph extract
# Extract from specific file
rai graph extract governance/prd.md

List concepts in the knowledge graph.

FlagShortDescription
--format-fOutput format: human, json, table. Default: table
--output-oOutput file path (default: stdout)
--index-iGraph index path
--memory-only / --allShow only memory types (pattern, calibration, session) or all. Default: --all
Terminal window
# Show summary table
rai graph list
# Show only patterns/calibrations/sessions
rai graph list --memory-only
# Export as JSON
rai graph list --format json --output graph.json

Generate an interactive HTML visualization of the knowledge graph. Creates a self-contained HTML file with a D3.js force-directed graph. Nodes are color-coded by type, filterable, zoomable, and searchable.

FlagShortDescription
--output-oOutput HTML file path
--index-iGraph index path
--open / --no-openOpen in browser after generating. Default: --open
Terminal window
# Generate and open in browser
rai graph viz
# Generate to specific path
rai graph viz --output graph.html
# Generate without opening
rai graph viz --no-open

See also: rai graph build, rai pattern