SpiceDB Client Integration
This skill helps you add a SpiceDB client to any project, in any of the seven languages
SpiceDB ships client libraries for: Go, Python, TypeScript, C#, Java, Rust, and Ruby. It is
general-purpose -- use it any time a codebase needs to talk to SpiceDB, whether that's a new
integration or one step in a larger migration.
Prototype status
The seven clients this skill covers are a prototype, vendored at a pinned commit rather
than installed as published packages. APIs, types, and behaviors may change or break upstream
at any time. See references/installation.md for the exact commit, why vendoring is the only
supported path for these clients, and what changes (and what doesn't) once they are
published. Every other file in this skill assumes you've already read that one.
This is not a claim that SpiceDB has no published clients. Authzed's established client
family is generally available and is what the rest of this plugin uses -- authzed-go
(v1.10.0), @authzed/authzed-node (1.6.1), authzed on PyPI (1.25.0), Authzed.Net
(1.6.0), all verified live and tabled in spicedb-best-practices/references/ client-patterns.md, which is where /spicedb-dev:implement-spicedb-checks and its siblings
already point. Use this skill when you specifically want the prototype's API, or one of the
three languages only it covers (Java, Rust, Ruby); use the established client otherwise.
references/installation.md has the per-registry evidence for both halves of that split.
Overview
Getting a SpiceDB client working in a project has two parts:
- Obtain the client. All seven languages are vendored the same way -- the language's
client directory plus its sibling
proto-clients/ directory, at one pinned commit.
references/installation.md is the only file in this skill that covers this; it's
written so that when the clients are published, that file changes to package installs and
nothing else here moves.
- Use the client correctly. The seven idiomatic clients differ in naming convention
(
NewPlaintext vs CreatePlaintext, snake_case vs camelCase) but share the same
underlying types and concepts. references/core-concepts.md covers that shared vocabulary
once, so you don't need to relearn it per language.
Quick Reference
| Need to... |
Read this |
| Obtain the client for any language (vendoring, pinned commit, prototype status) |
references/installation.md |
Shared vocabulary: Relationship/Filter/Transaction, consistency helpers, streaming iteration |
references/core-concepts.md |
LookupResources limits that affect UI/product design (no total count, duplicate resource IDs whether or not you paginate, 1000-per-call cap) |
references/core-concepts.md |
Per-language references
This skill routes by language for anything beyond the shared vocabulary. All seven are
written; each lives at references/<language>.md:
| Language |
Reference |
| Go |
references/go.md |
| Python |
references/python.md |
| TypeScript |
references/typescript.md |
| C# |
references/csharp.md |
| Java |
references/java.md |
| Rust |
references/rust.md |
| Ruby |
references/ruby.md |
Each one is verified against a live spicedb serve-testing run in that language. For anything
those seven don't cover, the vendored client's own examples/ directory (see
references/installation.md) is the next stop -- every idiomatic client ships runnable
examples for construction, writes, checks, and lookups.
Typed wrappers (spicedb-gen)
Four of the seven languages -- Go, Java, Python, TypeScript -- have an additional option:
spicedb-gen reads a .zed schema and generates a compile-time-checked wrapper (invalid
resource types, permissions, or subject types become compiler errors instead of runtime
PermissionDenieds). C#, Ruby, and Rust don't have generator support; use the idiomatic client
directly. references/installation.md covers obtaining spicedb-gen alongside the client
you're vendoring.
Read references/spicedb-gen.md's "Known limitations" before adopting it. A
self-referential resource type -- relation parent: folder inside definition folder, one of
the most common hierarchy shapes there is -- crashes the generator outright in all four
languages (exit 2, goroutine stack exceeds 1000000000-byte limit). That file is the only
place this is recorded, a fix is in progress upstream, and until it lands the typed wrapper is
an option to evaluate rather than a default to reach for.
Red Flags
If you find yourself:
- Reaching for a package manager to install this client --
npm install @spicedb/client,
pip install spicedb, cargo add spicedb, go get on the prototype's repo path. None of
the seven is published, and two of those names resolve to other people's libraries (PyPI
spicedb and NuGet SpiceDb are both unofficial third-party clients), so the install
succeeds and gives you the wrong code. Read references/installation.md for the vendoring
path -- and note that npm install @authzed/authzed-node (or pip install authzed,
go get github.com/authzed/authzed-go) is a perfectly good thing to do; it just gets you
Authzed's established client, which this skill is not about.
- Copying a consistency level from another call site without thinking about it -- read
references/core-concepts.md's consistency section; the wrong default causes either stale
reads or needless latency.
- Building a "Showing 1-20 of 150" pager on top of
LookupResources -- read
references/core-concepts.md first; that count does not exist.
- Deduplicating
LookupResources results only when you notice duplicates in testing -- it's
not an edge case, it's mandatory whenever a resource is reachable through more than one
relation; see references/core-concepts.md.
- Restating what a client's own comments or documentation claim it does, instead of what its
compiled signatures do -- prose and code have already diverged for at least one of the seven
clients (see
references/core-concepts.md's "Trust the code, not the docs" section). Trust
the code.
What This Skill Does NOT Do
- Map OpenFGA concepts onto SpiceDB clients, or otherwise cover migration-specific vocabulary
-- that lives in a separate migration pack, deliberately, so this skill stays useful to any
project adding a SpiceDB client, migration or not.
- Design SpiceDB schemas -- use
spicedb-schema-design for that.
- Cover consistency models, retries, caveats, and performance tuning in depth for
already-published clients --
spicedb-best-practices covers that ground for Go/TypeScript/
Python assuming a normal package install; this skill exists because the real clients aren't
installed that way yet, and cover three more languages besides.
- Write authorization tests -- use
authorization-testing for that.
Additional Resources
Reference Files
references/installation.md -- obtaining the client (the only file that covers this),
including which packages are published and which are other people's
references/core-concepts.md -- vocabulary shared across all seven languages, plus the
LookupResources product-level limits
references/<language>.md -- one per language: go, python, typescript, csharp,
java, rust, ruby
references/spicedb-gen.md -- the typed-wrapper generator: what it emits per language,
and its Known limitations, including the self-referential-type crash
External Resources
Workflow summary: Read references/installation.md and vendor the client for your
language (client directory + sibling proto-clients/ directory, at the pinned commit) -->
read references/core-concepts.md for the shared types, consistency helpers, and
LookupResources limits --> find your language's reference for idiomatic patterns, or fall
back to the vendored client's own examples/ directory if it isn't written yet.
1---2name: spicedb-client-integration3description: Use when adding a SpiceDB client library to a project in Go, Python, TypeScript, C#, Java, Rust, or Ruby - covers obtaining the prototype client and the common patterns (relationships, consistency, streaming lookups) shared across all seven languages4---56# SpiceDB Client Integration78This skill helps you add a SpiceDB client to any project, in any of the seven languages9SpiceDB ships client libraries for: Go, Python, TypeScript, C#, Java, Rust, and Ruby. It is10general-purpose -- use it any time a codebase needs to talk to SpiceDB, whether that's a new11integration or one step in a larger migration.1213## Prototype status1415**The seven clients this skill covers are a prototype**, vendored at a pinned commit rather16than installed as published packages. APIs, types, and behaviors may change or break upstream17at any time. See `references/installation.md` for the exact commit, why vendoring is the only18supported path *for these clients*, and what changes (and what doesn't) once they are19published. Every other file in this skill assumes you've already read that one.2021**This is not a claim that SpiceDB has no published clients.** Authzed's established client22family is generally available and is what the rest of this plugin uses -- `authzed-go`23(`v1.10.0`), `@authzed/authzed-node` (`1.6.1`), `authzed` on PyPI (`1.25.0`), `Authzed.Net`24(`1.6.0`), all verified live and tabled in `spicedb-best-practices/references/25client-patterns.md`, which is where `/spicedb-dev:implement-spicedb-checks` and its siblings26already point. Use this skill when you specifically want the prototype's API, or one of the27three languages only it covers (Java, Rust, Ruby); use the established client otherwise.28`references/installation.md` has the per-registry evidence for both halves of that split.2930## Overview3132Getting a SpiceDB client working in a project has two parts:33341. **Obtain the client.** All seven languages are vendored the same way -- the language's35 client directory plus its sibling `proto-clients/` directory, at one pinned commit.36 `references/installation.md` is the *only* file in this skill that covers this; it's37 written so that when the clients are published, that file changes to package installs and38 nothing else here moves.392. **Use the client correctly.** The seven idiomatic clients differ in naming convention40 (`NewPlaintext` vs `CreatePlaintext`, `snake_case` vs `camelCase`) but share the same41 underlying types and concepts. `references/core-concepts.md` covers that shared vocabulary42 once, so you don't need to relearn it per language.4344## Quick Reference4546| Need to... | Read this |47|-----------|-----------|48| Obtain the client for any language (vendoring, pinned commit, prototype status) | `references/installation.md` |49| Shared vocabulary: `Relationship`/`Filter`/`Transaction`, consistency helpers, streaming iteration | `references/core-concepts.md` |50| `LookupResources` limits that affect UI/product design (no total count, duplicate resource IDs whether or not you paginate, 1000-per-call cap) | `references/core-concepts.md` |5152### Per-language references5354This skill routes by language for anything beyond the shared vocabulary. All seven are55written; each lives at `references/<language>.md`:5657| Language | Reference |58|----------|-----------|59| Go | `references/go.md` |60| Python | `references/python.md` |61| TypeScript | `references/typescript.md` |62| C# | `references/csharp.md` |63| Java | `references/java.md` |64| Rust | `references/rust.md` |65| Ruby | `references/ruby.md` |6667Each one is verified against a live `spicedb serve-testing` run in that language. For anything68those seven don't cover, the vendored client's own `examples/` directory (see69`references/installation.md`) is the next stop -- every idiomatic client ships runnable70examples for construction, writes, checks, and lookups.7172## Typed wrappers (`spicedb-gen`)7374Four of the seven languages -- Go, Java, Python, TypeScript -- have an additional option:75`spicedb-gen` reads a `.zed` schema and generates a compile-time-checked wrapper (invalid76resource types, permissions, or subject types become compiler errors instead of runtime77`PermissionDenied`s). C#, Ruby, and Rust don't have generator support; use the idiomatic client78directly. `references/installation.md` covers obtaining `spicedb-gen` alongside the client79you're vendoring.8081**Read `references/spicedb-gen.md`'s "Known limitations" before adopting it.** A82self-referential resource type -- `relation parent: folder` inside `definition folder`, one of83the most common hierarchy shapes there is -- crashes the generator outright in all four84languages (`exit 2`, `goroutine stack exceeds 1000000000-byte limit`). That file is the only85place this is recorded, a fix is in progress upstream, and until it lands the typed wrapper is86an option to evaluate rather than a default to reach for.8788## Red Flags8990If you find yourself:91- Reaching for a package manager to install **this** client -- `npm install @spicedb/client`,92 `pip install spicedb`, `cargo add spicedb`, `go get` on the prototype's repo path. None of93 the seven is published, and two of those names resolve to *other people's* libraries (PyPI94 `spicedb` and NuGet `SpiceDb` are both unofficial third-party clients), so the install95 succeeds and gives you the wrong code. Read `references/installation.md` for the vendoring96 path -- and note that `npm install @authzed/authzed-node` (or `pip install authzed`,97 `go get github.com/authzed/authzed-go`) is a perfectly good thing to do; it just gets you98 Authzed's established client, which this skill is not about.99- Copying a consistency level from another call site without thinking about it -- read100 `references/core-concepts.md`'s consistency section; the wrong default causes either stale101 reads or needless latency.102- Building a "Showing 1-20 of 150" pager on top of `LookupResources` -- read103 `references/core-concepts.md` first; that count does not exist.104- Deduplicating `LookupResources` results only when you notice duplicates in testing -- it's105 not an edge case, it's mandatory whenever a resource is reachable through more than one106 relation; see `references/core-concepts.md`.107- Restating what a client's own comments or documentation claim it does, instead of what its108 compiled signatures do -- prose and code have already diverged for at least one of the seven109 clients (see `references/core-concepts.md`'s "Trust the code, not the docs" section). Trust110 the code.111112## What This Skill Does NOT Do113114- Map OpenFGA concepts onto SpiceDB clients, or otherwise cover migration-specific vocabulary115 -- that lives in a separate migration pack, deliberately, so this skill stays useful to any116 project adding a SpiceDB client, migration or not.117- Design SpiceDB schemas -- use `spicedb-schema-design` for that.118- Cover consistency models, retries, caveats, and performance tuning in depth for119 already-published clients -- `spicedb-best-practices` covers that ground for Go/TypeScript/120 Python assuming a normal package install; this skill exists because the real clients aren't121 installed that way yet, and cover three more languages besides.122- Write authorization tests -- use `authorization-testing` for that.123124## Additional Resources125126### Reference Files127128- **`references/installation.md`** -- obtaining the client (the only file that covers this),129 including which packages *are* published and which are other people's130- **`references/core-concepts.md`** -- vocabulary shared across all seven languages, plus the131 `LookupResources` product-level limits132- **`references/<language>.md`** -- one per language: `go`, `python`, `typescript`, `csharp`,133 `java`, `rust`, `ruby`134- **`references/spicedb-gen.md`** -- the typed-wrapper generator: what it emits per language,135 and its **Known limitations**, including the self-referential-type crash136137### External Resources138139- [SpiceDB Clients](https://authzed.com/docs/spicedb/getting-started/clients) -- official140 client documentation (for the eventual published packages)141- [Consistency Explained](https://authzed.com/docs/spicedb/concepts/consistency) -- consistency142 model details143144---145146**Workflow summary:** Read `references/installation.md` and vendor the client for your147language (client directory + sibling `proto-clients/` directory, at the pinned commit) -->148read `references/core-concepts.md` for the shared types, consistency helpers, and149`LookupResources` limits --> find your language's reference for idiomatic patterns, or fall150back to the vendored client's own `examples/` directory if it isn't written yet.