Skip to content

コーディングエージェントガイド ​

生成先の指示は frontend.framework に応じて Next.js API Routes、または React SPA + SWA マネージド Functions BFF を説明します。app/api の存在を仮定せず、 .swallowkit/project.json を検査してください。パス、検証、環境上の注意は React ガイドを参照してください。 このツールキット自身の直下の AGENTS.md は生成先のテンプレートとは別の開発者向け指示です。

pnpm 11/12 と npm の使い分けはコマンドとトラブルシューティングを参照してください。

SwallowKit は要件整理や実装、レビューの進め方を決めるツールではありません。 エージェントが現在のプロジェクトを調べ、モデルや設定から生成物を再現し、変更後の構造を検証するために使います。 コマンドと応答形式の詳細は AI / MCP 統合を参照してください。

目的 ​

開発プロセスを定めるスキルやフレームワークには、要件整理、仕様作成、チケット分割、TDD、実装、レビューの進め方を任せます。 その中で SwallowKit を呼び出すと、現在のモデル・ルート・所有権を調べ、変更計画を作り、適用後に検証できます。 エージェントは、取得した情報を根拠に編集するファイルと再生成するファイルを区別します。

text
要件・仕様・作業内容を決める
  ↓
現在のプロジェクトと編集規則を調べる(inspect)
  ↓
生成物の変更計画を確認して適用する(plan/apply)
  ↓
構造を検証し、実際の動作を確かめる(verify・テスト)

SwallowKit はプロジェクトの検査、生成物の再生成、記録からのずれの検出、構造の検証、失敗した検査の説明を担当します。 独自の要件定義やチケット管理の仕組みを導入するものではありません。

生成される指示ファイル ​

swallowkit init は、共通の規約と、利用するエージェントや作業ごとの指示を分けて生成します。

