cypher
Cypher query language: MATCH CREATE MERGE DELETE path expressions BFS/DFS aggregations graph algorithms
What this skill does
## Purpose
This skill allows OpenClaw to execute Cypher queries for interacting with graph databases, specifically Neo4j, enabling operations like node matching, relationship creation, and graph traversals.
## When to Use
Use this skill when working with graph-structured data, such as social networks or recommendation systems. For example, query relationships in a user graph or perform BFS on a knowledge base. Avoid it for relational data; opt for SQL-based skills instead.
## Key Capabilities
- Execute core Cypher clauses: MATCH, CREATE, MERGE, DELETE.
- Handle path expressions for traversals (e.g., shortest paths).
- Support BFS/DFS traversals via algorithms like shortestPath().
- Perform aggregations (e.g., COUNT, SUM) on graph data.
- Run graph algorithms such as PageRank or community detection.
- Integrate with Neo4j for querying nodes and relationships.
## Usage Patterns
To execute a Cypher query, use `cypher-shell` or the Python `neo4j` driver. Neo4j Community Edition runs on `bolt://localhost:7687` with no authentication by default.
Example 1: Match all nodes and return their labels.
```cypher
MATCH (n) RETURN labels(n), count(n) LIMIT 10;
```
Via CLI: `cypher-shell -a bolt://localhost:7687 --format plain "MATCH (n) RETURN labels(n), count(n) LIMIT 10"`
Example 2: Create a relationship between two nodes.
```cypher
MATCH (a:Person {name: 'Alice'}), (b:Person {name: 'Bob'})
CREATE (a)-[:KNOWS]->(b);
```
## Common Commands/API
Use `cypher-shell` for interactive queries or the Python `neo4j` driver for programmatic access:
```bash
# CLI query
cypher-shell -a bolt://localhost:7687 --format plain "MATCH (n:Skill) RETURN n.name LIMIT 10"
```
```python
# Python neo4j driver
from neo4j import GraphDatabase
driver = GraphDatabase.driver("bolt://localhost:7687")
with driver.session() as session:
result = session.run("MATCH (n:Skill) RETURN n.name LIMIT 10")
for record in result:
print(record["n.name"])
driver.close()
```
Config: Connection via `bolt://localhost:7687`, no auth. Use MERGE for upsert operations: `MERGE (n:Person {name: 'Alice'})`.
## Integration Notes
Integrate this skill in OpenClaw by ensuring Neo4j is running (`brew services start neo4j` on macOS, `systemctl start neo4j` on Linux). Connection defaults to `bolt://localhost:7687` with no authentication. Override via `NEO4J_URI` environment variable if needed.
## Error Handling
Common errors include syntax issues (e.g., missing semicolons) or connection failures. Check for "Neo4jError: Invalid input" by validating queries first. If connection fails, verify Neo4j is running. In code, wrap queries in try-catch blocks:
```python
from neo4j import GraphDatabase
from neo4j.exceptions import ServiceUnavailable, CypherSyntaxError
driver = GraphDatabase.driver("bolt://localhost:7687")
try:
with driver.session() as session:
result = session.run("MATCH (n) RETURN n LIMIT 5")
records = list(result)
except ServiceUnavailable:
print("Error: Neo4j is not running. Start with: brew services start neo4j")
except CypherSyntaxError as e:
print(f"Cypher syntax error: {e}")
finally:
driver.close()
```
For graph-specific errors like missing nodes, use OPTIONAL MATCH. Always log errors with details for debugging.
## Graph Relationships
- Nodes: Person, Movie, Organization.
- Relationships: (:Person)-[:KNOWS]-(:Person), (:Person)-[:ACTED_IN]-(:Movie), (:Organization)-[:EMPLOYS]-(:Person).
- Path examples: Shortest path via shortestPath((:Person {name: 'Alice'})-[:KNOWS*]-(:Person {name: 'Bob'})).
- Aggregations: Use on relationships, e.g., RETURN COUNT((:Person)-[:KNOWS]-()) AS connections.
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.