webiny-api-permissions
What it does
This skill guides your AI when adding permission rules to backend code in Webiny. It is for developers who need to control who can read, change or delete records.
When to use it
- βWhen a backend use case must check whether a user can read, edit, delete or publish.
- βWhen records should be limited to their owner.
- βWhen you need to write tests for permission scenarios.
Skill link
https://github.com/webiny/webiny-js/blob/next/skills/user-skills/api/permissions/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βOnly let users edit their own products in our Webiny API, and check the permission in the update use case.β
5 new skills a week. 1 minute to read.
How it works
The skill explains how to define a permission schema for each area, then inject a typed permission check into use cases. The check methods replace manual lookups of the user's permissions.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
API Permissions
Overview
Permissions follow two layers: domain (schema) and features (DI abstractions + feature registration). Each package declares a permission schema and gets a typed Permissions abstraction injectable into use cases via DI. Methods like canRead, canEdit, canDelete, canPublish, onlyOwnRecords replace manual identityContext.getPermission() calls.
Layer 1: Domain β Permission Schema
Define the schema in src/domain/permissionsSchema.ts:
import { createPermissionSchema } from "webiny/api/security";
export const SM_PERMISSIONS_SCHEMA = createPermissionSchema({
prefix: "sm",
fullAccess: true,
entities: [
{
id: "product",
permission: "sm.product",
scopes: ["full", "own"],
actions: [{ name: "rwd" }, { name: "pw" }]
},
{
id: "settings",
permission: "sm.settings",
scopes: ["full"]
}
]
});
The schema MUST use as const inference (handled by createPermissionSchema) for TypeScript to narrow entity IDs in method signatures.
Schema Fields
| Field | Description |
|---|---|
prefix |
Namespaces the DI abstraction: ${prefix}:Permissions |
fullAccess |
true for standard full access. Pass an object with custom boolean flags for full-access extras (e.g., { canForceUnlock: true }). |
entities[].id |
Entity identifier used in method calls: canRead("product") |
entities[].permission |
Permission name matched against identity permissions |
entities[].scopes |
["full"] or ["full", "own"] β determines if own-scope supported |
entities[].actions |
Action definitions β built-in: "rwd", "pw"; custom: boolean flags |
Scopes
"full"β User can access all records (default when noownflag on permission object)"own"β User can only access records wherecreatedBy.id === identity.id
Simple Apps (No Entities)
Omit entities for binary full/no access:
export const MA_PERMISSIONS_SCHEMA = createPermissionSchema({
prefix: "ma",
fullAccess: true
});
Layer 2: Features β DI Artifacts + Registration
Abstraction (src/features/permissions/abstractions.ts)
import { createPermissionsAbstraction } from "webiny/api/security";
import type { Permissions } from "webiny/api/security";
import { SM_PERMISSIONS_SCHEMA } from "~/domain/permissionsSchema.js";
export const SmPermissions = createPermissionsAbstraction(SM_PERMISSIONS_SCHEMA);
export namespace SmPermissions {
export type Interface = Permissions<typeof SM_PERMISSIONS_SCHEMA>;
}
Feature (src/features/permissions/feature.ts)
import { createPermissionsFeature } from "webiny/api/security";
import { SM_PERMISSIONS_SCHEMA } from "~/domain/permissionsSchema.js";
import { SmPermissions } from "./abstractions.js";
export const SmPermissionsFeature = createPermissionsFeature(SM_PERMISSIONS_SCHEMA, SmPermissions);
Registration
Register the feature in your context plugin:
import { SmPermissionsFeature } from "~/features/permissions/feature.js";
// In createContext:
SmPermissionsFeature.register(container);
File Structure
src/
βββ domain/
β βββ permissionsSchema.ts # createPermissionSchema()
βββ features/
β βββ permissions/
β βββ abstractions.ts # createPermissionsAbstraction() + namespace type
β βββ feature.ts # createPermissionsFeature()
βββ index.ts # SmPermissionsFeature.register(container)
Permission Methods
All methods follow a 3-tier bypass:
identityContext.hasFullAccess()βname: "*"permission (super admin)hasFullSchemaAccess()β wildcard permission (e.g."sm.*")- Entity-level permission check
Method Referen
FAQ
What does the permission schema define?
The entities, their permission names, scopes and actions, such as full or own scope.
How are own-record rules handled?
The skill covers own-record scoping through a method that checks only owned records.
Can permissions be tested?
Yes. The skill includes guidance on testing permission scenarios.
Details
Original description by the author
Schema-based permission system for API features. Use this skill when implementing authorization in use cases, defining permission schemas with createPermissionSchema, creating injectable permissions via createPermissionsAbstraction/createPermissionsFeature, checking read/write/delete/publish permissions, handling own-record scoping, or testing permission scenarios. Covers the full pattern from schema definition to use case integration to test matrices.
repo: webiny/webiny-js
Popularity
- GitHub stars
- 8.1k
- Ranking position
- #12589
- License
- β
- Updated
- 11/2/2026
Comments
- β¦
More skills from this repository
prd-to-plan
8.1kHelps your agent turn a product requirements document into a phased plan of small end-to-end slices, saved as a Markdown file.
webiny-admin-architect
8.1kTeaches your agent how to build admin screens for the Webiny platform, using its business logic layers and presenter pattern.
webiny-admin-permissions
8.1kTeaches your agent to add permission controls to Webiny admin screens, including auto-generated permission forms and hide-or-show checks.
webiny-form-model
8.1kTeaches your agent to build forms in Webiny using a declarative field builder, layouts, validation and conditional rules.
Similar skills
reverse-engineer-anything
422kHelps your agent look inside shipped apps and packages to explain features, compare versions, or guide a rebuild, using the REA tool.
1password
394kHelps your agent set up the 1Password CLI, sign in, and read or inject secrets without printing their values into chat.
healthcheck
394kHelps your agent audit the computer or server that runs OpenClaw for security risks, such as SSH, firewall, updates, and backups, then suggest safe fixes.