agentleFS
AlizHarbAlizHarb/agent-skills/skills/create-policy/SKILL.md

create-policy

Skill1 starsChanged 5 months agoMITView on GitHub

Use when creating or changing Laravel policies, gates, or authorization checks for protected resources and operations.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

11 rules. About 0 are common, 9 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill for protected resources, sensitive reads, state changes, exports, impersonation, billing, admin behavior, and external side …

    line 13
  2. Distinctive:

    Add methods for each protected operation.

    line 23
  3. Very specific:

    Use #[\Override] for policy methods that override a parent policy method.

    line 24
  4. Very specific:

    Use Laravel 13 controller #[Authorize] or Livewire #[Authorize] attributes at client boundaries when they make authorization more visible.

    line 25
  5. Distinctive:

    Call policies before state-changing operations and sensitive reads.

    line 26
  6. Distinctive:

    Keep authorization out of Blade-only visibility checks.

    line 27
  7. Distinctive:

    Add denial and allow tests.

    line 28
  8. Distinctive:

    Every protected resource needs authorization.

    line 41
  9. Distinctive:

    Test allowed actors, denied actors, unauthenticated users where relevant, and boundary callers.

    line 48
  10. Distinctive:

    Default to deny when uncertain.

    line 52
  11. Distinctive:

    Avoid relying on client-submitted ownership or role values.

    line 53

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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

Create Policy

When To Use

Use this skill for protected resources, sensitive reads, state changes, exports, impersonation, billing, admin behavior, and external side effects.

Inputs Needed

  • Resource, actor, operation, ownership rules, roles or permissions, edge cases, and denial behavior.

Workflow

  1. Inspect existing policies and authorization conventions.
  2. Generate or update the policy with Laravel conventions.
  3. Add methods for each protected operation.
  4. Use #[\Override] for policy methods that override a parent policy method.
  5. Use Laravel 13 controller #[Authorize] or Livewire #[Authorize] attributes at client boundaries when they make authorization more visible.
  6. Call policies before state-changing operations and sensitive reads.
  7. Keep authorization out of Blade-only visibility checks.
  8. Add denial and allow tests.

Files That May Be Created

  • app/Policies/*Policy.php
  • Authorization tests.

Files That May Be Modified

  • Models, controllers, Livewire components, Actions, providers, routes, and tests.

Architecture Rules

  • Every protected resource needs authorization.
  • Policies decide access; Actions perform operations.
  • Views may hide controls, but server-side checks must enforce access.
  • Attribute-based authorization is allowed at controllers and Livewire boundaries, but Actions still need explicit protection when reused directly.

Testing Requirements

  • Test allowed actors, denied actors, unauthenticated users where relevant, and boundary callers.

Security Requirements

  • Default to deny when uncertain.
  • Avoid relying on client-submitted ownership or role values.

Review Checklist

  • Is every protected operation covered?
  • Are checks made before mutations?
  • Are denial paths tested?

Common Mistakes

  • Authorizing only in Blade.
  • Checking authorization after mutation.
  • Duplicating policy rules in controllers or Livewire components.

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.