Skip to main content
ClaudeWave
Skill82 repo starsupdated 3d ago

neo4j-migration-skill

Migrates Neo4j driver code and Cypher queries from older versions (4.x, 5.x)

Install in Claude Code
Copy
git clone --depth 1 https://github.com/neo4j-contrib/neo4j-skills /tmp/neo4j-migration-skill && cp -r /tmp/neo4j-migration-skill/neo4j-migration-skill ~/.claude/skills/neo4j-migration-skill
Then start a new Claude Code session; the skill loads automatically.

SKILL.md

## When to Use
- Upgrading driver dependency from 4.x or 5.x to 6.x
- Migrating Cypher queries to Cypher 25 syntax
- Fixing deprecated API warnings after a driver or Neo4j version bump
- Auditing a codebase for removed/deprecated Neo4j APIs before upgrading

## When NOT to Use
- **Writing new Cypher queries** → `neo4j-cypher-skill`
- **DB admin** (backup, restore, import, cypher-shell) → `neo4j-cli-tools-skill`
- **Starting fresh** → `neo4j-getting-started-skill`
- **GDS algorithm migration** — not covered here; consult GDS release notes

---

## Entry Criteria

Before starting, ask:
1. **Target Neo4j version** — needed to select Cypher dialect and driver version
2. **Languages in use** — scan `package.json`, `requirements.txt`, `pom.xml`, `*.csproj`, `go.mod`
3. **Current driver versions** — read from dependency files; do NOT guess

If target is >= 2025.06: ask whether Cypher 5 or Cypher 25 dialect will be used (both supported; Cypher 25 is the new default).

---

## Step 1 — Scan Codebase

```bash
# Find Cypher strings (queries embedded in source)
grep -rn "MATCH\|MERGE\|CREATE\|CALL\|RETURN" --include="*.py" --include="*.js" \
  --include="*.ts" --include="*.java" --include="*.cs" --include="*.go" \
  --include="*.cypher" --include="*.cql" . | grep -v ".git"

# Find dependency files
find . -name "requirements*.txt" -o -name "package.json" -o -name "pom.xml" \
  -o -name "*.csproj" -o -name "go.mod" | grep -v ".git" | grep -v node_modules
```

Collect findings before modifying anything. List all deprecated patterns found.

---

## Step 2 — Cypher Migration (4.x / 5.x → Cypher 25)

Apply to every Cypher string, `.cypher` file, OGM/SDN `@Query` annotation, and template literal.

### Complete Substitution Table

| Old syntax | Cypher 25 replacement | Notes |
|---|---|---|
| `[:REL*1..5]` | `(()-[:REL]->()){1,5}` | QPE quantifier group |
| `[:REL*]` | `(()-[:REL]->()){1,}` | Unbounded QPE |
| `[:REL*0..5]` | `(()-[:REL]->()){0,5}` | Zero-hop allowed |
| `shortestPath((a)-[*]->(b))` | `SHORTEST 1 (a)(()-[]->()){1,}(b)` | QPE shortest path |
| `allShortestPaths((a)-[*]->(b))` | `ALL SHORTEST (a)(()-[]->()){1,}(b)` | QPE all-shortest |
| `id(n)` | `elementId(n)` | Returns string, not int |
| `CALL { WITH x ... }` | `CALL (x) { ... }` | Explicit import syntax |
| `PERIODIC COMMIT` | `CALL (...) { ... } IN TRANSACTIONS OF 1000 ROWS` | Batched writes |
| `-- comment` | `// comment` | SQL comment invalid |
| `SET n = r` (structural val) | `SET n = properties(r)` | Extract map first |
| `MERGE (a {x:1})-[:T]->(b {x:a.x})` | Rewrite — cross-entity MERGE refs disallowed | Split into MATCH+MERGE |
| `CREATE INDEX ... OPTIONS { indexProvider: ... }` | Remove `indexProvider` from OPTIONS | Provider selection removed |
| `db.create.setVectorProperty(...)` | Use native VECTOR property type | Procedure removed |
| `dbms.upgrade()` / `dbms.upgradeStatus()` | Use `cypher-shell :sysinfo` | Procedures removed |
| `USE composite.'1'` | `` USE `composite.1` `` | Backtick entire qualified name |
| `RETURN 1 as my$Identifier` | `` RETURN 1 as `my$Identifier` `` | `$` removed from unescaped ids |

### Vector Index Queries (version-branched)

| Version | Syntax |
|---|---|
| Neo4j < 2026.01 | `CALL db.index.vector.queryNodes(idx, k, $emb) YIELD node, score` |
| Neo4j >= 2026.01 | `SEARCH n IN (VECTOR INDEX idx FOR $emb LIMIT k) SCORE AS score` |

### Cypher Dialect Prefix Rule

