Thank you for your interest in contributing to Swarm! This document outlines best practices and guidelines to help you make effective, high-quality contributions to any package in the Swarm monorepo.
- Code Style
- TypeScript & Typing
- Error Handling
- Logging
- Testing
- Package-Specific Guidelines
- Pull Requests
- Use Prettier and ESLint for formatting and linting.
- Prefer single responsibility per file/module.
- Use descriptive variable and function names.
- Write JSDoc comments for all exported functions and types.
- Keep imports organized and avoid unused imports.
- All code must be written in TypeScript.
- Use strong typing everywhere; avoid
anyunless absolutely necessary. - Shared types and interfaces belong in
packages/swarm/src/types/. - Package-specific types belong in the respective package's
src/types/directory. - Prefer type aliases and enums for clarity.
- Always use the centralised error utility from
@ingenyus/swarm. - Do not use
console.log,console.error, orprocess.exitdirectly. - For user-facing errors, use:
import { error, handleFatalError } from '@ingenyus/swarm'; error('Something went wrong'); // or for fatal errors: handleFatalError('Critical failure', err);
- For non-fatal warnings or info:
import { warn, info, success } from '@ingenyus/swarm'; warn('This is a warning'); info('This is an info message'); success('Operation completed successfully');
- Debug mode:
- If you want to print stack traces, set the environment variable
SWARM_DEBUG=1. - The error utility will automatically print stack traces in debug mode.
- If you want to print stack traces, set the environment variable
- Validation errors:
- Use
error()and return early from the function/handler. - Do not call
process.exitdirectly in command handlers.
- Use
- All logging should use the signale logger via the error utility from
@ingenyus/swarm. - Use the appropriate log level:
info,success,warn,error. - Avoid raw
consolestatements.
- Place unit tests alongside code (e.g.,
src/utils/io.test.ts). - Place integration/e2e tests in the package's
tests/directory. - Write tests for all new features and bug fixes.
- Run tests for the specific package you're working on:
cd packages/package-name pnpm test
- Run all tests from the monorepo root:
pnpm test
- This is the foundational package containing shared logic.
- Ensure all functionality is well-documented and tested.
- This package includes both the CLI and MCP server implementations.
- CLI command implementation is in
packages/swarm/src/cli/. - MCP server implementation is in
packages/swarm/src/mcp/. - Use Commander.js for CLI argument parsing and validation.
- Focus on MCP protocol compliance and AI agent workflows for MCP features.
- This is a plugin containing Wasp-specific functionality
- This package includes generators for all documented Wasp components and a custom configuration class
- All generators inherit the
GeneratorBaseclass from theswarmpackage
- Follow the established package structure in
packages/. - Include proper
package.jsonwith workspace dependencies. - Add TypeScript configuration and build setup.
- Include comprehensive tests and documentation.
- Update root
pnpm-workspace.yamlif needed.
- Determine which package the feature belongs to:
- Core functionality →
packages/swarm/ - Wasp-specific →
packages/swarm-wasp/
- Core functionality →
- Add the feature to the appropriate package
- Update types in the appropriate
src/types/directory - Add tests for the new functionality
- Update documentation
- Reference the relevant issue or PRD milestone in your PR description.
- Ensure your branch is up to date with
mainbefore submitting. - Validate the codebase (runs tests, linter, formatter, etc) before opening a PR:
pnpm validate- Provide a clear summary of your changes and why they are needed.
- If your changes affect multiple packages, test all affected packages.
Use Conventional Commits format for clear, consistent commit messages:
# Package-specific commits
git commit -m "feat(wasp): add new feature to CRUD generator"
git commit -m "fix(swarm): resolve command parsing issue"
git commit -m "docs(wasp): update API documentation"
# Multi-package commits
git commit -m "feat: add new feature across packages"
git commit -m "fix: resolve shared utility issue"
# Breaking changes
git commit -m "feat!: breaking change in core API"If you wish to include a scope, you should provide the package name your changes relate to. Alternatively, to save characters, you can specify the package suffix alone (e.g. wasp == swarm-wasp).
This CI workflow for this project automatically generates Changesets from conventional commit messages when your PR is merged. You don't need to create them manually unless you want more control over the changelog entry.
- CI processes conventional commit messages (e.g.,
feat:,fix:,feat!:) and generates changesets automatically - Simply use Conventional Commits format in your commits
- Changesets are created for changes to individual packages (
@ingenyus/swarmor@ingenyus/swarm-wasp) - When a scope isn't provided in the commit message, the workflow will examine the included file paths to determine which packages are affected
- Test, documentation, build, CI or chore-only changes typically don't require changesets
If you want more control over the changelog entry or to provide additional context, you can create a changeset manually:
-
Run the changeset command from the monorepo root:
pnpm changeset
-
You'll be prompted to:
- Select which packages are affected (
@ingenyus/swarm,@ingenyus/swarm-wasp, or both) - Choose the change type:
major- Breaking changesminor- New featurespatch- Bug fixes or minor improvements
- Write a description of the changes (this will appear in the CHANGELOG)
- Select which packages are affected (
-
Commit the generated changeset file (it will be in
.changeset/) along with your code changes
Note: Manual changesets take precedence over auto-generated ones, so if you create one, it will be used instead of generating from commit messages.
Thank you for helping make Swarm better!