ファイル役割
AGENTS.mdすべての作業で参照する共通のプロジェクト規約
CLAUDE.mdClaude Code に共通規約の参照を指示するファイル
.github/copilot-instructions.mdGitHub Copilot に共通規約の参照を指示するファイル
.github/instructions/*.instructions.mdファイルの場所やレイヤーごとの編集規則
.mcp.jsonプロジェクトで使用する SwallowKit MCP サーバーの起動設定
.github/skills/*/SKILL.md特定の作業で読み込む Agent Skills
.swallowkit/workflows/*.mdAgent Skills 非対応のエージェントも読める作業手順書

Claude Code と Copilot 向けの指示にも、最初に AGENTS.md を読むことや MCP の利用方針を記載します。 モデル追加や検証などの詳しい手順は、対応するスキルまたは作業手順書に置きます。

これらのファイルは Next.js / React、各バックエンド言語、npm / pnpm 向けに init が生成します。 init は既存ディレクトリを拒否し、SwallowKit の更新だけでは指示ファイルは更新されません。 指示ファイル専用の更新コマンドはありません。既存プロジェクトに新しい指示を取り込む場合は、 選択済みのフロントエンド / バックエンド / パッケージマネージャーに合わせて新旧テンプレートの差分を確認し、 共通の AGENTS.md と必要な参照指示ファイル / 作業手順書に手動でマージしてください。 プロジェクト独自の指示を保ち、既存ドキュメントの上書きや既存プロジェクトへの init は避けます。

共通のプロジェクト規約は、Cosmos(本番)/ Emulator(ローカル)の永続化と障害を隠す代替ストレージの禁止、 dev-seeds/<environment>/ の明示的な適用、ローカル操作時のデータ保護を定めます。 シードファイル名は複数形のコンテナー名ではなく、モデル名の単数形 kebab-case (例: learning-profile.json)です。置換成功と判断する前に、実効 DB 名とシードログを確認します。 ビルド、テスト用データ、verify project は機械的な証拠にとどまります。起動・永続化・API・UI の変更では、 実アプリの BFF / Functions / DB を通した動作確認も必要です。永続化は再シードせずに 再読み込み・再起動して確認します。前提条件の不足、省略、警告、模擬サービスと実サービスの違いを 明示してください。ドキュメントだけの変更には実 DB の検証は不要です。

開発ライフサイクル全体での SwallowKit ​

要件整理 ​

実装の詳細を人に質問する前に、関連するモデル、ルート、インフラ、所有権を調べます。 リポジトリや検査結果から分かることはエージェントが確認し、アプリの仕様や業務上の判断が必要な点を人に質問します。

仕様作成 ​

利用者が何をしたときに何が起きるか、受け入れ条件は何か、どの動作をテストするかを記述します。 SwallowKit の構成と所有権は実装上の条件として扱い、自動生成するレイヤーを別々の手作業として計画しません。

計画 ​

利用できる機能や所有権が設計に影響する場合は、現在の CLI または MCP で調べます。 エージェントが学習した古い知識だけで、SwallowKit にできることを決めないでください。

チケット分割 ​

独立して利用者の目的を満たし、実装・検証できる単位で分割します。 1つのモデル変更からスキーマ、Functions、BFF、UI、インフラを再生成する場合は、それらを同じチケットに含めます。 生成先のディレクトリが違うという理由だけで、レイヤー別のチケットに分けません。

実装 ​

ファイルを選ぶ前に編集規則を確認します。ai-authored は直接編集し、deterministic はモデルや設定と plan/apply から変更します。 shared はパスごとの規則に従ってください。マーカーの外だけを編集するファイルと、手動でエクスポートを追記できるファイルがあります。

検証 ​

変更後に SwallowKit の検証を実行し、失敗した検査の結果を読んで修正します。 修正後は再検証し、人の判断が必要な場合は、その対象と選択肢を示します。

レビュー ​

構造や生成物のずれを検証したあとに、設計と動作が仕様を満たしているかをレビューします。 機械的な検査と、利用者の目的に照らしたレビューは、互いの代わりにはなりません。

質問・設計の前の検査 ​

タスクに関係する検査だけを利用します。

bash
npx swallowkit machine inspect project
npx swallowkit machine inspect entities
npx swallowkit machine inspect routes
npx swallowkit machine inspect boundaries
npx swallowkit machine inspect drift
npx swallowkit machine inspect infra
bash
pnpm exec swallowkit machine inspect project
pnpm exec swallowkit machine inspect entities
pnpm exec swallowkit machine inspect routes
pnpm exec swallowkit machine inspect boundaries
pnpm exec swallowkit machine inspect drift
pnpm exec swallowkit machine inspect infra

利用できる場合は swallowkit_* MCP ツールを優先し、MCP が使えない場合は machine CLI を使用します。

これにより、生成された CRUD レイヤーの接続設定、管理対象のルートの編集可否、インフラ操作 の 有無など、現在の検査結果で回答できる質問を人間へ転嫁しません。一方、曖昧な 製品の動作、業務ルール、リスクについての判断は適切に人間へ確認します。

責任範囲と編集規則 ​

machine inspect boundaries(または swallowkit_inspect_boundaries)が現在のプロジェクトの 機械可読な編集規則の確認元です。

zone編集ポリシー典型例
ai-authored直接編集する定義元のモデル、独自のロジックや画面、テスト
deterministic決して手編集せずモデルや設定と plan/apply で変更する生成 CRUD、BFF、UI、スキーマ、インフラの生成物
shared管理対象を示すマーカーの外側だけ編集するSwallowKit の管理区間 を含む集約・インフラファイル

例は検査の代わりにはなりません。所有権はバックエンド、機能、SwallowKit のバージョン によって変わり得ます。

計画とチケット作成 ​

仕様には、生成ファイルの作り方よりも、実現したい動作を書きます。 計画には SwallowKit の編集規則と plan/apply/verify の手順を含め、再生成で済む作業を独立した手作業として数えません。 チケットは単独で実装・検証できる機能単位にします。レイヤー別に分割するのは、それぞれに独立した価値やリスクがある場合です。

実装の進め方 ​

エージェントの標準作業手順は次のとおりです。

text
inspect → plan → conflict/approval の評価 → apply → verify

実行環境で MCP ツールを利用できる場合は優先し、それ以外では machine CLI を使います。

bash
npx swallowkit machine inspect drift
npx swallowkit machine plan scaffold todo
npx swallowkit machine apply scaffold --plan <planId>
npx swallowkit machine verify project
bash
pnpm exec swallowkit machine inspect drift
pnpm exec swallowkit machine plan scaffold todo
pnpm exec swallowkit machine apply scaffold --plan <planId>
pnpm exec swallowkit machine verify project

Agent Skills 対応実行環境では swallowkit-add-model、swallowkit-modify-model、 swallowkit-verify-repair を利用します。それ以外では対応する .swallowkit/workflows/ 作業手順書を読みます。これらは上位の実装手順から 呼び出せる作業単位の機能です。

カスタム API の有無にかかわらず、永続化モデルのインフラを生成する ​

新しい永続化モデルでは、 machine plan model <model> --overwrite never で変更予定を確認し、返された plan を machine apply model --plan <planId> で適用します。スキーマを作成し、 コネクタ以外のモデル用 Cosmos コンテナーマイグレーションを登録します。 対話 CLI の create-model も同じ生成処理 を使います。 スキーマを編集し、共有パッケージのエクスポートを確認してください。モデル生成は Azure へのデプロイや CRUD 生成を行いません。手書きモデルでは machine plan model-infrastructure <model> で 変更予定を確認し、返された plan を machine apply model --plan <planId> で適用すると、 スキーマの内容を変更せずコンテナーマイグレーションを追加できます。 生成 CRUD が必要な場合のみ plan/apply scaffold を使います。--api-only は UI を省略するだけで、CRUD は生成します。 pnpm を使う場合は npx を pnpm exec に置き換えます。

model-infrastructure の plan/apply は、登録済みコンテナーの場合も、 現在のすべてのモデルに合わせて .swallowkit/project.json を同期します。 メタデータだけを修復する場合は、model <existing-model> --overwrite never を plan し、 確認後に apply してください。スキーマがすべて省略されてもプロジェクト情報ファイルは更新されます。 CRUD 生成、インフラの書き換え、Azure 接続は不要です。

マイグレーション生成後にパーティションキーを変更した場合は、 npx swallowkit machine plan model-infrastructure <model> --refresh-pending --resource-group <name> で、未適用の定義を更新する計画を明示的に作成します。読み取り専用のリモート確認を行い、 適用済み・デプロイ試行済み・状態不明・手編集済みのマイグレーションは拒否します。 dry-run とローカルのモデル生成は Azure のリソースの作成・更新を行いません。

モデル、インフラ、生成物、記録からのずれを検査し、machine verify project を実行してください。 モデルのコンテナー名・パーティションキーと Bicep、マイグレーション台帳、生成台帳の対応を確認します。 既存初期インフラの接続や外部コネクターの対応も、該当する場合は検証してください。 --skip-infra などで生成を延期する場合は、理由と未完了事項を明示します。 verify が通っても、必要なインフラがない状態で完了扱いやデプロイ可能という案内をしてはなりません。 ローカルでの生成は Azure リソースの作成・更新の許可ではありません。

エージェントへの依頼例 ​

モデル変更は、生成ファイルごとの修正ではなく、実現したい振る舞いとして依頼します。

Todo に優先度を追加してください。このプロジェクトの AGENTS.md と関連するスキル/作業手順を読み、 選択済みのパッケージマネージャーを維持してください。編集前に所有権と記録とのずれを確認し、 モデルを変更したら scaffold の Plan を作成してください。変更対象と競合を確認して Apply し、 verify と優先度の振る舞いを確認するテストまで実施してください。 手編集の上書きなど判断が必要な場合は、対象の差分と選択肢を示してください。

ここでの Plan は SwallowKit が返す変更計画です。エージェントの文章による作業計画や Plan モードとは別で、生成対象・競合・planId を持ちます。Plan は生成対象を変更しませんが、 計画自体は .swallowkit/state/plans/ に保存します。内容を確認した Plan の planId を Apply に渡してください。

stale-plan が返ったら、計画時に記録したファイルが変更されています。現在の差分を調べ、 Plan を作り直して再確認します。--approve は古い Plan を有効にするオプションではありません。 requires-human の場合は、求められた判断を確認してから進めます。 競合のない通常の変更に、一律の追加承認手順を設ける必要はありません。

ドリフトが見つかったとき ​

ドリフトは、モデル・生成時の記録・現在のファイルなどの間のずれです。 machine inspect drift の検出結果にある種類、重要度、repairAction と、 machine inspect boundaries の編集ポリシーを合わせて確認します。 検出結果があるだけで、すべてを上書きする必要があるとは限りません。

検出結果エージェントが確認すること
schema-drift意図したモデル変更か確認し、対象モデルの scaffold を Plan → Apply します。
artifact-modified生成後の差分と所有権を確認します。ユーザー編集が認められる領域の変更は正常な場合があります。必要なカスタマイズを消さないでください。
artifact-missing削除が意図したものか確認し、必要な生成物を再生成します。
generator-drift生成時と実行中の SwallowKit のバージョンを確認し、更新を採用する場合は再生成の差分をレビューします。
manifest-drift実際のプロジェクト構造と記録のずれを調べ、提示された repairAction に従います。

MCP は既定で latest、通常の CLI はプロジェクトに固定されたバージョンを使います。 latest より新しいプレリリース版のプロジェクトでは、MCP をプロジェクトの版に固定するか、プロジェクトにインストールされた MCP に委譲します。MCP の応答の metadata.swallowkitVersion で確認してください。 バージョン差がある場合は同じ環境だと決めつけず、各インターフェースの現在の機能を確認してください。 Plan と Apply は同じプロジェクト・同じバージョンの実行経路で行います。 MCP のバージョン指定はパッケージマネージャーガイドを参照してください。

修復後は machine verify project を実行し、失敗時は machine explain failure の証拠を 確認します。ドリフトが解消しても、依頼した機能の振る舞いや Azure デプロイの成功まで 証明されたわけではありません。それぞれのテスト・実行結果で確認してください。

構造の検証と仕様のレビュー ​

SwallowKit の検証では、プロジェクトの構造、管理対象の生成物のずれ、設定されたチェックの結果を調べます。 一方、設計・仕様のレビューでは、実際の動作が利用者の目的と受け入れ条件を満たすかを確かめます。

実装、SwallowKit の検証、設計・仕様のレビューの順に進めます。 検証に失敗した場合は machine explain failure または対応する MCP ツールで原因を調べ、定義元を直して再検証してください。

人による承認 ​

machine 操作は処理の終了・継続状態と nextActions を返します。requires-human は意図的な 停止であり、回避すべきエラーではありません。エージェントは指定された判断を人間に求め、 承認を捏造してはなりません。

Azure リソースの作成・更新は常に swallowkit-provision スキル/作業手順書と明示的承認が必要な手順を 利用します。デプロイ完了までという広い依頼であっても、plan 提示後に必要となる承認が 暗黙に付与されたことにはなりません。

外部開発プロセスとの組み合わせ ​

要件整理、仕様作成、チケット管理、TDD、実装、レビューを進める外部ツールから、SwallowKit の検査・生成処理を呼び出せます。 独自のスキル、Spec Kit、GSD、BMAD を使う場合も、Codex、Claude Code、GitHub Copilot に直接作業を依頼する場合も、同じように組み合わせられます。

例: Matt Pocock スキル ​

以下は組み合わせて使う例です。連携を保証するものではなく、SwallowKit の依存パッケージでもありません。

text
grill-with-docs
    ├─ プロジェクト、モデル、ルート、編集規則を検査
    ├─ リポジトリから分かることを確認
    └─ 製品や業務の仕様に関する判断を人に質問
    ↓
to-spec
    ├─ 目的と、利用者が確認できる動作を記述
    ├─ SwallowKit の構成と所有権を条件に含める
    └─ 生成するレイヤーを別々の手作業として数えない
    ↓
to-tickets
    ├─ 独立して実装・検証できる機能単位に分割
    └─ スキーマ、API、BFF、UI、インフラの生成を同じ作業に含める
    ↓
implement
    ├─ 編集規則を検査
    ├─ ai-authored → 通常の実装・TDD
    ├─ deterministic → SwallowKit plan/apply
    ├─ shared → パスごとの編集規則に従う
    └─ SwallowKit verify
    ↓
code-review
    └─ 機械的な検証の後に、設計・仕様・実装をレビュー

Matt Pocock スキルと SwallowKit はそれぞれを呼び出して組み合わせて使えます。これらのスキルのインストール、取り込み、複製、書き換えを SwallowKit が行うわけではありません。

生成される指示ファイルの全文 ​

以下は swallowkit init が利用する完全な英語テンプレートであり、抜粋ではありません。 、、、 、、 は選択したプロジェクトに合わせて展開されます。 このページは生成用テンプレートを直接読み込むため、掲載する英語の原文はジェネレーターが使う内容と一致します。

生成される AGENTS.md ​

生成される英語の原文 ​

md
# AGENTS.md

This project was generated by **SwallowKit**.

SwallowKit is part of this project's architecture and development workflow.
Treat it as a standing constraint during discovery, requirements clarification,
specification, planning, ticket decomposition, implementation, verification,
and review — not only during code generation.

## How SwallowKit Fits Into the Development Process

SwallowKit does **not** own the overall software development process.

If the user or another Agent Skill or framework defines a process for
requirements discovery, specification, planning, ticketing, TDD,
implementation, or review, continue to follow that process.

Use SwallowKit as the authoritative project-specific layer for:

- inspecting the current project
- understanding entities, routes, infrastructure, and responsibility boundaries
- determining which artifacts may be edited directly
- performing deterministic generation through plan/apply
- detecting drift
- verifying the resulting project
- enforcing human approval gates for sensitive operations

External development-process skills and SwallowKit are intended to compose.

A process skill decides **how to proceed**.
SwallowKit determines **how this SwallowKit project can be changed safely and reproducibly**.

## Do Not Assume SwallowKit Capabilities From Memory

SwallowKit evolves over time.

Do not rely on model knowledge or assumptions about what SwallowKit can or
cannot generate.

When a SwallowKit capability, project structure, or ownership boundary affects
a design decision, inspect the current project and the currently available
SwallowKit interfaces before deciding.

Prefer the `swallowkit_*` MCP tools when available, with one exception: every
MCP response reports the SwallowKit version that answered in
`metadata.swallowkitVersion` and `metadata.mcp`. If that version is older than
the project's installed SwallowKit (`{{runCmd}} swallowkit --version`), or
`metadata.warnings` contains `mcp-older-than-project`, its capabilities,
boundaries, and plan/apply contracts may be outdated for this project. Use
`{{runCmd}} swallowkit machine ...` instead and follow the response's
`nextActions` (for example `{{runCmd}} swallowkit configure-mcp`).

If MCP is unavailable, use the machine interface:

```bash
{{runCmd}} swallowkit machine ...
```

The machine interface is the fallback Agent-facing interface and returns
structured `status` / `nextActions` suitable for autonomous workflows.

## Inspect Before Asking or Designing

When a task may affect SwallowKit-managed application structure, inspect the
project before asking the human questions or committing to an implementation
design.

Use only the inspections relevant to the task. Typical inspections include:

```bash
{{runCmd}} swallowkit machine inspect project
{{runCmd}} swallowkit machine inspect entities
{{runCmd}} swallowkit machine inspect routes
{{runCmd}} swallowkit machine inspect boundaries
{{runCmd}} swallowkit machine inspect drift
{{runCmd}} swallowkit machine inspect infra
{{runCmd}} swallowkit machine inspect capabilities
```

`inspect capabilities` answers "what can SwallowKit do" (supported model
declarations with exact formats, the correct auth-introduction workflow, what
generated CRUD does and does not guarantee, how seeds are applied). Use it
instead of guessing or grepping SwallowKit internals.

Use the equivalent `swallowkit_*` MCP tools when available.

Questions that can be answered from the repository or SwallowKit inspection
should be answered by the agent instead of being delegated to the human.

Examples:

- Do not ask how generated CRUD layers should be wired if SwallowKit already
  defines and generates them.
- Do not propose editing a generated file until responsibility boundaries have
  been checked.
- Do not assume an infrastructure capability is unavailable before inspecting
  the current SwallowKit project and available operations.

## Specification and Planning Guidance

When producing or refining a specification:

- describe user-visible behavior and domain intent
- define acceptance criteria and important test seams
- treat SwallowKit's architecture and responsibility boundaries as
  implementation constraints
- avoid prematurely describing generated artifacts as manually implemented
  components
- do not duplicate work that SwallowKit can deterministically derive from its
  source of truth

For example, if adding a model field causes SwallowKit to regenerate backend,
BFF, UI, and infrastructure artifacts, the specification should primarily
describe the desired end-to-end behavior and the SwallowKit constraint.

It should not imply that every generated layer is an independent manual
implementation decision.

If whether SwallowKit supports the desired behavior affects the specification,
inspect the current capabilities before finalizing the spec.

## Ticket Decomposition Guidance

Prefer independently verifiable **vertical slices** of user or system behavior.

Do not split work into horizontal tickets such as:

- schema ticket
- backend ticket
- BFF ticket
- UI ticket
- infrastructure ticket

merely because those artifacts exist in separate layers.

When SwallowKit deterministically produces those layers, keep them inside the
same vertical slice whenever they represent one end-to-end behavior.

Example:

```text
Add priority support to Todo
  ├─ update the source-of-truth model
  ├─ use SwallowKit plan/apply to realign managed artifacts
  ├─ add any required ai-authored business logic
  ├─ add/update tests
  └─ verify the project
```

Ticket boundaries should reflect independently valuable and verifiable
behavior, not SwallowKit's generated file structure.

## Responsibility Boundary

Before making file-level implementation decisions, inspect the current
machine-readable boundary contract:

```bash
{{runCmd}} swallowkit machine inspect boundaries
```

Treat its current result as authoritative.

The general ownership model is:

### ai-authored

The agent may edit these directly.

Typical examples include:

- source-of-truth models
- custom business logic
- custom pages/components
- tests

### deterministic

Do not hand-edit these artifacts.

They are generated and owned by SwallowKit. Change the appropriate source of
truth or configuration, then use SwallowKit plan/apply to regenerate them.

Managed artifacts are tracked by SwallowKit metadata such as
`.swallowkit/artifacts.json`.

### shared

Follow each path's current `editPolicy`. In marker-owned files, edit only outside
SwallowKit-managed markers. `shared/index.ts` has no markers and permits manual
model exports while preserving exports required by generated code.

Always inspect the current boundary contract instead of relying solely on the
examples in this document.

## Deterministic Changes: Plan → Apply → Verify

For autonomous or agent-driven generation, prefer the SwallowKit two-phase
workflow.

```text
inspect
   ↓
plan
   ↓
evaluate conflicts / approval requirements
   ↓
apply
   ↓
verify
```

Example:

```bash
{{runCmd}} swallowkit machine plan scaffold <model>
{{runCmd}} swallowkit machine apply scaffold --plan <planId>
{{runCmd}} swallowkit machine verify project
```

Do not bypass plan/apply by manually editing deterministic artifacts.

If a plan reports conflicts, determine whether existing hand-written behavior
must be moved to an ai-authored location or whether overwrite approval is
required.

Never invent or implicitly grant human approval.

Humans normally invoke `swallowkit provision` directly. Its invocation requests
execution without an additional confirmation. Agents must still use the
machine/MCP approval flow and must not switch to normal CLI to bypass it.

## Model Changes

For an existing model change, the normal pattern is:

```text
edit source-of-truth model
        ↓
inspect drift
        ↓
plan scaffold
        ↓
resolve conflicts / approvals if any
        ↓
apply
        ↓
verify
```

Use the `swallowkit-modify-model` Agent Skill when available.

Otherwise read and follow the equivalent runbook under
`.swallowkit/workflows/`.

Never repair schema drift by directly patching SwallowKit-managed artifacts.

Additional model-change facts:

- The shared package is consumed through its built `dist/`. `verify project`
  rebuilds it automatically before typecheck; when typechecking manually,
  build the shared package first (stale `dist/` shows up as
  "no exported member" errors).
- Keep development seed data aligned with model changes using the workflow below.

### Development seed data

Use `dev-seeds/<environment>/` and apply it explicitly with
`{{runCmd}} swallowkit dev --seed-env <environment>`. Editing JSON alone does
nothing. This command replaces the targeted containers' data; follow the
target inspection and approval rules under Everyday Commands before running it.

Seed filenames follow the model's singular kebab-case name, not the plural
Cosmos container name: `LearningProfile` uses
`dev-seeds/<environment>/learning-profile.json`, not `LearningProfiles.json`.
For example, a top-level array of documents (with fields matching the model):

```json
[
  { "id": "profile-1", "learnerId": "learner-1", "displayName": "Example" }
]
```

Match the intended models to the effective database and the logged seed
basenames, containers, and inserted counts. All-skipped files, no matching
schemas, or no target files do not prove seed application succeeded.

Do not inject demo data on HTTP requests, backend startup, or an empty database.
Do not replace this workflow with bespoke reset APIs/UI, importers, or demo
flags. Offline fixture generation is allowed when it produces standard seed
files and is not invoked by the backend. Legitimate business initialization is
distinct from demo seeding; do not remove required domain behavior.

## New Models / CRUD Features

Use the `swallowkit-add-model` Agent Skill when available.

Otherwise follow the equivalent runbook under `.swallowkit/workflows/`.

The agent may author domain-specific schema fields and custom behavior, but
SwallowKit should generate framework-owned CRUD artifacts.

Do not manually recreate boilerplate that SwallowKit owns.

### Persistent models require infrastructure, even with custom APIs

Whenever adding a persistent model, execute the installed SwallowKit model
creation and infrastructure generation workflow, whether or not it has custom
APIs. A hand-written model alone is not complete.

1. Preview source-of-truth schema creation and its registered Cosmos container
   migration with
   `{{runCmd}} swallowkit machine plan model <model> --overwrite never`, then
   apply the returned plan with
   `{{runCmd}} swallowkit machine apply model --plan <planId>`. The plan lists
   schema, shared export, migration, manifest, and artifact-ledger writes and
   writes no generated files before apply. Then author domain fields in
   `shared/models/` and check its export from `shared/index.ts`. For a
   hand-written schema or a model whose template was skipped, run
   `{{runCmd}} swallowkit machine plan model-infrastructure <model>` and apply
   the returned plan with
   `{{runCmd}} swallowkit machine apply model --plan <planId>`; this adds
   infrastructure records without overwriting the schema or generating CRUD.
   This also synchronizes `.swallowkit/project.json` for all current models,
   even when the container is already registered. For a metadata-only repair,
   plan `model <existing-model> --overwrite never`, then apply the reviewed
   plan. Skipped schemas are preserved; no CRUD, infrastructure rewrite, or
   Azure access is required.
2. If generated CRUD is needed, use `machine plan scaffold <model>` →
   `machine apply scaffold --plan <planId>` to derive Functions, BFF, UI,
   OpenAPI/native schema assets as applicable.
   `--api-only` skips UI only; it still generates CRUD Functions and BFF routes.
   If custom APIs replace CRUD, do **not** scaffold unnecessary CRUD; the model
   migration from step 1 (or the backfill command above) is sufficient.
3. Inspect `machine inspect entities`, `machine inspect infra`,
   `machine inspect artifacts`, and `machine inspect drift`, then run
   `{{runCmd}} swallowkit machine verify project`. Check that the model's
   container name and partition key match the generated Bicep under
   `infra/migrations/`, its `sourceModel` entry in
   `infra/migrations/manifest.json`, and `.swallowkit/artifacts.json`.
   An existing baseline-owned container may need no new migration; verify its
   tracked definition and wiring in `infra/main.bicep` instead. External
   `connectorConfig` models use the configured connector rather than Cosmos DB;
   verify that mapping instead of inventing a Cosmos container.

Do not hand-edit the checksum-locked baseline or an existing migration to add
a container; use the current migration workflow. Generation is local, not Azure
provisioning. Deployment still follows the provisioning approval gates below.

If infrastructure generation must be deferred, state the reason and the pending
container/migration work explicitly. For CRUD, pass `--skip-infra` to
`plan scaffold` / `apply scaffold` (MCP `skipInfra: true`). Nothing under `infra/`
changes during that scaffold plan and the plan reports `infra-skipped`. Generate
any missing model migration later with
`{{runCmd}} swallowkit machine plan model-infrastructure <model>` and apply
the reviewed plan with `{{runCmd}} swallowkit machine apply model --plan <planId>`.
If an unapplied container definition must be refreshed after editing its partition
key, preview with
`{{runCmd}} swallowkit machine plan model-infrastructure <model> --refresh-pending --resource-group <name>`;
this checks the target's migration tag and deployment history before changing the template.
Applied, attempted, unknown, or user-modified migrations are not rewritten.
`verify project` fails while a required local migration is missing or stale.
A passing verify confirms local model-to-container definitions only; it does
not prove that Azure has been provisioned or that deployment succeeded.

Treat plan `warnings` as decisions to make, not noise. In particular,
`user-scoped-data-without-auth` means the model looks per-user (for example a
`/userId` partition key) while authentication is not configured, so generated
CRUD would let any caller read and write every document.

## Authentication

Authentication is a **plan/apply operation**, not a free-form config edit.
Ownership of `swallowkit.config` is split:

- `auth.schemes` — owned by SwallowKit. **Always start with
  `{{runCmd}} swallowkit machine plan auth --provider <p> [--scheme <name>]`.
  Never hand-write `auth.schemes` entries**; apply auth appends them, and a
  hand-written scheme makes the plan fail with "already exists".
- `auth.authorization.policies` and `swa.allowedProviders` — hand-edited
  **after** apply (the config is an extension point; this edit is expected).
  `swa.allowedProviders` can also be set at plan time with
  `--allowed-providers github,aad`.

After `apply auth`, follow the returned `nextActions`:

1. Define `auth.authorization.policies` referencing the new scheme.
2. For `swa`: confirm `swa.allowedProviders`; generated login URLs use it.
3. For `external-token`: implement the generated verifier stub. It fails
   closed, and **verify passes with the stub in place** — a green verify does
   not mean external-token auth works end-to-end (`verify project` surfaces a
   `auth-verifier-stub` warning while the stub is unmodified).
4. Re-run plan/apply scaffold for models that need auth guards, then verify.

Use the `swallowkit-add-auth` Agent Skill or the
`.swallowkit/workflows/add-auth.md` runbook when available.

### Generated CRUD scope

Generated CRUD endpoints enforce the model's `authPolicy`
(authentication + roles) — **they do NOT scope data to the authenticated
user**. Any caller passing the policy can read or write any document. For
multi-user data where users may only touch their own records, add ai-authored
custom endpoints that derive the scoping key (e.g. `learnerId`) from the
verified principal — never from the request body — and restrict the generated
write endpoints to admin roles.

Configure authentication with `plan auth` / `apply auth` **before** declaring
`authPolicy`. Without authentication, an explicit policy
blocks plan/apply/scaffold with `auth-policy-without-auth` before file writes;
follow `nextActions`, then re-plan. Do not remove a required policy just to pass
generation.
An empty `authPolicy = {}` means no explicit policy; it does not enable authentication.

With named `auth.schemes`, define `auth.authorization.policies` selecting the
required schemes and roles, then use `authPolicy = { policy: 'adminOnly' }` (or
read/write policy names). Role-only declarations do not select a named scheme
and block with `auth-policy-requires-named-policy`. Conversely, single-provider
`auth.provider` supports role lists only; a named policy (including a named
`defaultPolicy`) blocks with `auth-named-policy-requires-named-scheme`.

## Verification Is a Completion Gate

Before treating an agent-driven implementation as complete, run SwallowKit
verification:

```bash
{{runCmd}} swallowkit machine verify project
```

or the equivalent MCP operation.

Default checks are `structure`, `drift`, `typecheck`, `backend-build`, plus
configured project checks. `backend-build` checks standalone `functions/`:
C# uses `dotnet build`, TypeScript uses the project's `tsc --noEmit`, and Python
uses Python 3 `compileall` (syntax only, not imports or type checking), preferring
`functions/.venv` over PATH. Missing toolchains are `skip` with an explanation;
a skipped backend check is **not** evidence that the backend works. Restore the
toolchain and re-run it before claiming backend validation.

Root `build` scripts do not replace standalone backend verification. To include
frontend production builds, use `--checks "structure,drift,typecheck,backend-build,build"`.
Quote comma-separated values in PowerShell.

When verification fails, use the structured failure explanation:

```bash
{{runCmd}} swallowkit machine explain failure
```

or its MCP equivalent, then repair the appropriate source and verify again.

Use the `swallowkit-verify-repair` Agent Skill or runbook when applicable.

SwallowKit verification answers:

> Is the SwallowKit project mechanically and structurally valid?

A semantic code review answers different questions:

> Is this implementation well designed?
> Does it satisfy the specification and user intent?

Therefore, perform SwallowKit verification before treating semantic code review
as the final quality gate, and include runtime evidence when required below.

### Runtime evidence for changed behavior

Verification, builds, typechecks, unit tests, fixtures, and readiness probes are
mechanical evidence, not proof of a real database connection or end-to-end behavior.
For startup, persistence, API, or UI changes, run the normal
`{{runCmd}} swallowkit dev` workflow and exercise the changed behavior from the
actual application through the configured frontend's same-origin BFF, standalone
Functions, and database. Use the frontend-specific routing under Everyday Commands;
calling Functions directly does not verify the BFF or UI.

For persistence changes, write through the application, reload and read back,
then restart the application without re-seeding and confirm the data remains.
Cover relevant validation failures, nonexistent IDs, and configured
authentication/authorization paths, not only the happy path.

Report evidence separately: Emulator versus Azure Cosmos DB, mock AI versus
real AI service calls, fixed development identity versus real authentication,
and checks that passed, skipped, or warned. API success is not host health:
HTTP success does not clear `AzureWebJobsStorage` warnings. Missing services,
credentials, containers, or tools are blockers or explicitly unverified behavior;
unrelated passing tests do not justify a completion claim.

A documentation-only change does not require live database verification.

## Human Approval Gates

A machine operation may return terminal states such as:

- `complete`
- `in-progress`
- `blocked`
- `requires-human`
- `failed`

Follow `nextActions`.

When the status is `requires-human`, stop and request the required human
decision.

Do not reinterpret `requires-human` as an error to work around.

Azure provisioning is a human-approved operation.

Use the `swallowkit-provision` Agent Skill or runbook and never bypass its
approval gate. A broad request to deploy does not itself grant the explicit
approval required by that workflow.

Provision applies Bicep once and tracks the original Azure deployment with a
bounded wait. A local timeout/error, output truncation, or Ctrl+C is not proof
that Azure failed. `in-progress` means Azure is Running/Accepted; `unknown`
means its result could not be read; `partial` means Azure succeeded but
tag/ledger completion is pending. Never re-submit Bicep, reconcile, adopt,
cancel, or delete just to repair waiting or migration bookkeeping.

Retain `.swallowkit/state/provision/` execution checkpoints. Use
`{{runCmd}} swallowkit machine inspect provision --plan <runId> --wait-seconds 300`
for read-only status/wait, and after explicit human approval use
`{{runCmd}} swallowkit machine apply provision --plan <runId> --approve`
to resume. `runId` equals the original `planId`; fingerprints, subscription,
deployment identity and migration checks remain in force. Only
`status: "complete"` / `outcome: "succeeded"` means Azure Succeeded plus verified
tags and local ledger. Do not print deployment output secrets or raw `az --debug`.
For older untracked baselines use `plan provision --resume-deployment <name>`
with original target/regions; it blocks unless ARM/parameter evidence matches.

## SwallowKit Agent Skills and Runbooks

SwallowKit installs task-specific Agent Skills under:

```text
.github/skills/
```

Current workflows include:

- `swallowkit-add-model`
- `swallowkit-modify-model`
- `swallowkit-add-auth`
- `swallowkit-verify-repair`
- `swallowkit-provision`

Equivalent agent-agnostic runbooks are available under:

```text
.swallowkit/workflows/
```

If the runtime supports Agent Skills, use the relevant Skill when the task
matches. If it does not, read the corresponding runbook.

These task-specific instructions supplement this `AGENTS.md`; they do not
replace the always-on project contract.

## Architecture

This is a full-stack application deployed on Azure with a TypeScript
frontend/BFF and an Azure Functions backend in {{backendLanguageLabel}}.

```text
Frontend ({{frontendLabel}})
  ↓
BFF ({{bffLabel}})
  ↓
Azure Functions
  ↓
Azure Cosmos DB
```

### Core architecture rules

1. {{bffLabel}} are a BFF/proxy layer. Do not place application business
   logic or direct database access there.
2. Zod schemas under `shared/models/` are the application model source of truth.
3. Do not duplicate model definitions across layers.
4. Azure Functions own backend business logic and data access.
5. SwallowKit-generated artifacts must be changed through their source of truth
   and deterministic generation workflow, not by hand.
6. Infrastructure is managed as code with Bicep. Respect SwallowKit ownership
   markers and boundaries.
7. Production access to Azure resources must follow the generated security
   architecture; do not introduce hard-coded credentials or connection strings.
8. Never link standalone Functions to SWA. The same-origin BFF calls the
   independent backend with server-side BACKEND_FUNCTIONS_BASE_URL and
   BACKEND_FUNCTIONS_KEY. Never expose these values in browser bundles or VITE_*.
   Managed Functions use HTTP triggers only; database access, non-HTTP triggers,
   managed identity, and private networking belong to the standalone backend.

### Backend-specific rules

{{backendRules}}

The backend owns `id`, `createdAt`, and `updatedAt`; never trust client-sent
values for these fields.

### Persistence contract

For Cosmos-backed models, use Azure Cosmos DB in production and Cosmos DB
Emulator locally. Missing services, credentials, or containers must be reported,
not bypassed with File/JSON/SQLite/InMemory application storage or a fallback
that hides connection failures. Explicit unit-test doubles are allowed, but
they are not database evidence.

Custom APIs and business logic must use the project's standard connection
settings and effective database name, including the worktree-isolated name
resolved by `swallowkit dev`. Do not hard-code the base database name or add
unnecessary custom database/path/storage options or production startup flags.
Use inspected configuration and capabilities, not a parallel persistence setup.
Explicit alternate-persistence requirements and external `connectorConfig`
models remain valid within inspected capabilities and ownership boundaries;
they are not permission to silently replace Cosmos when it fails.

## Project Structure

```text
{{projectName}}/
{{frontendStructure}}
├── functions/              # Azure Functions backend
{{functionsStructureLine}}
├── shared/
│   ├── models/             # Zod source-of-truth models
│   └── index.ts
├── lib/                    # auth, navigation, and shared application utilities
├── components/
├── infra/                  # Bicep infrastructure
├── .swallowkit/            # SwallowKit project metadata and runbooks
├── .github/skills/         # SwallowKit Agent Skills
├── .mcp.json               # project-scoped SwallowKit MCP bootstrap
└── AGENTS.md
```

Inspect the current project rather than assuming every project has exactly the
same generated structure.

## Naming and Model Conventions

- Model schema files use `shared/models/{kebab-case}.ts`.
- The Zod schema constant and inferred TypeScript type use the same PascalCase
  name: `export const Todo = z.object(...); export type Todo = z.infer<typeof Todo>`.
- Re-export models from `shared/index.ts`. create-model and plan/apply scaffold
  append missing exports, including manually authored models. Manual exports
  are allowed; this file has no managed markers and existing content is preserved.
- `id` is a required `z.string()`; only `createdAt` / `updatedAt` are optional
  backend-managed fields.
- Models may declare `partitionKey`, `authPolicy`, `displayName`,
  `references`, and `connectorConfig` as exported constants. Exact formats:
  `{{runCmd}} swallowkit machine inspect capabilities` (modelDeclarations).
- A string field named `<model>Id` is treated as a foreign key only when that
  model exists in `shared/models`. Declare other references explicitly with
  `export const references = { authorId: 'User' };` (map a field to `false`
  to opt out).
- Native C#/Python schema types come from Zod, not field names: use
  `z.iso.datetime()` / `z.iso.date()` for date values (`createdAt` stays a
  string), `z.number().int()` for integers, and inline `z.object` for nested
  classes. Length/range/regex/item constraints are enforced natively; formats
  such as email remain Zod (BFF) validation. See `inspect capabilities`
  (sharedModels.nativeSchemaMapping).
- Cosmos DB containers use PascalCase plural names and default to `/id` as the
  partition key unless the model declares another key, e.g.
  `export const partitionKey = '/learnerId';` (the field must exist in the
  schema).

## Everyday Commands

```bash
{{pm}} install
{{runCmd}} swallowkit dev
{{pm}} run build
{{pm}} run --if-present lint
{{runCmd}} swallowkit machine verify project
```

Always invoke SwallowKit using the package-runner convention generated for this
project. Do not arbitrarily mix package-manager invocation styles.

{{devGuidance}}

Inspect existing Emulator/server processes and occupied ports before starting
local services. Check Emulator availability before database tests; if unavailable,
report the prerequisite; do not start/restart/reset it without explicit
permission. Do not restart user services to free a port.

Before destructive seed replacement, container recreation, or other data changes,
inspect the actual endpoint, effective database name, and target containers.
Use an isolated test database and ports; verify isolation from resolved settings
and logs, not merely from being in a worktree. Existing production, shared, or
user data requires the applicable human approval; never assume it is disposable.
Do not disable TLS validation, change certificate trust/global tools/machine
settings, or guess a different protocol to make a check pass. Use the actual
configured HTTP/HTTPS endpoint and report connection failures.

Stop only processes you started, by specific process identity, never bulk-kill
by process name. Disclose local untracked configuration and test database
leftovers. Follow the runtime-evidence gate above and explicitly report
unverified cloud deployment or unavailable local prerequisites.

## Final Rules

Do not:

- rely on remembered SwallowKit capabilities when current inspection can answer
  the question
- hand-edit deterministic SwallowKit-managed artifacts
- bypass plan/apply safety checks
- bypass human approval gates
- duplicate model definitions across generated layers
- move backend business logic into the BFF
- decompose one end-to-end SwallowKit-generated feature into artificial
  horizontal tickets solely because multiple generated layers exist
- consider an implementation complete before SwallowKit verification succeeds

Do:

- inspect before making SwallowKit-dependent design assumptions
- preserve external development-process workflows
- use SwallowKit as the deterministic execution and verification layer
- keep specifications focused on intent and observable behavior
- prefer vertical, independently verifiable slices
- verify before final semantic review

Use `{{pm}}`, the package manager selected for this project. Do not introduce another package manager or lockfile. Use `{{runCmd}} swallowkit` for the project-local CLI. The MCP launcher intentionally resolves `latest` independently.
Exception for prerelease projects: when the project's SwallowKit is newer than
the published `latest` (for example `2.0.0-alpha.3` while `latest` is `1.1.2`),
`.mcp.json` may pin `SWALLOWKIT_MCP_VERSION` to the project version, and a
`latest` launcher that supports it hands the session to the project-installed
MCP. Run `{{runCmd}} swallowkit configure-mcp` to re-select the version (it
returns to `latest` once `latest` is at least the project version). Until MCP
reports the project version, prefer `{{runCmd}} swallowkit machine ...`.

日本語対訳 ​

md
# AGENTS.md

通常の `swallowkit provision` は人が直接使うデプロイコマンドであり、追加の確認なしで実行します。エージェントは machine/MCP の承認フローを使い、通常 CLI に切り替えて承認を回避してはいけません。

このプロジェクトは **SwallowKit** によって生成されました。

SwallowKit の構成と編集規則は、コード生成時だけでなく、調査、要件整理、仕様作成、計画、チケット分割、実装、検証、レビューのすべてで守ってください。

<!-- source-section: How SwallowKit Fits Into the Development Process -->
## SwallowKit と開発プロセスの関係

SwallowKit は開発プロセス全体の進め方を決めるものではありません。
利用者や別の Agent Skill、フレームワークが要件整理、仕様作成、計画、チケット管理、TDD、実装、レビューの手順を定めている場合は、その手順に従ってください。

その中で SwallowKit を使い、現在のプロジェクト、モデル、ルート、インフラ、責任範囲を調べます。
編集可能な生成物を判断し、plan/apply によって同じ定義から生成物を再現し、記録とのずれを検出して検証します。
人の承認が必要な操作では、定められた承認手順に従ってください。

開発プロセスのスキルが作業の進め方を定め、SwallowKit がプロジェクトの検査と再現可能な変更方法を担います。両方を組み合わせて使用してください。

<!-- source-section: Do Not Assume SwallowKit Capabilities From Memory -->
## 現在利用できる機能の確認

SwallowKit の機能はバージョンによって変わります。エージェントが学習した知識や記憶だけで、生成できるもの・できないものを判断してはいけません。
利用できる機能、プロジェクト構成、所有権が設計に影響する場合は、判断の前に現在のプロジェクトとツールを検査してください。

利用できる場合は `swallowkit_*` MCP ツールを優先します。MCP が使えない場合は machine CLI を使ってください。

```bash
{{runCmd}} swallowkit machine ...
```

machine CLI は `status` と `nextActions` を構造化された形式で返し、エージェントが次の操作を判断するために使えます。

<!-- source-section: Inspect Before Asking or Designing -->
## 質問・設計の前の検査

SwallowKit 管理の構成に影響する作業では、人に質問したり実装の設計を確定したりする前にプロジェクトを調べてください。
タスクに関連する検査を選びます。

```bash
{{runCmd}} swallowkit machine inspect project
{{runCmd}} swallowkit machine inspect entities
{{runCmd}} swallowkit machine inspect routes
{{runCmd}} swallowkit machine inspect boundaries
{{runCmd}} swallowkit machine inspect drift
{{runCmd}} swallowkit machine inspect infra
{{runCmd}} swallowkit machine inspect capabilities
```

`inspect capabilities` では、対応するモデル宣言の書式、認証の導入手順、生成 CRUD の範囲、シードの適用方法を確認できます。
機能を推測したり SwallowKit 内部の実装を検索したりする前に、この情報を使います。対応する MCP ツールが利用できる場合は、そちらを優先してください。

リポジトリや検査結果から分かることはエージェントが確認します。
たとえば、生成 CRUD の接続方法、生成ファイルを編集できるかどうか、必要なインフラ操作があるかどうかを、検査せずに人へ質問してはいけません。

<!-- source-section: Specification and Planning Guidance -->
## 仕様と計画

仕様には、利用者から確認できる動作と業務上の目的、受け入れ条件、テストで確かめる動作を記載します。
SwallowKit の構成と責任範囲は実装上の制約として扱い、モデルや設定から生成できるものを、手作業で実装する部品として重複して計画してはいけません。

たとえば、モデルにフィールドを追加して Functions、BFF、UI、インフラを再生成する場合は、その機能全体の期待動作と必要な制約を仕様に記載します。
各レイヤーが別々の手作業であるかのように扱わないでください。
目的の動作を SwallowKit が生成できるかによって仕様が変わる場合は、確定する前に現在の機能を検査します。

<!-- source-section: Ticket Decomposition Guidance -->
## チケット分割

単独で価値があり、実装・検証できる機能単位でチケットを作成してください。
スキーマ、バックエンド、BFF、UI、インフラの生成先が違うという理由だけで、レイヤー別のチケットに分割してはいけません。
1つの機能をモデルから再生成できる場合は、同じチケットに含めます。

```text
Todo に優先度を追加
  ├─ 定義元のモデルを変更
  ├─ plan/apply で生成物を更新
  ├─ 必要な独自の業務ロジックを実装
  ├─ テストを追加・更新
  └─ プロジェクトを検証
```

チケットの範囲は、生成先のディレクトリではなく、独立して価値と動作を確認できる単位で決めてください。

<!-- source-section: Responsibility Boundary -->
## 責任範囲と編集規則

編集するファイルを決める前に、現在の編集規則を取得してください。

```bash
{{runCmd}} swallowkit machine inspect boundaries
```

ここで返される現在の契約に従います。以下の例だけで編集可否を決めてはいけません。

### ai-authored

モデルの定義元、独自の業務ロジック、独自のページ・コンポーネント、テストなど、直接編集できる領域です。

### deterministic

SwallowKit が管理する生成物です。直接編集せず、モデルや設定を変更して plan/apply で再生成してください。
管理対象は `.swallowkit/artifacts.json` などに記録されています。

### shared

パスごとの `editPolicy` に従ってください。マーカーで管理するファイルでは、その外側を編集します。
`shared/index.ts` はマーカーがなく、必要なエクスポートを手動で追記できます。

<!-- source-section: Deterministic Changes: Plan → Apply → Verify -->
## 定義に基づく変更の手順

エージェントによる生成では、計画と適用を分ける SwallowKit の手順を優先してください。
現在の状態を検査し、plan を作り、競合と承認の要否を確認してから apply し、最後に verify します。

```bash
{{runCmd}} swallowkit machine plan scaffold <model>
{{runCmd}} swallowkit machine apply scaffold --plan <planId>
{{runCmd}} swallowkit machine verify project
```

生成物の手編集で plan/apply を迂回してはいけません。
競合が見つかった場合は、既存の手書き処理を直接編集できる場所へ移すか、上書きの承認を得るかを判断してください。
人の承認が必要な場面で、承認を捏造したり、暗黙に得たと解釈したりしてはいけません。

<!-- source-section: Model Changes -->
## モデルの変更

既存モデルは、次の順序で変更します。

```text
source-of-truth model を編集
        ↓
drift を inspect
        ↓
scaffold を plan
        ↓
conflict / approval を必要に応じて解決
        ↓
apply
        ↓
verify
```

利用可能なら `swallowkit-modify-model` Agent Skill を使用してください。

それ以外では `.swallowkit/workflows/` にある同等の作業手順書を読み、従ってください。

SwallowKit 管理の生成物を直接修正してスキーマと記録のずれを修復してはなりません。

モデル変更に関する追加事項:

- 共有パッケージはビルド済み `dist/` 経由で参照されます。`verify project` は型検査の前に
  自動で再ビルドしますが、手動で型検査する場合は先に共有パッケージをビルドしてください
  (古い `dist/` は "no exported member" エラーとして現れます)。
- 開発用シードは、次の手順でモデルの変更に追従させてください。

### 開発用シードデータ

`dev-seeds/<environment>/` を使い、
`{{runCmd}} swallowkit dev --seed-env <environment>` で明示的に適用します。
JSON の編集だけでは適用されません。このコマンドは対象コンテナーのデータを置換するため、
実行前に「日常的なコマンド」の対象確認と承認規則に従ってください。

シードファイル名は、複数形の Cosmos コンテナー名ではなく、モデル名の単数形 kebab-case です。
`LearningProfile` なら `LearningProfiles.json` ではなく
`dev-seeds/<environment>/learning-profile.json` を使います。
モデルに合うフィールドを持つ、トップレベルのドキュメント配列の例:

```json
[
  { "id": "profile-1", "learnerId": "learner-1", "displayName": "Example" }
]
```

意図したモデルを、実効 DB 名とログに出るシードファイル名、コンテナー、挿入件数に
照合してください。全ファイルの省略、対応スキーマなし、対象ファイルなしは、
シードの適用成功を示しません。

HTTP リクエスト、バックエンド起動、DB が空であることを契機にデモデータを自動投入しては
なりません。独自の reset API / UI、importer、demo フラグでこの手順を置き換えてはなりません。
標準のシードファイルを出力し、バックエンドから呼ばれないオフラインのテスト用データの生成は可能です。
正当な業務上の初期化はデモ用シードとは別です。必要なドメイン動作は削除しないでください。

<!-- source-section: New Models / CRUD Features -->
## 新しいモデルと CRUD 機能

利用可能なら `swallowkit-add-model` Agent Skill を使用してください。

それ以外では `.swallowkit/workflows/` の同等の作業手順書に従ってください。

エージェントは 業務に固有のスキーマフィールドと独自の動作を記述できますが、SwallowKit 管理の
CRUD 生成物は SwallowKit が生成すべきです。

SwallowKit が所有する 定型コード を手作業で再作成してはなりません。

### カスタム API の有無にかかわらず、永続化モデルにはインフラ生成が必要

永続化モデルを追加するときは、カスタム API の有無にかかわらず、インストールされている
SwallowKit のモデル作成・インフラ生成手順を実行してください。手書きモデルを追加しただけでは完了ではありません。

1. `{{runCmd}} swallowkit machine plan model <model> --overwrite never` で
   定義元のスキーマ、共有パッケージのエクスポート、Cosmos コンテナーマイグレーション、プロジェクト情報ファイル、
   生成台帳の書き込み予定を確認し、返された plan を
   `{{runCmd}} swallowkit machine apply model --plan <planId>` で適用します。
   plan は apply 前に生成ファイルを書き込みません。
   `shared/models/` にドメインのフィールドを記述し、`shared/index.ts` のエクスポートを確認してください。
   手書きスキーマやテンプレートをスキップしたモデルは、
   `{{runCmd}} swallowkit machine plan model-infrastructure <model>` で確認後、
   返された plan を `{{runCmd}} swallowkit machine apply model --plan <planId>`
   で適用してください。スキーマを変更せず既存モデルにインフラ定義を追加できます。
   登録済みコンテナーの場合も、現在のすべてのモデルに合わせて `.swallowkit/project.json` を同期します。
   メタデータだけを修復する場合は、`model <existing-model> --overwrite never` を plan し、
   確認後に apply してください。省略されたスキーマは保持されます。
   CRUD 生成、インフラの書き換え、Azure 接続は不要です。
2. 生成 CRUD が必要なら `machine plan scaffold <model>` →
   `machine apply scaffold --plan <planId>` で Functions、BFF、UI、必要な OpenAPI/ネイティブスキーマ
   生成ファイルを生成します。`--api-only` は UI だけを省略し、
   CRUD Functions と BFF ルートは生成します。
   カスタム API が CRUD を置き換える場合、不要な CRUD を scaffold してはなりません。
   手順 1 で生成したマイグレーション(または既存モデルへのインフラ定義の追加)だけで十分です。
3. `machine inspect entities`、`machine inspect infra`、`machine inspect artifacts`、
   `machine inspect drift` で確認し、`{{runCmd}} swallowkit machine verify project` を実行します。
   モデルのコンテナー名・パーティションキーが、`infra/migrations/` の Bicep、
   `infra/migrations/manifest.json` の `sourceModel`、`.swallowkit/artifacts.json` と対応することを確認してください。
   初期インフラが管理する既存コンテナーでは新規マイグレーションが不要な場合があります。
   その場合は追跡済みの定義と `infra/main.bicep` の接続を確認してください。
   外部 `connectorConfig` モデルは Cosmos DB ではなく設定済みのコネクターを使うため、
   Cosmos コンテナーを追加せず、その対応を検証してください。

コンテナー追加のためにチェックサムで保護された初期インフラや既存マイグレーションを手編集してはなりません。
現在のマイグレーション手順を使用してください。生成はローカル操作であり、Azure リソースの作成・更新ではありません。
デプロイには後述のリソースの作成・更新に関する承認手順が引き続き適用されます。

インフラ生成を延期する場合は、理由と未完了のコンテナー/マイグレーション作業を明示してください。
CRUD では `plan scaffold` / `apply scaffold` に `--skip-infra` (MCP は `skipInfra: true`) を指定します。
`infra/` は変更されず、plan は `infra-skipped` を返します。
手書き・スキップしたモデルでマイグレーションが未登録なら、後で
`{{runCmd}} swallowkit machine plan model-infrastructure <model>` で変更予定を確認し、
返された plan を `{{runCmd}} swallowkit machine apply model --plan <planId>`
で適用してください。パーティションキーの変更後に未適用のマイグレーションを更新する場合も、
`{{runCmd}} swallowkit machine plan model-infrastructure <model> --refresh-pending --resource-group <name>`
で明示的に変更予定を確認します。
この読み取り専用確認では対象のマイグレーションタグとデプロイ履歴を検証します。
適用済み・デプロイ試行済み・状態不明・手編集済みのマイグレーションは書き換えられません。
`verify project` が通っても、必要なインフラがない状態で永続化モデルを完了扱いにしたり、
デプロイ可能と案内したりしてはなりません。

<!-- source-section: Authentication -->
## 認証

認証は plan/apply で導入します。設定ファイルで編集できる項目は、次のように分かれます。

- `auth.schemes` は SwallowKit が管理します。`{{runCmd}} swallowkit machine plan auth --provider <p> [--scheme <name>]` から始め、返された plan を `apply auth` で適用してください。先にスキームを手書きすると、既存スキームとして扱われ、plan が `already exists` で停止します。
- `auth.authorization.policies` と `swa.allowedProviders` は apply 後に追記します。SWA のプロバイダーは plan 時に `--allowed-providers github,aad` でも指定できます。

適用後は `nextActions` に従ってください。

1. 追加したスキームを参照する認可ポリシーを定義します。
2. SWA では `swa.allowedProviders` を確認します。生成されるログイン URL はこの値を使います。
3. 外部トークンでは、生成された検証処理のひな形を実装します。ひな形はすべてのトークンを拒否します。未実装でも `verify project` は警告 `auth-verifier-stub` を表示して成功する場合があり、認証の動作確認の代わりにはなりません。
4. 認証・認可が必要なモデルを plan/apply scaffold で再生成し、検証します。

利用できる場合は `swallowkit-add-auth` Agent Skill、使えない場合は `.swallowkit/workflows/add-auth.md` の手順書に従ってください。

### 生成 CRUD が制御する範囲

生成 CRUD はモデルの `authPolicy` による認証とロールを検査しますが、利用者ごとのデータ所有権は制御しません。ポリシーを満たした呼び出し元は、任意のドキュメントを操作できます。
自分のレコードだけを操作させる場合は、検証済みの利用者情報から `learnerId` などの対象キーを取得する独自 API を作成してください。対象キーをリクエスト本文から信用して取得してはいけません。生成された書き込み API は管理者ロールに制限します。

`authPolicy` の宣言前に plan/apply auth で認証を設定してください。未設定のまま明示的なポリシーを宣言すると、書き込み前に `auth-policy-without-auth` で停止します。空の `{}` は明示的なポリシーなしと解釈し、認証を有効にしません。
名前付きスキームでは、`authPolicy.policy` または `read`/`write` で名前付きポリシーを参照します。ロールだけの宣言は `auth-policy-requires-named-policy` で停止します。
旧形式の単一 `auth.provider` ではロール配列を使います。名前付きポリシーや名前付きの `defaultPolicy` は `auth-named-policy-requires-named-scheme` で停止します。

<!-- source-section: Verification Is a Completion Gate -->
## 完了前に必要な検証

エージェントによる実装を完了とみなす前に SwallowKit の検証を実行してください。

```bash
{{runCmd}} swallowkit machine verify project
```

または同等の MCP 操作を使用します。

既定チェックは `structure` / `drift` / `typecheck` / `backend-build` と設定済みの
カスタムチェックです。`backend-build` は独立 `functions/` を検証します。
C# は `dotnet build`、TypeScript はプロジェクトの `tsc --noEmit`、
Python 3 は `compileall`(構文のみ。インポートや型は対象外)で、Python は
PATH より `functions/.venv` を優先します。ツールチェーンがなければ理由付きで
省略になります。省略はバックエンドの検証成功ではありません。復元して再実行してください。
本番フロントエンドビルドも含める場合は
`--checks "structure,drift,typecheck,backend-build,build"` を指定します。
PowerShell ではカンマ区切り値を引用符で囲みます。

検証が失敗した場合は失敗した検査の構造化された結果を使用します。

```bash
{{runCmd}} swallowkit machine explain failure
```

または対応する MCP ツールを使用し、適切な定義元を修復して再検証します。

該当する場合は `swallowkit-verify-repair` Agent Skill または作業手順書を使用してください。

SwallowKit の検証が答える問い:

> SwallowKit プロジェクトは構成・構造の規則を満たしているか?

設計と仕様に照らしたコードレビューが答える別の問い:

> この実装は適切に設計されているか?
> 仕様と利用者の目的を満たすか?

したがって、設計と仕様に照らしたコードレビューを完了の条件とする前に SwallowKit の検証を
実施し、以下で必要とされる実動作の証拠も確認してください。

### 変更した動作の実行時の証拠

検証、ビルド、型検査、単体テスト、テスト用データ、起動確認は機械的な証拠であり、
実 DB への接続や E2E 動作の証明ではありません。起動・永続化・API・UI の変更では、通常の
`{{runCmd}} swallowkit dev` を実行し、実アプリから、設定されたフロントエンドの同一オリジン BFF、
独立 Functions、DB を通して変更した動作を確認してください。
「日常的なコマンド」のフロントエンド別ルーティングに従います。
Functions の直接呼び出しでは BFF や UI は検証できません。

永続化の変更ではアプリから書き込み、再読み込みして読み戻し、
再シードせずにアプリを再起動してデータが残ることを確認します。
正常系だけでなく、関連する入力検証エラー、存在しない ID、設定された認証・認可も確認してください。

Emulator / Azure Cosmos DB、模擬 AI / 実 AI サービス呼び出し、
開発用の固定 ID / 実認証、および成功 / 省略 / 警告を分けて報告します。
API 成功はホストの健全性を意味しません。HTTP 成功で `AzureWebJobsStorage` の警告が
解消したことにはなりません。サービス、資格情報、コンテナー、ツールの不足は作業を進められない理由または
未検証事項です。無関係なテストの成功を根拠に完了を宣言してはなりません。

ドキュメントだけの変更には実 DB の検証は不要です。

<!-- source-section: Human Approval Gates -->
## 人の承認が必要な操作

machine 操作は次のような処理の終了・継続状態を返す場合があります。

- `complete`
- `in-progress`
- `blocked`
- `requires-human`
- `failed`

`nextActions` に従ってください。

状態が `requires-human` の場合は停止し、必要な人による判断を要求してください。

`requires-human` を回避すべきエラーと解釈してはなりません。

Azure リソースの作成・更新は人の承認が必要な操作です。

`swallowkit-provision` Agent Skill または作業手順書を使用し、その承認が必要な手順を決して迂回しては
なりません。デプロイ全体を依頼されただけでは、その作業手順が要求する明示的承認を得たことにはなりません。

Provision は Bicep を一度送信し、元の Azure デプロイを時間を区切って確認します。
ローカルのタイムアウト/エラー、出力の省略、Ctrl+C は Azure の失敗を意味しません。
`in-progress` は Running/Accepted、`unknown` は結果を照会できない状態、
`partial` は Azure 成功後の tag/台帳未完了です。待機や記録の修復だけのために
Bicep を再送したり、reconcile/adopt/cancel/delete を実行したりしないでください。

`.swallowkit/state/provision/` の実行チェックポイントを保持し、
`{{runCmd}} swallowkit machine inspect provision --plan <runId> --wait-seconds 300`
で読み取り専用の状態確認/待機を行います。再度、人間の明示承認を得て
`{{runCmd}} swallowkit machine apply provision --plan <runId> --approve`
で再開してください。runId は元の planId と同じです。変更検出用のハッシュ、サブスクリプション、
デプロイの識別子、マイグレーションのチェックは引き続き有効です。
Azure Succeeded と tag/台帳の確認が完了した
`status: "complete"`/`outcome: "succeeded"` だけを全体の成功と扱ってください。
デプロイ出力値の秘密値や `az --debug` の生の出力を表示してはいけません。
旧版の未追跡初期インフラは、元の対象/リージョンと
`plan provision --resume-deployment <name>` を使い、ARM/parameters の一致を確認します。

<!-- source-section: SwallowKit Agent Skills and Runbooks -->
## Agent Skills と作業手順書

SwallowKit は、次の作業に対応する Agent Skills を `.github/skills/` に生成します。

- `swallowkit-add-model`
- `swallowkit-modify-model`
- `swallowkit-add-auth`
- `swallowkit-verify-repair`
- `swallowkit-provision`

Agent Skills に対応する実行環境では、作業に合うスキルを使用してください。
対応しない場合は、`.swallowkit/workflows/` にある同じ作業の手順書を読みます。
これらは作業ごとの詳細であり、すべての作業に適用する `AGENTS.md` の代わりではありません。

<!-- source-section: Architecture -->
## アーキテクチャ

このアプリケーションは、TypeScript のフロントエンド・BFF と、{{backendLanguageLabel}} の独立 Azure Functions バックエンドで構成され、Azure にデプロイされます。

```text
フロントエンド({{frontendLabel}})
  ↓
BFF({{bffLabel}})
  ↓
独立 Azure Functions
  ↓
Azure Cosmos DB
```

### 構成の基本規則

1. {{bffLabel}} はリクエストの検証と転送を担います。業務ロジックやデータベースへの直接アクセスを置いてはいけません。
2. `shared/models/` の Zod スキーマをモデルの定義元とします。
3. レイヤーごとにモデル定義を重複させてはいけません。
4. 業務ロジックとデータアクセスは、独立 Azure Functions が担当します。
5. SwallowKit 管理の生成物は直接編集せず、定義元と plan/apply から変更します。
6. インフラは Bicep で管理し、SwallowKit の所有権と編集規則に従います。
7. 本番の Azure リソースには生成された認証・接続の構成でアクセスします。資格情報や接続文字列をコードに直接記述してはいけません。
8. 独立 Functions を SWA にリンクしてはいけません。同一オリジンの BFF が `BACKEND_FUNCTIONS_BASE_URL` と `BACKEND_FUNCTIONS_KEY` をサーバー側で使用します。ブラウザーのバンドルや `VITE_*` には公開しないでください。マネージド Functions は HTTP 専用です。DB、非 HTTP トリガー、マネージド ID、閉域網は独立バックエンドが担当します。

### バックエンドごとの規則

{{backendRules}}

`id`、`createdAt`、`updatedAt` はバックエンドが管理します。クライアントが送信した値を信頼してはいけません。

### 永続化の規約

Cosmos を使うモデルでは、本番は Azure Cosmos DB、ローカルは Cosmos DB Emulator を使用します。
サービス、資格情報、コンテナーが不足している場合は報告してください。接続障害を隠すために、保存先を File / JSON / SQLite / InMemory に置き換えてはいけません。
単体テスト用の代替実装は使用できますが、実 DB を検証した証拠にはなりません。

カスタム API と業務ロジックでも、標準の接続設定と実効 DB 名を使います。
`swallowkit dev` が解決する worktree 分離後の DB 名もこれに含まれます。
分離前の DB 名を直接記述したり、不要な独自の DB・パス・ストレージ設定や本番用の起動フラグを追加したりしてはいけません。
別の永続化要件や外部の `connectorConfig` モデルを使う場合も、確認した機能と編集規則に従ってください。Cosmos の障害時に無断で保存先を置き換える許可ではありません。

<!-- source-section: Project Structure -->
## プロジェクト構成

```text
{{projectName}}/
{{frontendStructure}}
├── functions/              # 独立 Azure Functions バックエンド
{{functionsStructureLine}}
├── shared/
│   ├── models/             # 定義元の Zod モデル
│   └── index.ts
├── lib/                    # 認証、ナビゲーション、共通処理
├── components/
├── infra/                  # Bicep インフラ
├── .swallowkit/            # プロジェクト情報と作業手順書
├── .github/skills/         # SwallowKit の Agent Skills
├── .mcp.json               # MCP サーバーの起動設定
└── AGENTS.md
```

すべてのプロジェクトで同じファイル構成になるとは限りません。作業するプロジェクトを検査してください。

<!-- source-section: Naming and Model Conventions -->
## 命名とモデルの規約

- モデルのファイルは `shared/models/{kebab-case}.ts` に置きます。
- Zod の定数と推論した TypeScript 型は同じ PascalCase 名を使います。例は `export const Todo = z.object(...); export type Todo = z.infer<typeof Todo>` です。
- `create-model` と plan/apply scaffold は、手書きモデルを含め、不足するエクスポートを `shared/index.ts` に追記します。マーカーはなく、既存内容を保持し、手動での追記もできます。
- `id` は必須の `z.string()` です。バックエンド管理の `createdAt` と `updatedAt` は任意項目にできます。
- `partitionKey`、`authPolicy`、`displayName`、`connectorConfig` はエクスポートした定数で指定できます。正確な書式は `{{runCmd}} swallowkit machine inspect capabilities` の `modelDeclarations` を確認してください。
- Cosmos DB のコンテナー名は PascalCase の複数形です。パーティションキーの既定値は `/id` で、たとえば `export const partitionKey = '/learnerId';` で変更できます。指定するフィールドはスキーマ内に定義してください。

<!-- source-section: Everyday Commands -->
## 日常的なコマンド

```bash
{{pm}} install
{{runCmd}} swallowkit dev
{{pm}} run build
{{pm}} run --if-present lint
{{runCmd}} swallowkit machine verify project
```

このプロジェクト向けに生成された package-runner convention で SwallowKit を呼び出してください。
package-manager invocation style を勝手に混在させてはなりません。

{{devGuidance}}

ローカルサービスを起動する前に、既存の Emulator / サーバープロセスと使用中のポートを
調べてください。DB の検証前に Emulator の稼働を確認し、利用できなければ報告します。
明示的な許可なく起動・再起動・リセットしてはなりません。
ポートを空けるために利用者のサービスを再起動してはなりません。

破壊的なシード置換、コンテナー再作成、その他のデータ変更の前に、
実際のエンドポイント、実効 DB 名、対象コンテナーを確認します。分離したテスト DB とポートを使い、
worktree 内にいるというだけで分離済みと判断せず、解決済みの設定とログで確認します。
本番・共有・既存の利用者データには適用される人間の承認が必要です。破棄可能と決めつけてはなりません。
検証を通すために TLS 検証を無効化したり、証明書の信頼設定・グローバルツール・PC の設定を
変更したり、別プロトコルを推測して使ってはなりません。
実際に設定された HTTP / HTTPS エンドポイントを使い、接続障害は報告してください。

停止するのは自分が起動したプロセスだけにし、個々のプロセスを特定してください。
プロセス名による一括停止は禁止です。ローカルの未追跡設定やテスト DB の残存を報告します。
上記の実動作確認の gate に従い、クラウド未検証や利用できないローカル前提条件を明示してください。

<!-- source-section: Final Rules -->
## 最終ルール

次の操作をしてはいけません。

- 現在の検査結果で分かる機能を、記憶だけで判断する。
- SwallowKit 管理の生成物を手編集する。
- plan/apply の検査や、人の承認が必要な手順を迂回する。
- 生成されるレイヤー間でモデル定義を重複させる。
- バックエンドの業務ロジックを BFF に移す。

生成される CLAUDE.md ​

生成される英語の原文 ​

md
# CLAUDE.md

This is a **SwallowKit** project.

Before discovery, requirements clarification, specification, planning, ticket
decomposition, implementation, verification, or review, read and follow the
root `AGENTS.md`.

SwallowKit must be considered before implementation, not only when generating
code.

Always-on rules:

- Inspect the current project and SwallowKit capabilities before making
  SwallowKit-dependent assumptions or asking questions the repository can answer.
- Prefer `swallowkit_*` MCP tools.
- Fall back to `{{runCmd}} swallowkit machine ...` when MCP is unavailable, or
  when an MCP response's `metadata.swallowkitVersion` is older than the project's
  SwallowKit (`metadata.warnings` contains `mcp-older-than-project`).
- Inspect responsibility boundaries before editing framework-related files.
- Never hand-edit deterministic SwallowKit-managed artifacts.
- Add auth schemes only via plan/apply auth; never hand-write `auth.schemes`
  in swallowkit.config (policies and `swa.allowedProviders` are hand-edited
  after apply).
- Use plan/apply for deterministic generation.
- Respect all `requires-human` states and provisioning approval gates.
- Normal `swallowkit provision` is for humans. Agents must not use it to bypass
  the machine/MCP approval flow.
- Provision timeouts/Ctrl+C do not prove Azure failed. Inspect the original
  execution checkpoint with `machine inspect provision --plan <runId>`; resume
  `machine apply provision --plan <runId> --approve` only after explicit human
  approval. Preserve checkpoints; never re-submit Bicep/reconcile/cancel/delete
  to repair waiting or tag/ledger failures. Do not print deployment output secrets.
- Run SwallowKit verification before considering implementation complete.
- Follow root `AGENTS.md` for persistence, development seeds, runtime evidence,
  and local service/data safety; mechanical verification alone is not E2E proof.
- Default verification includes `backend-build` for standalone Functions.
  Skipped toolchains are not validation; Python compilation checks syntax only.
- Configure auth via plan/apply auth before adding `authPolicy`; otherwise
  scaffold blocks before file writes. Scaffold appends missing shared model exports.

Task-specific SwallowKit Agent Skills are available under `.github/skills/`.
Equivalent agent-agnostic runbooks are available under
`.swallowkit/workflows/`.

The root `AGENTS.md` is the canonical project contract.

日本語対訳 ​

md
# CLAUDE.md

これは SwallowKit プロジェクトです。調査、要件整理、仕様作成、計画、チケット分割、実装、検証、レビューの前に、ルートの `AGENTS.md` を読んで従ってください。
コード生成を始める前から、SwallowKit の構成と編集規則を考慮します。

常に適用する規則は次のとおりです。

- 機能を推測したり人に質問したりする前に、現在のプロジェクトと利用できる機能を検査します。リポジトリで分かることはエージェントが確認してください。
- 利用できる場合は `swallowkit_*` MCP ツールを優先し、使えない場合は `{{runCmd}} swallowkit machine ...` を使用します。
- 構成に関わるファイルを編集する前に、責任範囲と編集規則を検査します。SwallowKit 管理の生成物を手編集してはいけません。
- 認証スキームは plan/apply auth で追加します。`swallowkit.config` の `auth.schemes` を手書きしてはいけません。`auth.authorization.policies` と `swa.allowedProviders` は apply 後に追記します。
- 生成物の変更には plan/apply を使い、`requires-human` とリソース作成・更新時の承認手順に従います。
- 完了前に SwallowKit の検証を実行します。機械的な検証だけでは E2E の動作を確認したことにはなりません。
- 永続化、開発用シード、実動作の証拠、ローカルサービスとデータの保護は、ルートの `AGENTS.md` に従います。

作業ごとの Agent Skills は `.github/skills/`、同じ作業の手順書は `.swallowkit/workflows/` にあります。
共通のプロジェクト規約は、ルートの `AGENTS.md` です。

生成される .github/copilot-instructions.md ​

生成される英語の原文 ​

md
# Copilot Instructions

This is a **SwallowKit** project.

Read and follow the root `AGENTS.md` as the canonical project contract.

SwallowKit applies during discovery, requirements clarification, specification,
planning, ticket decomposition, implementation, verification, and review — not
only during code generation.

Key rules:

- Inspect current SwallowKit capabilities instead of assuming them.
- Answer repository- and SwallowKit-inspectable questions before asking the human.
- Prefer `swallowkit_*` MCP tools when available.
- Otherwise use `{{runCmd}} swallowkit machine ...`. Also use it when an MCP
  response's `metadata.swallowkitVersion` is older than the project's SwallowKit
  or `metadata.warnings` contains `mcp-older-than-project`.
- Inspect responsibility boundaries before editing framework-related files.
- Never hand-edit deterministic SwallowKit-managed artifacts.
- Add auth schemes only via plan/apply auth; never hand-write `auth.schemes`
  in swallowkit.config (policies and `swa.allowedProviders` are hand-edited
  after apply).
- Use plan/apply for deterministic generation.
- Respect `requires-human` states and other human approval gates.
- Normal `swallowkit provision` is a human-facing deployment command. Agents must
  use the machine/MCP approval flow, not normal CLI as an approval bypass.
- Provision timeouts/Ctrl+C do not prove Azure failed. Read `status`, `outcome`,
  and `nextActions`; inspect the original run with `machine inspect provision
  --plan <runId>`, then resume `machine apply provision --plan <runId> --approve`
  only after explicit human approval. Preserve execution checkpoints; never
  re-submit Bicep or use reconcile/cancel/delete to repair waiting or tag/ledger
  failures. Do not print deployment output secrets.
- Run SwallowKit verification before completion.
- Follow root `AGENTS.md` for persistence, development seeds, runtime evidence,
  and local service/data safety; mechanical verification alone is not E2E proof.
- Default verification includes `backend-build` for standalone Functions.
  Skipped toolchains are not validation; Python compilation checks syntax only.
- Configure auth via plan/apply auth before adding `authPolicy`; otherwise
  scaffold blocks before file writes. Scaffold appends missing shared model exports.

Task-specific SwallowKit Agent Skills live under `.github/skills/`.
Agent-agnostic equivalents live under `.swallowkit/workflows/`.

日本語対訳 ​

md
# Copilot Instructions

これは SwallowKit プロジェクトです。調査、要件整理、仕様作成、計画、チケット分割、実装、検証、レビューの前に、ルートの `AGENTS.md` を読んで従ってください。
コード生成を始める前から、SwallowKit の構成と編集規則を考慮します。

常に適用する規則は次のとおりです。

- 機能を推測したり人に質問したりする前に、現在のプロジェクトと利用できる機能を検査します。リポジトリで分かることはエージェントが確認してください。
- 利用できる場合は `swallowkit_*` MCP ツールを優先し、使えない場合は `{{runCmd}} swallowkit machine ...` を使用します。
- 構成に関わるファイルを編集する前に、責任範囲と編集規則を検査します。SwallowKit 管理の生成物を手編集してはいけません。
- 認証スキームは plan/apply auth で追加します。`swallowkit.config` の `auth.schemes` を手書きしてはいけません。`auth.authorization.policies` と `swa.allowedProviders` は apply 後に追記します。
- 生成物の変更には plan/apply を使い、`requires-human` とリソース作成・更新時の承認手順に従います。
- 完了前に SwallowKit の検証を実行します。機械的な検証だけでは E2E の動作を確認したことにはなりません。
- 永続化、開発用シード、実動作の証拠、ローカルサービスとデータの保護は、ルートの `AGENTS.md` に従います。

作業ごとの Agent Skills は `.github/skills/`、同じ作業の手順書は `.swallowkit/workflows/` にあります。
共通のプロジェクト規約は、ルートの `AGENTS.md` です。

Released under the MIT License.