Tired of AI giving you buggy code snippets? These structured prompts extract perfect, tested code from ChatGPT and Copilot.
The Structure for Perfect Code Generation:
ROLE: Senior [Language] Developer with 10 years experience TASK: Create [specific feature] CONSTRAINTS: [technical limitations] REQUIREMENTS: [must-have features] OUTPUT FORMAT: [code structure] TEST: [validation criteria] Example: ROLE: Senior C#/.NET Developer with 10 years experience TASK: Create a repository pattern implementation with Entity Framework Core CONSTRAINTS: .NET 8, SQL Server, async/await, no stored procedures REQUIREMENTS: Generic repository, specific repositories, unit of work, DI ready OUTPUT FORMAT: Complete classes with XML documentation TEST: Include unit tests using xUnit and Moq
Prompt 1: Complete CRUD API Endpoint
Create a complete ASP.NET Core Web API endpoint for managing products in an e-commerce system.
Requirements:
1. Use .NET 8 minimal APIs
2. Entity Framework Core with SQL Server
3. Repository pattern with generic repository
4. DTOs for request/response (separate from entities)
5. AutoMapper for entity-DTO mapping
6. FluentValidation for request validation
7. Global error handling middleware
8. Swagger/OpenAPI documentation with examples
9. Response caching for GET endpoints
10. Rate limiting on POST/PUT/DELETE
Include:
- Product entity with: Id, Name, Description, Price, StockQuantity, CategoryId, CreatedDate
- ProductDto for requests/responses
- ProductRepository with all CRUD operations
- ProductsController with endpoints:
GET /api/products (with pagination, sorting, filtering)
GET /api/products/{id}
POST /api/products
PUT /api/products/{id}
DELETE /api/products/{id}
- Unit tests using xUnit (test repository and controller)
- Integration tests using TestServer
Add XML comments for Swagger with examples.
Include proper HTTP status codes (200, 201, 400, 404, 500).
Add request/response examples in Swagger.
Write complete, production-ready code that I can copy-paste into my project.
Prompt 2: React Component with TypeScript & Tests
Create a complete React TypeScript component for a data table with advanced features. Requirements: 1. React 18 with TypeScript strict mode 2. Material-UI v5 components 3. React Query for data fetching 4. React Hook Form for inline editing 5. Virtual scrolling for performance (1000+ rows) 6. Column sorting (multi-column) 7. Global filtering and column filtering 8. Row selection with checkboxes 9. Inline row editing with validation 10. Export to CSV/Excel functionality 11. Pagination (client-side and server-side options) 12. Responsive design (mobile-friendly) Features: - Lazy loading with infinite scroll option - Column resizing and reordering - Row grouping and aggregation - Custom cell renderers - Theme support (light/dark mode) - Accessibility (ARIA labels, keyboard navigation) - Localization support - Undo/redo for edits - Bulk operations Include: 1. DataTable component with all props typed 2. Custom hooks for data management 3. Context for table state 4. Utility functions for filtering/sorting 5. Complete TypeScript interfaces 6. Unit tests with Jest and React Testing Library 7. Storybook stories for documentation 8. Performance optimizations (React.memo, useCallback) 9. Error boundary for the component 10. Loading and empty states Write production-ready code with proper error handling, loading states, and comprehensive documentation. Include examples of how to use the component with mock data.
Prompt 3: Database Migration & Seeding
Create a complete database setup for a SaaS application using Entity Framework Core migrations. Requirements: 1. .NET 8 with EF Core 8 2. SQL Server database 3. Multi-tenant architecture (database per tenant) 4. Audit logging (who changed what and when) 5. Soft delete implementation 6. Row-level security for multi-tenancy 7. Database indexes for performance 8. Seed data for development 9. Migration scripts for production deployment Entities needed: 1. Tenant (Id, Name, ConnectionString, IsActive, Created) 2. User (Id, TenantId, Email, HashedPassword, Roles, LastLogin) 3. Product (Id, TenantId, Name, Description, Price, Category) 4. Order (Id, TenantId, UserId, TotalAmount, Status, CreatedDate) 5. OrderItem (Id, OrderId, ProductId, Quantity, Price) 6. AuditLog (Id, TenantId, UserId, Action, TableName, RecordId, OldValues, NewValues, Timestamp) Requirements for each entity: - Base entity with common fields (Id, CreatedDate, ModifiedDate, CreatedBy, ModifiedBy) - Soft delete with IsDeleted and DeletedDate - Tenant isolation (TenantId foreign key) - Proper indexes on foreign keys and frequently queried columns - Composite unique constraints where needed - Entity configurations in separate configuration classes - Value objects for complex types (Money, Address, etc.) Create: 1. Complete entity classes with relationships 2. DbContext with multi-tenant support 3. Entity configurations for each entity 4. Initial migration with seed data 5. Migration for adding new features 6. Script to apply migrations in production 7. Seed data for development (100 products, 50 users, 200 orders) 8. Repository pattern implementation 9. Unit tests for repositories 10. Performance considerations for large datasets Include: - Connection resiliency with retry logic - Database health checks - Migration rollback procedures - Data encryption for sensitive fields - Change tracking for auditing - Database views for complex queries - Stored procedures for batch operations Write complete, production-ready code that follows best practices for security, performance, and maintainability.
Prompt 4: DevOps Pipeline Configuration
Create a complete Azure DevOps pipeline for a .NET microservices application. Requirements: 1. 5 microservices (API Gateway, User Service, Product Service, Order Service, Payment Service) 2. Each service: ASP.NET Core 8, Docker, SQL Server, Redis cache 3. Infrastructure: Kubernetes (AKS), Azure SQL, Azure Redis, Application Insights 4. Pipeline stages: Build, Test, Scan, Package, Deploy, Monitor Pipeline should include: 1. Multi-stage YAML pipeline 2. Parallel builds for each microservice 3. Unit tests, integration tests, load tests 4. Security scanning (SAST, SCA, container scanning) 5. Code quality gates (SonarQube analysis) 6. Docker image building and pushing to ACR 7. Kubernetes manifest generation with Helm 8. Blue-green deployment to AKS 9. Database migrations as part of deployment 10. Smoke tests post-deployment 11. Rollback procedures 12. Monitoring and alerting setup Add: - Environment-specific configurations (dev, staging, prod) - Feature flag deployment - Canary releases configuration - Automated rollback on failure - Cost optimization (auto-scaling, resource limits) - Backup procedures for databases - Disaster recovery steps - Compliance checks (GDPR, HIPAA if applicable) Create complete YAML files for: 1. azure-pipelines.yml (main pipeline) 2. Dockerfile for each microservice 3. Helm charts for each service 4. Kubernetes manifests for all environments 5. Database migration scripts 6. Infrastructure as Code (Terraform/Bicep) 7. Monitoring dashboards (Grafana/Application Insights) 8. Alert rules for critical metrics Include best practices for: - Secret management (Azure Key Vault) - Network security (NSG, private endpoints) - Performance optimization (caching, CDN) - High availability (multiple regions) - Cost management (budget alerts, resource tagging) Write production-ready configurations that follow Azure Well-Architected Framework principles.
