Skip to content

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.

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 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.

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}}
  • Function purpose and behavior
  • Parameter descriptions with types
  • Return value specification
  • Usage examples
  • Error conditions
  • Performance considerations
  • Related functions or dependencies
  • Format: {{DOCUMENTATION_FORMAT}}
  • Audience: {{TARGET_AUDIENCE}}
  • Detail Level: {{DETAIL_LEVEL}}
  • Include Examples: {{INCLUDE_EXAMPLES}}
  • 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.

  • Title: {{PR_TITLE}}
  • Author: {{AUTHOR_NAME}}
  • Branch: {{BRANCH_NAME}}
  • Changes: {{CHANGE_SUMMARY}}
  • Purpose: {{PR_PURPOSE}}
{{CODE_CHANGES}}
  • Follows coding standards and conventions
  • Proper naming conventions
  • Appropriate code organization
  • No code duplication
  • Logic is correct and efficient
  • Edge cases are handled
  • Error handling is comprehensive
  • Input validation is present
  • No security vulnerabilities
  • Input sanitization
  • Authentication/authorization
  • Data exposure risks
  • Efficient algorithms
  • Proper resource management
  • Database query optimization
  • Memory usage considerations
  • Unit tests included
  • Test coverage adequate
  • Tests are meaningful
  • Integration tests if needed
  • Code is well-commented
  • API documentation updated
  • README updated if needed
  • {{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:

  • Issue: {{BUG_DESCRIPTION}}
  • Environment: {{ENVIRONMENT_INFO}}
  • Steps to Reproduce: {{REPRODUCTION_STEPS}}
  • Expected Behavior: {{EXPECTED_RESULT}}
  • Actual Behavior: {{ACTUAL_RESULT}}
{{PROBLEMATIC_CODE}}
  • Error Message: {{ERROR_MESSAGE}}
  • Stack Trace: {{STACK_TRACE}}
  • Log Output: {{LOG_OUTPUT}}
  • Frequency: {{ERROR_FREQUENCY}}
  • Platform: {{PLATFORM}}
  • Version: {{VERSION}}
  • Dependencies: {{DEPENDENCIES}}
  • Configuration: {{CONFIG_INFO}}
  1. Root Cause Analysis: Identify the underlying issue
  2. Impact Assessment: Evaluate severity and scope
  3. Solution Options: Propose multiple fix approaches
  4. Risk Assessment: Consider side effects of each solution
  5. Testing Strategy: Plan verification approach
  • 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:

{{TARGET_CODE}}
  • Testing Framework: {{TEST_FRAMEWORK}}
  • Coverage Target: {{COVERAGE_PERCENTAGE}}%
  • Test Types: {{TEST_TYPES}}
  • Mock Requirements: {{MOCKING_NEEDS}}
  • Happy Path: {{HAPPY_PATH_SCENARIOS}}
  • Edge Cases: {{EDGE_CASE_SCENARIOS}}
  • Error Conditions: {{ERROR_SCENARIOS}}
  • Boundary Conditions: {{BOUNDARY_TESTS}}
  • Valid Inputs: {{VALID_TEST_DATA}}
  • Invalid Inputs: {{INVALID_TEST_DATA}}
  • Mock Data: {{MOCK_DATA_REQUIREMENTS}}
  • Test Fixtures: {{FIXTURE_REQUIREMENTS}}
  • Test Naming: Clear, descriptive test names
  • Assertions: Specific, meaningful assertions
  • Test Organization: Logical grouping and structure
  • Documentation: Comments explaining complex test logic
  • 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}}.

  • Primary System: {{PRIMARY_SYSTEM}}
  • External System: {{EXTERNAL_SYSTEM}}
  • Integration Type: {{INTEGRATION_TYPE}}
  • Data Flow: {{DATA_FLOW_DESCRIPTION}}
  • Environment: {{TEST_ENVIRONMENT}}
  • Test Data: {{TEST_DATA_SETUP}}
  • Configuration: {{CONFIG_REQUIREMENTS}}
  • Dependencies: {{DEPENDENCY_SETUP}}
  • {{INTEGRATION_POINT_1}}: {{DESCRIPTION_1}}
  • {{INTEGRATION_POINT_2}}: {{DESCRIPTION_2}}
  • {{INTEGRATION_POINT_3}}: {{DESCRIPTION_3}}
  • Successful Integration: {{SUCCESS_SCENARIOS}}
  • Failure Handling: {{FAILURE_SCENARIOS}}
  • Timeout Handling: {{TIMEOUT_SCENARIOS}}
  • Data Validation: {{VALIDATION_SCENARIOS}}
  • Tools: {{TESTING_TOOLS}}
  • Language: {{PROGRAMMING_LANGUAGE}}
  • CI/CD Integration: {{CICD_REQUIREMENTS}}
  • 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.

  • Name: {{PROJECT_NAME}}
  • Type: {{PROJECT_TYPE}}
  • Language: {{PROGRAMMING_LANGUAGE}}
  • Framework: {{FRAMEWORK}}
  • Purpose: {{PROJECT_PURPOSE}}
  • What the project does
  • Key features and benefits
  • Target audience
  • Use cases
  • Prerequisites: {{PREREQUISITES}}
  • Installation steps for {{INSTALLATION_METHODS}}
  • Environment setup
  • Configuration requirements
  • Quick start guide
  • Basic usage examples
  • Advanced usage scenarios
  • Configuration options
  • Core functions/classes
  • Parameters and return values
  • Usage examples
  • Error handling
  • Development setup
  • Build process: {{BUILD_PROCESS}}
  • Testing: {{TESTING_APPROACH}}
  • Contributing guidelines
  • License: {{LICENSE_TYPE}}
  • Support: {{SUPPORT_CHANNELS}}
  • Changelog: {{CHANGELOG_LOCATION}}
  • Roadmap: {{ROADMAP_INFO}}
  • 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: {{SYSTEM_NAME}}
  • Purpose: {{SYSTEM_PURPOSE}}
  • Scale: {{SYSTEM_SCALE}}
  • Users: {{USER_BASE}}
  • Architecture Pattern: {{ARCHITECTURE_PATTERN}}
  • Core Components: {{CORE_COMPONENTS}}
  • Data Flow: {{DATA_FLOW}}
  • Integration Points: {{INTEGRATION_POINTS}}
  • Frontend: {{FRONTEND_TECH}}
  • Backend: {{BACKEND_TECH}}
  • Database: {{DATABASE_TECH}}
  • Infrastructure: {{INFRASTRUCTURE}}
  • Third-party Services: {{THIRD_PARTY_SERVICES}}
  • {{COMPONENT_1}}: {{COMPONENT_1_DESCRIPTION}}
  • {{COMPONENT_2}}: {{COMPONENT_2_DESCRIPTION}}
  • {{COMPONENT_3}}: {{COMPONENT_3_DESCRIPTION}}
  • Data Models: {{DATA_MODELS}}
  • Storage Strategy: {{STORAGE_STRATEGY}}
  • Data Flow: {{DATA_FLOW_DETAILS}}
  • Backup Strategy: {{BACKUP_STRATEGY}}
  • Authentication: {{AUTH_APPROACH}}
  • Authorization: {{AUTHZ_APPROACH}}
  • Data Protection: {{DATA_PROTECTION}}
  • Network Security: {{NETWORK_SECURITY}}
  • Scalability: {{SCALABILITY_APPROACH}}
  • Performance Targets: {{PERFORMANCE_TARGETS}}
  • Monitoring: {{MONITORING_STRATEGY}}
  • Caching: {{CACHING_STRATEGY}}
  • 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: {{PROJECT_NAME}}
  • Language: {{PROGRAMMING_LANGUAGE}}
  • Framework: {{FRAMEWORK}}
  • Target Environment: {{DEPLOYMENT_ENVIRONMENT}}
  • Build Tool: {{BUILD_TOOL}}
  • Dependencies: {{DEPENDENCY_MANAGEMENT}}
  • Artifacts: {{BUILD_ARTIFACTS}}
  • Build Triggers: {{BUILD_TRIGGERS}}
  • Unit Tests: {{UNIT_TEST_COMMAND}}
  • Integration Tests: {{INTEGRATION_TEST_COMMAND}}
  • Coverage Requirements: {{COVERAGE_THRESHOLD}}%
  • Test Reports: {{TEST_REPORTING}}
  • Security Scanning: {{SECURITY_TOOLS}}
  • Dependency Scanning: {{DEPENDENCY_SCANNING}}
  • Code Quality: {{CODE_QUALITY_TOOLS}}
  • Compliance Checks: {{COMPLIANCE_REQUIREMENTS}}
  • Deployment Strategy: {{DEPLOYMENT_STRATEGY}}
  • Environment: {{TARGET_ENVIRONMENT}}
  • Health Checks: {{HEALTH_CHECK_COMMANDS}}
  • Rollback Strategy: {{ROLLBACK_APPROACH}}
  • Environment Variables: {{ENV_VARIABLES}}
  • Secrets Management: {{SECRETS_MANAGEMENT}}
  • Notification: {{NOTIFICATION_SETTINGS}}
  • Monitoring: {{MONITORING_INTEGRATION}}
  • 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: {{APPLICATION_NAME}}
  • Language: {{PROGRAMMING_LANGUAGE}}
  • Framework: {{FRAMEWORK}}
  • Environment: {{RUNTIME_ENVIRONMENT}}
  • Base Image: {{BASE_IMAGE}}
  • Application Port: {{APPLICATION_PORT}}
  • Dependencies: {{DEPENDENCIES}}
  • Build Process: {{BUILD_STEPS}}
  • Multi-stage build: {{MULTI_STAGE_BUILD}}
  • Layer optimization: {{LAYER_OPTIMIZATION}}
  • Security scanning: {{SECURITY_REQUIREMENTS}}
  • Size optimization: {{SIZE_OPTIMIZATION}}
  • Environment variables: {{ENV_CONFIGURATION}}
  • Volume mounts: {{VOLUME_REQUIREMENTS}}
  • Network configuration: {{NETWORK_SETUP}}
  • Health checks: {{HEALTH_CHECK_CONFIG}}
  • Docker Compose: {{COMPOSE_REQUIREMENTS}}
  • Local development: {{DEV_SETUP}}
  • Database services: {{DATABASE_SERVICES}}
  • External dependencies: {{EXTERNAL_SERVICES}}
  • 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 task
2. **Customize Variables:** Replace placeholders with your specific requirements
3. **Adapt Code Style:** Modify to match your coding standards and conventions
4. **Test Implementation:** Verify the generated code works as expected
5. **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.