xiaohongshu
xiaohongshu
fsd-es-lite
FSD + ES-lite アーキテクチャに基づく機能開発スキル。新しいfeature/entity/widgetを追加する時、CQRS + Event Sourcingパターンで実装する時、scaffoldスクリプトを使う時に使用。AI-nativeアプリケーション開発向け。
Full skill instructions
Feature-Sliced Design (FSD) と Event Sourcing Lite (ES-lite) を組み合わせた開発プロセス。 PoC・小規模開発向けに最適化された軽量アーキテクチャ。
クラスを使わず、関数とvelonaのDIで実装する。
理由:
// ✅ 関数ベース + velona DI
import { depend } from "velona";
export const executeCommand = depend(
{ eventStore, projector, clock: () => new Date().toISOString(), idGen: () => crypto.randomUUID() },
async (deps, command: Command, correlationId: string) => {
// 実装
}
);
// テスト時
executeCommand.inject({ eventStore: mockStore })(command, correlationId);
// ❌ クラスベース(使わない)
class CommandHandler {
constructor(private eventStore: IEventStore) {}
async execute(command: Command) { /* ... */ }
}
全featureでEvent Sourcing Lite(軽量版ES)に統一。
特徴:
src/
shared/ # 共有インフラ・ユーティリティ
entities/ # ドメインモデル・スキーマ・表示UI(オプション)
features/ # ユースケース・API・状態管理
widgets/ # 複合UIブロック
pages/ # ルートコンポーネント
app/ # アプリ初期化
// decide: 状態 + コマンド → イベント(純粋関数)
function decide(
state: Aggregate | null,
command: Command,
meta: EventMeta
): Result<Event[], DecisionError>
// apply: 状態 + イベント → 新状態(純粋関数)
function apply(
state: Aggregate | null,
event: Event
): Aggregate
新しい機能を追加する際は、scaffoldスクリプトを使用して最小限のボイラープレートを生成する。 生成後、ドメインに合わせてカスタマイズする。
npx tsx .claude/skills/fsd-es-lite/scripts/scaffold-feature.ts <feature-name>
生成されるファイル(最小構成):
entities/<name>/model/schema.ts - Zodドメインスキーマentities/<name>/model/events.ts - イベント型定義features/<name>/model/decide.ts - 決定ロジックfeatures/<name>/model/apply.ts - 適用ロジックfeatures/<name>/model/commands.ts - コマンド実行features/<name>/model/queries.ts - クエリfeatures/<name>/model/projector.ts - Projection更新features/<name>/api/routes.ts - Hono APIルートfeatures/<name>/api/contracts.ts - RPC型定義features/<name>/api/schemas.ts - バリデーションスキーマUIやhooksは必要に応じて追加する(scaffoldでは生成しない)
npx tsx .claude/skills/fsd-es-lite/scripts/scaffold-entity.ts <entity-name>
生成されるファイル:
entities/<name>/model/schema.ts - Zodドメインスキーマentities/<name>/model/events.ts - イベント型定義entities/<name>/model/index.ts - エクスポートentities/<name>/ui/<Name>.tsx - UIコンポーネント(実装必須)entities/<name>/ui/index.ts - UIエクスポート生成後、TODOコメントを参照してドメインに合わせて実装する
npx tsx .claude/skills/fsd-es-lite/scripts/scaffold-widget.ts <widget-name>
生成されるファイル:
widgets/<name>/ui/<Name>.tsx - メインコンポーネント(実装必須)widgets/<name>/ui/index.ts - UIエクスポートwidgets/<name>/model/index.ts - モデルエクスポートwidgets/<name>/index.ts - パブリックAPI生成後、TODOコメントを参照してentities/featuresを組み合わせて実装する
scaffoldで雛形生成
npx tsx .claude/skills/fsd-es-lite/scripts/scaffold-feature.ts order
ドメインスキーマ定義 (entities/order/model/schema.ts)
イベント定義 (entities/order/model/events.ts)
decide/apply実装 (features/order/model/)
decide.ts: ビジネスルールを純粋関数で実装apply.ts: イベント適用を純粋関数で実装commands.ts実装
APIルート定義 (features/order/api/routes.ts)
必要に応じてUI/hooksを追加
features/order/hooks/ - TanStack Query hooksfeatures/order/ui/ - UIコンポーネントentities/order/ui/ - 表示専用コンポーネント詳細な実装パターンは以下を参照:
| 種類 | エラー例 | 対応 |
|---|---|---|
| Result型 | バリデーションエラー、バージョン競合 | 復帰可能 |
| 例外 | DBアクセスエラー | 復帰不能 |
// コマンドにexpectedVersionを含める
type UpdateCommand = {
type: "Update";
aggregateId: string;
expectedVersion: number;
// ...
};
// appendでバージョンチェック
await eventStore.append(aggregateId, events, expectedVersion);
// → ConflictErrorならリトライを促す
全ての日時はISO 8601文字列(string)で統一。
// ✅ ISO 8601文字列
createdAt: z.string().datetime()
// ❌ Dateオブジェクト(使わない)
createdAt: z.date()
イベントは保存済みなので、投影失敗はログのみ。後からリプレイで再構築可能。
try {
await deps.projector.save(next);
} catch (error) {
console.warn("Projection save failed:", error);
}
CommandLogでAI操作を追跡:
interface CommandLog {
actor: { type: 'user' | 'ai' | 'system'; id?: string };
aiInfo?: {
modelId: string;
runId: string;
promptHash?: string;
};
// ...
}
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience