Welcome to the Catalyst development guide! This document provides everything you need to set up your local development environment and start contributing to the project.
Before you begin, ensure you have the following installed:
- Node.js 20+ - Verify with
node --version - npm 9+ - Verify with
npm --version - Git - Verify with
git --version - macOS - Primary development target (Linux/Windows support coming soon)
git clone https://github.com/your-org/catalyst.git
cd catalystnpm installThis will install all required dependencies including TypeScript, testing frameworks, and development tools.
npm run buildThis compiles TypeScript to JavaScript in the dist/ directory and sets executable permissions on the CLI binary.
npm testVerify everything is working by running the test suite.
For quick iteration during development without building:
npm run dev -- setup # Run setup command
npm run dev -- --help # Show help
npm run dev -- init # Run init commandThe dev script uses tsx to execute TypeScript directly, providing faster feedback during development.
1. Make your changes in src/
2. Run type checking
npm run type-check3. Run tests in watch mode (recommended during development)
npm run test:watch4. Run linting
npm run lint5. Build the project
npm run buildLink your local development version globally to test the CLI as end users will use it:
npm linkNow you can run catalyst commands from anywhere:
catalyst --version
catalyst setup
catalyst --help
catalyst initWhen you're done testing, unlink the global installation:
npm unlink -g catalystAlternative: Install locally without linking:
npm install -g .Then uninstall when done:
npm uninstall -g catalystnpm testRuns the complete test suite using Vitest.
npm run test:watchAutomatically re-runs tests when files change. Excellent for TDD workflow.
npm run test:coverageGenerates coverage reports in the coverage/ directory.
npm test -- tests/unit/utils/filesystem.test.tsnpm run test:uiOpens an interactive browser-based test UI.
npm run test:mcp-serversTests the bundled MCP servers functionality.
The project includes pre-configured launch configurations in .vscode/launch.json:
To debug the CLI:
- Set breakpoints in your TypeScript source files
- Press
F5or select Run > Start Debugging - Choose "Debug CLI" from the dropdown
- The debugger will stop at your breakpoints
To debug tests:
- Set breakpoints in test files
- Press
F5or select Run > Start Debugging - Choose "Debug Tests" from the dropdown
- Tests will run in watch mode with debugging enabled
Use the built-in utilities for logging:
import { logger } from '@/utils';
logger.debug('Debugging info');
logger.info('Info message');
logger.warn('Warning message');
logger.error('Error message');Enable debug-level logging:
DEBUG=* npm run devFor advanced debugging:
node --inspect-brk ./dist/cli/index.jsThen open chrome://inspect in Chrome and click "inspect" on your process.
Problem: Running catalyst after npm link gives "command not found"
Solutions:
- Check your npm global bin directory:
npm bin -g - Ensure the directory is in your PATH
- Try running
npm linkagain - Restart your terminal
- On macOS with nvm, ensure your shell profile is configured correctly
Problem: Build fails with TypeScript errors
Solutions:
- Run
npm run type-checkfor detailed error messages - Check
tsconfig.jsonsettings - Verify all imports use correct paths and aliases
- Clear build artifacts:
npm run clean && npm run build - Delete
node_modulesand reinstall:npm run clean:all && npm install
Problem: Import statements fail or modules aren't found
Solutions:
- Check path aliases in
tsconfig.json-@/should alias to./src - Verify import paths are correct
- Ensure you're using
.jsextensions in import statements (ESM requirement) - Run
npm run clean && npm run build
Problem: Permission denied when running the CLI
Solutions:
- The build script should set permissions automatically
- Manually set:
chmod +x bin/catalyst - Check file ownership:
ls -la bin/catalyst
Problem: Tests pass locally but fail in CI, or vice versa
Solutions:
- Check Node.js version matches (use
node --version) - Clear coverage and rebuild:
npm run clean && npm install && npm test - Check for test isolation issues (tests depending on each other)
- Review Vitest configuration in
vitest.config.ts
Problem: Development server or MCP server fails to start
Solutions:
- Check what's using the port:
lsof -i :PORT_NUMBER - Kill the conflicting process
- Configure alternative ports in your local config
Problem: CLI can't find templates or configuration
Solutions:
- Check environment variables are set correctly
- For local development, the CLI should use relative paths
- Verify
.catalyst/directory exists in test locations - Check file permissions
- Write tests first - Follow TDD when possible
- Run
npm run checkbefore committing - This runs type-check, lint, format-check, and tests - Use TypeScript strict mode - No implicit
any, proper null checks - Leverage utility functions - Use helpers from
src/utils/for common operations - Document complex logic - Add JSDoc comments for public APIs
- Unit test all utilities - Aim for >80% coverage on utility modules
- Integration test CLI commands - Ensure commands work end-to-end
- Mock external dependencies - Use Vitest mocks for file system, network calls
- Test error cases - Don't just test the happy path
- Create feature branches -
git checkout -b feature/my-feature - Commit often - Small, focused commits
- Write clear commit messages - Follow Conventional Commits format
- Keep PR scope small - Easier to review and merge
- Keep files focused and single-purpose
- Use barrel exports (
index.ts) for clean imports - Follow the established project structure
- Place tests alongside source files or in
tests/mirror structure
When something isn't working, try these steps in order:
-
Clean build artifacts
npm run clean
-
Rebuild the project
npm run build
-
Run type checking
npm run type-check
-
Check for linting errors
npm run lint
-
Run tests
npm test -
Full clean and reinstall
npm run clean:all npm install npm run build npm test
- Documentation Index - Complete documentation map
- Architecture Docs - System design and technical architecture
- PRD - Product requirements and specifications
- Stories - Development stories and tasks
- Questions & Discussions: GitHub Discussions
- Bug Reports: GitHub Issues
- Contributing: See CONTRIBUTING.md
| Task | Command |
|---|---|
| Run CLI in dev mode | npm run dev -- [args] |
| Build project | npm run build |
| Run all tests | npm test |
| Run tests in watch mode | npm run test:watch |
| Run linter | npm run lint |
| Fix linting issues | npm run lint:fix |
| Format code | npm run format |
| Type check | npm run type-check |
| Run all checks | npm run check |
| Clean build artifacts | npm run clean |
| Link globally | npm link |
| Unlink globally | npm unlink -g catalyst |
Now that you have your development environment set up:
- Read the Architecture Documentation to understand the system design
- Review CONTRIBUTING.md for contribution guidelines
- Check GitHub Issues for tasks to work on
- Join our Discussions to connect with the community
Happy coding! 🚀