policy-agent

Implement Pundit-based authorization policies with RSpec tests for Rails apps.

Updated Mar 19, 2026
One-click install
npx skills add https://github.com/reckerswartz/resume_builder --skill policy-agent-reckerswartz
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: policy-agent
Source: https://github.com/reckerswartz/resume_builder/tree/main/.windsurf/skills/policy-agent
Command: npx skills add https://github.com/reckerswartz/resume_builder --skill policy-agent-reckerswartz

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Creates secure Pundit authorization policies with comprehensive RSpec tests and scope restrictions to enforce least-privilege access in Rails apps.

Core Features & Use Cases

  • Policy scaffolding: auto-generates app/policies and spec/policies for consistent authorization.
  • Controller integration: ensures every action uses authorize and policy_scope for reliable access control.
  • Testing guardrails: provides exhaustive RSpec tests covering visitors, authenticated users, owners, and admins, plus scope behavior.

Quick Start

Boot up a new policy with bin/rails generate pundit:policy Entity and add corresponding policy tests in spec/policies, then wire up authorize calls in your controllers.

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 policies in a Rails app?

Pundit authorization policies in Rails require a base ApplicationPolicy and per-entity policy classes in app/policies, integrated with controllers using authorize and policy_scope methods to enforce least-privilege access.

What do RSpec tests for Pundit policies need to cover?

RSpec tests for Pundit policies should cover visitors, authenticated users, owners, and admin roles, plus scope behavior, ensuring least-privilege access control is enforced across all common workflows.

Do I need a base ApplicationPolicy before generating Pundit policies?

Yes, a base ApplicationPolicy is required before using Pundit policies, serving as the parent class for per-policy specs and enabling controller integrations via authorize and policy_scope.

Can I use Pundit to enforce admin roles and ownership in Rails controllers?

Yes, Pundit enforces admin roles and ownership in Rails controllers by applying authorize to every action and policy_scope for index scoping, ensuring least-privilege access control across common workflows.

What's the best way to scope ActiveRecord queries with Pundit for least-privilege access?

The best way to scope ActiveRecord queries with Pundit is using policy_scope in controllers, restricting index results based on user roles, ownership, and admin privileges to enforce least-privilege access.