Dynamodbのロゴ

Dynamodb

コミュニティ
ericrisco
dynamodb

Use when modeling or operating a DynamoDB table: deriving partition/sort keys from access patterns, single-table vs table-per-entity, adding a GSI/LSI, on-demand vs provisioned capacity, or diagnosing hot-partition throttling. NOT relational schema/SQL/EXPLAIN (that is `postgresdb`), NOT aggregation-pipeline document modeling (that is `mongodb`).

概要

公開者ericrisco
リポジトリrsc-harness
スキル名dynamodb
スター
239
フォーク
24
同梱ファイル
4
ライセンスMIT
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 4個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    ericriscoがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Dynamodb」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/ericrisco/rsc-harness/tree/main/skills/dynamodb
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/ericrisco/rsc-harness.git /tmp/rsc-harness
mkdir -p .claude/skills
cp -r /tmp/rsc-harness/skills/dynamodb .claude/skills/dynamodb
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでDynamodbを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にDynamodbを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Dynamodbは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

DynamoDB — access-pattern-first modeling and capacity

DynamoDB is not a relational database with a different syntax. It has no joins, no ad-hoc queries, no server-side aggregation, and it punishes schema changes after launch. So the modeling discipline IS the work: enumerate every read and write the app must perform, THEN design keys so each one is a single GetItem or Query. Add an index only when the base table physically cannot serve a pattern. Decide capacity last.

Your job here is to stop the user from treating DynamoDB like SQL.

What you produce / what you refuse

You deliver three artifacts, in this order:

  1. An access-pattern list — a table of every query and write, with key condition, read/write, frequency, and what serves it. This is the contract the keys must satisfy.
  2. A key-design document — entity → PK/SK encoding → which table or named GSI serves each pattern.
  3. A capacity + cost recommendation — on-demand vs provisioned vs reserved, and the hot-partition risk.

You refuse to: click through the AWS console, wire the IaC/CI provisioning pipeline (that is ../deployment/SKILL.md), or model the data as normalized tables you then "join" in application code. You emit DDL, IaC snippets, and example SDK calls — you do not provision the infrastructure.

The steps below run in sequence — access patterns, then keys, then indexes, then capacity. Reordering them is the single most common DynamoDB mistake.

Step 1 — Enumerate access patterns

You cannot query what your keys do not express, and there is no WHERE over arbitrary columns, so produce this table before you name a single attribute. It is also exactly what scripts/verify.sh checks: run scripts/verify.sh <path-to-key-design.{md,json}> and every row must carry a key target (pk/sk or a named gsi) and a query_type. It FAILS on any pattern served by Scan, WARNS on FilterExpression, and asserts ≤20 GSIs / ≤5 LSIs. Read-only; exits 0 on an empty or clean target.

patternentitykey conditionread/writeest. freqserved by
Get a user by idUserPK=USER#<id>readhighbase table GetItem
Get a user's orders, newest firstOrderPK=USER#<id>, SK begins_with ORDER#readhighbase table Query
Look up a user by emailUserGSI1PK=EMAIL#<email>readmediumGSI1 Query
List open orders across all usersOrdersparse GSI2PK=OPENreadlowGSI2 (sparse) Query

Bad → Good. The whole game is moving from vague to executable:

  • Bad: "store users and orders." (No key condition is derivable from this.)
  • Good: "get all orders for a user, newest first, page size 25." (PK + SK range + sort direction fall out.)

Rule: if a pattern needs a FilterExpression over more than ~10% of the items it scans, that is a modeling smell — redesign the key, do not patch it with a filter.

Step 2 — Key design + single-table decision

Get this wrong and you pay for it forever: changing a table's key schema after launch means a full migration (new table + backfill + dual-write).

Composite-key encoding. Use prefixed, sortable strings so one partition holds an entity and its children — items read together are co-located, so one Query returns them — and so a sort-key range query slices them:

