policy-agent

Enforce Pundit authorization in Rails apps with policies and RSpec specs.

Updated Nov 1, 2025
One-click install
npx skills add https://github.com/nschneble/rails-superstack --skill policy-agent-nschneble
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: policy-agent
Source: https://github.com/nschneble/rails-superstack/tree/main/.agents/skills/policy-agent
Command: npx skills add https://github.com/nschneble/rails-superstack --skill policy-agent-nschneble

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Pundit-based authorization in Rails applications often requires a clear policy structure, consistent tests, and guardrails to prevent unauthorized actions. This Skill provides a proven framework for creating secure policies, comprehensive RSpec tests, and enforceable patterns that align with best practices.

Core Features & Use Cases

  • Create and extend policies under app/policies with a consistent, maintainable approach.
  • Write thorough RSpec policy specs that cover unauthenticated visitors, regular users, owners, admins, and policy scopes.
  • Enforce controller authorization and safe attribute handling with conventional patterns, scopes, and supportive references.

Quick Start

Create a new policy for a resource and generate its policy specs following the included references and guidelines.

Frequently Asked Questions about policy-agent

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

FAQPage Schema
How do I set up Pundit authorization in Rails with RSpec tests?

Pundit authorization in Rails requires a base ApplicationPolicy, consistent policy classes under app/policies, and thorough RSpec specs covering unauthenticated visitors, users, owners, and admins. This framework enforces deny-by-default security and comprehensive test coverage across all controller actions.

What's the best way to test Pundit policy scopes in RSpec?

Testing Pundit policy scopes in RSpec involves writing specs that verify authorized scope filtering for regular users, owners, and admins. The framework guides creating comprehensive policy tests that validate scope behavior alongside standard permission checks for unauthenticated visitors and admin scenarios.

Do I need a base ApplicationPolicy to enforce Pundit authorization patterns?

A base ApplicationPolicy is required to enforce Pundit authorization patterns consistently. It provides the foundational structure for deny-by-default security, ensuring all model-based resource policies inherit consistent patterns for controller actions, scopes, and safe attribute handling across the Rails application.

How do I enforce controller authorization and safe attribute handling with Pundit?

Enforcing controller authorization with Pundit involves applying conventional patterns that check policies before each action and handle safe attributes through permitted parameters. This framework guides consistent policy enforcement across controller actions and admin scenarios with supportive reference materials.

Can I use Pundit policies for admin scenarios and model-based resources in Rails?

Pundit policies support admin scenarios and model-based resources with controller actions in Rails. The framework provides consistent, maintainable policy patterns that extend a base ApplicationPolicy, ensuring deny-by-default security and comprehensive coverage for varying user roles and resource ownership.