- Node.js 18+
- pnpm (for installation and Claude Code CLI)
git clone https://github.com/your-username/start-claude.git
cd start-claude
pnpm installpnpm run build- Build the projectpnpm run watch- Build and watch for changespnpm run lint- Run ESLintpnpm run lint:fix- Fix linting issuespnpm test- Run testspnpm run test:run- Run tests oncepnpm run test:coverage- Run tests with coverage
The project uses Vitest for testing:
# Run tests
pnpm test
# Run tests with coverage
pnpm run test:coverage
# Run specific test file
pnpm test -- tests/config.test.ts
# Watch mode
pnpm run test:watchsrc/
├── cli/
│ ├── balance.ts # Load balancer CLI handling
│ ├── claude.ts # Claude CLI integration & auto-install
│ ├── common.ts # Common CLI utilities
│ ├── main.ts # Main CLI application
│ └── override.ts # Claude command override functionality
├── core/
│ ├── config.ts # Configuration management logic
│ ├── load-balancer.ts # Load balancer implementation
│ └── types.ts # TypeScript type definitions
├── storage/
│ └── s3-sync.ts # S3 synchronization functionality
└── utils/
├── detection.ts # Claude installation detection
├── editor.ts # Editor integration
├── ui.ts # User interface utilities
└── update-checker.ts # Auto-update functionality
tests/ # Test files mirror src structure
docs/ # Documentation
├── en/ # English documentation
└── zh/ # Chinese documentation
The ConfigManager class handles:
- Reading/writing configuration files
- Validation and type checking
- Default configuration management
- Configuration file format versioning
The LoadBalancer class provides:
- Health monitoring of multiple endpoints
- Round-robin request distribution
- Automatic failover and recovery
- Priority-based endpoint ordering
Built with Commander.js:
- Command parsing and validation
- Interactive prompts with Inquirer.js
- Colorful output with custom UI utilities
- Comprehensive help and error messages
S3-compatible synchronization:
- Multi-provider support (AWS S3, Cloudflare R2, Backblaze B2)
- Conflict resolution strategies
- Secure credential management
The project uses ESLint with a strict configuration:
# Check code style
pnpm run lint
# Auto-fix style issues
pnpm run lint:fixKey style guidelines:
- TypeScript strict mode enabled
- Explicit function return types required
- No unused variables allowed
- Consistent import/export ordering
- Trailing commas required
Each major component has comprehensive unit tests:
- Configuration management (
config.test.ts) - Load balancer functionality (
load-balancer.test.ts) - CLI commands (
claude.test.ts) - S3 sync operations (
s3-sync.test.ts) - Editor integration (
editor.test.ts)
Tests use Vitest mocking for:
- File system operations
- HTTP requests
- Child process execution
- UI output functions
Test configurations and fixtures are defined inline to ensure test isolation.
The project uses Rollup for building:
pnpm run buildThis creates:
bin/cli.cjs- CommonJS bundlebin/cli.mjs- ES modules bundle
The package.json includes:
- Dual module support (CJS + ESM)
- Executable binary configuration
- Comprehensive dependency management
- npm publish configuration
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes
- Add tests for your changes
- Run tests:
pnpm test - Run linting:
pnpm run lint:fix - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
Use conventional commits:
feat:- New featuresfix:- Bug fixesdocs:- Documentation changestest:- Test changesrefactor:- Code refactoringchore:- Build process or auxiliary tool changes
Pull requests require:
- All tests passing
- Linting checks passing
- Code review approval
- Documentation updates for new features
# Build and link for local testing
pnpm run build
npm link
# Test CLI commands
start-claude --helpThe project includes VS Code debug configuration:
{
"type": "node",
"request": "launch",
"name": "Debug CLI",
"program": "${workspaceFolder}/bin/cli.mjs",
"args": ["--help"],
"skipFiles": ["<node_internals>/**"]
}- Configuration Issues: Check
~/.start-claude/config.jsonformat - S3 Sync Problems: Verify credentials and bucket permissions
- Load Balancer: Monitor health check requests and responses
- Editor Integration: Check editor detection and path resolution
- Lazy loading of heavy dependencies
- Configuration caching
- Minimal initial file reads
- Streaming for large file operations
- Proper cleanup of temporary files
- Limited concurrent operations
- Request timeouts and retries
- Connection pooling for health checks
- Graceful degradation for network issues
- API keys stored in user's home directory
- File permissions restricted to user only
- No credentials logged or transmitted unnecessarily
- All user inputs validated and sanitized
- Configuration format validation
- Safe file path handling
Regular security audits:
npm audit
npm audit fixThe project follows semantic versioning:
- Major: Breaking changes
- Minor: New features, backwards compatible
- Patch: Bug fixes, backwards compatible
- Update version in
package.json - Update CHANGELOG.md
- Run full test suite
- Build and test distribution
- Create git tag
- Publish to npm
- Create GitHub release with notes
# Clear node modules and reinstall
rm -rf node_modules package-lock.json
pnpm install
# Clean TypeScript cache
pnpm run build -- --clean# Run tests with verbose output
pnpm test -- --reporter=verbose
# Run specific test pattern
pnpm test -- --grep "configuration"# See detailed linting errors
pnpm run lint -- --format=codeframe
# Fix auto-fixable issues
pnpm run lint:fix