This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
pnpm build- Build both core library and CLI using TypeScript and esbuildpnpm test- Run tests using Node.js native test runner with tsxpnpm typecheck- Type check using tsgo (TypeScript Native Preview)pnpm lint:check- Check code style with Biomepnpm lint:fix- Fix code style issues with Biome
pnpm cli:dev- Run CLI in development mode using tsxpnpm cli:prd- Run CLI in production mode from built dist
node --import tsx --test path/to/specific.test.ts- Run a single test file
FlagFrog is a feature flag management library with both a runtime API and a CLI tool for flag removal.
- Core Library (
src/core/): Runtime API for feature flagsHandler.ts- Conditional execution based on flag stateSwitcher.ts- Value switching based on flag stateRenderer.tsx- React component for conditional rendering
- CLI Tool (
src/cli/): AST-based flag management and removal- Uses ts-morph for TypeScript AST manipulation
- Commands:
list(find flag usage) andremove(remove flags from code)
- AST Context: The CLI creates a shared AST context using ts-morph Project for all file operations
- Use Cases Layer: Business logic is separated into
src/cli/usecases/ - Migrators: AST transformations in
src/cli/ast/migrators/handle code removal - Traversers: AST traversal utilities in
src/cli/ast/traversers/find flag usage
- Uses custom esbuild configuration in
build.ts - Builds both ESM and CJS formats for the core library
- CLI is built as a standalone executable with shebang
The CLI operates on glob patterns and uses ts-morph to:
- Parse TypeScript/JSX files into ASTs
- Find flag usages via traversers
- Apply transformations via migrators to remove flags
- Write modified code back to files
Example flag patterns the CLI handles:
flagHandler({ name: "FlagName", value: true/false, on: ..., off: ... })flagSwitcher({ name: "FlagName", value: true/false, on: ..., off: ... })<FlagRenderer name="FlagName" value={true/false} on={...} off={...} />