PermDock
CLI

init

Write a preset's permissions, policy, app definition and framework wiring into a project from a permdock.com/create code or from flags, keep every file that already exists, and print the install and shadcn commands to run.

permdock init writes the files a preset generates into the current project. It never overwrites a file that exists unless --force is set, installs nothing and calls no network: it prints the package manager and shadcn commands for you to run.

Usage

permdock init --preset p1AQIDBAc                  # a code from permdock.com/create
permdock init --archetype b2b --framework hono     # or pick with flags
permdock init --archetype api --auth supabase --backend drizzle --service cloud-decision-log
permdock init --archetype agent --integration ai-sdk --integration mcp --integration shadcn
permdock init --archetype consumer --dry-run       # print the plan, write nothing
permdock init --preset p1AQIDBAc --out-dir app --force

Each selection flag takes the ids of one step on /create, and both read the same catalogue in permdock/preset. A value outside it exits 2 with the nearest id.

FlagMeaning
--preset <code>A preset code from /create; the other selection flags are ignored
--archetype <id>b2b (default), agent, marketplace, api, internal or consumer
--framework <id>next (default), hono, express or none
--auth <id>custom (default), supabase, better-auth, clerk or jwt
--backend <id>memory (default), supabase, drizzle or prisma
--feature <id>A feature beyond the archetype's, repeatable: tenancy, custom-roles, approvals, operations, decision-log, limits, plans, ownership, api-keys, rls
--integration <id>ai-sdk or mcp wire an agent adapter; shadcn or react-native print the @permdock recipes to add. Repeatable
--service <id>A PermDock Cloud service, repeatable: cloud-decision-log, cloud-approvals, cloud-snapshots, cloud-hosted-grants
--out-dir <dir>The directory the files go in; default src
--dry-runList the files it would write; write nothing
--forceOverwrite files that already exist

The output ends with the preset's code and its /create link, so the same preset can be opened, changed and applied again. With --json, data is { preset, written, kept, dryRun, install, shadcn, docs } and next lists the install, shadcn and permdock doctor commands in order.

Generated files

Every preset writes permissions.ts, policy.ts, permdock.ts, data.ts, session.ts and permdock.config.ts. The config names the permissions, the policy and, with operations, the operations file, so permdock doctor and permdock check run without flags. The other choices add or change these files:

ChoiceWhat it writes
--auth customcurrentUser() in session.ts, returning null until you read your session, so every check denies
--auth supabase, clerk, jwtcurrentSubject() in session.ts through subjectFromSupabase, subjectFromClerk or jwtSubjectResolver
--auth better-authauth.ts with the organization plugin, and currentSubject() through subjectFromBetterAuth
--backend supabasepostgrestSources() as the app's memberships source in permdock.ts
--backend drizzleschema.ts with one table per resource, db.ts, and loaders and toWhere() lists in data.ts
--backend prismaprisma/schema.prisma, prisma.config.ts, db.ts, and loaders and toWhere() lists in data.ts
--framework next, hono, expressserver.ts (permdock/server.ts on Next.js) calling the session function with the request
--integration ai-sdk, mcpoperations.ts, plus agent.ts or mcp.ts
--service cloud-snapshotssnapshotsFor(token) in permdock.ts, reading signed snapshots from PermDock Cloud
--feature rlsrls in permdock.config.ts for permdock rls generate
--feature api-keyskeys.ts with decideReadKey()

With --auth supabase or --backend supabase, the Supabase clients in session.ts and permdock.ts send via=permdock/<version> in X-Client-Info through supabase-js's global.clientInfo, with the version of the CLI that wrote them. init leaves it out when the project already installs a supabase-js older than 2.120, whose types reject the option.

Side effects

What each command may change; side effects explains each one.

CommandSide effects
permdock initfiles

Why

init writes only the application's own files: declarations and wiring that call into the permdock package. Every rule, check and verification stays in the package, so npm update fixes them in a project init created long ago. Keeping existing files makes running it again safe; it adds what is missing and leaves your changes alone.

Last updated on

On this page