Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

neo4j

БесплатноБез исполняемых скриптовНе проверен

Neo4j is a graph database that stores nodes and relationships and is queried with Cypher. Use when a user asks to model connected data, write Cypher queries…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

Neo4j

Overview

Neo4j stores data as nodes (with labels and properties) and typed, directed relationships, which makes multi-hop questions (friends of friends, who bought what others bought, which accounts share a device) cheap compared with SQL joins. Releases now use calendar versions (2026.10 at the time of writing) next to the 5.26 long-term line; Docker tags neo4j:latest, neo4j:2026.10.1 and neo4j:5.26 exist. Queries run in Cypher; examples below were run against Neo4j 2026.10.1 Community with neo4j-driver 6.2 and the Python neo4j 6.4 driver.

Instructions

Step 1: Run Neo4j locally

export NEO4J_PASSWORD="$(openssl rand -base64 18)"   # keep it in your secret store
docker run -d --name neo4j \
  -p 127.0.0.1:7474:7474 -p 127.0.0.1:7687:7687 \
  -v neo4j_data:/data \
  -e NEO4J_AUTH="neo4j/${NEO4J_PASSWORD}" \
  neo4j:2026.10.1

Browser UI at http://localhost:7474, Bolt at neo4j://localhost:7687. The password must be at least 8 characters and is applied only on the first start of an empty /data volume. Publishing ports on 127.0.0.1 keeps the database off the network. Run queries from a shell with docker exec -it neo4j cypher-shell -u neo4j -p "$NEO4J_PASSWORD".

Drivers:

npm install neo4j-driver
pip install neo4j

Step 2: Create data

Use MERGE for anything that may already exist; CREATE always makes a new node.

CREATE (alice:Person {name: 'Alice', email: '[email protected]', age: 30})
CREATE (bob:Person {name: 'Bob', email: '[email protected]', age: 28})
CREATE (neo:Technology {name: 'Neo4j', category: 'Database'})
RETURN alice, bob, neo;

MATCH (a:Person {name: 'Alice'}), (b:Person {name: 'Bob'})
CREATE (a)-[:KNOWS {since: 2024}]->(b);

MATCH (a:Person {name: 'Alice'}), (t:Technology {name: 'Neo4j'})
CREATE (a)-[:USES {skill_level: 'expert'}]->(t);

Each MATCH ... CREATE makes one relationship per matched pair; if MATCH finds nothing, nothing is created and no error is raised.

Step 3: Query

// Friends of friends
MATCH (p:Person {name: 'Alice'})-[:KNOWS]->()-[:KNOWS]->(fof)
WHERE fof <> p
RETURN DISTINCT fof.name;

// Shortest path, any direction, at most 6 hops
MATCH path = shortestPath((a:Person {name: 'Alice'})-[:KNOWS*..6]-(b:Person {name: 'Charlie'}))
RETURN path, length(path);

// Same with the newer quantified-path syntax (Cypher 25 / GQL)
MATCH path = SHORTEST 1 (a:Person {name: 'Alice'})-[:KNOWS]-+(b:Person {name: 'Charlie'})
RETURN length(path);

// Filter on a relationship property and collect
MATCH (p:Person)-[r:USES]->(t:Technology)
WHERE r.skill_level = 'expert'
RETURN p.name, collect(t.name) AS technologies;

// Aggregation
MATCH (p:Person)-[:KNOWS]->(friend)
RETURN p.name, count(friend) AS friend_count
ORDER BY friend_count DESC LIMIT 10;

Never build Cypher by string concatenation. Pass values as parameters ($name); this prevents Cypher injection and lets Neo4j reuse the query plan. Labels, relationship types and property keys cannot be parameters.

Step 4: Indexes and constraints

Create them before loading data at scale; a MERGE or MATCH on an unindexed property scans every node with the label.

CREATE CONSTRAINT person_email IF NOT EXISTS
  FOR (p:Person) REQUIRE p.email IS UNIQUE;          // also creates a backing index

CREATE INDEX person_name IF NOT EXISTS FOR (p:Person) ON (p.name);

CREATE INDEX order_status_date IF NOT EXISTS
  FOR (o:Order) ON (o.status, o.created_at);          // composite

CREATE FULLTEXT INDEX person_search IF NOT EXISTS
  FOR (p:Person) ON EACH [p.name, p.bio];

CALL db.index.fulltext.queryNodes('person_search', 'Alice') YIELD node, score
RETURN node.name, score;

SHOW INDEXES YIELD name, type, state;

Indexes populate in the background; check state is ONLINE before relying on them.

Vector index for embeddings (set vector.dimensions to your model's size, for example 1536):

CREATE VECTOR INDEX doc_embeddings IF NOT EXISTS
  FOR (d:Doc) ON (d.embedding)
  OPTIONS {indexConfig: {`vector.dimensions`: 1536, `vector.similarity_function`: 'cosine'}};

CALL db.index.vector.queryNodes('doc_embeddings', 5, $queryEmbedding)
YIELD node, score RETURN node.title, score;

Step 5: Node.js driver

Create one driver per application and reuse it; sessions are cheap, drivers are not. executeQuery handles sessions, transactions and retries.

// db.js
const neo4j = require('neo4j-driver');

const driver = neo4j.driver(
  process.env.NEO4J_URI || 'neo4j://localhost:7687',
  neo4j.auth.basic(process.env.NEO4J_USER || 'neo4j', process.env.NEO4J_PASSWORD)
);

async function findFriends(name) {
  const { records } = await driver.executeQuery(
    'MATCH (p:Person {name: $name})-[:KNOWS]->(friend) RETURN friend.name AS name',
    { name },
    { database: 'neo4j', routing: neo4j.routing.READ }
  );
  return records.map(r => r.get('name'));
}

async function createFriendship(person1, person2) {
  await driver.executeQuery(
    `M
Полный SKILL.md на GitHub

Установить neo4j в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл neo4j?

Neo4j is a graph database that stores nodes and relationships and is queried with Cypher. Use when a user asks to model connected data, write Cypher queries, find shortest paths or recommendations, create indexes and constraints, run Neo4j in Docker, or connect from Node.js or Python with the official drivers. Covers social graphs, fraud detection, knowledge graphs and vector search.

Как установить скилл neo4j?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл neo4j запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить neo4j с