dynamodb

A set of query-safety rules for Laravel applications that use DynamoDB, Amazon's key-value and document database. It requires reads to use a key or an appropriate index instead of scanning a whole table.

In plain words
What is it for?
Use it when writing or reviewing DynamoDB reads through Laravel packages, custom query builders, or the AWS SDK, especially queries, indexes, and repositories.
Why use it?
It prevents slow and expensive full-table reads, including cases where a filter is applied only after the database has already scanned the data.

Cursor rule

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/pekral/cursor-rules/dynamodb
Clone the repo
git clone --depth 1 https://github.com/pekral/cursor-rules
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 856 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 $0.00000 $0.00856
Opus 5 $0.00000 $0.00428
Sonnet 5 $0.00000 $0.00171
Haiku 4.5 $0.00000 $0.00086

Measured yesterday against content hash f518feb520bc, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

dynamodb 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 yesterday.

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.

rules/laravel/dynamodb.mdc · 67 lines

How it starts

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

Laravel DynamoDB

Scope

Apply these rules whenever the project integrates with DynamoDB — via the baopham/laravel-dynamodb package, a DynamoDB-backed Eloquent model, a custom DynamoDB query builder, or the AWS SDK called directly from PHP.

Core Principle

  • Every read must target a key. Scan is the slow, expensive default and must never be the access pattern for production code paths.
  • Treat every change to a DynamoDB query builder, repository, or any code that issues DynamoDB requests as a place that may silently introduce a Scan.
  • A missing partition key turns the call into a Scan even when a FilterExpression is present — filters run after the read and do not replace a key condition.

Required Access Patterns

  • GetItem / BatchGetItem — single-item or known-keys reads.
  • Query with a partition key (and optionally a sort key) — collection reads inside one partition.
  • Query against a Global Secondary Index (GSI) — non-primary-key access patterns. Pass the index name to the query (->index('status-createdAt-index') with baopham/laravel-dynamodb; IndexName in QueryInput when calling the AWS SDK directly).
  • Scan is allowed only for explicit, documented offline/admin tasks (one-off backfills, maintenance scripts) — see the Review Checklist below for the justification requirement.

Reject patterns that omit a key:

Model::all();                                  // full scan
Model::where('status', 'active')->get();      // scan if `status` is not the PK / GSI hash
Model::whereNotNull('email')->first();        // scan

Prefer patterns that target a key:

Model::find($id);                                                       // GetItem
Model::where('userId', $userId)->get();                                 // Query on PK
Model::index('status-createdAt-index')                                  // Query on GSI
    ->where('status', 'active')
    ->get();

Review Checklist

For every PR that touches DynamoDB code, reviewers must verify:

Read the full file on GitHub · 67 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. yesterday First seen · 67 lines · 0 tokens per session scan A f518feb520bc

Subscribe to this mod's changes

dynamodb is a cursor rule published in the GitHub repository pekral/cursor-rules (6 stars, last pushed 6d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 856 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-31.