Thank you for your interest in contributing to Clack! This document provides detailed instructions for setting up your development environment, navigating the codebase, making changes, and submitting contributions.
Tip
For new contributors: Take a look at https://github.com/firstcontributions/first-contributions for helpful information on contributing to open source projects.
If you use volta or nvm, the correct Node.js version will be automatically selected based on the project's .nvmrc
file.
-
Fork the repository:
- Visit https://github.com/bombshell-dev/clack
- Click the "Fork" button in the top right
- Clone your fork to your local machine
git clone https://github.com/YOUR_USERNAME/clack.git cd clack
-
Set up the upstream remote:
git remote add upstream https://github.com/bombshell-dev/clack.git
-
Install dependencies:
pnpm install
-
Build the packages:
pnpm build
-
Run the development server:
pnpm dev
If you want to test changes to Clack packages in your own project, you can use pnpm's linking capabilities:
-
Build the Clack packages locally first:
# In the clack repository cd /path/to/clack pnpm build
-
Link the packages to your project using one of these methods:
Method 1: Using pnpm link
# In your project cd /path/to/your-project # Link @clack/core pnpm link --global /path/to/clack/packages/core # Link @clack/prompts pnpm link --global /path/to/clack/packages/prompts
Method 2: Using local path in package.json
In your project's package.json, reference the local paths:
{ "dependencies": { "@clack/core": "file:/path/to/clack/packages/core", "@clack/prompts": "file:/path/to/clack/packages/prompts" } }
Then run
pnpm install
in your project. -
Watch for changes (optional):
# In the clack repository cd /path/to/clack pnpm build --watch
-
Refresh after changes: If you're making changes to Clack while testing in your project, you'll need to rebuild Clack and potentially reinstall in your project:
# In the clack repository cd /path/to/clack pnpm build # In your project (if using Method 2) cd /path/to/your-project pnpm install
With this setup, you can develop and test your changes to Clack within the context of your own project. This is especially useful for implementing new features like filtering.
Clack is organized as a monorepo using pnpm workspaces. Understanding the structure will help you navigate and contribute effectively:
clack/
├── .changeset/ # Changeset files for versioning
├── .github/ # GitHub workflows and templates
├── examples/ # Example implementations of Clack
├── packages/ # Core packages
│ ├── core/ # Unstyled primitives (@clack/core)
│ └── prompts/ # Ready-to-use components (@clack/prompts)
├── biome.json # Biome configuration
├── package.json # Root package.json
├── pnpm-workspace.yaml # Workspace configuration
└── tsconfig.json # TypeScript configuration
-
@clack/core (
packages/core/
):- Contains the unstyled, extensible primitives for building CLI applications
- The foundation layer that provides the core functionality
-
@clack/prompts (
packages/prompts/
):- Built on top of @clack/core
- Provides beautiful, ready-to-use CLI prompt components
- What most users will interact with directly
The examples/
directory contains sample projects that demonstrate how to use Clack. Examining these examples is a great way to understand how the library works in practice.
-
Build all packages:
pnpm build
-
Start development environment:
pnpm dev
-
Run tests:
pnpm test
-
Lint code:
pnpm lint
-
Format code:
pnpm format
-
Type check:
pnpm type-check
-
Build stubbed packages (for faster development):
pnpm stub
-
Create a new branch:
git checkout -b my-feature-branch
-
Implement your changes:
- For bug fixes, start by reproducing the issue
- For new features, consider how it fits into the existing architecture
- Maintain type safety with TypeScript
- Add or update tests as necessary
-
Run local verification:
# Ensure everything builds pnpm build # Check formatting and lint issues pnpm format pnpm lint # Verify type correctness pnpm type-check # Run tests pnpm test
-
Create a changeset (for changes that need versioning):
pnpm changeset
- Follow the prompts to select which packages have changed
- Choose the appropriate semver increment (patch, minor, major)
- Write a concise but descriptive message explaining the changes
For testing changes to the core functionality:
-
Use the examples:
# Run an example to test your changes pnpm --filter @example/changesets run start
-
Create a test-specific example (if needed):
- Add a new directory in the
examples/
folder - Implement a minimal reproduction that uses your new feature/fix
- Run it with
pnpm --filter @example/your-example run start
- Add a new directory in the
When encountering issues during development:
- Check for errors in the console - Clack will often output helpful error messages
- Review the API documentation - Ensure you're using components and functions as intended
- Look at existing examples - See how similar features are implemented
- Inspect the packages individually - Sometimes issues are isolated to either
core
orprompts
-
Commit your changes:
git add . git commit -m "feat: add new awesome feature"
-
Push to your fork:
git push origin my-feature-branch
-
Create a pull request:
- Go to your fork on GitHub
- Click "New pull request"
- Select your branch and add a descriptive title
- Fill in the PR template with details about your changes
- Reference any related issues
-
Wait for the automated checks:
- GitHub Actions will run tests, type checking, and lint validation
- Fix any issues that arise
-
Address review feedback:
- Make requested changes
- Push additional commits to your branch
- The PR will update automatically
Clack uses pkg.pr.new (provided by bolt.new) to create continuous preview releases of all PRs. This simplifies testing and makes verifying bug fixes easier for our dependents.
The workflow that builds a preview version and adds instructions for installation as a comment on your PR should run automatically if you have contributed to Clack before. First-time contributors may need to wait until a maintainer manually approves GitHub Actions running on your PR.
Clack uses Changesets to manage versions and releases.
-
For contributors:
- Create a changeset file with your PR as described above
- Maintainers will handle the actual release process
-
For maintainers:
- Merging PRs with changesets will queue them for the next release
- When ready to release:
# Update versions based on changesets pnpm ci:version # Publish to npm pnpm ci:publish
Clack maintains a stable v0
branch alongside the main development branch. For maintainers who need to backport changes:
- Label PRs that should be backported with the
backport
label - After the PR is merged to
main
, manually cherry-pick the squashed commit into thev0
branch:# Ensure you have the latest v0 branch git checkout v0 git pull upstream v0 # Cherry-pick the squashed commit from main git cherry-pick <commit-hash> # Push the changes git push upstream v0
- CI is configured to run changesets from the
v0
branch, so release PRs will be opened automatically
The GitHub Actions are configured to cut releases from both the main
and v0
branches.
When reporting bugs or requesting features:
- Check existing issues to avoid duplicates
- Use the issue templates to provide all necessary information
- Be specific and clear about what's happening and what you expect
- Provide reproduction steps - ideally a minimal example that demonstrates the issue
- Include environment details like OS, Node.js version, etc.
When opening an issue, consider which category it falls into:
- Bug Report: Something isn't working as documented or expected
- Feature Request: A suggestion for new functionality
- Documentation Issue: Improvements or corrections to documentation
- Performance Issue: Problems with speed or resource usage
We use Biome for linting and formatting. Your code should follow these standards:
# To check formatting
pnpm format
# To lint and fix issues automatically where possible
pnpm lint
The project follows standard TypeScript practices. If you're new to TypeScript:
- Use precise types whenever possible
- Avoid
any
unless absolutely necessary - Look at existing code for patterns to follow
We follow conventional commits for commit messages:
feat:
- A new featurefix:
- A bug fixdocs:
- Documentation changesstyle:
- Changes that don't affect code functionality (formatting, etc)refactor:
- Code changes that neither fix bugs nor add featuresperf:
- Performance improvementstest:
- Adding or correcting testschore:
- Changes to the build process, tools, etc
By contributing, you agree that your contributions will be licensed under the project's MIT License.
Thank you for taking the time to contribute to Clack! Feel free to join our community Discord at bomb.sh/chat. It's a great place to connect with other project contributors—we're chill!
This contributing guide was inspired by and adapted from the Astro Contributing Manual. We appreciate their excellent documentation and open source practices.