About permix
A skill for implementing and maintaining permissions with Permix. It covers v4 definitions and checks, framework and server integrations, SSR hydration, migration, and verification, with server-side enforcement emphasized.
Key features
- 01Permix v4 API guidance
- 02Permission definitions and checks
- 03Framework and server integrations
- 04SSR dehydration and hydration
- 05v3-to-v4 migration guidance
- 06Typecheck and permission tests
Use cases
- 01Define rules for entity actions
- 02Enforce permissions in server middleware
- 03Hydrate permission state in an SSR app
- 04Migrate a project from Permix v3
Install
Copy the command and run it in a terminal.
npx skills add https:/ / github.com/ dobroslavradosavljevic/ skills --skill permixAfter installing, type/permixin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
agents/openai.yamlreferences/core-api.mdframeworks-ssr.mdmigration-v4.mdserver-integrations.mdsource-map.mdusage-guide.mdDetails
From the project READMEPermix
Use this skill when work touches Permix permissions: definitions, setup/check, SSR hydration, UI adapters, server middleware, NestJS guards, or v3→v4 migration.
Snapshot: [email protected] (verified 2026-10-01). Refresh from source-map.md if the installed version differs.
Workflow
- Inspect the local Permix surface:
- Package version (
[email protected]preferred; current stable snapshot 4.3.0). - Import path:
permix(core) vs subpaths (permix/react,permix/next,permix/nest,permix/tanstack-start, …). - Definition shape: action tuples /
{ name, type, required? }vs legacy v3{ action, dataType }. - Where enforcement runs (server middleware / Nest
@Checkvs client UX) and whether SSR dehydrate/hydrate is used.
- Package version (
- For day-to-day how-to, follow usage-guide.md first.
- Refresh docs when versions drift or the task is migration/SSR/integration-specific. Start from source-map.md.
- Route deeper detail:
- Core API, rules, check, template, ReBAC, errors: core-api.md.
- React/Vue/Solid/Svelte, Next, TanStack Start, hydration: frameworks-ssr.md.
- Express/Hono/Elysia/Fastify/Node/server/tRPC/oRPC/Nest/Drizzle/Effect: server-integrations.md.
- v3→v4 breaking changes: migration-v4.md.
- Prefer Permix v4 APIs (dot paths, action tuples). Treat client checks as UX only — enforce on the server.
- Verify with typecheck plus focused
setup/checktests (and middleware 403 / NestForbiddenExceptionpaths when server-integrated).
Core Judgment
- Flow:
createPermix<Definition>()→setup(rules)→check('entity.action'[, data]). - Definitions are action lists (strings or
{ name, type?, required? }), optionally nested trees. - Rules are booleans or
(data?) => booleanclosures (capture the actor atsetuptime). checkreturnsboolean. Use callbacks for AND/OR; use'~all'/'~any'(or'post.~all') for aggregates.checkAsyncis removed in v4 —await isReadyAsync()thencheck().- Before any rules:
check/dehydratethrowPermixNotReadyError(notfalse). - Invalid path throws
PermixRuleNotDefinedError. template(...)returns a function — call it:permix.setup(admin()).- SSR:
dehydrate()→ JSON booleans (functions becomefalse) → clienthydrate→ mustsetup()again for function rules; hydrate alone does not setisReady. - Server: prefer per-request instances via integration middleware / Nest
guard/ Nextcache(); do not share mutable core singletons across concurrent requests. - TanStack Start:
setupMiddleware(orcreateSetupHandlerinsidecreateMiddleware().server(...)when the callback imports server-only code). RouterbeforeLoad/loaderuse a separate core instance on router context — UX only. - NestJS:
permix/nest—guard()attaches per-request rules;@Checkenforces (fail-closed). HTTP only (Express/Fastify adapters). - Security: server enforcement is mandatory; hide UI with client checks only.
- Engines: package declares
node: >=22. Optional peer deps only for the adapters you import.
Verification
Prefer repository-owned commands. For meaningful Permix work, cover the relevant subset:
- Typecheck paths (
$inferPath),required: truedata args, and sharedValidateDefinition/Rules. - Unit tests: allow/deny, entity-data rules with/without data,
~all/~any, callback composition, not-ready / missing-path errors. - SSR: dehydrate snapshot shape; client hydrate + re-
setup;isReadygating in UI. - Server:
setupMiddlewarethencheckMiddleware— assert 200 vs 403 /onForbidden. Nest:APP_GUARD+@Check→ 201 vs 403; missing guard →PermixNotFoundError. - TanStack Start: server-function
checkMiddleware/getOrThrow(context)for enforcement;beforeLoadchecks are not enough. - Migration: no remaining
check('entity', 'action'),checkAsync, Better Auth plugin, orentity+actionUI props.
Report which checks ran, which did not, and any version assumptions that remain.