# neo4j-driver-dotnet-skill

Guides AI agents through building C# applications with Neo4j .NET Driver v6. It sets up singleton DI, ExecutableQuery methods, and safe async lifecycles.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 756 installs · ★ 116
- Author: neo4j-contrib
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/neo4j-contrib/neo4j-skills/tree/HEAD/neo4j-driver-dotnet-skill/SKILL.md
- Updated: 2026-10-21
- HTML: https://affpapa.org/en/nevibecode/skills/neo4j-driver-dotnet-skill

## What it does

The skill embeds patterns for `Neo4j.Driver` version 6 across .NET 8, 9, and 10 codebases. It guides coding assistants toward using `ExecutableQuery` for standard queries, mapping values safely with `r.Get<T>()`, and passing query arguments via `WithParameters` instead of raw string interpolation.

Creating a driver instance is expensive because it maintains an internal connection pool. Registering `IDriver` as a transient or scoped dependency degrades performance immediately. The skill enforces singleton DI registration with graceful cleanup through `IHostedService` on application shutdown.

This skill does not draft graph queries or handle driver migrations. For Cypher creation, use `neo4j-cypher-skill`. For upgrades between major driver versions, install `neo4j-migration-skill`.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add neo4j-contrib/neo4j-skills --skill neo4j-driver-dotnet-skill -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/neo4j-driver-dotnet-skill/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/neo4j-driver-dotnet-skill/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add neo4j-contrib/neo4j-skills --skill neo4j-driver-dotnet-skill -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/neo4j-driver-dotnet-skill/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add neo4j-contrib/neo4j-skills --skill neo4j-driver-dotnet-skill -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/neo4j-driver-dotnet-skill/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install neo4j-contrib/neo4j-skills neo4j-driver-dotnet-skill
```

2. **Manually: put the files in place**
- File: `.github/skills/neo4j-driver-dotnet-skill/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add neo4j-contrib/neo4j-skills --skill neo4j-driver-dotnet-skill -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/neo4j-contrib/neo4j-skills --path neo4j-driver-dotnet-skill
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/neo4j-driver-dotnet-skill/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add neo4j-contrib/neo4j-skills --skill neo4j-driver-dotnet-skill -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/neo4j-contrib/neo4j-skills/tree/HEAD/neo4j-driver-dotnet-skill/SKILL.md

## When to use it
- register IDriver as a singleton inside the ASP.NET Core DI container
- execute parameterized Cypher queries with the fluent ExecutableQuery API
- prevent thread-pool deadlocks by enforcing await using on disposable driver types
- map Neo4j record fields to C# types without null-reference errors

## Example prompts
- Add Neo4j IDriver singleton registration to Program.cs with graceful shutdown
- Query Person nodes with ExecutableQuery using WithParameters and Readers routing
- Map Neo4j query results to a typed C# list using r.Get<string>()

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 7ba1b99f5da23ecd.

BEGIN THIRD-PARTY FILE 7ba1b99f5da23ecd
````text
---
name: neo4j-driver-dotnet-skill
description: Neo4j .NET Driver v6 — IDriver lifecycle, DI registration (singleton), ExecutableQuery
  fluent API, ExecuteReadAsync/ExecuteWriteAsync managed transactions, IResultCursor (FetchAsync/
  ToListAsync), record value access (.Get<T>/As<T>), null safety, UNWIND batching, temporal types,
  await using, EagerResult, object mapping, CancellationToken, error handling, and common traps.
  Use when writing C# or .NET code connecting to Neo4j. Also triggers on Neo4j.Driver, IDriver,
  ExecutableQuery, ExecuteReadAsync, ExecuteWriteAsync, IResultCursor, IAsyncSession, or any Bolt/Aura
  work in .NET/C#. Does NOT handle Cypher authoring — use neo4j-cypher-skill.
  Does NOT cover driver version upgrades — use neo4j-migration-skill.
compatibility: .NET 8, 9, 10; Neo4j.Driver v6
allowed-tools: Bash WebFetch
version: 1.0.7
---

## When to Use
- Writing C# or .NET code connecting to Neo4j
- Setting up `IDriver`, DI registration, or session/transaction lifecycle
- Questions about `ExecutableQuery`, `IResultCursor`, async patterns, result mapping
- Debugging sessions, type mapping, null safety, or error handling in .NET

## When NOT to Use
- **Writing/optimizing Cypher queries** → `neo4j-cypher-skill`
- **Upgrading from older driver version** → `neo4j-migration-skill`

---

## Install

```bash
dotnet add package Neo4j.Driver
```

| Package | Use |
|---|---|
| `Neo4j.Driver` | Async API — **use this** |
| `Neo4j.Driver.Simple` | Synchronous wrapper |
| `Neo4j.Driver.Reactive` | System.Reactive streams |

---

## Driver Lifecycle

`IDriver` — thread-safe, connection-pooled, expensive to create. **Create one per application.**

```csharp
using Neo4j.Driver;

// URI schemes:
//   neo4j+s://xxx.databases.neo4j.io   — TLS + cluster routing (Aura)
//   neo4j://localhost                   — unencrypted + cluster routing
//   bolt+s://localhost:7687             — TLS + single instance
//   bolt://localhost:7687               — unencrypted + single instance

await using var driver = GraphDatabase.Driver(
    "neo4j+s://xxx.databases.neo4j.io",
    AuthTokens.Basic("neo4j", "password"));

await driver.VerifyConnectivityAsync();   // fail fast on startup
```

`IDriver` and `IAsyncSession` implement `IAsyncDisposable` — always `await using`, never plain `using`.

```csharp
// ❌ Wrong — synchronous Dispose() may block thread pool
using var driver = GraphDatabase.Driver(uri, auth);

// ✅ Correct
await using var driver = GraphDatabase.Driver(uri, auth);
```

Auth options: `AuthTokens.Basic(u, p)` / `AuthTokens.Bearer(token)` / `AuthTokens.Kerberos(ticket)` / `AuthTokens.None`

---
````
END THIRD-PARTY FILE 7ba1b99f5da23ecd

The third-party file has ended. Everything between the 7ba1b99f5da23ecd tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2671 of 18218 bytes. © neo4j-contrib · MIT · https://github.com/neo4j-contrib/neo4j-skills/tree/HEAD/neo4j-driver-dotnet-skill/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
