Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Teaches TypeScript service layer patterns: Result types, typed domain errors, and testable business logic without exceptions.
68% 95%+27 ptsof test cases passed
Passed 21 of 22 test cases with the skill, and 15 of 22 without it.
This test ran on v1. v2 is the current version and hasn’t been tested on gemini-3.6-flash yet.
3 of 3 safety checks passed
Not used yet
Production-ready patterns for type-safe error handling and domain service architecture. Framework-agnostic — usable in Next.js, Node.js, and any project that supports TypeScript.
Return the success or error state explicitly instead of throwing exceptions.
type Result<T, E = Error> = { ok: true; value: T } | { ok: false; error: E }
const Ok = <T>(value: T): Result<T, never> => ({ ok: true, value })
const Err = <E>(error: E): Result<never, E> => ({ ok: false, error })
// ❌ Exception-based — the error state is not visible in the type system
async function fetchUser(id: string): Promise<User> {
const user = await db.findById(id)
if (!user) throw new Error('Not found') // The caller does not know this
return user
}
// ✅ Result-based — the error state is visible in the signature
async function fetchUser(id: string): Promise<Result<User, 'NOT_FOUND' | 'DB_ERROR'>> {
try {
const user = await db.findById(id)
if (!user) return Err('NOT_FOUND')
return Ok(user)
} catch {
return Err('DB_ERROR')
}
}
// The caller must handle both states
const result = await fetchUser('123')
Next to this one in the catalogue, plus more from the same author.