Coding
PromptBeginner5 minmarkdown
Markdown Converter
Agent skill for markdown-converter
7
This document provides guidance for AI agents working with the `use-experiment` codebase.
Sign in to like and favorite skills
This document provides guidance for AI agents working with the
use-experiment codebase.
use-experiment is a lightweight React hook library that enables reactive feature toggles by reading from window.experiments. The library provides a simple API for components to respond to experiment flags without requiring providers or prop drilling.
useExperiment<T = boolean>(key: string, fallback?: T) - The primary exportwindow to track changes via the on-change librarywindow.experimentson-change for reactivity)tsup for buildingsrc/index.tsnpm run build # Build for production npm run dev # Build and watch for changes
When extending functionality:
While there are no tests in the current setup, when making changes:
on-change (for proxy-based change detection)react (16.8.0+, supporting hooks)typescript, tsup, @types/reactuse-experiment/ ├── src/ │ └── index.ts # Main hook implementation ├── dist/ # Built output (generated) ├── package.json # Package configuration ├── tsconfig.json # TypeScript configuration ├── README.md # User documentation └── AGENTS.md # This file
The hook must maintain this contract:
function useExperiment<T = boolean>( key: string, fallback?: T ): T;
fallback if window.experiments[key] is undefinedwindow.experiments[key] changesThis library is designed to work with:
window.experimentsBefore publishing:
package.jsonnpm run build to generate distribution filesdist/ contains .js, .cjs, and .d.ts filesfiles field in package.json includes distWhen contributing or making changes: