원클릭으로
backend-patterns
Backend architecture patterns for services, APIs, data access, and middleware design.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Backend architecture patterns for services, APIs, data access, and middleware design.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Optimize token usage and context window discipline. Reduce costs and improve response quality through smart context management.
Unified context lifecycle for FlowDeck sessions — ingest, filter, prune, protect, summarize, and persist with telemetry.
Predict affected files, modules, APIs, tests, and DB paths before changes. Returns an impact map for human review.
Map architecture, conventions, and file structure into `.codebase/`. Use when onboarding or before deep feature work.
Plan differently when the agent has low certainty — ask for clarification or narrow scope instead of pretending full understanding.
Protect critical context from pruning during compaction. Preserve active plans, safety files, pending operations, and user intent anchors.
| name | backend-patterns |
| description | Backend architecture patterns for services, APIs, data access, and middleware design. |
| origin | FlowDeck |
When implementing backend services, APIs, or server-side logic. Use when designing service layers, data access patterns, or middleware.
// Service Layer with Repository Pattern
interface UserRepository {
findById(id: string): Promise<User | null>;
findAll(filter?: UserFilter): Promise<User[]>;
create(attributes: CreateUserDTO): Promise<User>;
update(id: string, attributes: UpdateUserDTO): Promise<User>;
delete(id: string): Promise<void>;
}
class UserService {
constructor(private readonly userRepository: UserRepository) {}
async getUser(id: string): Promise<User> {
const user = await this.userRepository.findById(id);
if (!user) {
throw new NotFoundError(`User with id ${id} not found`);
}
return user;
}
async createUser(dto: CreateUserDTO): Promise<User> {
const existing = await this.userRepository.findByEmail(dto.email);
if (existing) {
throw new ConflictError('User with this email already exists');
}
return this.userRepository.create(dto);
}
}
// Dependency Injection Container
const container = new Container();
container.register('userRepository', () => new PostgresUserRepository());
container.register('userService', () => new UserService(container.resolve('userRepository')));
// Error Handling with Custom Exceptions
class AppError extends Error {
constructor(
message: string,
public readonly code: string,
public readonly statusCode: number = 500
) {
super(message);
this.name = 'AppError';
}
}
class NotFoundError extends AppError {
constructor(message: string) {
super(message, 'NOT_FOUND', 404);
}
}
class ValidationError extends AppError {
constructor(
message: string,
public readonly details?: Record<string, string[]>
) {
super(message, 'VALIDATION_ERROR', 422);
}
}
// Global Error Handler Middleware
function errorHandler(err: Error, req: Request, res: Response, next: NextFunction) {
if (err instanceof AppError) {
return res.status(err.statusCode).json({
error: {
code: err.code,
message: err.message,
details: err instanceof ValidationError ? err.details : undefined,
},
});
}
console.error('Unhandled error:', err);
return res.status(500).json({
error: {
code: 'INTERNAL_ERROR',
message: 'An unexpected error occurred',
},
});
}