claude-skills/

Anthropic公式スキル・プラグインの日本語ディレクトリ

last sync 22h ago
スキルOfficialdevelopment

🚀amplify-workflow

プラグイン
aws-amplify

説明

AWS Amplify Gen2(TypeScriptコードファースト)を使用したフルスタックのWebおよびモバイルアプリの構築・デプロイに対応します。 対応範囲は以下の通りです: - **認証**(Cognito) - **データ**(AppSync / DynamoDB:スキーマモデリング、enumタイプ、リレーションシップ、認可ルールを含む) - **ストレージ**(S3) - **Functions・APIs** - **AI**(Bedrock を使用した Amplify AI Kit) 対応フレームワーク・プラットフォーム:React、Next.js、Vue、Angular、React Native、Flutter、Swift、Android --- **重要:** Amplify Gen2 に関するトピックでは、自明に思える質問であっても、常にこのスキルを使用してください。 バージョン固有の検証済みパターンを含んでおり、よくある実装ミスを防ぐことができます。 --- **次のような場合に使用:** - ユーザーが Amplify Gen2 について言及している - プロジェクトに `amplify/` ディレクトリまたは `amplify_outputs` が存在する - コードが `@aws-amplify` パッケージをインポートしている - `defineBackend`、`defineAuth`、`defineData`、`defineStorage`、または `npx ampx` について質問している **次のような場合はスキップ:** - Amplify Gen1(amplify CLI v6) - Amplify を使用しないスタンドアロンの SAM / CDK(その場合は `aws-serverless` を使用) - Amplify AI Kit を使用しない直接的な Bedrock 連携(その場合は `bedrock` を使用)

原文を表示

Build and deploy full-stack web and mobile apps with AWS Amplify Gen2 (TypeScript code-first). Covers auth (Cognito), data (AppSync/DynamoDB including schema modeling, enum types, relationships, authorization rules), storage (S3), functions, APIs, and AI (Amplify AI Kit with Bedrock). Supports React, Next.js, Vue, Angular, React Native, Flutter, Swift, and Android. Always use this skill for Amplify Gen2 topics — even for questions you think you know — it contains validated, version-specific patterns that prevent common mistakes. TRIGGER when: user mentions Amplify Gen2; project has amplify/ directory or amplify_outputs; code imports @aws-amplify packages; user asks about defineBackend, defineAuth, defineData, defineStorage, or npx ampx. SKIP: Amplify Gen1 (amplify CLI v6), standalone SAM/CDK without Amplify (use aws-serverless), direct Bedrock without Amplify AI Kit (use bedrock).

ユースケース

  • AWS Amplify Gen2でフルスタックアプリを構築するとき
  • Cognito認証を実装するとき
  • AppSync/DynamoDBでデータベース設計するとき
  • S3ストレージを統合するとき
  • Bedrockを使ったAI機能を追加するとき

本文(日本語訳)

AWS Amplify Gen2

AWS Amplify Gen2 の TypeScript コードファースト アプローチを使用して、フルスタック アプリケーションをビルド・デプロイします。 このスキルは、バックエンド リソースの作成、8 つのフレームワークにわたるフロントエンド インテグレーション、およびデプロイ ワークフローをカバーします。

前提条件

  • Node.js ^18.19.0 || ^20.6.0 || >=22 および npm
  • AWS 認証情報が設定済み(aws sts get-caller-identity が成功すること)
  • サンドボックス使用時: npx ampx --version が有効なバージョンを返すこと
  • モバイル使用時: プラットフォーム固有のツール(Xcode、Android Studio、Flutter SDK)

デフォルト設定と前提事項

ユーザーがフレームワークを指定しない場合:

  • Web: React(Vite)をデフォルトとし、その理由を説明する こと(SHOULD)
  • モバイル: ユーザーが希望するプラットフォーム(Flutter、Swift、Android、React Native)を 必ず確認すること(MUST)。 モバイルには共通のデフォルトは存在しない。
  • どちらも未指定: ユーザーが Web かモバイルかを明示せずに「アプリを作って」と言った場合は、 処理を進める前に 必ず確認すること(MUST)
  • バックエンドのみ: バックエンドの変更のみが要求され、フロントエンド フレームワークの言及がない場合は、 フロントエンド インテグレーションの手順を完全にスキップする。

