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 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 4 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 ericrisco 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Dynamodb AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

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

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

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,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Dynamodb。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Dynamodb 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 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.

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Dynamodb AI 技能有什么作用?

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,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Dynamodb?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Dynamodb 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Dynamodb 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Dynamodb AI 技能免费吗?

是的。ericrisco 已在 GitHub 上根据 MIT 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