openfga-cli

module
v0.270.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2026 License: MIT

README ΒΆ

the interactive ofga playground TUI

ofga

A modern CLI & TUI for OpenFGA.

Manage stores, authorization models, relationship tuples, and run checks from your terminal, or explore everything interactively in a full-screen TUI.

Quick start Β· The TUI Β· Commands Β· Configuration Β· Docs Β· Contributing

CI CodeQL Go Report Card Release Go version GHCR Conventional Commits PRs welcome


πŸ“‘ Table of contents


✨ What is this?

ofga is a single, dependency-free binary that gives you two ways to work with an OpenFGA server:

  • 🧰 A scriptable CLI: create stores, write and inspect authorization models, manage relationship tuples, run check/list-objects/list-users/list-relations, and run assertion suites. Read commands provide consistent JSON/YAML output (plus -o jsonl for one object per line), tabular commands support --plain, and failures return meaningful exit codes.
  • πŸ€– Agent mode: when run by a coding agent (CLAUDECODE=1, GEMINI_CLI=1, OPENFGA_AGENT_MODE=1 or --agent), ofga defaults to compact JSON, no prompts, no color and JSON errors; set OPENFGA_AGENT_MODE=0 to opt out.
  • πŸ–₯ A full-screen TUI: launch it by running ofga with no arguments. Browse stores, visualize a model as a colored relation graph, edit tuples, run queries and expand their resolution trees, and manage assertions, all with the keyboard or the mouse.

It talks to any OpenFGA-compatible server and reuses your connection profiles so you can switch between local, staging, and production in one flag.

Naming: the official OpenFGA CLI is fga. This is a separate, independent reimagining focused on ergonomics and an interactive TUI, distributed as ofga. OpenFGA, Auth0 and Claude are trademarks of their respective owners; this project is not affiliated with or endorsed by them.


πŸš€ Quick start

# 1. Start a local OpenFGA server in another terminal
docker run --rm --name openfga -p 8080:8080 openfga/openfga run

# 2. Point ofga at it (guided; uses http://localhost:8080 by default)
ofga init

# 3. Create a store and make it active
ofga stores create demo --use

# 4. Write an authorization model
cat > model.fga <<'FGA'
model
  schema 1.1

type user

type document
  relations
    define viewer: [user]
FGA
ofga model write --file model.fga
# `.fga` DSL is transformed to JSON for you. `--file` also takes a `.json`
# model, or `-` to read from stdin.

# 5. Add a relationship tuple
ofga tuples write user:anne viewer document:roadmap

# 6. Ask an authorization question
ofga query check user:anne viewer document:roadmap
# βœ“ ALLOWED  user:anne viewer document:roadmap

# 7. …or explore everything interactively
ofga

Already have a server? Skip step 1 and pass its URL to ofga init.


πŸ“¦ Installation

brew install sergiught/tap/ofga
curl -fsSL https://raw.githubusercontent.com/sergiught/openfga-cli/main/install.sh | bash

Full matrix (AUR, go install, Docker, source), upgrade, and uninstall β†’ the installation guide


πŸ–₯ The interactive TUI

Run ofga with no arguments to launch the interactive TUI on your real profile, or ofga playground to explore sample stores in a local sandbox that needs no server. It is a keyboard- and mouse-driven cockpit covering profiles, stores, the model graph, tuples, queries with resolution trees, and assertions. Press ? at any time for the full, context-aware keybinding overlay.

Icons adapt to your terminal automatically. If they render as ? or boxes, press ctrl+g to cycle to a plainer glyph set β€” see terminal glyphs.

Full TUI guide & keybinding reference β†’ the TUI guide


πŸ“‹ Command reference

Every command has a generated reference page with a live demo recording: https://sergiught.github.io/openfga-cli/reference/


πŸ“š Documentation


πŸ— Contributing

Contributions are welcome! Please read CONTRIBUTING.md for the build/test/lint workflow and the Conventional Commits convention used for automated releases.

Report bugs and request features through GitHub Issues. Report vulnerabilities privately as described in SECURITY.md.

go build ./...
go test ./...

βš–οΈ License

MIT Β© Sergiu Ghitea. Built for the excellent OpenFGA project (not affiliated with or endorsed by OpenFGA, Auth0 or Claude).

Directories ΒΆ

