本文へ移動
cccskills
無料GitHub で公開

backend-implement

Use when it is time to make the backend follow the Lean model — regenerate Kotlin from Lean, implement the generated interfaces (UseCase, QueryService, Repository, Entity), wire every generated contract test, make the build green, then run the design and SQL reviews. Backend comes after the human confirmed the screens.

インストール方法を見る

含まれるファイル(2)

  • SKILL.md4.6 KB
  • references/gradle-wiring.md10.0 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

バックエンド追随

順序の確認から始める: cradle status で「人間による画面確認」が済んでいるか。済んでいなければ着手しない(バックエンドは画面確認の後)。

手順

  1. 初回だけ: 先に cradle doctor で lean2kotlin が ok であること(apm が apm_modules/ に配る。別のチェックアウトは LEAN2KOTLIN_HOME)。cradle-init スキルの scripts/init.mjs --project <Root> --backend <package> で ktlint 独自ルール・.editorconfig・gradle.properties を敷き、references/gradle-wiring.md の断片で lean2kotlin・OpenAPI・jOOQ・ktlint を配線する。
  2. 影響範囲: cradle regen-impact。変わった生成シンボル・参照する手書き実装・未配線の契約テスト・golden 回帰を読む。想定外の広がりは設計の見直しのサイン(ユーザーに示す)。
  3. コンパイルエラーが TODO リスト: ./gradlew compileKotlin compileTestKotlin。消えた interface・変わった署名を追随する。
  4. 実装(規約は backend-kotlin / backend-design):
    • UseCase: 固定形(validate が解決、execute が validate を呼んで作用、境界は execute)。内部入力(Observation)の UseCase も同じ固定形で、名義を受けない。Port を使う配送は送る印を保存してから Port を呼ぶ(backend-kotlin 規則)。
    • QueryService: jOOQ 直叩き、並び・絞り込みは DB。共有ヘルパを作らない。
    • Repository: 契約の写し。横断不変条件の直列化点(一意制約 / FOR UPDATE / version)を DB に置く。
    • Entity / VO: 生成 interface の実装。不変で新インスタンスを返す。
    • Port(application/port/<port>/ の生成 interface): Adapter を infrastructure/<port>/ に手書きし、DI で UseCase に渡す。UseCase 実装は validate → 要求の決定 → Port の呼び出し → 観測の反映の順(Lean の request / apply と同じ分岐を再実装しない)。Adapter の検査の扱いは backend-kotlin 規則。
    • 性能バイパスは宣言(UseCase のディレクトリ)と実装(infrastructure)を分け、観測同値を KDoc に。
  5. 契約テストの配線: 生成された抽象契約テストすべてに具象サブクラス(本番実装を実 DB に配線。Repository の fake 禁止。Port は渡される生成モックをそのまま配線する。骨格は cradle contract-skeleton <生成ファイル>)。cradle status の「契約テスト 配線 n/m」が m/m になるまで。 生成が error で止まったら(宣言した契約が検査に至らない・Port の対応が取れない・出力先の衝突)、note の分類どおりモデルか fixture に戻す(分類と戻り先は references/gradle-wiring.md)。note は生成が続いた情報で、失敗として読むものと設計どおりの除外を分けて読む。 生成された PBT が実スキーマで通らない(生成値が大域不変条件を満たさない)ときは、@Disabled や InMemory で通さない。まずその不変条件が <Root>RepositoryState の Prop フィールドとして宣言されているかを見る(lean-conventions §4 / §9 — 読める形の宣言なら fixture がそれを満たす)。それでも通らなければ三択(モデルの型を見直す / 永続化の表現を変える / 配線を見送る)を ai-note に書いてユーザーに委ねる。
  6. 境界と門のテスト: HTTP レベルで 401 / 403 / 404 / 422 の経路、トランザクションの巻き戻し(割った境界は両方向)。
  7. ./gradlew build(ktlint 込み)。通ったら hook の指示どおり sql-perf-review と backend-design-review。High / Medium は直す。
  8. cradle unslop --diff。ai-notes に残す判断(設計判断・性能以外の選択)があれば書き置く。

決めごと

  • モデルが定めた判断(並び順・可否・遷移)を Kotlin で再導出しない。足りなければ Lean の View / validate に足して再生成する。
  • 生成された Resolved 型を崩さない(validate の戻り型を勝手に変えない)。
  • 泉(IdGenerator)の消費順はモデルの契約。先行消費しない。

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Use when adding or changing REST endpoints or the OpenAPI contract — deriving endpoints from the Lean commands and views, writing documents/codebase/openapi.yaml first, then regenerating the backend controller interfaces and the frontend client.

日本語の概要は準備中です。原文の説明を表示しています。

asuka1975/cradle42026年10月1日 更新

Use after a backend build succeeds or whenever authentication, authorization, actor/identity handling, external service calls (IdP, JWKS, DB, clock), logging, observability, configuration or error contracts are in play — delegates to the backend-design-reviewer agent for a design-quality review of the current branch.

日本語の概要は準備中です。原文の説明を表示しています。

asuka1975/cradle42026年10月1日 更新

cradle

無料

Use when you need the current position in the Lean spec-driven pipeline, or any deterministic check of a Cradle project — status, golden regression, Lean layer walls, regeneration impact, unslop lint, ddd cleanup. Runs the scripts under scripts/ and reports their output verbatim.

日本語の概要は準備中です。原文の説明を表示しています。

asuka1975/cradle42026年10月1日 更新

Use to start a new product on Cradle or to add the Cradle skeleton to an existing repository — writes cradle.json, the project-facts instruction (.apm/instructions/project.instructions.md), documents/{ddd,ai-notes,infra-design,codebase} templates, CI, and a compiling Lean executable-spec scaffold with a minimal example domain, mockup and CLI.

日本語の概要は準備中です。原文の説明を表示しています。

asuka1975/cradle42026年10月1日 更新

Use when the product owner asks where the project stands, what to do next, or which phase of the Lean spec-driven pipeline is current — runs cradle status and proposes exactly one next step.

日本語の概要は準備中です。原文の説明を表示しています。

asuka1975/cradle42026年10月1日 更新

ddd

無料

Use to run or continue domain exploration with the product owner as domain expert — event storming interviews, hotspots (HS), ubiquitous language, UX review of the domain, checking or resolving open MQ/UX items, or a status summary of documents/ddd. Also use when the user starts explaining their business, purpose or workflow. Never edit documents/ddd directly; go through this skill.

日本語の概要は準備中です。原文の説明を表示しています。

asuka1975/cradle42026年10月1日 更新

asuka1975 のスキルをすべて見る

このスキルの問題を報告する