ユーザーがツールや戦略を指定しない場合:

  • パッケージ マネージャー: ユーザーが yarn または pnpm を指定しない限り、npm をデフォルトにする こと(SHOULD)
  • 言語: TypeScript をデフォルトにする こと(SHOULD)。 Gen2 バックエンドは TypeScript のみ対応。フロントエンドはプロジェクトの既存言語に従う こと(SHOULD)
  • Next.js: ユーザーが Pages Router を指定しない限り、App Router をデフォルトにする こと(SHOULD)
  • React Native: Expoベアの React Native CLI のどちらを使用しているかをユーザーに確認する。
  • 認証: ユーザーが希望するログイン方式(メール/パスワード、ソーシャル ログイン、SAML、パスワードレスなど)を 必ず確認すること(MUST)。デフォルトを勝手に想定しないこと。
  • データ認可: publicApiKeyallow.publicApiKey())をデフォルトとする — これはスターター テンプレートのデフォルト。 認証を追加する際は、defaultAuthorizationMode: 'userPool' を指定した オーナーベースallow.owner())に切り替える。

クイック スタート — 適切なリファレンスへのルーティング

ステップ 0: コア リファレンスの読み込み(常に必須)

対象プラットフォームのコア リファレンスは、他のリファレンス ファイルを読む前に必ず読むこと(MUST)。 これらのファイルには、Gen2 の検出方法、フレームワークごとの Amplify.configure() の配置場所、 サンドボックス コマンド、必要なパッケージ、ディレクトリ構造のルールが含まれており、 新規プロジェクトに限らず すべての タスクで必要となるパターンです。

  • Web(React、Next.js、Vue、Angular、React Native): core-web.md必ず読むこと(MUST)
  • モバイル(Flutter、Swift、Android): core-mobile.md必ず読むこと(MUST)
  • バックエンドのみ(フロントエンド作業なし): ステップ 1 へスキップ。

ステップ 1: タスクの種類を特定する

タスク 参照先
新規プロジェクトの作成 scaffolding.md、その後ステップ 2 および/またはステップ 3
バックエンド機能の追加または変更 → ステップ 2(バックエンド機能)
既存バックエンドへのフロントエンド接続 → ステップ 3(フロントエンド インテグレーション)
アプリケーションのデプロイ deployment.md

ステップ 2: バックエンド機能

各バックエンド機能に対応するリファレンスを 必ず読むこと(MUST):

機能 リファレンス 次のような場合に使用
認証 auth-backend.md メール/パスワード、ソーシャル ログイン、MFA、SAML/OIDC
データ モデル data-backend.md GraphQL スキーマ、DynamoDB、リレーション、認可ルール
ファイル ストレージ storage-backend.md S3 アップロード/ダウンロード、アクセス ルール
Functions と API functions-and-api.md Lambda、カスタム リゾルバー、REST/HTTP API、クライアントからの呼び出し
AI 機能 ai.md 会話、生成、Bedrock 経由の AI ツール (バックエンド設定 + React/Next.js フロントエンド)
Geo、PubSub、CDK advanced-features.md バックエンドのみ: カスタム CDK スタック、オーバーライド、カスタム出力。バックエンド + フロントエンド: Geo、PubSub、Face Liveness

各バックエンド機能ファイルは独立しています。必要なものだけ読み込んでください。

ルーティングに関する注意: これらのファイルは機能の 追加変更 の両方に適用されます。 ユーザーが「auth を追加」と言っても「auth 設定を変更」と言っても、同じファイルを参照してください — 各リファレンスは定義の全体をカバーしています。

ステップ 3: フロントエンド インテグレーション

バックエンド リソースを設定した後、フロントエンドを接続します。 プラットフォームと機能に応じて選択してください:

Web(React、Next.js、Vue、Angular、React Native):

