-
Notifications
You must be signed in to change notification settings - Fork 47
Document the spicedb-dev AI agent plugin #588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
667dce5
fix(best-practices): make sidebar priority links navigate from other …
samkim da769db
docs(getting-started): add Build with your AI agent page for the spic…
samkim 7774d8c
docs(first-steps): point to the spicedb-dev AI agent plugin from the …
samkim 0ffbc71
docs(best-practices): recommend the spicedb-dev plugin for AI-assiste…
samkim 9604346
docs(spicedb-dev-plugin): address final review findings (formatting, …
samkim f5d58e6
docs(build-with-an-agent): generalize migration-source references, ve…
samkim 104218b
docs(spicedb-dev-plugin): mention OSO as a supported migration source
samkim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
app/spicedb/getting-started/build-with-an-agent/page.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| --- | ||
| title: "Build with your AI agent" | ||
| description: "Install the spicedb-dev plugin for Claude Code, Codex CLI, or any AGENTS.md-based agent to design, implement, test, harden, and migrate SpiceDB authorization with AI assistance." | ||
| --- | ||
|
|
||
| import { Callout, Cards } from "nextra/components"; | ||
|
|
||
| # Build with your AI agent | ||
|
|
||
| If you're building with an AI coding agent, you don't have to design and wire up SpiceDB authorization by hand. | ||
| The `spicedb-dev` plugin teaches your agent how to design a permission model, generate a schema, write the relationship and permission-check code, audit coverage as your app grows, generate tests, and migrate an existing authorization solution (OpenFGA, Okta FGA, OSO, etc.) onto SpiceDB. | ||
| It's useful throughout the lifecycle, from exploration and design through implementation and testing, and can also help debug and harden an authorization setup you already have. | ||
|
|
||
| It's an official AuthZed plugin, distributed through the [AuthZed marketplace](https://github.com/authzed/authzed-marketplace). | ||
|
|
||
| <Callout type="info"> | ||
| Treat the plugin's output like any AI-generated code: review and validate it before you rely on | ||
| it, especially when it's touching an existing authorization setup. | ||
| </Callout> | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - An AI coding agent. | ||
| See [Other agents](#other-agents) below if you're not using Claude Code or Codex CLI. | ||
| - A running SpiceDB instance for the implementation steps. | ||
| The fastest option is an in-memory instance with no setup: | ||
|
|
||
| ```bash | ||
| spicedb serve-testing | ||
| ``` | ||
|
|
||
| This starts SpiceDB on `localhost:50051` with no persistence: data is lost on restart, which is fine for development. | ||
| For a persistent local instance, see [Datastores](/spicedb/concepts/datastores); for a hosted, self-service instance, see [AuthZed Cloud](https://authzed.com/cloud). | ||
|
|
||
| - The [`zed` CLI](/spicedb/getting-started/installing-zed) installed: the plugin's schema-validator agent uses it to validate `.zed` files. | ||
|
|
||
| ## Install the plugin | ||
|
|
||
| ### Claude Code | ||
|
|
||
| ``` | ||
| /plugin marketplace add authzed/authzed-marketplace | ||
| /plugin install spicedb-dev@authzed-marketplace | ||
| ``` | ||
|
|
||
| ### Codex CLI | ||
|
|
||
| ```bash | ||
| codex plugin marketplace add authzed/authzed-marketplace | ||
| codex plugin add spicedb-dev@authzed-marketplace | ||
| ``` | ||
|
|
||
| ### Other agents | ||
|
|
||
| Claude Code and Codex CLI are the only integrations tested against this plugin. | ||
| If you're on a different AGENTS.md-reading harness, the most reliable path is to read the plugin's [skills](https://github.com/authzed/authzed-marketplace/tree/main/spicedb-dev/skills) directly from the marketplace repository and copy the authorization snippet described in [Plan your authorization](#plan-your-authorization) into your own `AGENTS.md` by hand. | ||
| That gets you the plugin's guidance without depending on slash-command support. | ||
|
|
||
| ## What the plugin can do | ||
|
|
||
| - **Design a permission model** interactively, starting from entities it finds in your existing data model (Prisma, Django, Go structs, GraphQL, or SQL) | ||
| - **Generate a SpiceDB schema** from that model, and validate any `.zed` file for anti-patterns | ||
| - **Implement authorization in code**: relationship writes (`WriteRelationships`, `DeleteRelationships`) and permission checks (`CheckPermission`, `BulkCheckPermission`, `LookupResources`, `LookupSubjects`) in Go, TypeScript, Python, C#, Java, Rust, and Ruby | ||
| - **Audit permission coverage** across your codebase: for every permission in your schema, see whether a check exists in code, and catch unfiltered list endpoints, which is useful for debugging and hardening an authorization setup you didn't build with the plugin, too | ||
| - **Generate tests**: positive, negative, and hierarchical-inheritance test fixtures and integration tests, generated from your schema | ||
| - **Migrate from an existing authorization solution** (OpenFGA, Okta FGA, OSO, etc.): convert the model, the relationship data, the application code, and the tests, then verify the migration with a differential test harness before cutover | ||
|
|
||
| ## Plan your authorization | ||
|
|
||
| Start any new project with: | ||
|
|
||
| ``` | ||
| /spicedb-dev:plan | ||
| ``` | ||
|
|
||
| This scopes the work and produces `authorization-plan.md`. | ||
| It also writes an authorization snippet into your project's `CLAUDE.md` (or `AGENTS.md`) — the single most effective step, since it means your agent considers SpiceDB writes and checks automatically whenever it generates or modifies a handler, without you invoking a command every time. | ||
|
|
||
| ## Build a feature end to end | ||
|
|
||
| | Situation | Run this | | ||
| | --------------------------------------------- | -------------------------------- | | ||
| | Have a data model, need a permission design | `/spicedb-dev:design-model` | | ||
| | Have a permission model, need a schema | `/spicedb-dev:generate-schema` | | ||
| | Have a schema, need it validated | `/spicedb-dev:validate-schema` | | ||
| | Have a schema, need it implemented in code | `/spicedb-dev:implement-spicedb` | | ||
| | Inherited a codebase, need a coverage picture | `/spicedb-dev:audit-coverage` | | ||
| | Feature set is stable, need tests | `/spicedb-dev:test-permissions` | | ||
|
|
||
| After generating a schema, deploy it to your SpiceDB instance: | ||
|
|
||
| ```bash | ||
| zed schema write schema.zed --endpoint localhost:50051 --token my-token | ||
| ``` | ||
|
|
||
| ## Migrating to SpiceDB | ||
|
|
||
| If you already run an existing authorization solution (OpenFGA, Okta FGA, OSO, etc.): | ||
|
|
||
| ``` | ||
| /spicedb-dev:migrate /path/to/your/project | ||
| ``` | ||
|
|
||
| This analyzes your project and holds a single pre-flight gate: every decision that can't be made mechanically (tenancy shape, identifier encoding, permission naming) is asked once, up front, and recorded. | ||
| From there it converts the schema, migrates relationship data, rewrites client call sites, and converts your tests, phase by phase. | ||
| It will not push, open a pull request, or work on your default branch, and it won't run your cutover for you — a generated differential test harness lets you dual-run SpiceDB beside your existing system and confirm the two agree before you flip over. | ||
|
|
||
| ## Learn more | ||
|
|
||
| <Cards> | ||
| <Cards.Card | ||
| arrow={true} | ||
| title="spicedb-dev plugin source and README" | ||
| href="https://github.com/authzed/authzed-marketplace/tree/main/spicedb-dev" | ||
| /> | ||
| <Cards.Card | ||
| arrow={true} | ||
| title="Best Practices" | ||
| href="/spicedb/best-practices#use-the-spicedb-dev-plugin-for-ai-assisted-development" | ||
| /> | ||
| </Cards> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add that is also helps with migration from OpenFGA or OSO