npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@hauses/flags-cli

v0.1.2

Published

CLI tool for Flags SDK to generate TypeScript type definitions

Readme

@hauses/flags-cli

CLI tool for Flags SDK to generate TypeScript type definitions from your feature flags.

🌐 Website: flags.hauses.dev

Installation

npm install -D @hauses/flags-cli
# or
yarn add -D @hauses/flags-cli
# or
pnpm add -D @hauses/flags-cli
# or
bun add -D @hauses/flags-cli

Features

  • 🎯 Type-safe - Generate TypeScript definitions for your flags
  • Fast - Quick flag fetching and type generation
  • 🔐 Secure - Multiple ways to provide API keys
  • 📝 Simple - One command to sync your flags
  • 🔄 CI-friendly - Works great in CI/CD pipelines

Quick Start

1. Add script to package.json

{
  "scripts": {
    "flags:pull": "flags-cli pull --env VITE_FLAGS_KEY --out src/flags.d.ts"
  }
}

2. Run the command

npm run flags:pull

This generates a flags.d.ts file with type definitions for all your flags.

Usage

Basic Command

flags-cli pull [options]

Options

  • -k, --key <key> - Publishable key (supports $VARIABLE syntax)
  • -e, --env <variable> - Environment variable name containing the key
  • -o, --out <path> - Output file path (default: ./flags.d.ts)
  • -V, --version - Output the version number
  • -h, --help - Display help information

Examples

Using Environment Variable Name

flags-cli pull --env VITE_FLAGS_KEY

This reads the key from the VITE_FLAGS_KEY environment variable.

Using $ Syntax

flags-cli pull --key $VITE_FLAGS_KEY

This also reads from the VITE_FLAGS_KEY environment variable.

Direct Key

flags-cli pull --key pk_123456789

⚠️ Not recommended for production - Use environment variables instead.

Custom Output Path

flags-cli pull --env FLAGS_KEY --out types/flags.d.ts

Multiple Commands

{
  "scripts": {
    "flags:dev": "flags-cli pull --env VITE_FLAGS_DEV_KEY --out src/flags.d.ts",
    "flags:prod": "flags-cli pull --env VITE_FLAGS_PROD_KEY --out src/flags.d.ts"
  }
}

Generated Output

The CLI generates a TypeScript declaration file that extends the SDK types:

import "react-sdk";

declare module "react-sdk" {
  export interface FlagValues {
    "dark-mode": boolean;
    "new-dashboard": boolean;
    "beta-features": boolean;
    "experimental-ui": boolean;
  }
}

This provides autocomplete and type checking in your IDE:

import { useFlags } from '@hauses/react-sdk';

// ✅ TypeScript knows about these flags
useFlags('dark-mode');
useFlags('new-dashboard');

// ❌ TypeScript error - flag doesn't exist
useFlags('unknown-flag');

Framework Integration

Vite

{
  "scripts": {
    "flags:pull": "flags-cli pull --env VITE_FLAGS_KEY"
  }
}
VITE_FLAGS_KEY=pk_your_key_here

Create React App

{
  "scripts": {
    "flags:pull": "flags-cli pull --env REACT_APP_FLAGS_KEY"
  }
}
REACT_APP_FLAGS_KEY=pk_your_key_here

Next.js

{
  "scripts": {
    "flags:pull": "flags-cli pull --env NEXT_PUBLIC_FLAGS_KEY"
  }
}
NEXT_PUBLIC_FLAGS_KEY=pk_your_key_here

Remix

{
  "scripts": {
    "flags:pull": "flags-cli pull --env VITE_FLAGS_KEY"
  }
}

CI/CD Integration

GitHub Actions

name: Update Flag Types

on:
  schedule:
    - cron: '0 */6 * * *' # Every 6 hours
  workflow_dispatch:

jobs:
  update-flags:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: '18'
      - run: npm install
      - run: npm run flags:pull
        env:
          VITE_FLAGS_KEY: ${{ secrets.FLAGS_KEY }}
      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v5
        with:
          commit-message: 'chore: update flag types'
          title: 'Update feature flag types'
          branch: update-flags

GitLab CI

update-flags:
  stage: update
  script:
    - npm install
    - npm run flags:pull
  artifacts:
    paths:
      - src/flags.d.ts
  only:
    - schedules

Pre-commit Hook

{
  "husky": {
    "hooks": {
      "pre-commit": "npm run flags:pull && git add src/flags.d.ts"
    }
  }
}

Development Workflow

1. Create flags in dashboard

Go to flags.hauses.dev and create your flags.

2. Pull types locally

npm run flags:pull

3. Use flags with type safety

const myFlag = useFlags('my-new-flag'); // Autocomplete works!

4. Commit the generated file

git add src/flags.d.ts
git commit -m "chore: update flag types"

Best Practices

1. Run before build

{
  "scripts": {
    "prebuild": "npm run flags:pull",
    "build": "vite build"
  }
}

2. Use environment variables

# ✅ Good
flags-cli pull --env VITE_FLAGS_KEY

# ❌ Bad - exposes key in command history
flags-cli pull --key pk_123456789

3. Add to .gitignore (optional)

If you prefer to generate types locally only:

# .gitignore
src/flags.d.ts

Or commit it for team consistency:

# Keep flags.d.ts in version control
git add src/flags.d.ts

4. Set up CI/CD

Automate flag type updates with scheduled workflows.

Troubleshooting

Error: Environment variable not set

❌ Error: Environment variable VITE_FLAGS_KEY is not set.

Solution: Make sure the environment variable exists:

echo $VITE_FLAGS_KEY

Error: Publishable Key is missing

❌ Error: Publishable Key is missing.

Solution: Provide the key using one of these methods:

flags-cli pull --key pk_123
flags-cli pull --env FLAGS_KEY
flags-cli pull --key $FLAGS_KEY

Error: Failed to fetch flags

❌ Error generating types: Failed to fetch flags: 401 Unauthorized

Solution: Check that your publishable key is valid and has the correct permissions.

Warning: No flags found

Warning: No flags found.
✅ Successfully generated types at ./flags.d.ts
Found 0 flags:

Solution: Create some flags in your dashboard at flags.hauses.dev.

API

Command: pull

Fetches flags from the API and generates TypeScript definitions.

flags-cli pull [options]

Options:

| Option | Alias | Description | Required | Default | |--------|-------|-------------|----------|---------| | --key <key> | -k | Publishable key | Yes* | - | | --env <variable> | -e | Environment variable name | Yes* | - | | --out <path> | -o | Output file path | No | ./flags.d.ts |

* Either --key or --env is required

Version

Check the CLI version:

flags-cli --version

Help

Display help information:

flags-cli --help
flags-cli pull --help

Related Packages

License

MIT

Support


Part of the Flags SDK monorepo.