# Code Contributions

Set up the CopilotKit monorepo, test a change, and open a pull request.

## Step 1: Install Prerequisites [#step-1-install-prerequisites]

- [Node.js](https://nodejs.org/en/) 20.x or later
- [pnpm](https://pnpm.io/) v10.x installed globally (`npm i -g pnpm@^10`)

## Step 2: Repository Setup [#step-2-repository-setup]

<Steps>
  <Step>
  ### Fork The Repository [#fork-the-repository]
  First, head over to the [CopilotKit repository](https://github.com/CopilotKit/CopilotKit) and create a fork.

Then, clone your fork to your local machine:

```bash
git clone https://github.com/<your-username>/CopilotKit
cd CopilotKit
```

  </Step>
  <Step>
  ### Install Dependencies [#install-dependencies]
  <Callout type="info">
    The CopilotKit repository is a monorepo using a [pnpm](https://pnpm.io/) workspace. Tasks across packages are orchestrated with [Nx](https://nx.dev/).
  </Callout>

Install the dependencies using pnpm:

```bash
pnpm install
```

  </Step>
  <Step>
  ### Build Packages [#build-packages]
  To make sure that everything works, build all packages once:
  ```bash
  pnpm run build
  ```
  </Step>
</Steps>

## Step 3: Development Mode [#step-3-development-mode]

Now that everything is set up and works as expected, you can get started developing:

```bash
# Start all packages in development mode
pnpm run dev

# Start a specific package in development mode
pnpm exec nx watch --projects=packages/package-name -- pnpm run build
```

Now you can start making changes to the code.

<Callout type="info">
  You can find all `@copilotkit/*` packages under the `packages` folder of the
  monorepo.
</Callout>

## Step 4: Test Changes in Real-Time [#step-4-test-changes-in-real-time]

Run an example from the `examples` folder. The examples use the monorepo packages, so they show your changes.

## Step 5: Formatting and Linting [#step-5-formatting-and-linting]

Before committing your changes, make sure your files are formatted properly by running the following at the root of the monorepo:

```bash
pnpm run format
```

Also, make sure that you have no linting errors:

```bash
pnpm run lint
```

## Step 6: Submit a Pull Request [#step-6-submit-a-pull-request]

Now that you've made your changes, commit and push them. Then, go to the [Pull Requests page](https://github.com/CopilotKit/CopilotKit/pulls) and create a pull request.

## Debugging [#debugging]

When you run CopilotKit on localhost, the CopilotKit Inspector is on by default. Use it to see agent state, context, and the tools the agent can call. See [Inspector and dev console](/troubleshooting/inspector-dev-console).

## (Advanced) Package Linking [#advanced-package-linking]

In some cases, you want to test your CopilotKit changes in your own project. For example, you tried to integrate CopilotKit into your own codebase and encountered a bug you want to fix.

Conveniently, you can link your local CopilotKit packages to your own project to test your changes.

Check out the [Advanced: Package Linking](/react-native/mastra/contributing/code-contributions/package-linking) guide to learn how to do that.

## Need help? [#need-help]

If you need help with anything, please don't hesitate to reach out to us on [Discord](https://discord.gg/6dffbvGU3D). We have a dedicated [#contributing](https://discord.com/channels/1122926057641742418/1183863183149117561) channel.
