This guide will help you get started with contributing to the Opik TypeScript SDK.

:::callout{intent="tip"}
Before you start, please review our general [Contribution Overview](https://www.comet.com/contributing/overview) and the [Contributor
License Agreement (CLA)](https://github.com/comet-ml/opik/blob/main/CLA.md).
:::

## Project Structure

The TypeScript SDK is located in the `sdks/typescript` directory. Here's an overview of the key files and directories:

- `src/`: Contains the main source code
- `tests/`: Contains test files
- `examples/`: Contains example usage of the SDK
- `package.json`: Project dependencies and scripts
- `tsconfig.json`: TypeScript configuration
- `tsup.config.ts`: Build configuration
- `vitest.config.ts`: Test configuration

## Setup

::::::steps{titleSize="h3"}
:::::step{title="Set up Opik Locally"}
To develop and test TypeScript SDK features, you'll need a local Opik instance running:

::::tabs
:::tab{title="Linux/Mac"}
```bash
# From the root of the repository
./opik.sh --port-mapping
```
:::

:::tab{title="Windows"}
```powershell
# From the root of the repository
.\opik.ps1 --port-mapping
```
:::
::::

**Note:** The `--port-mapping` flag exposes all service ports (including MySQL on 3306, ClickHouse on 8123, Redis on 6379) which is useful for debugging. The TypeScript SDK routes traffic through the API gateway (nginx) in the frontend service.

Your local Opik server will be accessible at `http://localhost:5173`.
:::::

:::step{title="Install dependencies"}
`bash cd sdks/typescript npm install `
:::

:::step{title="Build the SDK"}
`bash npm run build `
:::

:::step{title="Run tests"}
`bash npm test `
:::
::::::

## Development Workflow

::::steps{titleSize="h3"}
:::step{title="Create a new branch"}
Create a new branch for your changes
:::

:::step{title="Make your changes"}
Implement your changes
:::

:::step{title="Add tests"}
Add tests for new functionality
:::

:::step{title="Run test suite"}
Run the test suite to ensure everything works
:::

:::step{title="Build the SDK"}
Build the SDK to ensure it compiles correctly
:::

:::step{title="Submit PR"}
Submit a pull request
:::
::::

## Testing

We use Vitest for testing. Tests are located in the `tests/` directory. When adding new features:

::::steps{titleSize="h3"}
:::step{title="Write unit tests"}
Write unit tests for your changes
:::

:::step{title="Run tests"}
Ensure all tests pass with `npm test`
:::

:::step{title="Check coverage"}
Maintain or improve test coverage
:::
::::

## Building

The SDK is built using tsup. To build:

```bash
npm run build
```

This will create the distribution files in the `dist/` directory.

## Documentation

When adding new features or making changes:

::::steps{titleSize="h3"}
:::step{title="Update README"}
Update the README.md if necessary
:::

:::step{title="Add JSDoc"}
Add JSDoc comments for new functions and classes
:::

:::step{title="Add examples"}
Include examples in the `examples/` directory
:::

:::step{title="Update docs"}
Update the main documentation if necessary. See the [Documentation Guide](/guides/contributing-guides-documentation) for details.
:::
::::

## Code Style

We use ESLint for code style enforcement. The configuration is in `eslint.config.js`. Before submitting a PR:

::::steps{titleSize="h3"}
:::step{title="Run linter"}
Run `npm run lint` to check for style issues
:::

:::step{title="Fix issues"}
Fix any linting errors
:::

:::step{title="Check style"}
Ensure your code follows the project's style guidelines
:::
::::

## Pull Request Process

::::steps{titleSize="h3"}
:::step{title="Fork repository"}
Fork the repository
:::

:::step{title="Create branch"}
Create your feature branch
:::

:::step{title="Make changes"}
Make your changes
:::

:::step{title="Run checks"}
Run tests and linting
:::

:::step{title="Submit PR"}
Submit a pull request
:::
::::

Your PR should:

- Have a clear description of the changes
- Include tests for new functionality
- Pass all CI checks
- Follow the project's coding standards

## Need Help?

If you need help or have questions:

- Open an issue on GitHub
- Join our [Comet Chat](https://chat.comet.com) community
- Check the existing documentation

***

_Remember to review our [Contributor License Agreement (CLA)](https://github.com/comet-ml/opik/blob/main/CLA.md) before contributing._

## Related pages

- [Documentation](./contributing-guides-documentation.md)
- [Local Development Setup](./contributing-guides-local-development.md)
- [Python SDK](./contributing-guides-python-sdk.md)
- [Opik Optimizer](./contributing-guides-agent-optimizer-sdk.md)
- [Frontend](./contributing-guides-frontend.md)
- [Backend](./contributing-guides-backend.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