text
PK = USER#123
SK = USER#123                      <- the user item itself
SK = ORDER#2026-06-02T10:15#A91    <- an order, ISO-8601 timestamp sorts lexically = chronologically
SK = ORDER#2026-06-02T11:40#B07
json
{ "PK": "USER#123", "SK": "ORDER#2026-06-02T10:15#A91",
  "Type": "Order", "Total": 4200, "Status": "OPEN" }

One Query with PK = USER#123 AND SK begins_with("ORDER#") returns all of that user's orders, already sorted. That is a one-to-many relationship with no join.

Many-to-many uses an adjacency list: store the edge twice (or use an inverted GSI, see Step 3) so you can traverse it from either side. Worked end-to-end in references/access-patterns.md — a multi-tenant SaaS / e-commerce model (pattern table → PK/SK map → GSI map → AWS SDK v3 @aws-sdk/lib-dynamodb calls), adjacency-list many-to-many, time-series and leaderboard patterns.

Single-table vs table-per-entity — decide honestly, do not cargo-cult:

signalsingle-tabletable-per-entity
Many entities read together in one requestyesno
Many access patterns over related entitiesyesno
Entities are independent, patterns are few/simplenoyes (simpler, fine)
Team unfamiliar with overloaded keysweigh the costyes
Need clean per-entity IAM / TTL / capacity isolationnoyes

Single-table design earns its complexity when many related entities share access patterns. When entities are independent and the queries are few, separate tables are simpler and perfectly correct — say so.

