Create DynamoDB CRUD operations
✓Works with OpenClaudeYou are an AWS DynamoDB developer. The user wants to implement complete CRUD (Create, Read, Update, Delete) operations for a DynamoDB table.
What to check first
- Run
aws dynamodb list-tablesto verify your table exists and AWS credentials are configured - Confirm your IAM user has
dynamodb:*permissions on the target table - Check the table's primary key structure with
aws dynamodb describe-table --table-name YourTableName
Steps
- Install the AWS SDK v3 for JavaScript:
npm install @aws-sdk/client-dynamodb @aws-sdk/util-dynamodb - Initialize a DynamoDB client by creating a new
DynamoDBClientwith your region - Use
PutItemCommandto insert a new item into the table withItemparameter containing attribute values - Use
GetItemCommandwith theKeyparameter to retrieve a single item by its primary key - Use
UpdateItemCommandwithUpdateExpressionto modify specific attributes without replacing the entire item - Use
DeleteItemCommandwith theKeyparameter to remove an item from the table - Use
ScanCommandorQueryCommandto retrieve multiple items (ScanCommand for full table scans, QueryCommand for key-based queries) - Always wrap operations in try-catch blocks and handle
ResourceNotFoundExceptionorValidationExceptionerrors
Code
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import {
DynamoDBDocumentClient,
PutCommand,
GetCommand,
UpdateCommand,
DeleteCommand,
ScanCommand,
} from "@aws-sdk/lib-dynamodb";
const client = new DynamoDBClient({ region: "us-east-1" });
const docClient = DynamoDBDocumentClient.from(client);
const TABLE_NAME = "Users";
// CREATE - Put a new item
export async function createUser(userId, userData) {
try {
const command = new PutCommand({
TableName: TABLE_NAME,
Item: {
userId: userId,
...userData,
createdAt: new Date().toISOString(),
},
});
const response = await docClient.send(command);
return { success: true, data: userData };
} catch (error) {
console.error("Error creating user:", error);
throw error;
}
}
// READ - Get a single item by key
export async function getUser(userId) {
try {
const command = new GetCommand({
TableName: TABLE_NAME,
Key: { userId: userId },
});
const response = await docClient.send(command);
return response.Item || null;
} catch (error) {
console.error("Error getting user:", error);
throw error;
}
}
// UPDATE - Modify existing item attributes
export
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Cloud (AWS/GCP/Azure) Skills
Other Claude Code skills in the same category — free to download.
Lambda Function
Create AWS Lambda function with handler
S3 Operations
Set up S3 bucket operations (upload, download, presigned URLs)
SQS Setup
Set up SQS queue producer and consumer
SNS Notifications
Configure SNS for push notifications
CloudFront Setup
Set up CloudFront CDN distribution
Cognito Auth
Implement AWS Cognito authentication
RDS Setup
Configure RDS database connection
ECS Task Definition
Create ECS task definitions
Want a Cloud (AWS/GCP/Azure) skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.