agentsclimarketplace

Aws blocks

Skill tomoki10/aws-blocks-skills/skills/aws-blocks

Guidance for building backends with AWS Blocks, the @aws-blocks/* TypeScript "infrastructure from code" framework where a single Block instantiation (e.g. new DistributedTable(...)) resolves to a local mock in dev, a CDK construct at deploy, and an AWS SDK call in Lambda. Use this skill whenever the project contains an aws-blocks/ directory, imports from @aws-blocks/blocks or any @aws-blocks/* package, or the user mentions AWS Blocks, Building Blocks, KVStore, DistributedTable, DistributedDatabase, Database, FileBucket, AuthBasic/AuthCognito/AuthOIDC, Realtime, AsyncJob, CronJob, Agent, ApiNamespace, Scope, the IFC layer, BlocksContext, or runs npm run dev/sandbox/deploy, even if unnamed. It routes to the SDK bundled docs and encodes the mental model and critical footguns (Block-ID rename = permanent data loss, the --conditions=cdk flag, DSQL parity limits). Do NOT use for plain AWS CDK, AWS Amplify, SST, or generic DynamoDB/Lambda/API Gateway work not involving @aws-blocks.From its SKILL.md

Install
npx -y skills add tomoki10/aws-blocks-skills --skill aws-blocks

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its file declares

Copied from the file, not written here

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

11.4 KB, ~2.3k tokens by cl100k_base, as published. Nobody here has run it

AWS Blocks Implementation Guide (Steering Layer)

AWS Blocks is the @aws-blocks/* TypeScript "Infrastructure from Code" framework. This skill is a thin steering layer + router. It is not an API reference. The canonical docs ship inside the SDK (node_modules/@aws-blocks/blocks/docs/) and always match the installed version. This skill's job is to (1) give you the correct mental model, (2) route you to the bundled docs, and (3) prevent the critical footguns before they happen.

The one-liner mental model

The same single line you write — new DistributedTable(scope, 'todos', {...}) — resolves to a different implementation per execution context, via Node.js conditional exports:

ContextResolved implementationBehavior
Local dev npm run devmock (in-memory + JSON/PGlite under .bb-data/)No AWS, offline
CDK synth npm run deploy/sandboxCDK constructDefines resources such as DynamoDB
Lambda runtime (production)AWS SDK callsHits the real services

One codebase. No rewrites. Details in references/mental-model.md.

Top rules (always follow)

  1. Before using a Block, read its bundled doc. Each page has the API, options, local behavior, production behavior, and best practices. Location: node_modules/@aws-blocks/blocks/docs/<package>.md (if you can't find it, locate it with find . -path '*@aws-blocks/blocks/docs/index.md' -not -path '*/.git/*').
  2. Always do persistence and cloud abstractions through a Building Block. Don't use local arrays, your own files, or a separate local DB (the mock plays that role, so a Block deploys to AWS as-is).
  3. The JSON-RPC transport is transparent. Don't hand-assemble RPC payloads. Call the typed API directly via import { api } from 'aws-blocks'. Backend types propagate to the frontend automatically (there is no codegen step).

Block selection routing (always in this order)

  1. First read the decision treenode_modules/@aws-blocks/blocks/docs/index.md (a catalog + keywords that pick the right Block from "what you want to do").
  2. Then read the per-Block docnode_modules/@aws-blocks/blocks/docs/<package>.md.
  3. Cross-cutting core concepts (Scope / ApiNamespace / withAuth / RawRoute / CORS / JSON-RPC) → node_modules/@aws-blocks/blocks/docs/core.md.
  4. The overall guide (architecture, common mistakes) → node_modules/@aws-blocks/blocks/README.md.

Main Blocks and their uses (always go to the docs above for details):

What you want to doBlockBundled doc
Key-value (cache/flags)KVStorebb-kv-store.md
Structured data + indexes + queries (the default for data)DistributedTablebb-distributed-table.md
Serverless SQL (basic Postgres-compatible)DistributedDatabase (Aurora DSQL)bb-distributed-data.md
Full Postgres (FK/RLS/triggers/large transactions)Database (Aurora Serverless v2)bb-data.md
Files/uploadsFileBucketbb-file-bucket.md
Auth (prototype/production/OIDC)AuthBasic / AuthCognito / AuthOIDCbb-auth-*.md
WebSocket pub/subRealtimebb-realtime.md
Background jobs / scheduled runsAsyncJob / CronJobbb-async-job.md / bb-cron-job.md
AI agents / RAGAgent / KnowledgeBasebb-agent.md / bb-knowledge-base.md
Email / settings / observabilityEmailClient / AppSetting / Logger etc.bb-email-client.md and others

Choosing a data Block: the default is DistributedTable. Go to SQL only when you need JOINs across multiple records, multi-dimensional filtering, transactions, or SQL flexibility. If you need SQL, prefer DistributedDatabase (DSQL, zero idle cost) as a rule. Use Database (Aurora Serverless v2, with a minimum 0.5 ACU idle cost or a cold start) only when you need FK/RLS/triggers, transactions over 3,000 rows, or integration with existing Postgres.

Critical warnings (inline; details in rules-and-gotchas.md)

  • ⚠️ Renaming a Block ID (the 2nd constructor argument) = deleting and recreating the resource = permanent data loss for stateful Blocks. Treat IDs as immutable after deploy.
  • ⚠️ Every API is public by default. A gate only takes effect once you explicitly call requireAuth() / requireRole() inside the method. Forgetting it = an authorization hole.
  • ⚠️ DSQL (DistributedDatabase) has constraints: no DDL, no FK, no JSONB, and more. The mock rejects these at dev time, but OCC (optimistic concurrency) conflicts do not arise naturally, so test them with simulateConflict() and finally verify on real infra with npm run sandbox.
  • ⚠️ Dropping --conditions=cdk leaks the mock into CDK synth. Always use npm run sandbox/deploy (they set NODE_OPTIONS=--conditions=cdk automatically). Don't invoke a bare cdk synth directly.

Details, workarounds, and minimal code examples → references/rules-and-gotchas.md

Development workflow (details in workflow-troubleshooting.md)

CommandWhat happens
npm run devAll Blocks start locally as mocks (persisted under .bb-data/). No AWS, hot reload
npm run test:e2ee2e with the typed client. Auto-starts dev if it isn't running
npm run sandbox / npm run sandbox:destroyFast deploy to real AWS (Lambda hot-swap) / teardown
npm run deploy / npm run destroyFull production deploy (CloudFormation) / teardown

Fast iteration: start npm run dev & in the background and re-run npm run test:e2e (reusing the server each time). Don't fire curl/fetch directly at the API (except when debugging connection issues). Call the typed API directly. Details and a symptom→cause→fix table → references/workflow-troubleshooting.md

The shape of the backend (IFC layer)

The backend is consolidated into a single file, aws-blocks/index.ts (= the IFC layer). There you instantiate Blocks, define the API with ApiNamespace, and export it. The frontend (src/) calls it type-safely via import { api } from 'aws-blocks'. The CDK definition lives in an optional aws-blocks/index.cdk.ts (BlocksStack.create({ backendCDKPath: './index.ts', ... })), which re-reads that same index.ts under the cdk condition to derive the infrastructure.

Best practices (read the bundled ones; few additions here)

Most best practices ship in the SDK and match the installed version — read those, don't reinvent: README.md ## Best practices / ## Common mistakes / ## Testing / Adding auth and data; docs/core.md (error handling via ApiError/isBlocksError, auth-public-by-default); docs/index.md (block selection); each docs/<block>.md ## Best Practices / ## Scaling & Cost. Copying them here risks version drift (e.g. the public web page's "partition one KVStore by key prefix" contradicts the bundled bb-kv-store.md's "one logical entity per instance" — follow the bundled doc).

The few cross-cutting practices the bundled docs don't state → references/best-practices.md:

  • One Scope per app; keep index.ts thin and extract business logic into modules (also enables unit-testing pure functions with mock Blocks).
  • Separate AWS accounts for dev/staging/prod; env-specific config (domain, VPC, WAF, CORS) in index.cdk.ts, not runtime code.
  • Descriptive Block IDs + JSDoc on API methods give AI coding agents better context.

Reference files (read as needed)

FileWhen to read
references/mental-model.mdTo understand the two layers of conditional exports, the switches, and why things break
references/rules-and-gotchas.mdTo avoid the data-loss / authorization / DSQL / conditions footguns (recommended read before implementing)
references/workflow-troubleshooting.mdFor commands, environment differences, the e2e loop, and resolving errors
references/best-practices.mdTo route best-practice topics to their canonical bundled location, plus the few cross-cutting additions

And don't forget: for the exact API of any individual Block, always consult the bundled node_modules/@aws-blocks/blocks/docs/<package>.md. This skill is a guide to that location; it keeps no copy of the API (to avoid version mismatch).

What ships with it: 15 files

72.5 KB alongside SKILL.md, 2 of them executable

Gives 0 of the 12 instructions most containers cloud skills give in ~2.3k tokens

Counted across 607 of the 657 authors here whose files we hold, read 2026-08-07

  • Run containers as a non-root userin 66 of 607, across 46 files
  • Use multi-stage buildsin 53 of 607, across 44 files
  • Use Promise.all for independent operationsin 47 of 607, across 13 files
  • Import directly instead of barrel filesin 46 of 607, across 12 files
  • Use ternary instead of AND for conditionalsin 45 of 607, across 12 files
  • Use Set or Map for O(1) lookupsin 42 of 607, across 10 files
  • Create a .dockerignore filein 41 of 607, across 31 files
  • Read individual rule files for detailsin 39 of 607, across 9 files
  • Copy dependency files before source codein 36 of 607, across 23 files
  • Authenticate server actions like API routesin 35 of 607, across 7 files
  • Use next/dynamic for heavy componentsin 34 of 607, across 9 files
  • Use React.cache for per-request deduplicationin 34 of 607, across 10 files

Said here and by no other author read

  • read the bundled doc before using a block
  • use a block for persistence and cloud abstractions
  • read the bundled decision tree before selecting a block
  • treat block ids as immutable
  • call requireauth or requirerole inside api methods
  • test concurrency conflicts using simulateconflict

Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.

Keep looking

Skills are one crate of 326,835. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.