majiayu000/spellbook / skills/typescript-project
typescript-project
FlaggedModern TypeScript project architecture guide for 2025. Use when creating new TS projects, setting up configurations, or designing project structure. Covers tech stack selection, layered architecture, and best practices.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 12.9 KB |
| reference/architecture.md | markdown | 8.4 KB |
| reference/patterns.md | markdown | 12.0 KB |
| reference/tech-stack.md | markdown | 9.4 KB |
| templates/project/biome.json | config | 566 B |
| templates/project/package.json | manifest | 735 B |
| templates/project/src/adapters/in-memory.repository.ts | script | 909 B |
| templates/project/src/adapters/llm.adapter.ts | script | 2.6 KB |
| templates/project/src/index.ts | script | 595 B |
| templates/project/src/lib/config.ts | script | 1.5 KB |
| templates/project/src/lib/errors.ts | script | 1.5 KB |
| templates/project/src/lib/index.ts | script | 148 B |
| templates/project/src/lib/logger.ts | script | 2.2 KB |
| templates/project/src/lib/types.ts | script | 947 B |
| templates/project/src/services/example.service.ts | script | 2.3 KB |
| templates/project/tests/example.service.test.ts | script | 3.5 KB |
| templates/project/tsconfig.json | config | 584 B |
templates/project/src/services/example.service.ts
View on GitHub/**
* Example service template
*
* Services contain business logic and orchestrate operations.
* They depend on repository/adapter interfaces, not implementations.
*/
import { z } from 'zod';
import { AppError, createLogger, type Result } from '../lib/index.js';
const log = createLogger('example-service');
// Input validation schemas
export const CreateExampleSchema = z.object({
name: z.string().min(1).max(100),
description: z.string().optional(),
});
export type CreateExampleInput = z.infer<typeof CreateExampleSchema>;
// Domain entity
export interface Example {
id: string;
name: string;
description?: string;
createdAt: Date;
}
// Repository interface (implemented by adapters)
export interface ExampleRepository {
findById(id: string): Promise<Example | null>;
findAll(): Promise<Example[]>;
save(example: Example): Promise<Example>;
delete(id: string): Promise<void>;
}
// Service implementation
export class ExampleService {
constructor(private readonly repo: ExampleRepository) {}
async create(input: CreateExampleInput): Promise<Result<Example, AppError>> {
try {
const validated = CreateExampleSchema.parse(input);
const example: Example = {
id: crypto.randomUUID(),
name: validated.name,
description: validated.description,
createdAt: new Date(),
};
const saved = await this.repo.save(example);
log.info('Example created', { id: saved.id });
return { ok: true, value: saved };
} catch (error) {
if (error instanceof z.ZodError) {
return {
ok: false,
error: AppError.validation('Invalid input', { issues: error.issues }),
};
}
throw error;
}
}
async findById(id: string): Promise<Result<Example, AppError>> {
const example = await this.repo.findById(id);
if (!example) {
return { ok: false, error: AppError.notFound('Example', id) };
}
return { ok: true, value: example };
}
async findAll(): Promise<Example[]> {
return this.repo.findAll();
}
async delete(id: string): Promise<Result<void, AppError>> {
const existing = await this.repo.findById(id);
if (!existing) {
return { ok: false, error: AppError.notFound('Example', id) };
}
await this.repo.delete(id);
log.info('Example deleted', { id });
return { ok: true, value: undefined };
}
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |