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.
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
- Node.js with TypeScript support
- LaunchDarkly SDK key with AI configuration access
- Claude Code with hooks enabled
-
Install dependencies:
npm install
-
Set your LaunchDarkly SDK key:
export LD_SDK_KEY="your-sdk-key-here"
-
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" } ] } ] } }
Create an AI Agent configuration in LaunchDarkly with the key you specify when running the hook. The model will be ignored.
The hook supports custom variables from two locations:
- Project-specific:
{cwd}/.launchdarkly/agent/variables.json - 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.
The hook sends the following context to LaunchDarkly for AI configuration evaluation:
session_id: Unique Claude session identifierremotes: Git remote URLs for the repositorybasename: Repository directory nameworkingDirectory: Current working directory path (marked as private attribute)
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.
The hook will evaluate your LaunchDarkly AI configuration and display any enabled instructions to Claude.
Chris Tarquini ctarquini@launchdarkly.com
ISC



