adonisjs-policies

Enforce resource-level authorization rules for AdonisJS applications using Bouncer.

2|1|Updated Mar 16, 2026
One-click install
npx skills add https://github.com/omakei/adonisjs-architecture-skill --skill adonisjs-policies
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: adonisjs-policies
Source: https://github.com/omakei/adonisjs-architecture-skill/tree/main/adonisjs/skills/adonisjs-policy
Command: npx skills add https://github.com/omakei/adonisjs-architecture-skill --skill adonisjs-policies

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Authorization rules for AdonisJS projects can become scattered and hard to audit. This Skill consolidates resource-level access control using @adonisjs/bouncer, organizing policy logic per model to keep checks consistent and testable.

Core Features & Use Cases

  • Policy classes per model group ownership, permissions, and state checks into a single, testable class.
  • Standard methods (viewAny, view, create, update, delete) and custom actions (cancel, publish, ship) with admin bypass support.
  • References and tests illustrating usage, patterns, and validation to ensure correct behavior.

Quick Start

Create a policy by extending BasePolicy for your model and wire it to the bouncer in your controllers.

Frequently Asked Questions about adonisjs-policies

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce resource-level authorization in AdonisJS using Bouncer?▼

You can enforce resource-level authorization in AdonisJS by creating policy classes per model that extend BasePolicy, grouping ownership, permissions, and state checks into a single testable class wired to your controllers.

What is the best way to organize AdonisJS authorization rules for CRUD operations?▼

The best way to organize AdonisJS authorization rules is consolidating standard CRUD methods like view, create, update, and delete into per-model policy classes, keeping access control logic consistent and auditable rather than scattered.

Can I implement custom authorization actions and admin bypass with AdonisJS Bouncer?▼

Yes, you can implement custom authorization actions like publish, cancel, and ship alongside standard CRUD permissions, including admin bypass support, by defining these methods within your Bouncer policy classes.

How do I test ownership and state checks in AdonisJS Bouncer policies?▼

You test ownership and state checks in AdonisJS Bouncer policies by utilizing included references and tests that validate per-model policy behavior, ensuring correct authorization outcomes for different user roles and resource states.

Does AdonisJS Bouncer support per-model policy classes for access control?▼

Yes, AdonisJS Bouncer supports per-model policy classes that group ownership, permissions, and state checks together, allowing you to define resource-level access control rules tailored to each specific model.

Why should I consolidate scattered authorization rules into AdonisJS policies?▼

You should consolidate scattered authorization rules into AdonisJS policies because grouping logic into per-model policy classes keeps access checks consistent, testable, and significantly easier to audit across your application.