agentleFS
chenson42chenson42/stackkeel/.claude/skills/add-permission/SKILL.md

add-permission

Skill1 starsChanged 53 days agoMITView on GitHub

Add a new feature permission to FEATURE_CATALOG in packages/permissions and optionally bind it to a role on next seed

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 1 is distinctive, and 7 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 7

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    When the user invokes /add-permission, walk through adding a new feature permission to the kit's permission system.

    line 9
  2. Distinctive:

    Ask the user (if not already provided):

    line 15
  3. Very specific:

    Add the new key to the FEATURES constant:

    line 27
  4. Very specific:

    Add the matching FEATURE_CATALOG entry:

    line 36
  5. Very specific:

    Keep the catalog entries in the same order as the FEATURES constant — it makes review diffs easier to read.

    line 47
  6. Very specific:

    If the new permission should be granted to a role on a fresh seed, edit packages/db/src/seed.ts and add the feature key to that role's …

    line 51
  7. Very specific:

    Update docs/product/functionality-map.md if the permission gates a new capability.

    line 86
  8. Very specific:

    Run /release-notes to record the new permission in the current release notes file.

    line 87

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “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

Add Feature Permission

When the user invokes /add-permission, walk through adding a new feature permission to the kit's permission system. The permission key may be provided as $ARGUMENTS (e.g., audit.read).

FEATURE_CATALOG in packages/permissions/src/index.ts is the source of truth. The seed script (packages/db/src/seed.ts) reads this catalog and inserts each feature into the features table. Role bindings happen in the seed too. The catalog in code — not the database — is the source of truth for what features exist; the admin roles UI renders directly from it.

Step 1: Gather Information

Ask the user (if not already provided):

  1. Permission key — dot-notation (e.g., audit.read, users.invite, tickets.triage).
  2. Constant name — UPPER_SNAKE_CASE for the FEATURES object (e.g., AUDIT_READ).
  3. Human-readable name — for the admin UI (e.g., "Read audit log").
  4. Description — one sentence; shown next to the name in the admin roles editor.
  5. Category — usually admin; add a new category if the feature belongs to a non-admin surface.
  6. Default roles — which roles get this permission on a fresh seed? Usually admin. Sometimes also member. Rarely none (assigned manually).
  7. Admin-protected? — if losing this permission would lock admins out of the admin app, add it to ADMIN_PROTECTED_FEATURES (the anti-lockout list the roles UI refuses to remove from the admin role).

Step 2: Update packages/permissions/src/index.ts

Add the new key to the FEATURES constant:

export const FEATURES = {
  // ... existing entries ...
  AUDIT_READ: "audit.read",
} as const;

Add the matching FEATURE_CATALOG entry:

{
  key: FEATURES.AUDIT_READ,
  name: "Read audit log",
  description: "View the append-only audit log of security-sensitive actions.",
  category: "admin",
},

Keep the catalog entries in the same order as the FEATURES constant — it makes review diffs easier to read.

Step 3: Wire the Default Role Binding (Optional)

If the new permission should be granted to a role on a fresh seed, edit packages/db/src/seed.ts and add the feature key to that role's binding list. The seed is idempotent — re-running it is safe.

For an existing database, the seed will only add the binding; it will not revoke it from any role that already has the permission via custom assignment. That's the right behavior.

Step 4: Apply the Change Locally

pnpm db:seed

This inserts the new row into features and (if you updated the seed) binds it to the configured roles.

Step 5: Use the New Permission

API route handler / server action:

import { auth } from "@/auth";
import { FEATURES, hasFeature } from "@repo/permissions";

const session = await auth();
if (!hasFeature(session?.user?.features, FEATURES.AUDIT_READ)) {
  return NextResponse.json({ error: "Forbidden" }, { status: 403 });
}

UI conditional render:

const canRead = hasFeature(session?.user?.features, FEATURES.AUDIT_READ);
{canRead && <AuditLogPanel />}

Remember the invariant: a permission answers "is this user allowed to do X?" A feature flag answers "is X turned on here?" A flag never gates a permission (AGENTS.md → Key Invariants).

Step 6: Document and Release-Note

  • Update docs/product/functionality-map.md if the permission gates a new capability.
  • Run /release-notes to record the new permission in the current release notes file.

Summary

Present what changed:

  • New FEATURES.<KEY> constant in packages/permissions
  • New FEATURE_CATALOG entry (name, description, category)
  • ADMIN_PROTECTED_FEATURES updated: yes / no
  • Seed binding updated (which roles get it on fresh install): yes / no
  • Local seed run: PASS / FAIL
  • Files modified

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.