Path Synopsis
cmd
ofga command
Command ofga is a modern CLI and TUI for OpenFGA.
Command ofga is a modern CLI and TUI for OpenFGA.
internal
agentmode
Package agentmode decides whether the CLI is being driven by a coding agent and should default to compact, prompt-free, colorless machine output.
Package agentmode decides whether the CLI is being driven by a coding agent and should default to compact, prompt-free, colorless machine output.
agentskill
Package agentskill embeds the SKILL.md that teaches a coding agent to drive ofga.
Package agentskill embeds the SKILL.md that teaches a coding agent to drive ofga.
apilog
Package apilog captures OpenFGA HTTP traffic.
Package apilog captures OpenFGA HTTP traffic.
atomicfile
Package atomicfile writes a file by staging it next to its destination and renaming it into place only once the caller is satisfied with the contents.
Package atomicfile writes a file by staging it next to its destination and renaming it into place only once the caller is satisfied with the contents.
cli
Package cli holds the shared dependencies threaded through every command: the logger, the loaded config, and the global flag overrides.
Package cli holds the shared dependencies threaded through every command: the logger, the loaded config, and the global flag overrides.
client
Package client constructs a configured go-openfga client from resolved config.
Package client constructs a configured go-openfga client from resolved config.
clierr
Package clierr centralizes how command errors map to user-facing messages and process exit codes, so main can stay a thin shell and every command surfaces failures consistently.
Package clierr centralizes how command errors map to user-facing messages and process exit codes, so main can stay a thin shell and every command surfaces failures consistently.
cmdmeta
Package cmdmeta attaches machine-readable metadata to cobra commands and flags, so tooling (the command catalog) can describe the CLI without parsing help text.
Package cmdmeta attaches machine-readable metadata to cobra commands and flags, so tooling (the command catalog) can describe the CLI without parsing help text.
command
Package command defines the shared Command abstraction used by every ofga command, mirroring the structure of task-pilot-cli: each command exposes its cobra command, registers its sub-commands, and implements its run logic.
Package command defines the shared Command abstraction used by every ofga command, mirroring the structure of task-pilot-cli: each command exposes its cobra command, registers its sub-commands, and implements its run logic.
command/agent
Package agent implements `ofga agent`: material for coding agents that drive ofga.
Package agent implements `ofga agent`: material for coding agents that drive ofga.
command/api
Package api implements `ofga api`: send a raw request to the OpenFGA API using the active profile's connection and authentication.
Package api implements `ofga api`: send a raw request to the OpenFGA API using the active profile's connection and authentication.
command/assertions
Package assertions implements `ofga assertions`: read and write the assertion test-suite attached to an authorization model, and run it.
Package assertions implements `ofga assertions`: read and write the assertion test-suite attached to an authorization model, and run it.
command/base
Package base provides the root `ofga` command: persistent flags, the help banner, and registration of every top-level sub-command.
Package base provides the root `ofga` command: persistent flags, the help banner, and registration of every top-level sub-command.
command/configcmd
Package configcmd implements `ofga config`: inspect where ofga's configuration lives and what it resolves to.
Package configcmd implements `ofga config`: inspect where ofga's configuration lives and what it resolves to.
command/docs
Package docs implements `ofga docs`: search and read the OpenFGA documentation on openfga.dev from the terminal.
Package docs implements `ofga docs`: search and read the OpenFGA documentation on openfga.dev from the terminal.
command/mapping
Package mapping implements the `ofga mappings` command group, which authors openfga/mapper mapping files.
Package mapping implements the `ofga mappings` command group, which authors openfga/mapper mapping files.
command/mapping/tui
Package tui holds the `ofga mappings` editors as components.
Package tui holds the `ofga mappings` editors as components.
command/model
Package model implements `ofga model`: write, list, inspect, and visualize authorization models (including a colored relation graph).
Package model implements `ofga model`: write, list, inspect, and visualize authorization models (including a colored relation graph).
command/playground
Package playground implements the interactive `ofga` TUI: a full-screen, Crush-style shell for exploring a store β€” picking models, browsing tuples, running live checks, and visualizing the authorization model as a graph.
Package playground implements the interactive `ofga` TUI: a full-screen, Crush-style shell for exploring a store β€” picking models, browsing tuples, running live checks, and visualizing the authorization model as a graph.
command/profiles
Package profiles implements `ofga profiles`: manage named connection profiles β€” list, switch, inspect, create, edit and remove them.
Package profiles implements `ofga profiles`: manage named connection profiles β€” list, switch, inspect, create, edit and remove them.
command/query
Package query implements `ofga query`: the read-side authorization questions β€” check, batch-check, expand, list-objects and list-users.
Package query implements `ofga query`: the read-side authorization questions β€” check, batch-check, expand, list-objects and list-users.
command/store
Package store implements `ofga stores`: create, list, inspect and delete OpenFGA stores.
Package store implements `ofga stores`: create, list, inspect and delete OpenFGA stores.
command/tuple
Package tuple implements `ofga tuples`: write, delete, read relationship tuples and follow the changelog.
Package tuple implements `ofga tuples`: write, delete, read relationship tuples and follow the changelog.
config
Package config loads and persists ofga configuration: a set of named connection profiles (contexts) plus the name of the active one.
Package config loads and persists ofga configuration: a set of named connection profiles (contexts) plus the name of the active one.
configtest
Package configtest isolates the CLI's on-disk config so a test never reads or writes the developer's real one.
Package configtest isolates the CLI's on-disk config so a test never reads or writes the developer's real one.
docsearch
Package docsearch is a client for the openfga.dev documentation: the Mintlify MCP search endpoint and the markdown rendering of each docs page.
Package docsearch is a client for the openfga.dev documentation: the Mintlify MCP search endpoint and the markdown rendering of each docs page.
dsl
Package dsl provides syntax highlighting and syntax-error diagnostics for OpenFGA DSL text, built on the openfga/language ANTLR lexer and parser.
Package dsl provides syntax highlighting and syntax-error diagnostics for OpenFGA DSL text, built on the openfga/language ANTLR lexer and parser.
fga
Package fga holds OpenFGA domain helpers shared by the CLI commands and the TUI: parsing tuple shorthand and turning an authorization model into a graph.
Package fga holds OpenFGA domain helpers shared by the CLI commands and the TUI: parsing tuple shorthand and turning an authorization model into a graph.
filelock
Package filelock holds an exclusive cross-process lock on a file, released when the returned func is called (or the process exits).
Package filelock holds an exclusive cross-process lock on a file, released when the returned func is called (or the process exits).
mapping
Package mapping builds, renders and previews openfga/mapper mapping documents.
Package mapping builds, renders and previews openfga/mapper mapping documents.
mapping/auth0
Package auth0 carries a catalog of Auth0 Events event types and an example payload for each, embedded so the `ofga mappings` workspace can preview a rule without network access.
Package auth0 carries a catalog of Auth0 Events event types and an example payload for each, embedded so the `ofga mappings` workspace can preview a rule without network access.
modeldiff
Package modeldiff compares two authorization models and classifies the differences between their shapes.
Package modeldiff compares two authorization models and classifies the differences between their shapes.
modeltest
Package modeltest runs authorization-model tests declared by an ofga workspace (an ofga.yaml manifest and its *.test.yaml files).
Package modeltest runs authorization-model tests declared by an ofga workspace (an ofga.yaml manifest and its *.test.yaml files).
optimize
Package optimize analyses authorization models and proposes equivalence-preserving rewrites.
Package optimize analyses authorization models and proposes equivalence-preserving rewrites.
optimize/bench
Package bench synthesizes tuples and checks from an authorization model and benchmarks the checks against a before and an after model on a counting embedded OpenFGA server.
Package bench synthesizes tuples and checks from an authorization model and benchmarks the checks against a before and an after model on a counting embedded OpenFGA server.
optimize/benchfmt
Package benchfmt renders a bench.Result as the human-readable benchmark report shared by the CLI and the playground.
Package benchfmt renders a bench.Result as the human-readable benchmark report shared by the CLI and the playground.
output
Package output renders command results either as a styled table/summary for humans or as indented JSON for machines (--json).
Package output renders command results either as a styled table/summary for humans or as indented JSON for machines (--json).
outputschema
Package outputschema names the published JSON Schemas that describe what each command prints under --json.
Package outputschema names the published JSON Schemas that describe what each command prints under --json.
outputschema/outputschematest
Package outputschematest validates command output against the committed JSON Schema files, so each command package can prove its schema describes exactly what --json prints.
Package outputschematest validates command output against the committed JSON Schema files, so each command package can prove its schema describes exactly what --json prints.
prompt
Package prompt provides consistent confirmation gates for destructive commands: interactive y/N (or type-to-confirm) on a terminal, and a required --force flag when running non-interactively so scripts fail safe.
Package prompt provides consistent confirmation gates for destructive commands: interactive y/N (or type-to-confirm) on a terminal, and a required --force flag when running non-interactively so scripts fail safe.
readlimit
Package readlimit provides bounded reads for user-controlled files, stdin, and HTTP bodies.
Package readlimit provides bounded reads for user-controlled files, stdin, and HTTP bodies.
sandbox
Package sandbox runs the playground on the CLI's embedded OpenFGA server, persisted in a SQLite file.
Package sandbox runs the playground on the CLI's embedded OpenFGA server, persisted in a SQLite file.
style
Package style centralizes the lipgloss palette and reusable styles.
Package style centralizes the lipgloss palette and reusable styles.
theme
Package theme defines named color palettes for the CLI and TUI.
Package theme defines named color palettes for the CLI and TUI.
ui/extedit
Package extedit resolves the user's terminal editor and builds the command that opens a file in it, so every TUI that hands a file to $EDITOR picks the same editor and parses the variable the same way.
Package extedit resolves the user's terminal editor and builds the command that opens a file in it, so every TUI that hands a file to $EDITOR picks the same editor and parses the variable the same way.
ui/field
Package field provides a minimal themed form: labeled text inputs with an accent bar on focus, inline validation, tab-cycled focus, and enter-to-submit.
Package field provides a minimal themed form: labeled text inputs with an accent bar on focus, inline validation, tab-cycled focus, and enter-to-submit.
ui/icons
Package icons resolves the process-wide glyph set: auto (the default, which promotes to Nerd Font only on a positive signal), an explicit Nerd Font rung, a universal Unicode fallback, or off for decorative glyphs.
Package icons resolves the process-wide glyph set: auto (the default, which promotes to Nerd Font only on a positive signal), an explicit Nerd Font rung, a universal Unicode fallback, or off for decorative glyphs.
ui/list
Package list wraps bubbles/list with a task-pilot-style delegate: a thick left-border selection accent, title+description rows, and built-in filtering.
Package list wraps bubbles/list with a task-pilot-style delegate: a thick left-border selection accent, title+description rows, and built-in filtering.
ui/logo
Package logo renders the OPENFGA block wordmark, in the spirit of charmbracelet/crush's stylized title.
Package logo renders the OPENFGA block wordmark, in the spirit of charmbracelet/crush's stylized title.
ui/picker
Package picker is a small vertical single-select list with per-row descriptions.
Package picker is a small vertical single-select list with per-row descriptions.
ui/shell
Package shell renders the Crush-style playground frame: a left sidebar (gradient logo + context + nav + status footer), a main content pane, and a bottom status bar, composited flat on a lipgloss canvas with no painted panel backgrounds β€” structure comes from headers and rules.
Package shell renders the Crush-style playground frame: a left sidebar (gradient logo + context + nav + status footer), a main content pane, and a bottom status bar, composited flat on a lipgloss canvas with no painted panel backgrounds β€” structure comes from headers and rules.
ui/toast
Package toast renders transient bottom-right status chips that auto-expire.
Package toast renders transient bottom-right status chips that auto-expire.
version
Package version holds build information, injected at release time via -ldflags.
Package version holds build information, injected at release time via -ldflags.
tools
docgen command
Command docgen generates the per-command MDX reference pages for the docs site (docs/site/src/content/docs/reference) from the live cobra tree, so the published reference can never drift from the binary.
Command docgen generates the per-command MDX reference pages for the docs site (docs/site/src/content/docs/reference) from the live cobra tree, so the published reference can never drift from the binary.
genassets command
Command genassets generates the shell completions and man pages that ship inside the release archives and OS packages.
Command genassets generates the shell completions and man pages that ship inside the release archives and OS packages.
licensegen command
Command licensegen generates THIRD_PARTY_LICENSES, the attribution bundle shipped alongside every ofga artifact.
Command licensegen generates THIRD_PARTY_LICENSES, the attribution bundle shipped alongside every ofga artifact.
samplestores command
Command samplestores converts upstream openfga/sample-stores store files into ofga model-test workspaces.
Command samplestores converts upstream openfga/sample-stores store files into ofga model-test workspaces.
schemagen command
Command schemagen generates the JSON Schemas that describe what each command prints under --json (docs/site/public/schemas/output).
Command schemagen generates the JSON Schemas that describe what each command prints under --json (docs/site/public/schemas/output).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL