Complete workflow examples demonstrating AI-assisted code generation following Google GenAI best practices and established patterns. User requests implementation of a UserService class with CRUD operations, following existing repository patterns in the codebase. Create a UserService class that handles user management operations including create, read, update, and delete functionality with proper error handling. Search for existing service patterns src (Service|Repository).*\.(ts|js) *.ts ]]> Identify existing service and repository patterns Examine existing service implementations src/services/BaseService.ts src/repositories/UserRepository.ts src/types/User.ts src/utils/validation.ts ]]> - Understand existing error handling patterns - Identify validation approaches - Note testing conventions - Understand type definitions Create UserService implementation following established patterns src/services/UserService.ts /** * UserService handles user management operations * Following established patterns with proper error handling */ import { User, CreateUserRequest } from '../types/User'; import { UserRepository } from '../repositories/UserRepository'; type Result = | { success: true; data: T } | { success: false; error: E }; export class UserService { constructor(private userRepository: UserRepository) {} async createUser(request: CreateUserRequest): Promise> { try { // Validate input if (!request.email || !request.name) { return { success: false, error: 'Email and name are required' }; } // Check if user exists const existing = await this.userRepository.findByEmail(request.email); if (existing) { return { success: false, error: 'User already exists' }; } // Create user const user = await this.userRepository.create(request); return { success: true, data: user }; } catch (error) { return { success: false, error: `Failed to create user: ${error.message}` }; } } }