Habify BaseHabify Base
Scoped Agent Auth & CLIHabify Base · Developer Experience Team2026-11-287 min read

Safely Let AI Agents Create Projects, PG18 Tables & APIs via `habify` CLI and Scoped Tokens

Want Claude Code, Codex CLI, or Antigravity to provision PG18 tables, enforce RLS, import Sheets CSVs, and write dev .env keys without handing over Owner credentials? Learn how Device Login + hb_at_* tokens work.

habify CLIhb_at_* TokenDevice Auth FlowMCP 18 Tools
Safe Device Flow authorization for AI coding agents in Habify Base

Until now, letting AI agents provision backend infrastructure meant clicking through dashboards manually or pasting privileged session keys into prompts. With our zero-dependency habify CLI and scoped `hb_at_*` tokens, your AI agent automates the setup inside a strict security perimeter.

1. 15-Second Browser Device Login (Never Paste Secrets in Chat)

Run two commands in your project terminal. The CLI opens `/console/device?code=HB-...` in your browser so you pick the Workspace, preset (`read_only`, `prototype_db`, `full_dev`), and allowed Projects. Your `hb_at_*` token lands quietly in `~/.habify/credentials.json` (chmod `0600`) for both CLI and `@habifybase/mcp`.

bash
curl -fsSL https://habifybase.com/install.sh | bash
habify login
habify whoami
habify projects create --name "Customer Portal" --auth-mode local_auth
habify env init --project <project_id> --file .env.local

2. Permission Intersection & Permanent Hard Denylist

Every `hb_at_*` request enforces `User RBAC Permissions ∩ Selected Token Scopes \ Hard Denylist`. Lowering a member's role or revoking the token immediately cuts off agent access.

  • Permanent Guardrails: Wallet, Billing, Members, RBAC changes, Drop Table, Delete Project, Vault export, and rotating live keys are always blocked.
  • Server-only enforcement: Requests carrying `hb_at_*` with a browser Origin header fail with 403.
  • Additive dev keys (`habify env init`): Appends fresh dev keys to .env.local without disrupting production keys.

Frequently Asked Questions

If a project-scoped agent creates a new project, can it immediately create tables in it?

Yes. Newly created projects issued by a selected-project agent token are automatically added to that token's allowed_project_ids allowlist.

Related Documentation & Guides

Launch This Architecture in Free Sandbox in 3 Minutes

Spin up an isolated PostgreSQL 18 database, grab your hb_pk_* / hb_sk_* keys, and wire @habifybase/sdk.

More Engineering Articles & Use Cases