FoundationDB .NET Keys and Layers
Helps you design FoundationDB keys, values, subspaces and layers in .NET with the client's safe, typed API.
Claude's review
8/10 Thorough FoundationDB .NET key, value, subspace, versionstamp and layer guidance with clear do and don't rules.
We asked Claude the question you would ask: would I be glad I installed this? Two separate reviews, the second blind to the first, must both rate a skill 7 or higher before we sell it.
In detail
How to correctly encode keys and values, use subspaces and the Directory layer, and write custom "Layers" with the FoundationDB .NET client (FoundationDB.Client / SnowBank). Covers the lazy strongly-typed key structs (subspace.Key(...), FdbTupleKey, FdbRawKey, FdbKey.Increment / Successor / Dump), the tuple encoding (TuPack, IVarTuple, STuple), value encodings (FdbValue.ToBytes / ToTextUtf8 / FromTuple / ToJson / ToFixed64LittleEndian and which one a given access pattern requires), subspaces and ISubspaceLocation, the Directory layer (FdbDirectoryLayer, FdbPath, FdbDirectorySubspace), and the IFdbLayer contract with its per-transaction Resolve(tr) State that must never escape the transaction. Use whenever code reads or writes FoundationDB keys, builds or decodes a tuple key, picks a value encoding, resolves a subspace or location, designs a key layout for a table / secondary index / queue / document collection, reasons about key ordering, prefixes and range boundaries, or defines a class that stores data in F
How you use it
- Add it to your pack, then download your pack (1 credit).
- In Claude, open Customize > Skills and upload the zip. Code execution needs to be on under Settings > Capabilities.
- Ask Claude for the job in your own words. It uses the skill when your request matches what it does. Step by step guide
Safety check
Nothing risky found: no hidden instructions, no download and run, no reading of saved passwords or keys.
An automated scan lowers risk but cannot promise zero risk. How we check skills
Preview
The first lines of SKILL.md
---
name: foundationdb-keys-and-layers
description: >-
How to correctly encode keys and values, use subspaces and the Directory layer, and write custom "Layers"
with the FoundationDB .NET client (FoundationDB.Client / SnowBank). Covers the lazy strongly-typed key
structs (subspace.Key(...), FdbTupleKey, FdbRawKey, FdbKey.Increment / Successor / Dump), the tuple encoding
(TuPack, IVarTuple, STuple), value encodings (FdbValue.ToBytes / ToTextUtf8 / FromTuple / ToJson /
ToFixed64LittleEndian and which one a given access pattern requires), subspaces and ISubspaceLocation, the
Directory layer (FdbDirectoryLayer, FdbPath, FdbDirectorySubspace), and the IFdbLayer contract with its
per-transaction Resolve(tr) State that must never escape the transaction. Use whenever code reads or writes
FoundationDB keys, builds or decodes a tuple key, picks a value encoding, resolves a subspace or location,
designs a key layout for a table / secondary index / queue / document collection, reasons about key ordering,
prefixes and range boundaries, or defines a class that stores data in FoundationDB. Also use it for "how do I
model X in FoundationDB", for range scans that return too much or nothing, and for keys that are too big.
Read this BEFORE writing or reviewing any such code.
---
# FoundationDB .NET — Keys, Values & Layers
FoundationDB is a **single, flat, ordered key/value store**. Both keys and values are byte strings. Keys are sorted **lexicographically by their raw bytes**, and that ordering is the *only* structure the database gives you — every "table", "index", "queue", or "document collection" is an illusion built by choosing key bytes carefully. Getting the key encoding right is therefore the whole game. This skill explains the idiomatic, type-safe API this client provides so you don't reinvent (incorrectly) what already exists.
> If you remember one thing: **you almost never touch raw bytes.** You build keys with `subspace.Key(...)` and values with `FdbValue.*`, and you pass those objects *directly* to the transaction. The library renders them to bytes for you, efficiently, at the last moment.
---
## 1. The mental model
- A **subspace** is a key prefix. All keys you create live "inside" it. You get subspaces from a **location** resolved against a transaction (see §6). Never hard-code prefixes.
- **Tuple encoding** (`TuPack`) turns typed elements — strings, integers, GUIDs, booleans, `VersionStamp`, … — into bytes whose **byte order matches the logical order** of the values. `(42, "hello")` always sorts before `(42, "world")` and before `(43, …)`. This order-preservation is why tuples are the default key encoding.
- A **key** in this API is a small **struct** (e.g. `FdbTupleKey<string,int>`) that *remembers its subspace and its elements* and knows how to render itself. It is **lazy**: no bytes exist until the transaction asks for them.
- A **value** is likewise a lightweight encodable (e.g. `FdbRawValue`, `FdbVarTupleValue`, `FdbJsonValue`) produced by `FdbValue.*`.
---
## 2. Golden rules (this is where vibe-coded usage goes wrong)
✅ **DO**
- Build keys with `subspace.Key(a, b, c)` and pass the result straight into `tr.GetAsync(...)` / `tr.Set(...)`.
- Build values with `FdbValue.ToBytes(...)`, `FdbValue.FromTuple(...)`, `FdbValue.ToTextUtf8(...)`, `FdbValue.ToFixed64LittleEndian(...)`, `FdbValue.ToJson(...)`.
...From SnowBankSDK's repository, BSD-3-Clause licence.
Related skills
-
Checked
Supabase auth and database
Builds with Supabase auth, database, storage and edge functions while avoiding common security traps.
8/101 credit -
Checked
AWS schema conversion
Runs AWS DMS Schema Conversion projects to move database schemas between engines and convert SQL to match.
7/101 credit -
Checked
Firebase Done Right
Builds Firebase apps with safe security rules, data models that scale and reliable Cloud Functions.
7/101 credit -
Checked
Google Workspace API Setup
Connects your server code to Gmail, Drive, Calendar and Sheets with safe service accounts and fewer quota errors.
7/101 credit -
Checked
Supabase Backend Security
Wires up Supabase auth, row level security, storage and realtime so your data stays private and queries stay fast.
8/101 credit -
Checked
NestJS API endpoints
Adds NestJS endpoints with proper validation, status codes and the traps that break startup fixed.
8/101 credit