機能 リファレンス
認証 UI とフロー auth-web.md
データ CRUD とサブスクリプション data-web.md
ストレージ アップロード/ダウンロード storage-web.md

モバイル(Flutter、Swift、Android):

機能 リファレンス
認証 UI とフロー auth-mobile.md
データ CRUD とサブスクリプション data-mobile.md
ストレージ アップロード/ダウンロード storage-mobile.md

注意: AI と Functions のフロントエンド パターンは、それぞれ ai.mdfunctions-and-api.md に含まれています — Web/モバイル別の独立したファイルには 分割されていません

コア コンセプト

Amplify Gen2 アーキテクチャ

  • コードファースト: すべてのバックエンド リソースは amplify/ 配下の TypeScript で定義される
  • メイン設定: amplify/backend.tsdefineBackend() を通じてすべてのリソースをインポートして結合する
  • リソース ファイル: amplify/auth/resource.tsamplify/data/resource.tsamplify/storage/resource.tsamplify/functions/<name>/resource.ts
  • 生成された出力: amplify_outputs.json — フロントエンドの Amplify.configure() が使用する。 .gitignore 対象npx ampx sandbox(ローカル開発)または npx ampx pipeline-deploy(CI/CD)によって生成されるため、コミットしないこと。

ディレクトリ構造

project-root/
├── amplify/
│   ├── backend.ts            # defineBackend({ auth, data, ... })
│   ├── auth/resource.ts      # defineAuth({ ... })
│   ├── data/resource.ts      # defineData({ schema })
│   ├── storage/resource.ts   # defineStorage({ ... })
│   └── functions/
│       └── my-func/
│           ├── resource.ts   # defineFunction({ ... })
│           └── handler.ts    # export const handler = ...
├── src/                      # フロントエンド コード
├── amplify_outputs.json      # 生成ファイル — 編集・コミット禁止(.gitignore 対象)
└── package.json

主要 API

パッケージ 用途
@aws-amplify/backend defineAuthdefineDatadefineStoragedefineFunctiondefineBackend
aws-amplify フロントエンド: Amplify.configure()generateClient()、認証/データ/ストレージ API
@aws-amplify/ui-react プリビルト UI: <Authenticator><StorageBrowser>
@aws-amplify/ui-react-ai AI UI: <AIConversation>useAIConversation

ドキュメントとリソースの確認

AWS ドキュメントが必要な場合(高度な CDK コンストラクト、サービス制限、プロバイダー固有の認証設定など):

  1. AWS ドキュメント ツールが利用可能な場合(例: AWS MCP 経由)、 それらを使用して関連するドキュメント ページを検索・取得する こと(SHOULD)
  2. AWS ドキュメント ツールが利用できない場合、 Web 検索または aws CLI によるリソース確認にフォールバックする こと(MUST)

条件付きである理由: Amplify Gen2 はコードファースト — 主なワークフローは TypeScript ファイルの編集と npx ampx コマンドの実行です。 AWS MCP ツールはデプロイ後の確認に有用ですが、必須ではありません

セキュリティに関する考慮事項

  • すべての認証情報と API キーには secret() を使用する — 機密情報をハードコードしたり、プレーンな環境変数で管理したりしないこと
  • allow.guest() の公開範囲を慎重に確認する — ゲスト アクセスはデフォルトで有効であり、 未認証ユーザーに IAM 認可リソースへのアクセスを許可する
  • IAM ポリシーは特定のリソース ARN にスコープを絞る — 本番環境では resources: ['*'] を避ける
  • シークレットをログに記録したり、エラー メッセージに含めたりしないこと
  • Amplify でデプロイされたリソースの監視に CloudTrail と CloudWatch アラームを有効化する。 S3、AppSync、API Gateway のアクセス ログを有効化する
  • Web アプリにセキュリティ ヘッダーを設定する — amplify.ymlcustomHeaders で CSP、HSTS、X-Frame-Options、X-Content-Type-Options を設定する
  • 多層防御のため、公開向けの AppSync API と API Gateway エンドポイントに AWS WAF をアタッチする
  • API Gateway と AppSync API にスロットリングとレート制限を有効化して悪用を防ぐ
  • CI/CD パイプラインと Lambda 実行ロールには、一時的な認証情報を使用する IAM ロールを使用する — 長期的なアクセス キーは使用しないこと
  • PII、トークン、シークレットが含まれる可能性がある場合は、CloudWatch Logs グループを KMS(aws:kms)で暗号化する。ログ保持ポリシーを有効化する
  • AppSync のスキーマ バリデーションと API Gateway のリクエスト バリデーターを有
