Thank you for your interest in contributing to x402-cli! This document provides guidelines and instructions for contributing.
By participating in this project, you agree to:
- Be respectful and inclusive
- Welcome newcomers and help them learn
- Focus on constructive feedback
- Follow professional standards
- Node.js >= 18.0.0
- npm >= 9.0.0
- Git
- Basic TypeScript knowledge
- Fork the repository
# Fork on GitHub, then clone your fork
git clone https://github.com/sol-warrior/x402-cli.git
cd x402-cli- Install dependencies
npm install- Build the project
npm run build- Run tests
npm test- Link locally (optional)
npm linkmain- Production-ready codedevelop- Integration branch (if applicable)feature/*- New featuresfix/*- Bug fixesdocs/*- Documentation updates
git checkout -b feature/your-feature-name
# or
git checkout -b fix/your-bug-fix-
Code Style
- Follow existing code style
- Run
npm run formatbefore committing - Run
npm run lintto check for issues
-
TypeScript
- Use strict TypeScript settings
- Add types for all new code
- Avoid
anytypes (useunknownif needed)
-
Testing
- Write tests for new features
- Ensure all tests pass (
npm test) - Aim for high test coverage
-
Documentation
- Update README.md if needed
- Add JSDoc comments for public APIs
- Update architecture docs if structure changes
Follow Conventional Commits:
type(scope): subject
[optional body]
[optional footer]
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting)refactor: Code refactoringtest: Test additions/changeschore: Maintenance tasks
Examples:
feat(pay): add batch payment support
fix(config): handle corrupted config files gracefully
docs(readme): update installation instructions
test(utils): add tests for address validation
Husky runs pre-commit hooks automatically:
- Linting
- Formatting check
- Tests
To bypass (not recommended):
git commit --no-verify-
Update your branch
git fetch origin git rebase origin/main
-
Run all checks
npm run lint npm run format:check npm test npm run build -
Test your changes
- Test locally with
npm link - Test on different Node.js versions if possible
- Test edge cases
- Test locally with
-
Push your branch
git push origin feature/your-feature-name
-
Create Pull Request
- Use clear, descriptive title
- Reference related issues
- Describe changes in detail
- Include screenshots if UI changes
-
PR Template
- Description of changes
- Testing steps
- Checklist
- Related issues
- Maintainers will review within 48 hours
- Address feedback promptly
- Keep PR focused (one feature/fix per PR)
- Keep PRs small when possible
- Squash commits if requested
- Wait for CI to pass
- Maintainers will merge
- Use strict mode
- Prefer interfaces over types for object shapes
- Use
constassertions where appropriate - Avoid
any- useunknownif type is truly unknown
- Files:
kebab-case.ts - Functions:
camelCase - Classes:
PascalCase - Constants:
UPPER_SNAKE_CASE - Interfaces:
PascalCase(noIprefix)
- One function/class per file when possible
- Group related code together
- Keep functions small and focused
- Use early returns for readability
- Use try/catch for async operations
- Provide clear error messages
- Log errors appropriately
- Exit with proper exit codes
Good:
async function sendPayment(options: PaymentOptions): Promise<PaymentResult> {
try {
const result = await processPayment(options);
return { status: 'success', ...result };
} catch (error) {
logger.error(`Payment failed: ${error.message}`);
return { status: 'failed', error: error.message };
}
}Bad:
async function sendPayment(options: any) {
const result = await processPayment(options);
return result;
}- Test one thing per test
- Use descriptive test names
- Test edge cases
- Mock external dependencies
Example:
describe('isValidSolanaAddress', () => {
it('should validate correct Solana addresses', () => {
expect(isValidSolanaAddress('111...111')).toBe(true);
});
it('should reject invalid addresses', () => {
expect(isValidSolanaAddress('invalid')).toBe(false);
});
});- Test command execution end-to-end
- Use real Solana devnet for network tests
- Clean up after tests
- Add JSDoc for public functions
- Explain "why" not "what"
- Update comments when code changes
Example:
/**
* Send SOL payment to a recipient address.
* Validates inputs, checks balance, and sends transaction.
*
* @param options - Payment options including recipient and amount
* @returns Payment result with signature or error
*/
export async function sendPayment(options: PaymentOptions): Promise<PaymentResult> {
// ...
}- Update usage examples
- Add new command documentation
- Update installation steps if needed
- Test coverage improvements
- Bug fixes
- Documentation improvements
- Performance optimizations
- See ROADMAP.md for planned features
- Pick a feature from roadmap
- Discuss in issue before implementing
- Use GitHub Issues
- Include: steps to reproduce, expected vs actual behavior, environment details
- Add labels if possible
- Open a GitHub Discussion
- Check existing issues
- Review documentation
Your contributions make this project better. Thank you for taking the time to contribute! 🎉