agentleFS
jimmypocockjimmypocock/cursor-rules/.cursor/rules/aws-dynamodb.mdc

cursor-rules / rules

Cursor rule8 starsChanged 19 months agoMITView on GitHub

AWS DynamoDB Best Practices

The file

Show its rules and text

We split this aws-dynamodb.mdc into the rules it gives an agent

44 rules. About 0 are common, 43 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈43

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Start with access patterns before determining table structure

    line 17
  2. Distinctive:

    Use single-table design for related entities when appropriate

    line 18
  3. Distinctive:

    Keep item sizes small (preferably under 4KB)

    line 19
  4. Distinctive:

    Avoid overly normalized data structures

    line 20
  5. Distinctive:

    Avoid partition keys that could create hot spots

    line 26
  6. Distinctive:

    Use composite sort keys for hierarchical relationships

    line 27
  7. Distinctive:

    Use meaningful prefixes in sort keys for item collection filtering

    line 29
  8. Distinctive:

    Consider using GSIs for alternative access patterns

    line 31
  9. Distinctive:

    Use consistent attribute naming conventions

    line 34
  10. Distinctive:

    Use short attribute names for frequently accessed items

    line 37
  11. Distinctive:

    Use consistent JSON serialization for complex nested objects

    line 39
  12. Distinctive:

    Consider compression for large attribute values

    line 40
  13. Distinctive:

    Use sparse indexes where appropriate

    line 43
  14. Distinctive:

    Create GSIs only for required access patterns

    line 44
  15. Very specific:

    Keep index projections minimal (KEYS_ONLY or INCLUDE specific attributes)

    line 45
  16. Distinctive:

    Use LSIs sparingly due to partition size limits

    line 46
  17. Distinctive:

    Consider overloading indexes for multiple access patterns

    line 48
  18. Distinctive:

    Use index sort keys to enable range filtering

    line 49
  19. Distinctive:

    Use query operations instead of scans whenever possible

    line 52
  20. Distinctive:

    Use consistent reads for time-sensitive operations

    line 54
  21. Distinctive:

    Use eventually consistent reads for non-critical operations

    line 55
  22. Distinctive:

    Use BatchWriteItem for bulk operations (max 25 items)

    line 61
  23. Distinctive:

    Use conditional writes to prevent race conditions

    line 62
  24. Distinctive:

    Use atomic counters for high-contention updates

    line 64
  25. Distinctive:

    Use streams for event-driven architectures

    line 69
  26. Distinctive:

    Use on-demand capacity for unpredictable workloads

    line 78
  27. Distinctive:

    Use provisioned capacity with auto-scaling for predictable workloads

    line 79
  28. Distinctive:

    Use DAX for read-heavy workloads that can leverage caching

    line 82
  29. Distinctive:

    Use appropriate retry policies with exponential backoff

    line 84
  30. Distinctive:

    Use TTL for automatic data expiration

    line 89
  31. Distinctive:

    Use DAX for read-heavy workloads to reduce read capacity needs

    line 92
  32. Distinctive:

    Consider using Reserved Capacity for stable workloads

    line 93
  33. Distinctive:

    Use VPC endpoints for private access

    line 97
  34. Distinctive:

    Use IAM condition keys to restrict access to specific items

    line 100
  35. Distinctive:

    Create migration strategies for changing access patterns

    line 107
  36. Distinctive:

    Use DynamoDB Streams for online migrations

    line 108
  37. Distinctive:

    Test migrations in non-production environments

    line 109
  38. Distinctive:

    Document data structures and access patterns

    line 111
  39. Distinctive:

    Use a repository pattern to abstract database operations

    line 114
  40. Distinctive:

    Create strongly typed data models

    line 115
  41. Distinctive:

    Add tracing and logging for database operations

    line 120
  42. Distinctive:

    Use transactions for multi-item operations requiring consistency

    line 124
  43. Distinctive:

    Document consistency requirements for each operation

    line 126
  44. Distinctive:

    Consider event sourcing for complex state tracking

    line 127

≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule 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
aws-dynamodb.mdc
---
description: AWS DynamoDB Best Practices
globs: 
alwaysApply: false
---
---
Description: AWS DynamoDB Best Practices
Globs: **/dynamodb/**/*.ts, **/models/**/*.ts, **/database/**/*.ts, **/repositories/**/*.ts
---

