migrate-code

A migration command that replaces OpenFGA authorization calls with SpiceDB client calls. OpenFGA and SpiceDB are systems that let applications define and check access rules.

In plain words
What is it for?
It adds a SpiceDB client, updates dependencies, and rewrites OpenFGA call sites into equivalent SpiceDB operations.
Why use it?
It addresses the gap between converting authorization data or rules and updating the application that still calls the old system.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/authzed/authzed-marketplace/migrate-code
Clone the repo
git clone --depth 1 https://github.com/authzed/authzed-marketplace
Per session 27 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 17,641 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00027 $0.17641
Opus 5 $0.00014 $0.08821
Sonnet 5 $0.00005 $0.03528
Haiku 4.5 $0.00003 $0.01764

Measured yesterday against content hash b0a7156a6a9b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

migrate-code scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

spicedb-dev/commands/migrate-code.md · 936 lines

How it starts

The opening of the file, as written. The whole thing — 936 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Migrate Code

Phase 4 of the migration pipeline: add a real SpiceDB client to the project, then rewrite every OpenFGA call site into the SpiceDB equivalent -- construct by construct, per code-mapping.md -- so the conversion ends with working SpiceDB client code, not a converted schema and data set the application still checks against the old system.

It is not the last thing the plugin automates. Phase 5 (/spicedb-dev:migrate-tests) has no ordering dependency on this command and may run before or after it, and /spicedb-dev:migrate-verify automates cutover-strategies.md step 4's differential harness once phase 3 has passed verification. Step 7 of this command's own report (below) is where that routing is stated to the user; keep the two consistent.

This command does two things the earlier phases didn't need to: it changes the project's dependencies, and it edits files a human wrote. /spicedb-dev:migrate-schema, /spicedb-dev:migrate-data, and /spicedb-dev:migrate-tests all produce new, standalone artifacts (schema.zed, a migration script, validation YAML) that a human reviews before anything downstream depends on them. This command instead vendors a client into the project's own dependency manifest and rewrites existing application source files in place. Five traps are common enough to name up front, because each produces code that compiles clean and then fails or answers wrong at runtime:

  • A split relation is two names, and the write path and the check path need different ones. Phase 1 turned every source define that fused a [...] type list with an operator into a generated relation (viewer__direct) plus a same-named permission (viewer), and recorded the pair in migration-map.json's relation_splits. A rewrite that carries the source name through unchanged writes to a permission -- which SpiceDB rejects outright, on every write, at runtime -- and reads relationships through a filter that errors the same way; a rewrite that carries the generated name onto a check gets a narrower answer with no error at all. See code-mapping.md's "The relation-split obligation," and step 6 rule 3.
  • Check code cannot be ported across languages mechanically. Python's check_permission has no permission parameter at all -- it reads Relationship.resource_relation -- and Rust's check_permission (singular) returns a CheckResult wrapper, not a bare bool. Converting a Go call site's CheckOne(ctx, cs, "viewer", rel) shape into Python or Rust by find-and-replace produces code that either doesn't compile or discards a wrapper silently. See code-mapping.md's "Per-language check-signature divergence."
  • The identifier obligation fails closed, not at build time. Data written under base64url(email) by /spicedb-dev:migrate-data while a call site still checks user:[email protected] is a silent half-migration: the raw form fails SpiceDB's own object-id grammar on every single check, discovered in production traffic, not by a type checker or zed validate. Every call site that builds or reads an id of an encoded type must go through the codec phase 3 emitted -- see code-mapping.md's "The identifier obligation."
  • batchCheck ordering silently corrupts results, not just names. OpenFGA's response is a map keyed by correlation_id, with no order guarantee. The SpiceDB client returns a plain, positionally-ordered array. Code that still pairs responses back to requests by correlation_id after a rename-only conversion pairs the wrong answer to the wrong request whenever the two happen to reorder -- see code-mapping.md's "batchCheck ordering."
  • A sync OpenFGA source converting to Python's async-only client can turn a denial into a silent allow. Python is the one language of the seven where this actually happens: openfga_sdk.sync.OpenFgaClient is a real, documented sync client, but the prototype spicedb-python client has no sync form at all -- every method is async def, so the rewrite necessarily adds an await that was not in the source. A call site that misses it gets back a bare coroutine object, not a bool; a coroutine is truthy in Python's own if, so a check that would answer False takes the allowed branch instead, and the object compiles and runs without error. Confirmed live, and confirmed invisible to pyright and mypy --strict alike -- this is not a symptom of an untyped codebase, no Python type checker currently flags it. The other six languages do not share this shape: Go/Java/Ruby's SpiceDB targets are synchronous (no await to omit), and C#/Rust reject a missing await/.await at compile time; TypeScript's Promise is truthy the same way a coroutine is, but @openfga/sdk has no sync client for a rewrite to carry the habit over from, and tsc itself flags the bare case (TS2801) under a real type-check build. Review every Python call site converted from a sync OpenFGA client for a missing await by inspection -- see code-mapping.md's "Async-only target vs. sync source: the un-awaited-coroutine fail-open."

Read the full file on GitHub · 936 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 936 lines · 27 tokens per session scan A b0a7156a6a9b

Subscribe to this mod's changes

migrate-code is a command published in the GitHub repository authzed/authzed-marketplace (2 stars, last pushed 5d ago), licensed Apache-2.0. It adds 27 tokens to every session and 17,641 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.