Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

aws-dynamodb

БесплатноБез исполняемых скриптовНе проверен

Amazon DynamoDB is a fully managed NoSQL key-value and document database with single-digit millisecond reads and writes. Use this skill to design tables with…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub17 установок в других каталогах

Об этом скилле

AWS DynamoDB

Overview

DynamoDB stores items (rows) in tables addressed by a primary key: a partition key (PK) alone, or a partition key plus sort key (SK). Reads that give the full key (GetItem) or a PK plus an SK condition (Query) are fast and cheap; Scan reads every item and should be reserved for small tables and one-off jobs. You model data around the queries you need, not the other way round.

Building blocks: GSI (global secondary index, any alternate key, can be added later), LSI (same PK, different SK, only at table creation, caps a partition at 10 GB), Streams (ordered change log), TTL (automatic expiry) and point-in-time recovery (PITR).

Instructions

1. Create a table

On-demand (PAY_PER_REQUEST) is the right default for new or spiky workloads; it needs no capacity settings. Turn on deletion protection for production tables.

aws dynamodb create-table \
  --table-name Orders \
  --attribute-definitions AttributeName=PK,AttributeType=S AttributeName=SK,AttributeType=S \
      AttributeName=GSI1PK,AttributeType=S AttributeName=GSI1SK,AttributeType=S \
  --key-schema AttributeName=PK,KeyType=HASH AttributeName=SK,KeyType=RANGE \
  --global-secondary-indexes '[{
    "IndexName": "GSI1",
    "KeySchema": [
      {"AttributeName":"GSI1PK","KeyType":"HASH"},
      {"AttributeName":"GSI1SK","KeyType":"RANGE"}
    ],
    "Projection": {"ProjectionType":"ALL"}
  }]' \
  --billing-mode PAY_PER_REQUEST \
  --deletion-protection-enabled \
  --tags Key=Env,Value=prod

aws dynamodb wait table-exists --table-name Orders
aws dynamodb update-continuous-backups --table-name Orders \
  --point-in-time-recovery-specification PointInTimeRecoveryEnabled=true

For provisioned mode use --billing-mode PROVISIONED --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5, and give every GSI its own ProvisionedThroughput block. Only key attributes are declared in --attribute-definitions.

2. Read and write items (CLI)

The CLI uses typed attribute values ({"S": ...}, {"N": "149.99"}; numbers are strings). status is a reserved word, so expressions alias it with #s.

aws dynamodb put-item --table-name Orders --item '{
  "PK": {"S": "CUSTOMER#C001"}, "SK": {"S": "ORDER#2026-01-15#O001"},
  "total": {"N": "149.99"}, "status": {"S": "pending"}}'

aws dynamodb get-item --table-name Orders \
  --key '{"PK":{"S":"CUSTOMER#C001"},"SK":{"S":"ORDER#2026-01-15#O001"}}'

aws dynamodb update-item --table-name Orders \
  --key '{"PK":{"S":"CUSTOMER#C001"},"SK":{"S":"ORDER#2026-01-15#O001"}}' \
  --update-expression "SET #s = :new, updated_at = :ts" \
  --condition-expression "#s = :old" \
  --expression-attribute-names '{"#s":"status"}' \
  --expression-attribute-values '{":new":{"S":"shipped"},":old":{"S":"pending"},":ts":{"S":"2026-01-16T10:00:00Z"}}'

If the condition fails the call returns ConditionalCheckFailedException and nothing is written; use this for optimistic locking and "create only if absent" (attribute_not_exists(PK)). delete-item takes the same --key.

3. Query, do not scan

aws dynamodb query --table-name Orders \
  --key-condition-expression "PK = :pk AND begins_with(SK, :prefix)" \
  --expression-attribute-values '{":pk":{"S":"CUSTOMER#C001"},":prefix":{"S":"ORDER#2026"}}' \
  --no-scan-index-forward --limit 10

aws dynamodb query --table-name Orders --index-name GSI1 \
  --key-condition-expression "GSI1PK = :pk" \
  --expression-attribute-values '{":pk":{"S":"ORDER#O001"}}'

Results are capped at 1 MB per call; page with LastEvaluatedKey (the CLI and boto3 paginators do this for you). GSI reads are eventually consistent only; base-table reads can pass --consistent-read. --filter-expression filters after the read, so you still pay for the items it drops.

4. boto3: single-table design, Decimal and batches

boto3 refuses Python floats; use Decimal built from strings or the write raises TypeError: Float types are not supported.

import boto3
from decimal import Decimal
from boto3.dynamodb.conditions import Key

table = boto3.resource("dynamodb").Table("Orders")

table.put_item(Item={
    "PK": "CUSTOMER#C001", "SK": "PROFILE", "name": "Alice Johnson",
    "email": "[email protected]", "GSI1PK": "CUSTOMERS", "GSI1SK": "Alice Johnson",
    "entity_type": "Customer",
})
table.put_item(Item={
    "PK": "CUSTOMER#C001", "SK": "ORDER#2026-01-15#O001", "total": Decimal("149.99"),
    "status": "shipped", "GSI1PK": "ORDER#O001", "GSI1SK": "CUSTOMER#C001", "entity_type": "Order",
})

resp = table.query(KeyConditionExpression=Key("PK").eq("CUSTOMER#C001") & Key("SK").begins_with("ORDER#"))
orders = resp["Items"]          # follow resp.get("LastEvaluatedKey") for more pages

with table.batch_writer() as batch:       # chunks into 25-item BatchWriteItem calls and retries unprocessed items
    for i in range(100):
        batch.put_item(Item={"PK": f"PRODUCT#P{i:04d}", "SK": "DETAILS",
Полный SKILL.md на GitHub

Установить aws-dynamodb в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл aws-dynamodb?

Amazon DynamoDB is a fully managed NoSQL key-value and document database with single-digit millisecond reads and writes. Use this skill to design tables with partition and sort keys, add global and local secondary indexes, write and query items with the AWS CLI and boto3, use conditional writes and transactions, enable streams and TTL, and apply single-table design. Use when someone says "create a DynamoDB table", "query by sort key", "add a GSI" or "expire items automatically".

Как установить скилл aws-dynamodb?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл aws-dynamodb запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить aws-dynamodb с