All skills
aws avatar

/aws-sdk-js-v3-usage

@c3ed514

AWS SDK for JavaScript v3 development patterns. Use when writing JavaScript or TypeScript code that uses AWS services via @aws-sdk/* packages (aws-sdk-js-v3), or when asked about schemas, runtime validation, serialization, or code generation in the context of the JS/TS AWS SDK.

Use this Skill: https://skilld.dev/gh/aws/agent-toolkit-for-aws/aws-sdk-js-v3-usage

This session only. Nothing lands on disk.

referencesdynamodb.md

≈727 tokens on demand. Your agent reads this file only when SKILL.md points to it.

DynamoDB Reference

DocumentClient (lib-dynamodb)

@aws-sdk/lib-dynamodb marshals native JS types to/from DynamoDB AttributeValues automatically.

import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient, GetCommand, PutCommand, QueryCommand, DeleteCommand } from "@aws-sdk/lib-dynamodb";

const client = DynamoDBDocumentClient.from(new DynamoDBClient({ region: "us-east-1" }));

// Put
await client.send(new PutCommand({ TableName: "MyTable", Item: { id: "1", name: "Alice", age: 30 } }));

// Get
const { Item } = await client.send(new GetCommand({ TableName: "MyTable", Key: { id: "1" } }));

// Query
const { Items } = await client.send(new QueryCommand({
  TableName: "MyTable",
  KeyConditionExpression: "id = :id",
  ExpressionAttributeValues: { ":id": "1" },
}));

// Delete
await client.send(new DeleteCommand({ TableName: "MyTable", Key: { id: "1" } }));

Type Mapping

JS type DynamoDB type
string S
number / bigint / NumberValue N
boolean BOOL
null NULL
Array L
Object M
Uint8Array / Buffer / Blob / File... B
Set<string> SS
Set<number> / Set<bigint> / Set<NumberValue> NS
Set<Uint8Array> / Set<Blob>... BS

Marshall Options

const client = DynamoDBDocumentClient.from(new DynamoDBClient({}), {
  marshallOptions: {
    removeUndefinedValues: true,   // strip undefined from objects/arrays
    convertEmptyValues: false,     // convert "" / empty sets to null
    convertClassInstanceToMap: false,
    allowImpreciseNumbers: false,  // true = allow numbers > MAX_SAFE_INTEGER (loses precision)
  },
  unmarshallOptions: {
    wrapNumbers: false,            // true = return NumberValue instead of JS number
  },
});

Large Numbers

Numbers exceeding Number.MAX_SAFE_INTEGER throw by default. Use NumberValue for precision:

import { NumberValue, DynamoDBDocumentClient } from "@aws-sdk/lib-dynamodb";

await client.send(new PutCommand({
  TableName: "MyTable",
  Item: { id: "1", bigNum: NumberValue.from("1000000000000000000000.000000001") },
}));

Custom unmarshalling with BigInt:

const client = DynamoDBDocumentClient.from(new DynamoDBClient({}), {
  unmarshallOptions: { wrapNumbers: (str) => BigInt(str) },
});

Pagination (Scan / Query)

import { paginateScan } from "@aws-sdk/lib-dynamodb";

for await (const page of paginateScan({ client }, { TableName: "MyTable", Limit: 100 })) {
  console.log(page.Items);
}

Aggregated (full) Client

import { DynamoDBDocument } from "@aws-sdk/lib-dynamodb";

const doc = DynamoDBDocument.from(new DynamoDBClient({}));
await doc.put({ TableName: "MyTable", Item: { id: "1" } });
await doc.get({ TableName: "MyTable", Key: { id: "1" } });

Destroy

ddbDocClient.destroy() is a no-op. Call destroy() on the underlying DynamoDBClient.

Source: SKILL.md on GitHub

No alerts16d3 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    This skill is a comprehensive documentation resource for the AWS SDK for JavaScript v3. It provides development patterns, best practices for credential management, resource handling, and performance optimization using official AWS packages and repositories.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

Signed by skilld at c3ed514. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 5 months ago

README badge

README badge for aws/agent-toolkit-for-aws/aws-sdk-js-v3-usage