LaunchDarkly Developer Documentation

Get started in under 30 minutes.
LaunchDarkly provides feature flags as a service for Java · Python · Ruby · Go · Node.js · PHP · .NET. Control feature launches -- who sees what and when -- without multiple code deploys. Easy dashboard for phased rollouts, targeting and segmenting.
Need more help? write us at

Get Started    Documentation

Git code references

The Git code references feature allows you to find source code references to your feature flags within LaunchDarkly. This makes it easy to determine which projects reference your feature flags, and makes cleanup and removal of technical debt easy.

We've designed this feature so that LaunchDarkly does not need any direct access to your source code. It's also agnostic to which git hosting provider you use-- our approach makes it possible to push references to LaunchDarkly whether you're using GitHub, GitHub Enterprise, Bitbucket, Bitbucket Enterprise, Azure DevOps, GitLab, or any other Git code hosting tool.

We've open-sourced a utility called ld-find-code-refs that scans your Git repositories and pushes code reference information to LaunchDarkly. You can integrate this utility into your CI / CD process, or take advantage of other trigger mechanisms like GitHub Actions, cron jobs, or Lambda functions triggered by a commit webhook.

Creating an access token

The first step to configuring code references is to create a personal access token with writer-level access, or access to a custom role that includes the code-reference-repository resource specifier if custom roles are enabled on your account. To create a personal access token, visit the Access Tokens page.

You'll need to pass this token to the ld-find-code-refs utility, which we'll describe shortly.

Setting up code reference triggers

Next, you'll need to set up a mechanism to allow LaunchDarkly's ld-find-code-refs utility to run whenever you commit to your git repository.

We provide turnkey support for common trigger mechanisms and CI / CD providers. You can also invoke the ld-find-code-refs utility from the command line, which can be run in any custom workflow you define (e.g. from a bash script, or a cron job).


GitHub Actions

Bitbucket Pipes

CircleCI Orbs

Custom via CLI

Using code references

Once you've set up triggers for Code references, you'll be able to view your existing code references for your feature flags in the LaunchDarkly dashboard. To do so, visit the "Code references" tab on a feature flag's configuration page.

You may also view and edit your connected repositories on the Integrations page.

A repository may be toggled on or off to allow or disallow code reference triggers from pushing new data to the repository.

Note that if automated code reference updates are still connected when a repository connection is deleted, the connection will be recreated the next time an automated code reference trigger executes. So, be sure to remove any ld-find-code-refs triggers before deleting your repository connection.

Context Lines

By default, the ld-find-code-refs utility sends two lines of surrounding source context to LaunchDarkly (two lines of code above, and two lines below the actual reference).

Code references with context lines

Code references with context lines

Having a few lines of context can make it easier to understand why a feature flag is being referenced and how to remove it.

If you are sensitive to sending source context lines you can disable this feature when configuring ld-find-code-refs. If context lines are disabled, your code references will only show a code location (filename and line) as well as a link to that location in your Git hosting provider.

Code references with no context lines

Code references with no context lines

Managing code references

You can manage code references on the Integrations page for your project. Code references are organized into repositories, which are created automatically by the ld-find-code-refs tool. Once a repository appears on the integrations page, you can either temporarily disable it (preventing new code references from being added to LaunchDarkly), or delete all code references associated with the repository.

We do hard deletes for code reference data-- once you delete a repository, we will no longer have any record of the code reference or any source context lines.

Prior to deleting a repository, you should disable or remove the trigger that invokes the ld-find-code-refs tool on your repository, otherwise the repository (and your code references) will be re-populated the next time the trigger runs. If you're not sure how (or where) your trigger is invoked, you can also delete the personal access token used by your trigger.


The LaunchDarkly code references API asserts various limits to limit the number of "false positive" code references. ld-find-code-refs will log warning messages if any of these limits are exceeded. Some of these limits include:

  • Code references for flags with short keys (less than 3 characters) will not be scanned
  • A maximum of 5000 files containing code references will be scanned per repository. Additional files will be ignored.
  • A maximum of 500 characters is allowed per line of source code stored. Additional characters will be truncated.
  • A maximum of 5000 code references are allowed per repository. Additional code references will be ignored.
  • A maximum of 1000 code references are allowed per file. Additional code references will be ignored

If you've encountered any of these limits, or are noticing a large number of false positives being detected by ld-find-code-refs, we'd recommend configuring the exclude (or LD_EXCLUDE, in some configuration methods) argument with a regular expression matching the files and directories you'd like to exclude.

Git code references

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.