schema

📁 octaviopavon/cypher-shell 📅 8 days ago
2
总安装量
2
周安装量
#74935
全站排名
安装命令
npx skills add https://github.com/octaviopavon/cypher-shell --skill schema

Agent 安装分布

mcpjam 2
codebuddy 2
claude-code 2
junie 2
windsurf 2
zencoder 2

Skill 文档

cypher-shell Schema Discovery

Full schema retrieval of the connected graph.

Pre-flight

source ~/.neo4j-connection 2>/dev/null || { echo "Not connected. Run /cypher-shell:connect first."; exit 1; }

Execution

source ~/.neo4j-connection && cypher-shell --format verbose "<QUERY>"

Full Schema (no argument)

Run ALL of these and present a formatted summary:

1. Node labels with counts

MATCH (n) RETURN labels(n) AS label, count(n) AS count ORDER BY count DESC;

2. Relationship types with counts

MATCH ()-[r]->() RETURN type(r) AS type, count(r) AS count ORDER BY count DESC;

3. Schema topology (label-to-label via relationship type)

MATCH (a)-[r]->(b)
RETURN DISTINCT labels(a) AS from_label, type(r) AS relationship, labels(b) AS to_label
ORDER BY from_label, relationship, to_label;

4. Properties per node label

MATCH (n)
WITH labels(n) AS lbls, keys(n) AS props
RETURN DISTINCT lbls AS label, props AS properties
ORDER BY lbls;

5. Properties per relationship type

MATCH ()-[r]->()
WITH type(r) AS rel, keys(r) AS props
WHERE size(props) > 0
RETURN DISTINCT rel AS relationship, props AS properties
ORDER BY rel;

6. Indexes

SHOW INDEXES YIELD name, type, labelsOrTypes, properties, state
RETURN name, type, labelsOrTypes, properties, state ORDER BY name;

7. Constraints

SHOW CONSTRAINTS YIELD name, type, labelsOrTypes, properties
RETURN name, type, labelsOrTypes, properties ORDER BY name;

8. APOC meta stats (skip gracefully if unavailable)

CALL apoc.meta.stats()
YIELD labels, relTypes, propertyKeyCount, nodeCount, relCount
RETURN nodeCount, relCount, propertyKeyCount, labels, relTypes;

Present as ASCII Schema Map

Graph Schema — <database> @ <uri>
===================================
Nodes: X total across Y labels
Relationships: Z total across W types

[File] (145 nodes)
  Props: name, path, language, extension
  --[:CONTAINS]--> [Function]
  --[:IMPORTS]--> [File]

[Function] (312 nodes)
  Props: name, file, line, kind, language
  --[:CALLS]--> [Function]
  <--[:CONTAINS]-- [File]

Indexes:
  - idx_file_path (RANGE) on :File(path) [ONLINE]

Constraints:
  - uniq_file_id (UNIQUENESS) on :File(id)

Label Deep Dive ($ARGUMENTS matches a known label)

Sample nodes

MATCH (n:<LABEL>) RETURN n LIMIT 5;

Property types (sampled)

MATCH (n:<LABEL>)
WITH n LIMIT 100
UNWIND keys(n) AS key
RETURN DISTINCT key AS property,
       head(collect(DISTINCT valueType(n[key]))) AS type,
       count(*) AS present_in
ORDER BY present_in DESC;

Outgoing connections

MATCH (n:<LABEL>)-[r]->(m)
RETURN type(r) AS rel, labels(m) AS target, count(*) AS count
ORDER BY count DESC;

Incoming connections

MATCH (n:<LABEL>)<-[r]-(m)
RETURN type(r) AS rel, labels(m) AS source, count(*) AS count
ORDER BY count DESC;

Counts

MATCH (n:<LABEL>) RETURN count(n) AS total;
MATCH (n:<LABEL>) WHERE NOT (n)--() RETURN count(n) AS orphans;

Report: total, orphans, all properties with types, all in/out connections with counts.