原文(English)を表示

AWS Amplify Gen2

Build and deploy full-stack applications using AWS Amplify Gen2's TypeScript code-first approach. This skill covers backend resource creation, frontend integration across 8 frameworks, and deployment workflows.

Prerequisites

  • Node.js ^18.19.0 || ^20.6.0 || >=22 and npm
  • AWS credentials configured (aws sts get-caller-identity succeeds)
  • For sandbox: npx ampx --version returns a valid version
  • For mobile: Platform-specific tooling (Xcode, Android Studio, Flutter SDK)

Defaults & Assumptions

When the user does not specify a framework:

  • Web: You SHOULD default to React (Vite) and explain the choice.
  • Mobile: You MUST ask which platform the user wants (Flutter, Swift, Android, or React Native). There is no universal mobile default.
  • Neither specified: If the user says "build an app" without clarifying web vs. mobile, you MUST ask before proceeding.
  • Backend only: If only backend changes are requested and no frontend framework is mentioned, skip the frontend integration step entirely.

When the user does not specify tooling or strategy:

  • Package manager: You SHOULD default to npm unless the user specifies yarn or pnpm.
  • Language: You SHOULD default to TypeScript. Gen2 backends are TypeScript-only; frontends SHOULD follow the project's existing language.
  • Next.js: You SHOULD default to App Router unless the user specifies Pages Router.
  • React Native: Ask the user whether they use Expo or bare React Native CLI.
  • Auth: You MUST ask which login method the user wants (email/password, social login, SAML, passwordless, etc.). Do not assume a default.
  • Data authorization: default to publicApiKey (allow.publicApiKey()) — this is the starter template default. When auth is added, switch to owner-based (allow.owner()) with defaultAuthorizationMode: 'userPool'.

Quick Start — Route to the Right Reference

Step 0: Read Core Reference (ALWAYS)

You MUST read the core reference for your target platform before reading any other reference file. These contain Gen2 detection, Amplify.configure() placement per framework, sandbox commands, required packages, and directory structure rules — patterns needed for all tasks, not just new projects.

  • Web (React, Next.js, Vue, Angular, React Native): You MUST read core-web.md
  • Mobile (Flutter, Swift, Android): You MUST read core-mobile.md
  • Backend only (no frontend work): Skip to Step 1.

Step 1: Identify the Task Type

Task Go To
Create a new project scaffolding.md, then Step 2 and/or Step 3
Add or modify a backend feature → Step 2 (Backend Features)
Connect frontend to existing backend → Step 3 (Frontend Integration)
Deploy the application deployment.md

Step 2: Backend Features

You MUST read the corresponding reference for each backend feature:

Feature Reference When to Use
Authentication auth-backend.md Email/password, social login, MFA, SAML/OIDC
Data Models data-backend.md GraphQL schema, DynamoDB, relationships, auth rules
File Storage storage-backend.md S3 uploads/downloads, access rules
Functions & API functions-and-api.md Lambda, custom resolvers, REST/HTTP APIs, calling from client
AI Features ai.md Conversation, generation, AI tools via Bedrock (backend config + React/Next.js frontend)
Geo, PubSub, CDK advanced-features.md Backend-only: custom CDK stacks, overrides, custom outputs. Backend + frontend: Geo, PubSub, Face Liveness

Each backend feature file is self-contained. Load only what you need.

Routing note: These files apply for both adding and modifying features. Route to the same file whether the user says "add auth" or "change auth config" — each reference covers the full define surface.

Step 3: Frontend Integration

After configuring backend resources, connect the frontend. Choose by platform and feature:

Web (React, Next.js, Vue, Angular, React Native):