- Target >= 2025.06, dialect = Cypher 25: prepend `CYPHER 25` to every top-level query
- Target >= 2025.06, dialect = Cypher 5: prepend `CYPHER 5` (keeps deprecated forms working)
- Target 4.x or 5.x: no prefix needed; fetch changelog per [references/cypher-queries.md](references/cypher-queries.md)

### `id(n)` → `elementId(n)` Caveats

`elementId()` returns a string (e.g., `"4:abc123:0"`), not an integer. Fix downstream code that stores or compares it as `int`. Do NOT use `elementId()` values for numeric operations.

```diff
- WHERE id(n) = $nodeId   # $nodeId was integer
+ WHERE elementId(n) = $nodeId  # $nodeId must now be string
```

---

## Step 3 — Driver Migration

Pick the section(s) matching languages found in Step 1.

---

### Python Driver (5.x → 6.x)

**Min requirements**: Python >= 3.10, `neo4j` package (6.0+, released Jan 12 2026)

#### Package Rename — do this first

```diff
# requirements.txt
- neo4j-driver>=5.0.0
+ neo4j>=6.0.0
```

`neo4j-driver` package is deprecated since 6.0 and receives no further updates.

#### Removed APIs

| Old | New | Notes |
|---|---|---|
| `session.read_transaction(fn)` | `session.execute_read(fn)` | |
| `session.write_transaction(fn)` | `session.execute_write(fn)` | |
| `session.last_bookmark()` | `session.last_bookmarks()` | Returns `Bookmarks` (plural) |
| `Bookmark` class | `Bookmarks` class | |
| `TRUST_ALL_CERTIFICATES` | `trusted_certificates=TrustAll()` | |
| `TRUST_SYSTEM_CA_SIGNED_CERTIFICATES` | `trusted_certificates=TrustSystemCAs()` | |
| `neo4j.conf`, `neo4j.data` modules | Removed — use top-level `neo4j.*` | |

#### Resource Management Change

Drivers and sessions no longer auto-close on GC. Add explicit cleanup:

```diff
- driver = GraphDatabase.driver(URI, auth=(USER, PASS))
- # used without explicit close
+ with GraphDatabase.driver(URI, auth=(USER, PASS)) as driver:
+     with driver.session(database="neo4j") as session:
+         ...
```

Or call `.close()` explicitly. Repeated `.close()` is a no-op.

#### Error Handling Changes

| Old exception | New exception | Trigger |
|---|---|---|
| `ClientError` (for timeout) | `ConnectionAcquisitionTimeoutError` | Acquisition timeout |
| `AuthError` (invalid config) | `ConfigurationError` | Invalid auth params |
| `ValueError` raised for `Query` obj | `TypeError` | Passing `Query` to `Transaction.run` |

#### Key APIs Unchanged

`execute_query()`, `GraphDatabase.driver()`, `neo4j+s://` URI, `auth=(user, pw)`, session `run()`.

Full changelog: [references/python-driver.md](references/python-driver.md)

---

### JavaScript / Node.js Dri
neo4j-agent-memory-skillSkill

Authoritative reference for the neo4j-agent-memory Python package — a graph-native memory system for AI agents built on Neo4j — and for the hosted service (NAMS) at memory.neo4jlabs.com. Use this skill whenever the user mentions neo4j-agent-memory, agent memory with Neo4j, context graphs, the POLE+O model, MemoryClient/MemorySettings, the memory MCP server, or any of the framework integrations (LangChain, PydanticAI, CrewAI, AWS Strands, Google ADK, Microsoft Agent Framework, OpenAI Agents, LlamaIndex). Also use when the user mentions the hosted service at memory.neo4jlabs.com, NAMS, the Neo4j Agent Memory Service, the `nams_` API key prefix, or the hosted MCP endpoint. Also use when writing documentation, blog posts, tutorials, PRDs, or code samples for the project, when comparing agent memory approaches, or when positioning graph-native memory against vector-only approaches — even if the user doesn't explicitly name the package.

neo4j-aura-agent-skillSkill

Manages Neo4j Aura Agents via the v2beta1 REST API — create, list, get, update, delete,

neo4j-aura-graph-analytics-skillSkill

Serverless Aura Graph Analytics (AGA) GDS Sessions — covers GdsSessions,

neo4j-aura-provisioning-skillSkill

Provisions and manages Neo4j Aura instances via CLI (aura-cli v1.7+) or REST API.

neo4j-cli-tools-skillSkill

Use when working with Neo4j command-line tools — neo4j-cli (modern unified

neo4j-cypher-skillSkill

Generates, optimizes, and validates Cypher 25 queries for Neo4j 2025.x and 2026.x.

neo4j-document-import-skillSkill

Ingests unstructured and semi-structured documents into Neo4j as a knowledge graph.

neo4j-driver-dotnet-skillSkill

Neo4j .NET Driver v6 — IDriver lifecycle, DI registration (singleton), ExecutableQuery