Overview
Flag definitions live in TypeScript or Go, reviewed in pull requests like any other code. The CLI readsshipd.config.ts or shipd.config.go directly. In this guide you add a boolean flag and a variant flag, then create both with shipd push.
Prerequisites
- The shared
@shipdit/cliinstalled (npm install -g @shipdit/cli), with Node.js 22.12+ to run it. TypeScript projects also installshipdit; Go definitions usegithub.com/alasti-company/useshipd.com/sdks/go/config; install the Go SDK when evaluating flags. shipd logincompleted, or a service account token inSHIPD_API_KEY. See Push permissions.
Define the flags
For TypeScript, createshipd.config.ts in the project root. For Go, create shipd.config.go in your module. The CLI finds its config by walking up from the current directory.
- The object key is the flag key your code reads.
defaultis what the environment you push to serves until you add rules.- In TypeScript, write
variantswithas const; invalid defaults fail type checking. Go validates defaults when you callConfig.Validate, orConfig.Defaults.
Go definitions
Flag definitions use theconfig package, which ships with the Go SDK:
shipd.config.go directly and generates Go accessors by default, unless typesLanguage overrides the output language. Define an exported var Config = config.ShipdConfig{...} in a self-contained Go file inside your module. The CLI evaluates that file with Go; imported packages and helper declarations in the same file are supported. It does not load sibling Go files, so keep application dependencies in imported packages. Use the same package name as other Go files in its directory; package main above assumes that directory is an application package. Do not define main in the definition file. shipd pull rewrites the Go definitions and regenerates accessors; review the resulting diff because comments and helper code are replaced.
Push
Output
What push did
- Created both flags in the project. Definitions (type, variants, description, tags) are shared by every environment.
- Enabled them in
development, the environment you pushed to, serving theirdefault. Other environments get the flags disabled until you configure them in the dashboard or push to them. - Wrote types to
src/generated/flags.ts, for TypeScript; Go projects configured above getinternal/flags/flags_gen.gowith per-flag accessors. See Generate flag types.
--prune, conflicts, and approvals, are in shipd push.
Next steps
Evaluate the flag
Read
new-checkout in your app.Push, pull, and diff
The everyday edit, diff, push loop.
Generate flag types
Use TypeScript types or generated Go accessors.
Sync flags in CI
Diff on pull requests, push on merge.
defineFlags and config files · CLI