# AWS DynamoDB Development Standards
@base.mdc
@typescript.mdc

## Data Modeling Principles
- Design for query patterns, not data relationships
- Start with access patterns before determining table structure
- Use single-table design for related entities when appropriate
- Keep item sizes small (preferably under 4KB)
- Avoid overly normalized data structures
- Balance between read and write efficiency based on workload
- Design with future growth and changing access patterns in mind

## Key Design
- Choose partition keys with high cardinality to distribute data evenly
- Avoid partition keys that could create hot spots
- Use composite sort keys for hierarchical relationships
- Design sort keys to support range queries efficiently
- Use meaningful prefixes in sort keys for item collection filtering
- Implement composite keys with delimiters (e.g., `USER#123#PROFILE`)
- Consider using GSIs for alternative access patterns

## Item Structure
- Use consistent attribute naming conventions
- Include entity type discriminator attributes
- Denormalize data when it supports common access patterns
- Use short attribute names for frequently accessed items
- Store date/time values in ISO format
- Use consistent JSON serialization for complex nested objects
- Consider compression for large attribute values

## Secondary Indexes
- Use sparse indexes where appropriate
- Create GSIs only for required access patterns
- Keep index projections minimal (KEYS_ONLY or INCLUDE specific attributes)
- Use LSIs sparingly due to partition size limits
- Design indexes to support efficient query patterns
- Consider overloading indexes for multiple access patterns
- Use index sort keys to enable range filtering

## Query Optimization
- Use query operations instead of scans whenever possible
- Implement pagination for large result sets
- Use consistent reads for time-sensitive operations
- Use eventually consistent reads for non-critical operations
- Batch operations for multiple items when possible
- Leverage query filtering only for post-filtering, not as a primary filter
- Implement cursor-based pagination over offset-based

## Write Operations
- Use BatchWriteItem for bulk operations (max 25 items)
- Use conditional writes to prevent race conditions
- Implement optimistic locking with version attributes
- Use atomic counters for high-contention updates
- Leverage transactions for multi-item consistency
- Implement idempotent write operations

## DynamoDB Streams
- Use streams for event-driven architectures
- Process stream events asynchronously
- Implement idempotent Lambda consumers
- Set appropriate batch size and window for stream processors
- Handle partial failures in stream consumers
- Track stream processing position for recovery
- Leverage Kinesis for complex stream processing

## Performance & Scaling
- Use on-demand capacity for unpredictable workloads
- Use provisioned capacity with auto-scaling for predictable workloads
- Implement adaptive capacity planning
- Monitor and adjust capacity based on usage patterns
- Use DAX for read-heavy workloads that can leverage caching
- Implement client-side request batching and caching
- Use appropriate retry policies with exponential backoff

## Cost Optimization
- Choose the right capacity mode for your workload
- Minimize index count and attribute projections
- Use TTL for automatic data expiration
- Implement data archiving strategies for historical data
- Monitor and optimize read/write capacity usage
- Use DAX for read-heavy workloads to reduce read capacity needs
- Consider using Reserved Capacity for stable workloads

## Security Best Practices
- Implement fine-grained IAM policies with least privilege
- Use VPC endpoints for private access
- Enable server-side encryption
- Implement attribute-level encryption for sensitive data
- Use IAM condition keys to restrict access to specific items
- Audit DynamoDB access with CloudTrail
- Implement data classification and handling procedures

## Data Migration & Evolution
- Plan for schema evolution in single-table designs
- Implement versioning for item structures
- Create migration strategies for changing access patterns
- Use DynamoDB Streams for online migrations
- Test migrations in non-production environments
- Implement rollback procedures for failed migrations
- Document data structures and access patterns

## Repository Pattern Implementation
- Use a repository pattern to abstract database operations
- Create strongly typed data models
- Implement data validation before persistence
- Create entity-specific repositories
- Share common query building utilities
- Handle errors and retries consistently
- Add tracing and logging for database operations

## Data Consistency
- Understand and leverage DynamoDB's consistency model
- Use transactions for multi-item operations requiring consistency
- Implement optimistic concurrency control
- Document consistency requirements for each operation
- Consider event sourcing for complex state tracking

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.