Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LaunchDarkly Claude Startup Hook

A Claude Code hook that integrates with LaunchDarkly's AI SDK to provide dynamic, feature-flagged instructions to Claude sessions based on repository context.

The instructions returned by the AI Agent Config will be added to your context on session start.

Overview

This hook runs at startup and uses LaunchDarkly's AI configuration system to deliver contextual instructions to Claude based on:

  • Git repository information
  • Working directory context
  • Session metadata
  • Custom variables from configuration files

Prerequisites

  • Node.js with TypeScript support
  • LaunchDarkly SDK key with AI configuration access
  • Claude Code with hooks enabled

Setup

  1. Install dependencies:

    npm install
  2. Set your LaunchDarkly SDK key:

    export LD_SDK_KEY="your-sdk-key-here"
  3. Configure in Claude Code: Add to your Claude Code hooks configuration:

     {
         "hooks": {
           "SessionStart": [
             {
               "matcher": "startup",
               "hooks": [
                 {
                   "type": "command",
                   "command": "node /path/to/launchdarkly-claude-startup-hook/index.ts your-ai-agent-config-key"
                 }
               ]
             }
           ]
         }
     }

Configuration

LaunchDarkly AI Configuration

Create an AI Agent configuration in LaunchDarkly with the key you specify when running the hook. The model will be ignored.

Variable Files

The hook supports custom variables from two locations:

  1. Project-specific: {cwd}/.launchdarkly/agent/variables.json
  2. Global: $XDG_CONFIG_HOME/launchdarkly/agent/variables.json (or ~/.config/launchdarkly/agent/variables.json)

Variables are merged with project-specific taking precedence. You can interpolate variables in the prompt/instrucitons field.

Context Provided to LaunchDarkly

The hook sends the following context to LaunchDarkly for AI configuration evaluation:

  • session_id: Unique Claude session identifier
  • remotes: Git remote URLs for the repository
  • basename: Repository directory name
  • workingDirectory: Current working directory path (marked as private attribute)

Usage

The hook automatically runs when Claude Code starts in a repository. If the LaunchDarkly configuration is enabled, the instructions will be displayed to Claude at startup.

Example: Repo-Specific instructions

Create a variation

prompt

Target by folder or remotes

Target a specific folder

Target by remotes

Prompt is added to the context

claude context

The hook will evaluate your LaunchDarkly AI configuration and display any enabled instructions to Claude.

Author

Chris Tarquini ctarquini@launchdarkly.com

License

ISC

About

Use LaunchDarkly AI Agent Configs to dynamically add context to your claude code session

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages