Enforces full DDD conventions for TypeScript/Next.js: folder structure, layer boundaries, functional patterns, and ubiquitous language.
80
100%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Established once per project in shared/domain/. Copy verbatim; these files rarely change.
Result.tsexport type Result<T, E = string> = { ok: true; value: T } | { ok: false; error: E };
export const ok = <T>(value: T): Result<T, never> => ({ ok: true, value });
export const err = <E>(error: E): Result<never, E> => ({ ok: false, error });
export const map = <T, U, E>(r: Result<T, E>, fn: (v: T) => U): Result<U, E> =>
r.ok ? ok(fn(r.value)) : r;
export const flatMap = <T, U, E>(r: Result<T, E>, fn: (v: T) => Result<U, E>): Result<U, E> =>
r.ok ? fn(r.value) : r;identity.tsexport type Brand<T, B extends string> = T & { readonly _brand: B };
export type Id<B extends string> = Brand<string, B>;
export const createId = <B extends string>(brand: B) => (): Id<B> => crypto.randomUUID() as Id<B>;
export const castId = <B extends string>(brand: B) => (raw: string): Id<B> => raw as Id<B>;DomainEvent.tsexport type DomainEvent<T extends string, P extends Record<string, unknown>> = {
readonly eventType: T; readonly eventId: string;
readonly occurredAt: Date; readonly payload: P;
};
export const createEvent = <T extends string, P extends Record<string, unknown>>(
eventType: T, payload: P,
): DomainEvent<T, P> => ({ eventType, eventId: crypto.randomUUID(), occurredAt: new Date(), payload });skills
ddd-functional-nextjs