This document defines the coding standards and best practices for contributors to ensure consistency, readability, and maintainability across the AgenticPay codebase.
- Enable strict typing (
strict: true) - Avoid using
any; prefer explicit types orunknown - Use
interfacefor object shapes andtypefor unions
- Variables & functions:
camelCase - Types & interfaces:
PascalCase - Constants:
UPPER_SNAKE_CASE
- Use
kebab-casefor filesuser-service.tstransfer-utils.ts
- Keep functions small and single-purpose
- Always type function parameters and return values
function calculateFee(amount: number): number {
return amount * 0.01;
}- Use functional components only
- Prefer arrow functions
const SendButton = () => {
return <button>Send</button>;
};- Use React hooks (
useState,useEffect) properly - Extract reusable logic into custom hooks
- Keep state as minimal as possible
- Avoid deeply nested state
- Use derived state where possible
- Use TailwindCSS utility classes
- Avoid hardcoded colors, prefer theme-aware classes (
dark: variants)
- Follow Rust standard formatting (
cargo fmt) - Lint with
cargo clippy
- Functions:
snake_case - Structs/Enums:
PascalCase - Constants:
UPPER_SNAKE_CASE
- Keep modules focused and small
- Group related logic together
- Use
Result<T, E>for fallible operations - Avoid panics in production code
pub fn deposit(amount: i128) -> Result<(), Error> {
if amount <= 0 {
return Err(Error::InvalidAmount);
}
Ok(())
}Use the following conventions:
feat/short-descriptionfix/short-descriptiondocs/short-descriptionchore/short-descriptionrefactor/short-description
Example:
feat/add-transfer-endpoint
fix/incorrect-balance-calculation
Follow this format:
type: short description
Examples:
feat: add transfer API endpointfix: resolve balance overflow issuedocs: add style guide
Before submitting a PR:
- Ensure code builds successfully
- Run all tests
- Follow the style guide
- Keep PRs small and focused
- Reference related issues (e.g.
Closes #12)
- Write readable and self-documenting code
- Avoid duplication, reuse existing logic
- Add comments only when necessary
- Keep functions and components small
- Prioritize clarity over cleverness
Consistency is key. Following this guide ensures:
- Easier code reviews
- Better collaboration
- Higher code quality