Reliverse Standard
Reliverse Standard provides best practice recommendations to help keep your code clean, maintainable, and efficient, both in Reliverse projects and your own work.
Avoid Repeated I/O Operations
Repeated I/O operations—like reading a configuration file every time a function is called—can degrade performance, especially in large-scale or performance-sensitive applications.
❌ Bad Example (Reading config on every prompt):
✅ Good Example (Read config once and pass it along):
By loading the configuration once and passing it to decide()
, you avoid repetitive file reads and ensure better performance.
Avoid Using console.log
in Production
In production environments, avoid using console.log
for debugging, as it may expose sensitive information and clutter logs. Instead, use a proper logging framework or monitoring tool that can manage log levels and ensure that sensitive data is handled securely.
Maintain Consistent Code Formatting and Style
A consistent coding style improves readability and reduces cognitive overhead. Use tools like Prettier for formatting and ESLint for linting. Enforce these tools via your CI pipeline so that all contributors follow the same code style.
- Add
biome
andeslint
as dev dependencies. - Configure
.eslintrc.js
and.prettierrc
for your project. - Run
npx eslint . --fix
andnpx prettier --write .
as part of your CI workflow.
Use Environment Variables Securely
❌ Bad Example (Hardcoding secrets):
✅ Good Example (Load from .env):
Store sensitive credentials like API keys and database passwords in .env
files (excluded from version control) and load them with a library such as dotenv
. On production, rely on environment variables provided by your deployment platform. This approach keeps secrets out of source control and reduces the risk of unauthorized access.
Write Automated Tests
Automated tests catch bugs early and improve code confidence. Write unit, integration, and end-to-end tests as appropriate. Consider using frameworks like Jest, Mocha, or Vitest for unit tests, and Playwright or Cypress for end-to-end testing.
✅ Good Example (Simple Jest test):
Adding tests ensures that your codebase remains stable as it evolves.
Implement Continuous Integration and Deployment (CI/CD)
Set up a CI pipeline to run tests, linters, and build steps before merging changes. This helps maintain code quality and ensures that issues are caught before production releases. Tools like GitHub Actions, GitLab CI, and CircleCI make it easier to implement CI/CD workflows.
✅ Good Example (GitHub Actions Workflow):
Perform Regular Code Reviews
Encourage code reviews for every pull request. Peer reviews help maintain code quality, share knowledge, and catch issues early. Reviews also ensure that guidelines like those listed above are being followed, improving overall project health.
By following these recommendations—avoiding repeated I/O operations, using secure logging practices, maintaining consistent code style, handling secrets safely, writing automated tests, implementing CI/CD, and performing code reviews—you ensure that your code remains efficient, secure, and maintainable, embodying the principles of the Reliverse Standard.