Feature Reference
Auth UI & flows auth-web.md
Data CRUD & subscriptions data-web.md
Storage upload/download storage-web.md

Mobile (Flutter, Swift, Android):

Feature Reference
Auth UI & flows auth-mobile.md
Data CRUD & subscriptions data-mobile.md
Storage upload/download storage-mobile.md

Note: AI and Functions frontend patterns are included in ai.md and functions-and-api.md respectively — they are not split into separate web/mobile files.

Core Concepts

Amplify Gen2 Architecture

  • Code-first: All backend resources defined in TypeScript under amplify/
  • Main config: amplify/backend.ts imports and combines all resources via defineBackend()
  • Resource files: amplify/auth/resource.ts, amplify/data/resource.ts, amplify/storage/resource.ts, amplify/functions/<name>/resource.ts
  • Generated output: amplify_outputs.json — consumed by frontend Amplify.configure(). Gitignored — generated by npx ampx sandbox (local dev) or npx ampx pipeline-deploy (CI/CD), never committed.

Directory Structure

project-root/
├── amplify/
│   ├── backend.ts            # defineBackend({ auth, data, ... })
│   ├── auth/resource.ts      # defineAuth({ ... })
│   ├── data/resource.ts      # defineData({ schema })
│   ├── storage/resource.ts   # defineStorage({ ... })
│   └── functions/
│       └── my-func/
│           ├── resource.ts   # defineFunction({ ... })
│           └── handler.ts    # export const handler = ...
├── src/                      # Frontend code
├── amplify_outputs.json      # Generated — DO NOT edit or commit (gitignored)
└── package.json

Key APIs

Package Purpose
@aws-amplify/backend defineAuth, defineData, defineStorage, defineFunction, defineBackend
aws-amplify Frontend: Amplify.configure(), generateClient(), auth/data/storage APIs
@aws-amplify/ui-react Pre-built UI: <Authenticator>, <StorageBrowser>
@aws-amplify/ui-react-ai AI UI: <AIConversation>, useAIConversation

Documentation & Resource Verification

When you need AWS documentation (advanced CDK constructs, service limits, provider-specific auth config):

  1. If AWS documentation tools are available (e.g., via AWS MCP), you SHOULD use them to search and retrieve relevant documentation pages.
  2. If AWS documentation tools are unavailable, you MUST fall back to web search or the aws CLI for resource verification.

Why conditional: Amplify Gen2 is code-first — the primary workflow is editing TypeScript files and running npx ampx commands. AWS MCP tools are useful for post-deployment verification but are not required.

Security Considerations

  • Use secret() for all credentials and API keys — never hardcode or use plain environment variables for sensitive values
  • Review allow.guest() exposure carefully — guest access is enabled by default and grants unauthenticated users access to IAM-authorized resources
  • Scope IAM policies to specific resource ARNs — avoid resources: ['*'] in production
  • Never log secrets or include them in error messages
  • Enable CloudTrail and CloudWatch alarms for monitoring Amplify-deployed resources; enable access logging on S3, AppSync, and API Gateway
  • Configure security headers for web apps — set CSP, HSTS, X-Frame-Options, and X-Content-Type-Options via customHeaders in amplify.yml
  • Attach AWS WAF to public-facing AppSync APIs and API Gateway endpoints for defense in depth
  • Enable throttling and rate limiting on API Gateway and AppSync APIs to prevent abuse
  • Use IAM roles with ephemeral credentials for CI/CD pipelines and Lambda execution roles — never long-lived access keys
  • Encrypt CloudWatch Logs groups with KMS (aws:kms) when they may contain PII, tokens, or secrets; enable log retention policies
  • Enable AppSync schema validation and API Gateway request validators to reject malformed input at the edge
  • Use ACM-managed TLS certificates for custom domains on Amplify Hosting — configure via customDomain in deployment config

Links

All documentation links use react as the default platform slug. Replace /react/ in any URL with your target framework:

Framework Slug
React react
Next.js nextjs
Vue vue
Angular angular
React Native react-native
Flutter flutter
Swift swift
Android android

原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。