crudable

Implement CRUDable model operations with Can* permission checks in pkg/models/.

5.0k|597|Updated Nov 28, 2018
One-click install
npx skills add https://github.com/go-vikunja/vikunja --skill crudable
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: crudable
Source: https://github.com/go-vikunja/vikunja/tree/main/.claude/skills/crudable
Command: npx skills add https://github.com/go-vikunja/vikunja --skill crudable

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill prevents insecure or inconsistent CRUD implementations by ensuring model-level permission checks are implemented once and enforced reliably.

Core Features & Use Cases

  • Model-level CRUD + permission methods: Add the required CRUDable interface and implement CanRead, CanCreate, CanUpdate, and CanDelete on the model.
  • Centralized access control: Enforce permissions via Can* methods rather than duplicating logic in route handlers.
  • Test coverage for access behavior: Provide positive and negative test cases, including inherited and shared access edge cases when supported.
  • Operational checklist for reviews: Covers method placement, interface usage, call order expectations, and common anti-patterns to avoid.

Quick Start

Use the crudable skill to review or implement a new model in pkg/models/ by adding CRUD operations plus the full set of model-level Can* permission methods and ensuring both sides of permission tests are covered.

Frequently Asked Questions about crudable

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

FAQPage Schema
How do I implement model-level access control for CRUD operations in Go?

To centralize access control, implement the required CRUDable interface and define CanRead, CanCreate, CanUpdate, and CanDelete methods on your model. This enforces permissions directly at the model layer, avoiding duplicated logic in route handlers.

What is the best way to structure Go CRUD permissions using xorm?

The best way to structure CRUD permissions with xorm is to place permission logic inside model-level Can* methods rather than route handlers. This ensures secure and consistent behavior by querying access rights exactly where model operations are handled.

How do I write unit tests for Go model permission checks?

Write unit tests for Go model permission checks by providing both positive and negative test cases. You must also include inherited and shared access edge cases to ensure the Can* methods correctly enforce read, create, update, and delete restrictions.

Do I need to check permissions in route handlers if my model has Can* methods?

No, you should avoid rechecking permissions in route handlers. The Can* methods on the model layer handle access control enforcement, so duplicating these checks in routes creates unnecessary logic and potential inconsistencies.

Why do my Go model CRUD operations bypass access control rules?

Go model CRUD operations bypass access control when permission checks are omitted from Can* methods or incorrectly placed in route handlers. Implementing the CRUDable interface with proper CanRead, CanCreate, CanUpdate, and CanDelete logic resolves this enforcement issue.