Code Examples
Enhance your development workflow with StickyPrompts’ powerful code-focused templates. These examples cover code generation, documentation, debugging, code reviews, and technical writing scenarios.
Code Generation Examples
Section titled “Code Generation Examples”Function Creation
Section titled “Function Creation”API Endpoint Function:
Create a function in {{PROGRAMMING_LANGUAGE}} that {{FUNCTION_PURPOSE}}.
Requirements:- Input: {{INPUT_PARAMETERS}}- Output: {{EXPECTED_OUTPUT}}- Edge cases to handle: {{EDGE_CASES}}- Performance considerations: {{PERFORMANCE_REQUIREMENTS}}
Additional guidelines:- Code style: {{CODING_STYLE}}- Include comments: {{COMMENT_LEVEL}}- Error handling: {{ERROR_HANDLING_APPROACH}}
Data Processing Function:
Write a function in {{PROGRAMMING_LANGUAGE}} that processes {{DATA_TYPE}} data.
Requirements:- Input: {{INPUT_FORMAT}}- Output: {{OUTPUT_FORMAT}}- Processing Logic: {{PROCESSING_REQUIREMENTS}}- Performance Target: {{PERFORMANCE_GOAL}}
Additional guidelines:- Data Transformation: - Source Structure: {{SOURCE_SCHEMA}} - Target Structure: {{TARGET_SCHEMA}} - Business Rules: {{TRANSFORMATION_RULES}} - Validation: {{DATA_VALIDATION}}- Technical Requirements: - Memory Efficiency: {{MEMORY_CONSTRAINTS}} - Error Handling: {{ERROR_SCENARIOS}} - Testing: Include unit tests - Documentation: Comprehensive docstrings
Edge Cases:- {{EDGE_CASE_1}}- {{EDGE_CASE_2}}- {{EDGE_CASE_3}}
Create production-ready code with proper error handling and performance optimization.
Class and Module Design
Section titled “Class and Module Design”Class Implementation:
Design a class in {{FRAMEWORK}} that {{CLASS_PURPOSE}}.
Requirements:- Class Name: {{CLASS_NAME}}- Inheritance: {{PARENT_CLASS}}- Design Pattern: {{DESIGN_PATTERN}}- Interfaces: {{INTERFACES}}
Properties:- {{PROPERTY_1}}: {{PROPERTY_TYPE}} - {{PROPERTY_DESCRIPTION}}- {{PROPERTY_2}}: {{PROPERTY_TYPE}} - {{PROPERTY_DESCRIPTION}}- {{PROPERTY_3}}: {{PROPERTY_TYPE}} - {{PROPERTY_DESCRIPTION}}
Methods:- {{METHOD_1}}({{PARAMETERS}}) -> {{RETURN_TYPE}}: {{METHOD_PURPOSE}}- {{METHOD_2}}({{PARAMETERS}}) -> {{RETURN_TYPE}}: {{METHOD_PURPOSE}}- {{METHOD_3}}({{PARAMETERS}}) -> {{RETURN_TYPE}}: {{METHOD_PURPOSE}}
Features:- Encapsulation: {{ENCAPSULATION_LEVEL}}- Validation: {{VALIDATION_REQUIREMENTS}}- Thread Safety: {{THREAD_SAFETY}}- Serialization: {{SERIALIZATION_NEEDS}}
Quality Requirements:- Follow {{CODING_STANDARDS}}- Include comprehensive docstrings- Add type hints where applicable- Implement proper error handling
Generate a well-structured, maintainable class implementation.
Code Documentation Examples
Section titled “Code Documentation Examples”API Documentation
Section titled “API Documentation”REST API Documentation:
Create comprehensive API documentation for {{API_NAME}}.
## API Overview:- Service: {{API_NAME}}- Version: {{API_VERSION}}- Base URL: {{BASE_URL}}- Authentication: {{AUTH_METHOD}}
## Endpoint Documentation:
### {{ENDPOINT_NAME}}**{{HTTP_METHOD}} {{ENDPOINT_PATH}}**
**Purpose:** {{ENDPOINT_PURPOSE}}
**Parameters:**- Path: {{PATH_PARAMETERS}}- Query: {{QUERY_PARAMETERS}}- Headers: {{REQUIRED_HEADERS}}- Body: {{REQUEST_BODY_SCHEMA}}
**Request Example:**```{{REQUEST_FORMAT}}{{REQUEST_EXAMPLE}}
Response Examples:
Success (200):
{{SUCCESS_RESPONSE_EXAMPLE}}
Error (400):
{{ERROR_RESPONSE_EXAMPLE}}
Error Codes:
- {{ERROR_CODE_1}}: {{ERROR_DESCRIPTION_1}}
- {{ERROR_CODE_2}}: {{ERROR_DESCRIPTION_2}}
Rate Limiting: {{RATE_LIMIT_INFO}} SDK Examples: Include code examples in {{SUPPORTED_LANGUAGES}}
Create clear, comprehensive documentation that enables easy API integration.
### Code Comments and Docstrings
**Function Documentation:**
Write comprehensive documentation for this {{PROGRAMMING_LANGUAGE}} function:
{{FUNCTION_CODE}}
Documentation Requirements:
Section titled “Documentation Requirements:”- Function purpose and behavior
- Parameter descriptions with types
- Return value specification
- Usage examples
- Error conditions
- Performance considerations
- Related functions or dependencies
Documentation Style:
Section titled “Documentation Style:”- Format: {{DOCUMENTATION_FORMAT}}
- Audience: {{TARGET_AUDIENCE}}
- Detail Level: {{DETAIL_LEVEL}}
- Include Examples: {{INCLUDE_EXAMPLES}}
Additional Context:
Section titled “Additional Context:”- Module: {{MODULE_NAME}}
- Package: {{PACKAGE_NAME}}
- Version: {{VERSION}}
- Author: {{AUTHOR_INFO}}
Generate professional documentation that helps developers understand and use this function effectively.
## Code Review Examples
### Code Review Template
**Pull Request Review:**
Conduct a comprehensive code review for this {{PROGRAMMING_LANGUAGE}} pull request.
Pull Request Context:
Section titled “Pull Request Context:”- Title: {{PR_TITLE}}
- Author: {{AUTHOR_NAME}}
- Branch: {{BRANCH_NAME}}
- Changes: {{CHANGE_SUMMARY}}
- Purpose: {{PR_PURPOSE}}
Code to Review:
Section titled “Code to Review:”{{CODE_CHANGES}}
Review Checklist:
Section titled “Review Checklist:”Code Quality:
Section titled “Code Quality:”- Follows coding standards and conventions
- Proper naming conventions
- Appropriate code organization
- No code duplication
Functionality:
Section titled “Functionality:”- Logic is correct and efficient
- Edge cases are handled
- Error handling is comprehensive
- Input validation is present
Security:
Section titled “Security:”- No security vulnerabilities
- Input sanitization
- Authentication/authorization
- Data exposure risks
Performance:
Section titled “Performance:”- Efficient algorithms
- Proper resource management
- Database query optimization
- Memory usage considerations
Testing:
Section titled “Testing:”- Unit tests included
- Test coverage adequate
- Tests are meaningful
- Integration tests if needed
Documentation:
Section titled “Documentation:”- Code is well-commented
- API documentation updated
- README updated if needed
Review Focus Areas:
Section titled “Review Focus Areas:”- {{FOCUS_AREA_1}}
- {{FOCUS_AREA_2}}
- {{FOCUS_AREA_3}}
Provide constructive feedback with specific suggestions for improvement.
## Debugging Examples
### Bug Analysis
**Debug Investigation:**
Analyze and debug this {{PROGRAMMING_LANGUAGE}} issue:
Bug Report:
Section titled “Bug Report:”- Issue: {{BUG_DESCRIPTION}}
- Environment: {{ENVIRONMENT_INFO}}
- Steps to Reproduce: {{REPRODUCTION_STEPS}}
- Expected Behavior: {{EXPECTED_RESULT}}
- Actual Behavior: {{ACTUAL_RESULT}}
Code Affected:
Section titled “Code Affected:”{{PROBLEMATIC_CODE}}
Error Information:
Section titled “Error Information:”- Error Message: {{ERROR_MESSAGE}}
- Stack Trace: {{STACK_TRACE}}
- Log Output: {{LOG_OUTPUT}}
- Frequency: {{ERROR_FREQUENCY}}
System Context:
Section titled “System Context:”- Platform: {{PLATFORM}}
- Version: {{VERSION}}
- Dependencies: {{DEPENDENCIES}}
- Configuration: {{CONFIG_INFO}}
Analysis Framework:
Section titled “Analysis Framework:”- Root Cause Analysis: Identify the underlying issue
- Impact Assessment: Evaluate severity and scope
- Solution Options: Propose multiple fix approaches
- Risk Assessment: Consider side effects of each solution
- Testing Strategy: Plan verification approach
Additional Investigation:
Section titled “Additional Investigation:”- Related Issues: {{RELATED_ISSUES}}
- Recent Changes: {{RECENT_CHANGES}}
- Data Patterns: {{DATA_ANALYSIS}}
Provide a thorough analysis with actionable debugging steps and solution recommendations.
### Performance Optimization
**Performance Analysis:**
Optimize the following {{PROGRAMMING_LANGUAGE}} code for {{OPTIMIZATION_GOAL}}:
{{CODE_TO_OPTIMIZE}}
Optimization requirements:
- Target improvement: {{IMPROVEMENT_TARGET}}
- Constraints: {{OPTIMIZATION_CONSTRAINTS}}
- Must maintain: {{FUNCTIONAL_REQUIREMENTS}}
- Priority: {{OPTIMIZATION_PRIORITY}}
Please provide:
- Optimized code
- Explanation of changes
- Expected performance difference
## Testing Examples
### Unit Test Generation
**Test Suite Creation:**
Generate comprehensive unit tests for this {{PROGRAMMING_LANGUAGE}} code:
Code Under Test:
Section titled “Code Under Test:”{{TARGET_CODE}}
Testing Requirements:
Section titled “Testing Requirements:”- Testing Framework: {{TEST_FRAMEWORK}}
- Coverage Target: {{COVERAGE_PERCENTAGE}}%
- Test Types: {{TEST_TYPES}}
- Mock Requirements: {{MOCKING_NEEDS}}
Test Scenarios:
Section titled “Test Scenarios:”- Happy Path: {{HAPPY_PATH_SCENARIOS}}
- Edge Cases: {{EDGE_CASE_SCENARIOS}}
- Error Conditions: {{ERROR_SCENARIOS}}
- Boundary Conditions: {{BOUNDARY_TESTS}}
Test Data:
Section titled “Test Data:”- Valid Inputs: {{VALID_TEST_DATA}}
- Invalid Inputs: {{INVALID_TEST_DATA}}
- Mock Data: {{MOCK_DATA_REQUIREMENTS}}
- Test Fixtures: {{FIXTURE_REQUIREMENTS}}
Quality Criteria:
Section titled “Quality Criteria:”- Test Naming: Clear, descriptive test names
- Assertions: Specific, meaningful assertions
- Test Organization: Logical grouping and structure
- Documentation: Comments explaining complex test logic
Special Considerations:
Section titled “Special Considerations:”- Performance Tests: {{PERFORMANCE_TEST_NEEDS}}
- Integration Points: {{INTEGRATION_TEST_AREAS}}
- Dependencies: {{DEPENDENCY_MOCKING}}
- Setup/Teardown: {{SETUP_REQUIREMENTS}}
Create a complete test suite that ensures code reliability and maintainability.
### Integration Testing
**Integration Test Plan:**
Create integration tests for {{SYSTEM_COMPONENT}} integration with {{EXTERNAL_SYSTEM}}.
Integration Overview:
Section titled “Integration Overview:”- Primary System: {{PRIMARY_SYSTEM}}
- External System: {{EXTERNAL_SYSTEM}}
- Integration Type: {{INTEGRATION_TYPE}}
- Data Flow: {{DATA_FLOW_DESCRIPTION}}
Test Environment:
Section titled “Test Environment:”- Environment: {{TEST_ENVIRONMENT}}
- Test Data: {{TEST_DATA_SETUP}}
- Configuration: {{CONFIG_REQUIREMENTS}}
- Dependencies: {{DEPENDENCY_SETUP}}
Integration Points:
Section titled “Integration Points:”- {{INTEGRATION_POINT_1}}: {{DESCRIPTION_1}}
- {{INTEGRATION_POINT_2}}: {{DESCRIPTION_2}}
- {{INTEGRATION_POINT_3}}: {{DESCRIPTION_3}}
Test Scenarios:
Section titled “Test Scenarios:”- Successful Integration: {{SUCCESS_SCENARIOS}}
- Failure Handling: {{FAILURE_SCENARIOS}}
- Timeout Handling: {{TIMEOUT_SCENARIOS}}
- Data Validation: {{VALIDATION_SCENARIOS}}
Test Framework:
Section titled “Test Framework:”- Tools: {{TESTING_TOOLS}}
- Language: {{PROGRAMMING_LANGUAGE}}
- CI/CD Integration: {{CICD_REQUIREMENTS}}
Success Criteria:
Section titled “Success Criteria:”- Performance: {{PERFORMANCE_REQUIREMENTS}}
- Reliability: {{RELIABILITY_STANDARDS}}
- Data Integrity: {{DATA_INTEGRITY_CHECKS}}
Generate comprehensive integration tests that validate system interactions.
## Technical Writing Examples
### README Documentation
**Project README:**
Create a comprehensive README.md for the {{PROJECT_NAME}} project.
Project Information:
Section titled “Project Information:”- Name: {{PROJECT_NAME}}
- Type: {{PROJECT_TYPE}}
- Language: {{PROGRAMMING_LANGUAGE}}
- Framework: {{FRAMEWORK}}
- Purpose: {{PROJECT_PURPOSE}}
Documentation Sections:
Section titled “Documentation Sections:”Project Description
Section titled “Project Description”- What the project does
- Key features and benefits
- Target audience
- Use cases
Installation
Section titled “Installation”- Prerequisites: {{PREREQUISITES}}
- Installation steps for {{INSTALLATION_METHODS}}
- Environment setup
- Configuration requirements
- Quick start guide
- Basic usage examples
- Advanced usage scenarios
- Configuration options
API Reference
Section titled “API Reference”- Core functions/classes
- Parameters and return values
- Usage examples
- Error handling
Development
Section titled “Development”- Development setup
- Build process: {{BUILD_PROCESS}}
- Testing: {{TESTING_APPROACH}}
- Contributing guidelines
Additional Information
Section titled “Additional Information”- License: {{LICENSE_TYPE}}
- Support: {{SUPPORT_CHANNELS}}
- Changelog: {{CHANGELOG_LOCATION}}
- Roadmap: {{ROADMAP_INFO}}
Style Requirements:
Section titled “Style Requirements:”- Clear, concise language
- Code examples with syntax highlighting
- Screenshots/diagrams where helpful
- Proper markdown formatting
Create a professional README that enables quick project understanding and adoption.
### Technical Architecture Documentation
**Architecture Document:**
Document the technical architecture for {{SYSTEM_NAME}}.
System Overview:
Section titled “System Overview:”- System: {{SYSTEM_NAME}}
- Purpose: {{SYSTEM_PURPOSE}}
- Scale: {{SYSTEM_SCALE}}
- Users: {{USER_BASE}}
Architecture Components:
Section titled “Architecture Components:”High-Level Architecture
Section titled “High-Level Architecture”- Architecture Pattern: {{ARCHITECTURE_PATTERN}}
- Core Components: {{CORE_COMPONENTS}}
- Data Flow: {{DATA_FLOW}}
- Integration Points: {{INTEGRATION_POINTS}}
Technology Stack
Section titled “Technology Stack”- Frontend: {{FRONTEND_TECH}}
- Backend: {{BACKEND_TECH}}
- Database: {{DATABASE_TECH}}
- Infrastructure: {{INFRASTRUCTURE}}
- Third-party Services: {{THIRD_PARTY_SERVICES}}
System Components
Section titled “System Components”- {{COMPONENT_1}}: {{COMPONENT_1_DESCRIPTION}}
- {{COMPONENT_2}}: {{COMPONENT_2_DESCRIPTION}}
- {{COMPONENT_3}}: {{COMPONENT_3_DESCRIPTION}}
Data Architecture
Section titled “Data Architecture”- Data Models: {{DATA_MODELS}}
- Storage Strategy: {{STORAGE_STRATEGY}}
- Data Flow: {{DATA_FLOW_DETAILS}}
- Backup Strategy: {{BACKUP_STRATEGY}}
Security Architecture
Section titled “Security Architecture”- Authentication: {{AUTH_APPROACH}}
- Authorization: {{AUTHZ_APPROACH}}
- Data Protection: {{DATA_PROTECTION}}
- Network Security: {{NETWORK_SECURITY}}
Performance Considerations
Section titled “Performance Considerations”- Scalability: {{SCALABILITY_APPROACH}}
- Performance Targets: {{PERFORMANCE_TARGETS}}
- Monitoring: {{MONITORING_STRATEGY}}
- Caching: {{CACHING_STRATEGY}}
Documentation Requirements:
Section titled “Documentation Requirements:”- Technical detail level: {{DETAIL_LEVEL}}
- Audience: {{TARGET_AUDIENCE}}
- Diagrams: {{DIAGRAM_REQUIREMENTS}}
- Update frequency: {{UPDATE_SCHEDULE}}
Create comprehensive architecture documentation that guides development and operational decisions.
## DevOps and Deployment Examples
### CI/CD Pipeline
**Pipeline Configuration:**
Create a CI/CD pipeline configuration for {{PROJECT_NAME}} using {{CICD_PLATFORM}}.
Project Details:
Section titled “Project Details:”- Project: {{PROJECT_NAME}}
- Language: {{PROGRAMMING_LANGUAGE}}
- Framework: {{FRAMEWORK}}
- Target Environment: {{DEPLOYMENT_ENVIRONMENT}}
Pipeline Stages:
Section titled “Pipeline Stages:”Build Stage
Section titled “Build Stage”- Build Tool: {{BUILD_TOOL}}
- Dependencies: {{DEPENDENCY_MANAGEMENT}}
- Artifacts: {{BUILD_ARTIFACTS}}
- Build Triggers: {{BUILD_TRIGGERS}}
Test Stage
Section titled “Test Stage”- Unit Tests: {{UNIT_TEST_COMMAND}}
- Integration Tests: {{INTEGRATION_TEST_COMMAND}}
- Coverage Requirements: {{COVERAGE_THRESHOLD}}%
- Test Reports: {{TEST_REPORTING}}
Security Stage
Section titled “Security Stage”- Security Scanning: {{SECURITY_TOOLS}}
- Dependency Scanning: {{DEPENDENCY_SCANNING}}
- Code Quality: {{CODE_QUALITY_TOOLS}}
- Compliance Checks: {{COMPLIANCE_REQUIREMENTS}}
Deployment Stage
Section titled “Deployment Stage”- Deployment Strategy: {{DEPLOYMENT_STRATEGY}}
- Environment: {{TARGET_ENVIRONMENT}}
- Health Checks: {{HEALTH_CHECK_COMMANDS}}
- Rollback Strategy: {{ROLLBACK_APPROACH}}
Configuration Requirements:
Section titled “Configuration Requirements:”- Environment Variables: {{ENV_VARIABLES}}
- Secrets Management: {{SECRETS_MANAGEMENT}}
- Notification: {{NOTIFICATION_SETTINGS}}
- Monitoring: {{MONITORING_INTEGRATION}}
Quality Gates:
Section titled “Quality Gates:”- Build Success: Required
- Test Coverage: {{COVERAGE_THRESHOLD}}%
- Security Scan: No critical issues
- Code Quality: {{QUALITY_THRESHOLD}}
Generate a complete CI/CD pipeline that ensures quality and reliable deployments.
### Docker Configuration
**Containerization Setup:**
Create Docker configuration for {{APPLICATION_NAME}}.
Application Details:
Section titled “Application Details:”- Application: {{APPLICATION_NAME}}
- Language: {{PROGRAMMING_LANGUAGE}}
- Framework: {{FRAMEWORK}}
- Environment: {{RUNTIME_ENVIRONMENT}}
Docker Requirements:
Section titled “Docker Requirements:”- Base Image: {{BASE_IMAGE}}
- Application Port: {{APPLICATION_PORT}}
- Dependencies: {{DEPENDENCIES}}
- Build Process: {{BUILD_STEPS}}
Dockerfile Structure:
Section titled “Dockerfile Structure:”- Multi-stage build: {{MULTI_STAGE_BUILD}}
- Layer optimization: {{LAYER_OPTIMIZATION}}
- Security scanning: {{SECURITY_REQUIREMENTS}}
- Size optimization: {{SIZE_OPTIMIZATION}}
Configuration Files:
Section titled “Configuration Files:”- Environment variables: {{ENV_CONFIGURATION}}
- Volume mounts: {{VOLUME_REQUIREMENTS}}
- Network configuration: {{NETWORK_SETUP}}
- Health checks: {{HEALTH_CHECK_CONFIG}}
Development Environment:
Section titled “Development Environment:”- Docker Compose: {{COMPOSE_REQUIREMENTS}}
- Local development: {{DEV_SETUP}}
- Database services: {{DATABASE_SERVICES}}
- External dependencies: {{EXTERNAL_SERVICES}}
Production Considerations:
Section titled “Production Considerations:”- Resource limits: {{RESOURCE_LIMITS}}
- Logging: {{LOGGING_CONFIGURATION}}
- Monitoring: {{MONITORING_SETUP}}
- Scaling: {{SCALING_STRATEGY}}
Create optimized Docker configuration for development and production environments.
## Database Examples
### Database Schema Design
**Database Schema:**
Design a database schema for {{DATABASE_TYPE}} to store {{DATA_DESCRIPTION}}.
Requirements:
- Entity relationships: {{ENTITY_RELATIONSHIPS}}
- Primary keys: {{PRIMARY_KEY_STRATEGY}}
- Indexing strategy: {{INDEXING_APPROACH}}
- Data types: {{DATA_TYPES}}
Consider:
- Query patterns: {{COMMON_QUERIES}}
- Scalability needs: {{SCALABILITY_REQUIREMENTS}}
- Data integrity rules: {{INTEGRITY_CONSTRAINTS}}
- Performance optimization: {{PERFORMANCE_CONSIDERATIONS}}
Output format:
- {{SCHEMA_FORMAT}}
## Variable Definitions
Common coding variables used in these examples:
### Programming Context- `{{PROGRAMMING_LANGUAGE}}` - Target programming language- `{{FRAMEWORK}}` - Development framework- `{{PROJECT_NAME}}` - Project or application name- `{{PROJECT_TYPE}}` - Type of project (web app, API, library, etc.)
### Technical Specifications- `{{API_TYPE}}` - Type of API (REST, GraphQL, etc.)- `{{DATABASE_TYPE}}` - Database system- `{{DEPLOYMENT_ENVIRONMENT}}` - Target deployment platform- `{{PERFORMANCE_REQUIREMENTS}}` - Performance criteria
### Code Structure- `{{FUNCTION_NAME}}` - Name of function- `{{CLASS_NAME}}` - Name of class- `{{METHOD_NAME}}` - Name of method- `{{VARIABLE_NAME}}` - Name of variable
### Documentation Context- `{{DOCUMENTATION_FORMAT}}` - Documentation format (JSDoc, Sphinx, etc.)- `{{TARGET_AUDIENCE}}` - Intended audience for documentation- `{{DETAIL_LEVEL}}` - Level of technical detail required
### Testing Context- `{{TEST_FRAMEWORK}}` - Testing framework (Jest, pytest, etc.)- `{{COVERAGE_PERCENTAGE}}` - Required test coverage- `{{TEST_TYPES}}` - Types of tests needed
## Getting Started
1. **Select Template:** Choose the appropriate coding example for your task2. **Customize Variables:** Replace placeholders with your specific requirements3. **Adapt Code Style:** Modify to match your coding standards and conventions4. **Test Implementation:** Verify the generated code works as expected5. **Document Results:** Save successful prompts for team reuse
These coding examples help streamline development workflows, improve code quality, and maintain consistency across programming projects. Adapt them to match your technology stack, coding standards, and team practices.