···11+# Contributing to Clack
22+33+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.
44+55+> [!Tip]
66+> **For new contributors:** Take a look at [https://github.com/firstcontributions/first-contributions](https://github.com/firstcontributions/first-contributions) for helpful information on contributing to open source projects.
77+88+## Getting Started
99+1010+### Prerequisites
1111+1212+- [Node.js](https://nodejs.org/) (version specified in `.nvmrc`, currently v20.18.1)
1313+- [pnpm](https://pnpm.io/) (version 9.14.2 or higher)
1414+1515+If you use [volta](https://volta.sh/) or [nvm](https://github.com/nvm-sh/nvm), the correct Node.js version will be automatically selected based on the project's `.nvmrc` file.
1616+1717+### Local Development Setup
1818+1919+1. **Fork the repository**:
2020+ - Visit [https://github.com/bombshell-dev/clack](https://github.com/bombshell-dev/clack)
2121+ - Click the "Fork" button in the top right
2222+ - Clone your fork to your local machine
2323+2424+ ```bash
2525+ git clone https://github.com/YOUR_USERNAME/clack.git
2626+ cd clack
2727+ ```
2828+2929+2. **Set up the upstream remote**:
3030+ ```bash
3131+ git remote add upstream https://github.com/bombshell-dev/clack.git
3232+ ```
3333+3434+3. **Install dependencies**:
3535+ ```bash
3636+ pnpm install
3737+ ```
3838+3939+4. **Build the packages**:
4040+ ```bash
4141+ pnpm build
4242+ ```
4343+4444+5. **Run the development server**:
4545+ ```bash
4646+ pnpm dev
4747+ ```
4848+4949+### Using Clack Packages in Your Own Projects During Development
5050+5151+If you want to test changes to Clack packages in your own project, you can use pnpm's linking capabilities:
5252+5353+1. **Build the Clack packages locally first**:
5454+ ```bash
5555+ # In the clack repository
5656+ cd /path/to/clack
5757+ pnpm build
5858+ ```
5959+6060+2. **Link the packages to your project using one of these methods**:
6161+6262+ **Method 1: Using pnpm link**
6363+ ```bash
6464+ # In your project
6565+ cd /path/to/your-project
6666+6767+ # Link @clack/core
6868+ pnpm link --global /path/to/clack/packages/core
6969+7070+ # Link @clack/prompts
7171+ pnpm link --global /path/to/clack/packages/prompts
7272+ ```
7373+7474+ **Method 2: Using local path in package.json**
7575+7676+ In your project's package.json, reference the local paths:
7777+ ```json
7878+ {
7979+ "dependencies": {
8080+ "@clack/core": "file:/path/to/clack/packages/core",
8181+ "@clack/prompts": "file:/path/to/clack/packages/prompts"
8282+ }
8383+ }
8484+ ```
8585+ Then run `pnpm install` in your project.
8686+8787+3. **Watch for changes** (optional):
8888+ ```bash
8989+ # In the clack repository
9090+ cd /path/to/clack
9191+ pnpm build --watch
9292+ ```
9393+9494+4. **Refresh after changes**:
9595+ If you're making changes to Clack while testing in your project, you'll need to rebuild Clack and potentially reinstall in your project:
9696+ ```bash
9797+ # In the clack repository
9898+ cd /path/to/clack
9999+ pnpm build
100100+101101+ # In your project (if using Method 2)
102102+ cd /path/to/your-project
103103+ pnpm install
104104+ ```
105105+106106+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.
107107+108108+## Repository Structure
109109+110110+Clack is organized as a monorepo using pnpm workspaces. Understanding the structure will help you navigate and contribute effectively:
111111+112112+```
113113+clack/
114114+├── .changeset/ # Changeset files for versioning
115115+├── .github/ # GitHub workflows and templates
116116+├── examples/ # Example implementations of Clack
117117+├── packages/ # Core packages
118118+│ ├── core/ # Unstyled primitives (@clack/core)
119119+│ └── prompts/ # Ready-to-use components (@clack/prompts)
120120+├── biome.json # Biome configuration
121121+├── package.json # Root package.json
122122+├── pnpm-workspace.yaml # Workspace configuration
123123+└── tsconfig.json # TypeScript configuration
124124+```
125125+126126+### Key Packages
127127+128128+1. **@clack/core** (`packages/core/`):
129129+ - Contains the unstyled, extensible primitives for building CLI applications
130130+ - The foundation layer that provides the core functionality
131131+132132+2. **@clack/prompts** (`packages/prompts/`):
133133+ - Built on top of @clack/core
134134+ - Provides beautiful, ready-to-use CLI prompt components
135135+ - What most users will interact with directly
136136+137137+### Examples
138138+139139+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.
140140+141141+## Development Workflow
142142+143143+### Common Commands
144144+145145+- **Build all packages**:
146146+ ```bash
147147+ pnpm build
148148+ ```
149149+150150+- **Start development environment**:
151151+ ```bash
152152+ pnpm dev
153153+ ```
154154+155155+- **Run tests**:
156156+ ```bash
157157+ pnpm test
158158+ ```
159159+160160+- **Lint code**:
161161+ ```bash
162162+ pnpm lint
163163+ ```
164164+165165+- **Format code**:
166166+ ```bash
167167+ pnpm format
168168+ ```
169169+170170+- **Type check**:
171171+ ```bash
172172+ pnpm type-check
173173+ ```
174174+175175+- **Build stubbed packages** (for faster development):
176176+ ```bash
177177+ pnpm stub
178178+ ```
179179+180180+### Making Changes
181181+182182+1. **Create a new branch**:
183183+ ```bash
184184+ git checkout -b my-feature-branch
185185+ ```
186186+187187+2. **Implement your changes**:
188188+ - For bug fixes, start by reproducing the issue
189189+ - For new features, consider how it fits into the existing architecture
190190+ - Maintain type safety with TypeScript
191191+ - Add or update tests as necessary
192192+193193+3. **Run local verification**:
194194+ ```bash
195195+ # Ensure everything builds
196196+ pnpm build
197197+198198+ # Check formatting and lint issues
199199+ pnpm format
200200+ pnpm lint
201201+202202+ # Verify type correctness
203203+ pnpm type-check
204204+205205+ # Run tests
206206+ pnpm test
207207+ ```
208208+209209+4. **Create a changeset** (for changes that need versioning):
210210+ ```bash
211211+ pnpm changeset
212212+ ```
213213+ - Follow the prompts to select which packages have changed
214214+ - Choose the appropriate semver increment (patch, minor, major)
215215+ - Write a concise but descriptive message explaining the changes
216216+217217+### Testing Your Changes
218218+219219+For testing changes to the core functionality:
220220+221221+1. **Use the examples**:
222222+ ```bash
223223+ # Run an example to test your changes
224224+ pnpm --filter @example/changesets run start
225225+ ```
226226+227227+2. **Create a test-specific example** (if needed):
228228+ - Add a new directory in the `examples/` folder
229229+ - Implement a minimal reproduction that uses your new feature/fix
230230+ - Run it with `pnpm --filter @example/your-example run start`
231231+232232+### Debugging Tips
233233+234234+When encountering issues during development:
235235+236236+1. **Check for errors in the console** - Clack will often output helpful error messages
237237+2. **Review the API documentation** - Ensure you're using components and functions as intended
238238+3. **Look at existing examples** - See how similar features are implemented
239239+4. **Inspect the packages individually** - Sometimes issues are isolated to either `core` or `prompts`
240240+241241+## Pull Request Process
242242+243243+1. **Commit your changes**:
244244+ ```bash
245245+ git add .
246246+ git commit -m "feat: add new awesome feature"
247247+ ```
248248+249249+2. **Push to your fork**:
250250+ ```bash
251251+ git push origin my-feature-branch
252252+ ```
253253+254254+3. **Create a pull request**:
255255+ - Go to your fork on GitHub
256256+ - Click "New pull request"
257257+ - Select your branch and add a descriptive title
258258+ - Fill in the PR template with details about your changes
259259+ - Reference any related issues
260260+261261+4. **Wait for the automated checks**:
262262+ - GitHub Actions will run tests, type checking, and lint validation
263263+ - Fix any issues that arise
264264+265265+5. **Address review feedback**:
266266+ - Make requested changes
267267+ - Push additional commits to your branch
268268+ - The PR will update automatically
269269+270270+### PR Previews
271271+272272+Clack uses [pkg.pr.new](https://pkg.pr.new) (provided by [bolt.new](https://bolt.new)) to create continuous preview releases of all PRs. This simplifies testing and makes verifying bug fixes easier for our dependents.
273273+274274+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.
275275+276276+## Release Process
277277+278278+Clack uses [Changesets](https://github.com/changesets/changesets) to manage versions and releases.
279279+280280+1. **For contributors**:
281281+ - Create a changeset file with your PR as described above
282282+ - Maintainers will handle the actual release process
283283+284284+2. **For maintainers**:
285285+ - Merging PRs with changesets will queue them for the next release
286286+ - When ready to release:
287287+ ```bash
288288+ # Update versions based on changesets
289289+ pnpm ci:version
290290+291291+ # Publish to npm
292292+ pnpm ci:publish
293293+ ```
294294+295295+### Backporting to v0 Branch
296296+297297+Clack maintains a stable `v0` branch alongside the main development branch. For maintainers who need to backport changes:
298298+299299+1. Label PRs that should be backported with the `backport` label
300300+2. After the PR is merged to `main`, manually cherry-pick the squashed commit into the `v0` branch:
301301+ ```bash
302302+ # Ensure you have the latest v0 branch
303303+ git checkout v0
304304+ git pull upstream v0
305305+306306+ # Cherry-pick the squashed commit from main
307307+ git cherry-pick <commit-hash>
308308+309309+ # Push the changes
310310+ git push upstream v0
311311+ ```
312312+3. CI is configured to run changesets from the `v0` branch, so release PRs will be opened automatically
313313+314314+The GitHub Actions are configured to cut releases from both the `main` and `v0` branches.
315315+316316+## Filing Issues
317317+318318+When reporting bugs or requesting features:
319319+320320+1. **Check existing issues** to avoid duplicates
321321+2. **Use the issue templates** to provide all necessary information
322322+3. **Be specific and clear** about what's happening and what you expect
323323+4. **Provide reproduction steps** - ideally a minimal example that demonstrates the issue
324324+5. **Include environment details** like OS, Node.js version, etc.
325325+326326+### Issue Types
327327+328328+When opening an issue, consider which category it falls into:
329329+330330+- **Bug Report**: Something isn't working as documented or expected
331331+- **Feature Request**: A suggestion for new functionality
332332+- **Documentation Issue**: Improvements or corrections to documentation
333333+- **Performance Issue**: Problems with speed or resource usage
334334+335335+## Style Guide
336336+337337+We use [Biome](https://biomejs.dev/) for linting and formatting. Your code should follow these standards:
338338+339339+```bash
340340+# To check formatting
341341+pnpm format
342342+343343+# To lint and fix issues automatically where possible
344344+pnpm lint
345345+```
346346+347347+The project follows standard TypeScript practices. If you're new to TypeScript:
348348+- Use precise types whenever possible
349349+- Avoid `any` unless absolutely necessary
350350+- Look at existing code for patterns to follow
351351+352352+### Commit Message Format
353353+354354+We follow conventional commits for commit messages:
355355+356356+- `feat:` - A new feature
357357+- `fix:` - A bug fix
358358+- `docs:` - Documentation changes
359359+- `style:` - Changes that don't affect code functionality (formatting, etc)
360360+- `refactor:` - Code changes that neither fix bugs nor add features
361361+- `perf:` - Performance improvements
362362+- `test:` - Adding or correcting tests
363363+- `chore:` - Changes to the build process, tools, etc
364364+365365+## License
366366+367367+By contributing, you agree that your contributions will be licensed under the project's MIT License.
368368+369369+Thank you for taking the time to contribute to Clack! Feel free to join our community Discord at [bomb.sh/chat](https://bomb.sh/chat). It's a great place to connect with other project contributors—we're chill!
370370+371371+## Acknowledgments
372372+373373+This contributing guide was inspired by and adapted from the [Astro Contributing Manual](https://github.com/withastro/astro/blob/main/CONTRIBUTING.md). We appreciate their excellent documentation and open source practices.