crud-layer

crud-layer is a cursor rule for Cursor from airweave-ai/airweave. It costs 0 tokens per session (1,790 once invoked), scanned A, original, MIT.

A backend layer that provides standard operations for creating, reading, updating, and deleting database records. It also checks whether users belong to the right organisation and records who changed each resource.

In plain words
What is it for?
Use it when adding database operations for organisation-owned, user-owned, or public resources, with authentication, access control, transactions, and audit information.
Why use it?
It keeps database access and permission checks consistent instead of requiring every endpoint to implement them differently.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/airweave-ai/airweave/crud-layer
Clone the repo
git clone --depth 1 https://github.com/airweave-ai/airweave

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for crud-layer

README.md
[![agentmods](https://agentmods.dev/badge/rules/airweave-ai/airweave/crud-layer.svg)](https://agentmods.dev/rules/airweave-ai/airweave/crud-layer)
Your own site
<a href="https://agentmods.dev/rules/airweave-ai/airweave/crud-layer"><img src="https://agentmods.dev/badge/rules/airweave-ai/airweave/crud-layer.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,790 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.01790
Opus 5 $0.00000 $0.00895
Sonnet 5 $0.00000 $0.00358
Haiku 4.5 $0.00000 $0.00179

Measured 6d ago against content hash 00bf460f12af, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

crud-layer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/crud-layer.mdc · 220 lines

How it starts

The opening of the file, as written. The whole thing — 220 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Airweave CRUD Layer Architecture

Overview

The CRUD layer provides a consistent interface for database operations across all models in Airweave. It implements a sophisticated inheritance hierarchy that enforces proper access control, transaction management, and audit tracking.

Inheritance Hierarchy

Base Classes

1. CRUDBaseOrganization (_base_organization.py)
  • Purpose: For resources scoped to organizations (most common pattern)
  • Key Features:
    • Enforces organization-level access control via BaseContext
    • Tracks user modifications with created_by_email and modified_by_email
    • Validates organization access on every operation
    • Supports both user and API key authentication contexts
    • Logger access via ctx.logger for contextual logging
2. CRUDBaseUser (_base_user.py)
  • Purpose: For pure user-level data (e.g., user profiles)
  • Key Features:
    • Enforces strict user-level access (can only access own data)
    • No organization scoping
    • Simpler permission model - user can only CRUD their own resources
3. CRUDPublic (_base_public.py)
  • Purpose: For system-wide public resources (e.g., sources, destinations, embedding models)
  • Key Features:
    • No access control - publicly accessible
    • Often used for system configuration data
    • Supports filtering by organization for multi-tenant scenarios
    • Includes sync() method for bulk updates

Core Concepts

BaseContext

The BaseContext (from core.context) is the universal context type for the CRUD layer. ApiContext and SyncContext both inherit from it:

@dataclass
class BaseContext:
    organization: schemas.Organization  # Always present
    user: Optional[schemas.User] = None # Present for user auth, None for API keys/system
    logger: ContextualLogger            # Auto-derived from org/user if not provided

Key Properties:

  • has_user_context: True if user is present (Auth0 or system with user)
  • tracking_email: Returns user email for audit tracking
  • user_id: Returns user UUID if available
  • has_feature(flag): Check organization feature flags
  • logger: Contextual logger (auto-derived from identity, overridable)

Read the full file on GitHub · 220 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 220 lines · 1,790 tokens per session scan A 00bf460f12af

Subscribe to this mod's changes

crud-layer is a cursor rule published in the GitHub repository airweave-ai/airweave (6,566 stars, last pushed 3mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,790 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.