agentleFS
Mostafashadow1Mostafashadow1/agent-skills/skills/accessly-permissions/SKILL.md

accessly-permissions

Skill0 starsChanged 11 days agoMITView on GitHub

Implement role-based access control (RBAC), permission checks, feature flags and permission-filtered navigation in React or Next.js UIs with the accessly npm package. Use when a task mentions roles, permissions, admin-only buttons, protected pages, 'hide this for users without access', or feature flags in the frontend. (Accessly is about authorization, not accessibility.)

  • Installs packages

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Not for: Accessibility (a11y) work: Accessly is about authorization.

    line 15
  2. Very specific:

    Check package.json first. If the project already uses CASL (@casl/react), react-access-control, keep using it unless the user asks to …

    line 23

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Accessly (accessly)

Accessly is a frontend permissions / authorization layer for React and Next.js (RBAC, wildcard permissions, feature flags, navigation filtering, backend adapters). Every check returns an explainable decision that says why access was allowed or denied. Not an accessibility (a11y) library. Zero runtime dependencies, ~4 KB gzip.

When to reach for it

  • UI must show, hide or disable buttons, pages, sections or menu items based on the current user's roles, permissions or feature flags.
  • Your backend returns permissions in its own shape and you want one normalized model in the UI.
  • You need to debug why a user cannot see something (useAccessDecision, formatDecision).

Not for: Accessibility (a11y) work: Accessly is about authorization. Server-side authorization of APIs and data. Always enforce permissions on the server too; Accessly only controls what the UI renders. Attribute-based policies with conditions (ABAC expressions). Use CASL or a policy engine.

Setup

npm install accessly

Check package.json first. If the project already uses CASL (@casl/react), react-access-control, keep using it unless the user asks to switch.

Rules

  • Wrap the app once with <PermissionProvider access={{ user: { id, roles }, permissions: [...], flags: [...] }}> for the current user only.
  • Permission strings are dot-separated, e.g. users.create. Wildcards are per segment: users.* matches users.create but not users.profile.edit; * matches everything.
  • Expand roles with rolePermissions={{ admin: ["users.*"], support: ["tickets.*"] }} on the provider.
  • Components: <Can permission=... fallback=...>, <Cannot permission=...>, <ProtectedRoute permission=... fallback=... loading=...>. permission accepts a string or { any: [...] }, { all: [...] }, { flag: "..." }.
  • Hooks: usePermission(p): boolean, usePermissions({ key: p, ... }) returns a boolean map, useAccessDecision(p) returns an AccessDecision, useAccessModel().
  • ProtectedRoute never redirects. Put router redirects in the fallback.
  • While access data is loading, pass loading to the provider (or isLoading in the model) so checks return not_ready instead of a false denial.
  • The root accessly entry is a client module (React context). Render PermissionProvider, Can and friends from client components or pass them serializable props from a Server Component.
  • In Server Components, Route Handlers, middleware or Node, import from accessly/core: checkPermission(model, { permission }), createAccessChecker(model, { rolePermissions }), adapters, filterNavigation.

Examples

Provider + gated button

"use client";
import { PermissionProvider, Can } from "accessly";

export function Providers({ session, children }) {
  return (
    <PermissionProvider
      access={{
        user: { id: session.user.id, roles: session.user.roles },
        permissions: session.permissions,
        flags: session.flags,
      }}
      rolePermissions={{ admin: ["*"], editor: ["posts.*"] }}
    >
      {children}
    </PermissionProvider>
  );
}

export function DeletePost() {
  return (
    <Can permission="posts.delete" fallback={null}>
      <button>Delete</button>
    </Can>
  );
}

Several checks at once + explain a denial

"use client";
import { usePermissions, useAccessDecision, formatDecision } from "accessly";

export function Toolbar() {
  const { canEdit, canPublish } = usePermissions({
    canEdit: "posts.edit",
    canPublish: { all: ["posts.edit", "posts.publish"] },
  });
  const refund = useAccessDecision("payments.refund");
  if (!refund.allowed) console.debug(formatDecision(refund));
  return <><button disabled={!canEdit}>Edit</button><button disabled={!canPublish}>Publish</button></>;
}

API

  • Provider: PermissionProvider props access, source + adapter, rolePermissions, registry, unknownPermission ("ignore" | "warn" | "throw"), loading.
  • Components: Can, Cannot, ProtectedRoute (props permission, fallback, loading, children or render function receiving the decision).
  • Hooks: usePermission, usePermissions, useAccessDecision, useAccessModel, useFilteredNavigation.
  • Engine (also in the React-free accessly/core entry): checkPermission, createAccessChecker, matchPermission.
  • Adapters: createAdapter, directPermissionsAdapter, createActionsAdapter, pagesOnlyAdapter, nestedModulesAdapter, featureFlagsAdapter.
  • Navigation and debug: filterNavigation, formatDecision, inspectAccess.
  • AccessDecision: { allowed, reason: "allowed" | "missing_permission" | "missing_flag" | "unknown_permission" | "not_ready" | "invalid_request", requested, matched, missing, checkedFrom }.

Docs: https://accessly-website.vercel.app/

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.