> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kubiya.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Context Graph

> Query and explore the organizational knowledge graph powered by Neo4j

Neo4j-based organizational knowledge graph storing resources, relationships, and execution history.

## Quick Start

```bash theme={null}
# View graph statistics
kubiya graph stats

# List all node labels
kubiya graph labels

# Execute custom Cypher query
kubiya graph query --query "MATCH (n:Agent) RETURN n LIMIT 10"
```

**Output:**

```
📊 Graph Statistics

Total Nodes: 1,247
Total Relationships: 3,891

Node Types:
  - Agent: 42
  - Team: 15
  - Environment: 8
  - Skill: 127
  - Execution: 892
  - User: 163
```

```bash theme={null}
# List available integrations
kubiya graph integrations list
```

**Output:**

```
📊 Available Integrations (32)

INTEGRATION       DESCRIPTION
aws              Amazon Web Services cloud platform
github           GitHub repository management
slack            Slack team communication
kubernetes       Kubernetes cluster management
terraform        Infrastructure as code
datadog          Monitoring and analytics
pagerduty        Incident management
jira             Issue tracking and project management
[... 24 more integrations]
```

## Graph Statistics

### Get Overall Statistics

```bash theme={null}
# View overall statistics
kubiya graph stats

# Stats for specific integration
kubiya graph stats --integration github
```

## Nodes

### List Nodes

```bash theme={null}
# List all nodes
kubiya graph nodes list

# Filter by label
kubiya graph nodes list --label Agent
kubiya graph nodes list --label Team

# Limit results
kubiya graph nodes list --limit 100
```

### Get Node Details

```bash theme={null}
# View specific node
kubiya graph nodes get <node-id>
```

### Get Node Relationships

```bash theme={null}
# View node relationships
kubiya graph nodes relationships <node-id>
```

### Search Nodes

```bash theme={null}
# Search by property
kubiya graph nodes search \
  --label Agent \
  --property-name name \
  --property-value "deploy"
```

## Integrations

List all integrated data sources that contribute to the knowledge graph:

```bash theme={null}
# List all integrated data sources
kubiya graph integrations list
```

## Custom Queries

Run custom Cypher queries to analyze your organizational knowledge graph:

```bash theme={null}
# Run Cypher query
kubiya graph query --query "MATCH (n:Agent) RETURN n LIMIT 10"

# Find agents with specific skill
kubiya graph query --query "MATCH (a:Agent)-[:HAS_SKILL]->(s:Skill) WHERE s.name = 'kubernetes' RETURN a.name"

# Analyze team composition
kubiya graph query --query "MATCH (t:Team)-[:HAS_MEMBER]->(a:Agent) RETURN t.name, count(a) as member_count"
```

## Schema Discovery

### List Labels

```bash theme={null}
# List all node labels
kubiya graph labels
```

**Output:**

```
📋 Node Labels (12)

- Agent
- Team
- Environment
- Skill
- Policy
- Execution
- User
- Integration
- Secret
- WorkerQueue
- Job
- Project
```

### List Relationship Types

```bash theme={null}
# List all relationship types
kubiya graph relationship-types
```

**Output:**

```
🔗 Relationship Types (18)

- HAS_SKILL
- HAS_MEMBER
- BELONGS_TO
- EXECUTED_BY
- USES_POLICY
- CREATED_BY
- HAS_INTEGRATION
- DEPLOYED_TO
- DEPENDS_ON
...
```

## Subgraph Exploration

Extract a subgraph around a specific node:

```bash theme={null}
# Get subgraph around node
kubiya graph subgraph --node-id <node-id> --depth 2
```

## Intelligent Search

AI-powered natural language search for the context graph using Claude:

```bash theme={null}
# Simple search
kubiya graph search "Find all production environments in AWS"

# Search with streaming
kubiya graph search "Show me critical security issues" --stream

# Advanced search with parameters
kubiya graph search "Find Kubernetes clusters" \
  --max-turns 10 \
  --model kubiya/claude-opus-4 \
  --temperature 0.5 \
  --integration AWS

# Continue a conversation
kubiya graph search "Tell me more about the first one" --session abc-123-def

# JSON output
kubiya graph search "List all teams" --output json
```

**Output:**

```
🤖 AI-Powered Graph Search

🔍 Query: Find all production environments in AWS

Searching context graph...

✓ Found 3 production environments:

1. prod-us-east-1 (Environment)
   Region: us-east-1
   Status: active
   Resources: 42 nodes

2. prod-us-west-2 (Environment)
   Region: us-west-2
   Status: active
   Resources: 38 nodes

3. prod-eu-west-1 (Environment)
   Region: eu-west-1
   Status: active
   Resources: 31 nodes
```

**Available Features**:

* **AI-powered**: Claude-based agent with specialized graph tools
* **Flexible**: Configurable model, temperature, and search parameters
* **Smart tools**: 10 graph operations (property search, relationships, subgraphs, etc.)
* **Streaming**: Real-time progress updates (default: enabled)
* **Session continuity**: Continue conversations with `--session` flag

**Optional Flags**:

* `--stream` - Enable real-time streaming (default: true)
* `--model` - LiteLLM model name (default: kubiya/claude-sonnet-4)
* `--temperature` - Model temperature 0.0-2.0 (default: 0.7)
* `--max-turns` - Maximum conversation turns 1-20 (default: 5)
* `--integration` - Filter by integration (AWS, Azure, Slack, etc.)
* `--label` - Filter by node label
* `--semantic` - Enable semantic search
* `--cypher` - Enable custom Cypher queries
* `--output` - Output format (text, json)

<Tip>
  Use intelligent search for exploratory queries. For structured data retrieval, use `kubiya graph nodes` commands or custom Cypher queries.
</Tip>

## Best Practices

* Use graph queries for resource discovery and pattern analysis
* Monitor agent activity and execution success rates
* Optimize graph queries with indexes and limits
* Archive old execution data periodically
* Implement regular Neo4j backups
* Use intelligent search for exploration, structured queries for automation
* Filter queries by integration or label for performance
* Set appropriate depth limits for subgraph queries

## Command Reference

```bash theme={null}
# Statistics
kubiya graph stats [--integration <name>]

# Nodes
kubiya graph nodes list [--label <type>] [--limit <n>]
kubiya graph nodes get <id>
kubiya graph nodes relationships <id>
kubiya graph nodes search --label <type> --property-name <key> --property-value <val>

# Integrations
kubiya graph integrations list

# Custom Queries
kubiya graph query --query "<cypher>"

# Schema
kubiya graph labels
kubiya graph relationship-types

# Subgraph
kubiya graph subgraph --node-id <id> --depth <n>

# Intelligent Search
kubiya graph search "<query>" [--stream] [--model <name>] [--temperature <n>]
kubiya graph search "<query>" --integration <name> --label <type>
kubiya graph search "<query>" --session <id> --max-turns <n>
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Cognitive Memory" icon="brain" href="/cli/cognitive-memory">
    Store and recall contextual knowledge using semantic search
  </Card>

  <Card title="Core Resources" icon="cube" href="/cli/core-resources">
    Create and manage agents, teams, and projects
  </Card>

  <Card title="On-Demand Execution" icon="bolt" href="/cli/on-demand-execution">
    Execute tasks with intelligent planning
  </Card>

  <Card title="Capabilities" icon="puzzle-piece" href="/cli/capabilities">
    Configure skills, models, and policies
  </Card>
</CardGroup>