Step 3 — GSIs (only when the base table can't serve it)

Three named patterns, each with a one-line why:

  • Inverted index — swap PK and SK on the GSI so you can read the relationship from the other side (GSI1PK = SK_value, GSI1SK = PK_value). Serves "given an order, who owns it" / many-to-many reverse.
  • Sparse index — only items that carry the GSI's key attribute are indexed. Write the attribute only on the few items you want to find ("OPEN" orders, flagged accounts) so the index is tiny and the query is "find the few" instead of "scan the many."
  • Overloaded GSI — reuse generic GSI1PK/GSI1SK attributes across multiple entity types so one index serves several patterns. Keeps you under the index quota.

Rule: add a GSI only when the base table physically cannot answer the pattern. Every GSI is a standing cost.

Warnings that bite people:

  • GSIs are always eventually consistent — you cannot read-your-own-write through a GSI. If a pattern needs strong consistency, it must hit the base table.
  • Each write to the base table replicates to every GSI whose keys changed, each consuming its own write capacity. More indexes = multiplied write cost.
  • Project only the attributes each pattern needs. Blanket ProjectionType: ALL doubles storage and write cost; use KEYS_ONLY or INCLUDE when you can.

Quotas (default, adjustable for GSIs): up to 20 GSIs and 5 LSIs per table. LSIs must be defined at table creation, share the base partition key, and impose a 10 GB item-collection cap (all items under one partition key). GSI-only tables have no such cap — a real reason to prefer GSIs over LSIs.

Step 4 — Capacity & cost

Capacity mode is a billing decision, not a modeling one — it changes nothing about the keys, so pick it after the model is stable. Decision table:

traffic shaperecommendationwhy
Spiky / unpredictable, or < ~10M req/monthOn-demand (the AWS default)Nov-2024 ~50% price cut made it cheapest for most workloads; no capacity planning
Sustained utilization > ~40%Provisioned + auto-scalingprovisioned writes (~$0.047/M) are far cheaper than on-demand at high utilization
Predictable, long-running, > ~70% utilProvisioned + reserved capacity3-year reserved (~$0.013/M write) is dramatically cheaper still

On-demand request unit pricing (us-east-1, standard table class): RRU $0.125 / million, WRU $0.625 / million. Warm throughput (the instantaneous read/write a table can serve) is shown by default at no cost and rises automatically as you scale; you pay only if you proactively pre-warm ahead of a known spike.

Hot partitions. Each physical partition has a hard ceiling of 3,000 RCU and 1,000 WCU per second, regardless of the table's total capacity. Drive one partition key past that and you are throttled even while well under your table limit — this is why "writes throttled but I'm under capacity" means a hot key. Fix with high-cardinality keys or write-sharding: append a suffix bucket to the PK.

text
# Hot: every write lands on one partition
PK = METRIC#daily_total

# Sharded: spread writes across N buckets, scatter-gather on read
PK = METRIC#daily_total#<0..9>

Capacity math, full pricing detail (including the Nov-2024 cut), warm throughput, the full quota table, and hot-partition diagnosis + the sharding recipe live in references/capacity-and-limits.md.

Step 5 — Operational guardrails

  • Item size is hard-capped at 400 KB (attribute names + values). Offload large blobs to S3 and store the S3 key in the item.
  • Query/Scan return at most 1 MB per request. That is why a Query "only returns some rows" — loop on LastEvaluatedKey until it is absent.
bash
aws dynamodb query --table-name App \
  --key-condition-expression 'PK = :pk' \
  --expression-attribute-values '{":pk":{"S":"USER#123"}}' \
  --starting-token "$LAST_EVALUATED_KEY"   # paginate; absent => done
  • TransactWriteItems / TransactGetItems group up to 100 unique items; a transactional write consumes 2× WCU.
  • BatchWriteItem takes up to 25 put/delete requests per call.
  • FilterExpression runs AFTER the read consumes capacity — it saves bandwidth, not RCU. Never use a filter as a substitute for a key condition.
  • TTL for automatic expiry (set an epoch-seconds attribute); deletion is best-effort, not instant.
  • DynamoDB Streams for change capture / building derived & denormalized views.

Anti-patterns

Anti-patternWhy it failsDo instead
Designing keys before listing access patternsThe keys won't express the queries; post-launch fix is a full migrationList every read/write first; derive keys from them
Scan + FilterExpression as your "query"Scan reads (and bills) the whole table; the filter only trims the responseMake the pattern a Query on a key or GSI
One GSI per attribute "just in case"Each GSI multiplies write cost and counts against the 20-GSI quotaAdd a GSI only when the base table can't serve a real pattern
Normalizing into separate tables joined in app codeDynamoDB has no joins; app-side joins are N round-trips and racesCo-locate related items under one PK; query once
Low-cardinality PK (e.g. status, tenant)All traffic funnels to one partition → throttling at 3000 RCU / 1000 WCUHigh-cardinality PK; write-shard hot keys
Expecting strong consistency from a GSIGSIs are always eventually consistent — stale readsRead consistency-critical patterns from the base table
ProjectionType: ALL on every GSIDoubles storage and write cost on each indexed writeProject KEYS_ONLY / INCLUDE only what the pattern needs
Storing > 400 KB inline (images, docs, logs)Hits the 400 KB item cap; bloats every readPut the blob in S3, store the pointer in the item
Picking capacity mode before the model is doneMode is billing, not modeling — premature and often wrongStabilize keys/GSIs first, then choose on-demand vs provisioned

Route elsewhere when the engine is different

Relational schema / SQL / EXPLAIN / indexing → ../postgresdb/SKILL.md; MySQL-engine schema → mysql; document modeling + aggregation pipeline → mongodb; cache / queue / rate-limiter → redis; vector store / semantic search → vector-db; AWS account / IAM / VPC setup → aws-essentials; provisioning the table in CI/CD → ../deployment/SKILL.md; API-layer auth/secrets in front of the table → ../secure-coding/SKILL.md.

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Dynamodb」では何ができますか?

Use when modeling or operating a DynamoDB table: deriving partition/sort keys from access patterns, single-table vs table-per-entity, adding a GSI/LSI, on-demand vs provisioned capacity, or diagnosing hot-partition throttling. NOT relational schema/SQL/EXPLAIN (that is `postgresdb`), NOT aggregation-pipeline document modeling (that is `mongodb`).

TypingMindでDynamodbを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Dynamodbはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにDynamodbをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/ericrisco/rsc-harness/tree/main/skills/dynamodbを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Dynamodbを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Dynamodbで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもDynamodbを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Dynamodb」は無料ですか?

はい。ericriscoがMITライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