Code contributions are welcome! Whether you’re fixing bugs, adding features, or improving performance, your contributions help deliver a better developer experience for everyone.
Before submitting large new features or refactors, please first discuss your ideas in the forum. This ensures alignment with project goals and prevents duplicate work.This does not apply to bugfixes or small improvements, which you can contribute directly via pull requests. Be sure to link any relevant issues in your PR description. Use to automatically close issues when the PR is merged.New integrations should follow the integration guidelines.

Philosophy

Aim to follow these core principles for all code contributions:

Getting started

Quick fix: submit a bugfix

For simple bugfixes, you can get started immediately:
1

Fork the repository

Fork the LangChain or LangGraph repo to your personal GitHub account
2

Clone and setup

git clone https://github.com/your-username/name-of-forked-repo.git

# For instance, for LangChain:
git clone https://github.com/parrot123/langchainjs.git

# For LangGraph:
git clone https://github.com/parrot123/langgraphjs.git
# Inside your repo, install dependencies
pnpm install
# Create a build for all packages to resolve workspace dependencies
pnpm build
3

Create a branch

git checkout -b your-username/short-bugfix-name
4

Make your changes

Fix the bug while following our code quality standards
5

Add tests

Include unit tests that fail without your fix. This allows us to verify the bug is resolved and prevents regressions
6

Run build

Run the build command to ensure the package still builds properly
pnpm build
# or build a specific workspace package
pnpm --filter @langchain/core build
7

Run tests

Ensure all tests pass locally before submitting your PR
pnpm lint
pnpm test

# For bugfixes involving integrations, also run:
pnpm test:int

# Or run tests in a specific workspace package
cd libs/langchain-core
pnpm test
pnpm lint

# Or run tests for a specific package from the root of the repo
pnpm --filter @langchain/core test
pnpm --filter @langchain/core lint
8

Submit a pull request

Follow the PR template provided. If applicable, reference the issue you’re fixing using a closing keyword (e.g. Fixes #123).

Full development setup

For ongoing development or larger contributions:
1

Development environment

Set up your environment following our setup guide
2

Repository structure

Understand the repository structure and package organization
3

Development workflow

Learn our development workflow including testing, linting, and pre-commit hooks
4

Contribution guidelines

Review our contribution guidelines for features, bugfixes, and integrations

Development environment

Our JS/TS projects uses pnpm for dependency management. Make sure you have the latest version of pnpm installed, or run corepack enable (on Node 24+) to setup the required pnpm version.
Set up a development environment for the package(s) you’re working on:

Repository structure

LangChain is organized as a monorepo with multiple packages:

Core packages


Development workflow

Testing requirements

Directories are relative to the package you’re working in.
Every code change must include comprehensive tests.
1

Unit tests

Location: src/tests/FILENAME_BEING_TESTED.test.tsRequirements:
  • No network calls allowed
  • Test all code paths including edge cases
  • Use mocks for external dependencies
# Run the entire test suite
pnpm test
# Or run a specific test file
pnpm test src/tests/FILENAME_BEING_TESTED.test.ts
# Or run a specific test function
pnpm test -t "the test that should be run"
2

Integration tests

Integration tests require access to external services/ provider APIs (which can cost money) and therefore are not run by default.Not every code change will require an integration test, but keep in mind that we’ll require/ run integration tests separately as apart of our review process.Location: src/tests/FILENAME_BEING_TESTED.int.test.tsRequirements:
  • Test real integrations with external services
  • Use environment variables for API keys
  • Skip gracefully if credentials unavailable
pnpm test:int
3

Test quality checklist

  • Tests fail when your code is broken
  • Edge cases and error conditions are tested
  • Proper use of fixtures and mocks

Code quality standards

Quality requirements:
Required: Complete types for all functions
function processDocuments(
    docs: Document[],
    processor: DocumentProcessor,
    batchSize: number = 100
): ProcessingResult {
    // ...
}

Contribution guidelines

Backwards compatibility

Breaking changes to public APIs are not allowed except for critical security fixes.See our versioning policy for details on major version releases.
Maintain compatibility:

Bugfixes

For bugfix contributions:
1

Reproduce the issue

Create a minimal test case that demonstrates the bug. Maintainers and other contributors should be able to run this test and see the failure without additional setup or modification
2

Write failing tests

Add unit tests that would fail without your fix
3

Implement the fix

Make the minimal change necessary to resolve the issue
4

Verify the fix

Ensure that tests pass and no regressions are introduced
5

Document the change

Update docstrings if behavior changes, add comments for complex logic

New features

We aim to keep the bar high for new features. We generally don’t accept new core abstractions, changes to infra, changes to dependencies, or new agents/chains from outside contributors without an existing issue that demonstrates an acute need for them. In general, feature contribution requirements include:
1

Design discussion

Open an issue describing:
  • The problem you’re solving
  • Proposed API design
  • Expected usage patterns
2

Implementation

  • Follow existing code patterns
  • Include comprehensive tests and documentation
  • Consider security implications
3

Integration considerations

  • How does this interact with existing features?
  • Are there performance implications?
  • Does this introduce new dependencies?
We will reject features that are likely to lead to security vulnerabilities or reports.

Security guidelines

Security is paramount. Never introduce vulnerabilities or unsafe patterns.
Security checklist:

Testing and validation

Running tests locally

Before submitting your PR, ensure you have completed the following steps. Note that the requirements differ slightly between LangChain and LangGraph.
1

Unit tests

pnpm test
All unit tests must pass
2

Integration tests

pnpm test:int
(Run if your changes affect integrations)
3

Formatting

pnpm format
pnpm lint
Code must pass all style checks
4

PR submission

Push your branch and open a pull request. Follow the provided form template. Note related issues using a closing keyword. After submitting, wait, and check to ensure the CI checks pass. If any checks fail, address the issues promptly - maintainers may close PRs that do not pass CI within a reasonable timeframe.

Test writing guidelines

In order to write effective tests, there’s a few good practices to follow:
  • Encapsulate the test in a describe block that describes the component being tested
  • Use natural language to describe the test name
  • Be exhaustive with assertions
  • Only use snapshots for reasonably sized data objects
describe("DocumentProcessor", () => {
    it("Should handle empty document list", () => {
        const processor = new DocumentProcessor();
        const result = processor.process([]);

        expect(result.success).toBe(true);
        expect(result.processedCount).toBe(0);
        expect(result.errors).toHaveLength(0);
    });
});

Getting help

Our goal is to have the simplest developer setup possible. Should you experience any difficulty getting setup, please ask in the community slack or open a forum post.
You’re now ready to contribute high-quality code to LangChain!