Skip to content

Instantly share code, notes, and snippets.

@j-fischer
Created January 2, 2025 04:35
Show Gist options
  • Save j-fischer/8a055d6a16c7926dabfd6c19ad1c1707 to your computer and use it in GitHub Desktop.
Save j-fischer/8a055d6a16c7926dabfd6c19ad1c1707 to your computer and use it in GitHub Desktop.
General Development instructions for RFLIB development with Gen AI tools
Always write all source files out in full and use the knowledge base for reference. Do not replace any code content with comments.
Custom Instructions for RFLIB Salesforce Application Development
Project Overview
RFLIB is a comprehensive Salesforce utility library providing:
- Logging framework with client and server-side capabilities
- Feature switching functionality
- Trigger framework
- Retryable actions framework
- Permission management tools
- Custom settings management
Development Standards & Code Organization
Follow the package structure:
- Main components under main/default
- Clear separation between classes, triggers, and LWC components
- Maintain module-specific grouping (logging, feature switches, triggers)
Naming Conventions:
- Use the rflib_ prefix for all components to prevent namespace conflicts
- Follow Pascal case for class names (e.g., rflib_Logger, rflib_FeatureSwitch)
- Use underscore notation for custom fields and metadata (Feature_Switch__c)
- Keep LWC component names descriptive and prefixed (rflibLogger, rflibFeatureSwitch)
Code Style
Follow Apex best practices:
- Use sharing declarations appropriately (with sharing, without sharing)
- Implement proper error handling and logging
- Use appropriate access modifiers (private, public, global)
- Add @TestVisible where needed for unit testing but never add it to methods, only to static or private members.
JavaScript/LWC standards:
- Use ES6+ features appropriately
- Implement proper error handling with promises
- Use consistent logging throughout components
- Follow LWC best practices for reactivity and data handling
- Keep in mind that LWC HTML template do not support function calls in expressions.
Documentation Requirements
Each class must include:
Copyright notice.
Class description using ApexDocs format.
Group annotation for module organization.
Method-level documentation on interface and public utility methods.
Code comments should:
- Explain complex logic
- Document any assumptions
- Clarify business rules
- Note any limitations or potential issues
Testing Standards
Apex testing:
- Maintain >85% code coverage
- Test both positive and negative scenarios
- Use appropriate test utils and mocks
- Follow test method naming convention: test<methodName>_expectedBehavior
LWC testing:
- Use Jest for component testing
- Implement mock services for Apex calls
- Test component lifecycle methods
- Verify event handling
Security Considerations:
- Implement proper sharing rules and object access
- Use FLS and CRUD checks where appropriate
- Validate input parameters
- Handle sensitive data appropriately
- Follow principle of least privilege
Performance Guidelines:
- Bulkify all Apex operations
- Optimize SOQL queries
- Use selective queries
- Minimize the number of queries
- Implement proper filtering
Handle governor limits appropriately.
Implement caching where beneficial.
Error Handling:
- Use custom exceptions when appropriate
- Implement proper error logging
- Provide meaningful error messages
- Handle both system and custom exceptions
- Implement retry mechanisms for critical operations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment