On this page
Package strictcli is a strict, zero-dependency CLI framework for Go with mandatory help text, type-safe flags, groups, and schema export.
#go/strictcli
#go/strictcli
Package strictcli is a strict, zero-dependency CLI framework for Go with mandatory help text, type-safe flags, groups, and schema export.
#EffectReadOnly
const EffectReadOnly = "read_only"The two legal command classifications. There is no default: every command declares one through WithEffect, and a command registered without it is a registration-time hard error. Deprecated commands are exempt (no handler).
#EffectMutating
const EffectMutating = "mutating"#ProcMutate
const ProcMutate = "proc_mutate"Effect kinds. CacheWrite has NO public method: it is minted only by framework-internal code (schema dump, test-coverage shards and manifest) and is unreachable from application code.
#ProcSpawn
const ProcSpawn = "proc_spawn"#FileWrite
const FileWrite = "file_write"#NetMutate
const NetMutate = "net_mutate"#CacheWrite
const CacheWrite = "cache_write"#SourceCLI
const SourceCLI Source = iota // explicitly passed on the command line#SourceEnv
const SourceEnv Source = iota // from an environment variable#SourceConfig
const SourceConfig Source = iota // from a config file#SourceDefault
const SourceDefault Source = iota // from the flag's default value#SourceImplied
const SourceImplied Source = iota // injected by an Implies dependency#SourceInfra
const SourceInfra Source = iota // default resolved through a RelativeToRoot infra root#TypeStr
const TypeStr FlagType = iota#TypeBool
const TypeBool FlagType = iota#TypeInt
const TypeInt FlagType = iota#TypeFloat
const TypeFloat FlagType = iota#TypeListStr
const TypeListStr FlagType = listBit | TypeStrList types: a repeatable flag whose items are coerced to the element type.
#TypeListInt
const TypeListInt FlagType = listBit | TypeInt#TypeListFloat
const TypeListFloat FlagType = listBit | TypeFloat#TypeDictStr
const TypeDictStr FlagType = listBit | dictBit | TypeStrDict types: a repeatable key=value flag whose values are coerced to the value type.
#TypeDictInt
const TypeDictInt FlagType = listBit | dictBit | TypeInt#TypeDictFloat
const TypeDictFloat FlagType = listBit | dictBit | TypeFloat#CheckContext
type CheckContext interfaceCheckContext provides project context to check implementations.
#ConnectionEnvReader
type ConnectionEnvReader interfaceConnectionEnvReader is an OPTIONAL capability a CheckContext may expose: the value of a declared connection env (WithConnectionEnv), read live -- EXCEPT under --hermetic, where it resolves as absent ("", false) so a check can skip visibly instead of connecting. The check command wraps the tool-supplied CheckContext in a value that satisfies this interface, backed by the app's declared connection envs and the invocation's hermetic state. Checks that need a connection URL type-assert the context to this interface:
if r, ok := ctx.(strictcli.ConnectionEnvReader); ok { dsn, present := r.ConnectionEnvValue("DATABASE_URL") ... }
IsHermetic reports whether the invocation ran under --hermetic. It exists so a check can DISTINGUISH the two cases that ConnectionEnvValue's present=false otherwise conflates: "--hermetic suppressed the connection env" vs "the env var is simply unset". A check that layers config fallbacks below the env must honor hermetic even when the env is unset -- otherwise it falls through to a config URL and connects, violating the hermetic guarantee. The pattern is:
dsn, present := r.ConnectionEnvValue("DATABASE_URL") if !present { if r.IsHermetic() { return rep.Skipped("hermetic: connection suppressed") } // env unset but not hermetic -- config fallback is allowed here }
#CheckOutcome
type CheckOutcome structCheckOutcome is the ceiling-typed result of a check implementation. Its fields are unexported so callers cannot forge one: a valid CheckOutcome is obtained ONLY through reporter methods (Passed/Skipped/Found). The zero value has minted=false and is rejected by the runner (belt-and-braces against an impl that returns something a reporter did not mint).
#WarnReporter
type WarnReporter structWarnReporter is handed to warn-severity check impls. It can mint warn-severity problems and terminal outcomes but structurally LACKS error-minting: there is no Error method in its method set, so an attempt to raise an error-severity problem from a warn check fails to compile.
#ErrorReporter
type ErrorReporter structErrorReporter is handed to error-severity check impls. It has everything WarnReporter has PLUS Error (mints an error-severity problem).
#CheckSpecMeta
type CheckSpecMeta structCheckSpecMeta carries the declarative metadata of a provider-sourced check, mirroring the fields of a [checks.
#CheckSpec
type CheckSpec structCheckSpec is a fully-formed, ceiling-typed check produced by a provider. It is opaque: construct one ONLY via NewErrorCheckSpec / NewWarnCheckSpec, which bind the reporter form to the severity so the impl cannot mint a problem its declared severity forbids.
#RunChecksOptions
type RunChecksOptions structRunChecksOptions configures which checks to run and how to handle results.
#CheckRunResult
type CheckRunResult structCheckRunResult holds the outcome of running a single check. The verdict is derived from the minted CheckOutcome -- the runner's exit/cascade logic and the formatters all consume the same derived accessors (one source of truth).
#ConfigField
type ConfigField structConfigField describes a declared config file field.
#ConfigFieldOption
type ConfigFieldOption func(*ConfigField)ConfigFieldOption configures a ConfigField.
#Context
type Context structContext provides structured output and provenance for command handlers. It is constructed unconditionally for every dispatch and passed to the handler. Each output method writes to the appropriate stream (stdout or stderr).
#Grant
type Grant structGrant is a per-command, per-effect-kind authorization with a mandatory reason.
A grant is not permission to do something otherwise forbidden; it is a labelled reason that surfaces in the preview so a reviewer reading a dry run sees why a dangerous step is there.
#Forwarding
type Forwarding structForwarding declares that a handler deliberately accepts and forwards the app's global flag values. In Go the declaration is inert beyond the schema emission (guard v2's enforcement is Python-only, §10.3); it exists so the API surface stays in parity and consumers can label forwarding wrappers uniformly.
#Unsettled
type Unsettled structUnsettled is Go's VOID carrier: the value returned by write, mkdir, remove, rename and chmod in BOTH modes. It never carries a value, only a brand, and exists solely to give every Go effect method one uniform return shape. Its extractors panic in both modes, and it is never forwardable -- passing one into a later effect is a call-time hard error.
The [0]func() field makes the struct non-comparable: u == v is a compile error. That is the only compile-time protection Go can offer (§17).
#Completed
type Completed structCompleted is the result of a subprocess that ran to completion, and a settleable carrier. Stdout/Stderr are the child's output decoded as UTF-8 strictly with a single trailing newline removed -- the form that can be forwarded straight into a later effect's argv.
#Spawned
type Spawned structSpawned is a handle for a started-but-not-awaited child process, and a settleable carrier. It has NO scalar projection: forwarding a Spawned into a string position is a call-time hard error.
#Response
type Response structResponse is the result of an HTTP request, and a settleable carrier. Header names are lower-cased.
#EffectOption
type EffectOption structEffectOption is one trailing option on an effects-handle call. Its canonical snake_case name is what errEffectOptionNotAccepted renders, so the message is byte-identical across the three implementations even though the constructor is spelled Stream(bool).
#Effects
type Effects structEffects is the effects handle reached as ctx.Effects().
Exactly eight methods, and the set is CLOSED: there is no escape hatch that mints an unlisted effect, and CacheWrite has no public method at all.
#InvokeError
type InvokeError structInvokeError is returned by App.Call() when invocation fails (unknown command, missing flags, mutex violations, etc.).
#CallOption
type CallOption func(*callOptions)CallOption configures one App.Call. Go's Call takes its kwargs as a map, so consent cannot ride in them the way Python's keyword-only argument does -- it is a variadic option instead, which is this package's existing shape for "a declaration that is not data".
#Outcome
type Outcome structOutcome is the opaque, branded result of a command handler. It is constructed only via Exit or ExitData and carries an exit code plus, optionally, structured data. When data is present, the framework JSON-prints it to stdout as one compact line and makes it available to Test and Call.
#Source
type Source intSource represents where a flag value came from.
#FlagType
type FlagType intFlagType represents the type of a flag value. Scalar types: TypeStr, TypeBool, TypeInt, TypeFloat. Compound types encode the item/value type in the upper bits: list types = 0x100 | scalar, dict types = 0x200 | scalar.
#Flag
type Flag structFlag represents a --flag declaration.
#Arg
type Arg structArg represents a positional argument.
#FlagSet
type FlagSet structFlagSet is a reusable bundle of flags.
#MutexGroup
type MutexGroup structMutexGroup is a group of mutually exclusive flags. Exactly one must be provided.
#CoRequired
type CoRequired structCoRequired declares flags that must all appear together or none.
#Requires
type Requires structRequires declares that one flag depends on another being present.
#Implies
type Implies structImplies declares that providing one bool flag automatically sets another bool flag to a value. If the user explicitly provides a contradicting value for the target, it is a parse error.
#Dependency
type Dependency interfaceDependency is either a CoRequired, Requires, or Implies constraint.
#InfraRootPath
type InfraRootPath structInfraRootPath is an opaque marker produced by RelativeToRoot. It represents a filesystem path built from a declared infrastructure root (identified by its env var name) joined with zero or more path parts. Config-path markers resolve eagerly at construction; flag-default markers resolve when defaults are applied at parse time. A marker referencing an undeclared root is a registration-time hard error.
#PassthroughHandler
type PassthroughHandler func(ctx *Context, name string, args []string, globals map[string]interface{}) intPassthroughHandler is the handler type for passthrough commands.
#Command
type Command structCommand is a leaf command with a handler.
#Group
type Group structGroup is a container for nested commands and subgroups (arbitrary depth).
#Result
type Result structResult is returned by App.Test().
#App
type App structApp is the root CLI application.
#AppOption
type AppOption func(*App)AppOption configures an App.
#FlagOption
type FlagOption func(*Flag)FlagOption configures a Flag.
#ArgOption
type ArgOption func(*Arg)ArgOption configures an Arg.
#CmdOption
type CmdOption func(*Command)CmdOption configures a Command during registration.
#Tool
type Tool structTool is a descriptor for exposing CLI commands to tool-using LLM agents.
Effect and Consequential publish the effects-regime classification BESIDE the argument schema (never inside it): a consumer rendering this tool must be able to see that the command changes things and that calling it requires stating consent. Same vocabulary as the schema dump: Effect is mandatory, Consequential defaults to false.
#NewErrorCheckSpec
func NewErrorCheckSpec(meta CheckSpecMeta, impl func(CheckContext, *ErrorReporter) CheckOutcome) CheckSpecNewErrorCheckSpec builds an error-severity check spec. The impl receives an *ErrorReporter (which can mint both error- and warn-severity problems). The meta's Severity must be "error" -- a mismatch is a hard error at materialization (the provider analog of the TOML/register severity check).
#NewWarnCheckSpec
func NewWarnCheckSpec(meta CheckSpecMeta, impl func(CheckContext, *WarnReporter) CheckOutcome) CheckSpecNewWarnCheckSpec builds a warn-severity check spec. The impl receives a *WarnReporter, which structurally lacks error-minting: a warn check cannot cascade. The meta's Severity must be "warn".
#FormatCheckResults
func FormatCheckResults(results []CheckRunResult, verbose bool) stringFormatCheckResults formats check results as a human-readable string. Layout: the derived status label, name, and message, with minted problems listed under the check row grouped by severity (error problems first, then warn problems), each tagged with its severity. Problems are shown for fail/warn/skip outcomes or when verbose is true. No trailing newline -- callers use fmt.Println().
#FormatCheckResultsJSON
func FormatCheckResultsJSON(results []CheckRunResult) stringFormatCheckResultsJSON formats check results as a JSON array string. Each entry carries the derived status plus the minted problems (each with its severity and text). Empty problems serialize as [] rather than null. No trailing newline.
#ConfigFieldType
func ConfigFieldType(t FlagType) ConfigFieldOptionConfigFieldType sets the type for a config field (default: TypeStr).
#ConfigFieldHelp
func ConfigFieldHelp(help string) ConfigFieldOptionConfigFieldHelp sets the help text for a config field (required).
#ConfigFieldDefault
func ConfigFieldDefault(v interface{}) ConfigFieldOptionConfigFieldDefault sets the default value for a config field.
#Resource
func Resource(token string) EffectOptionResource declares an opaque resource token naming what the effect produces. Declared metadata only: it never gates, skips, orders or deduplicates anything.
#SkipIfCurrent
func SkipIfCurrent(token string) EffectOptionSkipIfCurrent declares a preview-only conditional annotation. In dry mode it renders a suffix on the log line; in real mode the effect executes unconditionally. There is no currency machinery of any kind behind it.
#UseGrant
func UseGrant(name string) EffectOptionUseGrant names a grant declared on the running command. Its kind must match the effect's kind.
#Cwd
func Cwd(dir string) EffectOptionCwd sets the working directory of a run or spawn.
#EffectEnv
func EffectEnv(env map[string]string) EffectOptionEffectEnv merges environment entries OVER the inherited environment, never replacing it.
Named EffectEnv rather than Env because the package already exports Env(varName string) FlagOption and Go has no overloading.
#Check
func Check(check bool) EffectOptionCheck opts a single call out of the "a failed operation is an error" rule: with Check(false) the result is returned with its real exit code / status and the handler decides.
#Stream
func Stream(stream bool) EffectOptionStream makes a run inherit stdout/stderr instead of capturing them; the returned Stdout/Stderr are then empty strings.
#Body
func Body(body []byte) EffectOptionBody sets an HTTP request body. A body is a payload, not a name: it is not a carrier-accepting position.
#Header
func Header(name, value string) EffectOptionHeader adds one HTTP request header. Repeat it for several headers.
#WithApproveConsequential
func WithApproveConsequential() CallOptionWithApproveConsequential is the caller's explicit consent on the programmatic path, the counterpart of the CLI's --approve-consequential. A command that declares itself consequential is refused without it; read-only and plain mutating commands are unaffected.
#Exit
func Exit(code int) OutcomeExit returns an Outcome that terminates the command with the given exit code and emits no data.
#ExitData
func ExitData(code int, data interface{}) OutcomeExitData returns an Outcome that terminates the command with the given exit code and emits data. The framework JSON-marshals data to stdout and captures it for programmatic callers (Test/Call). Data emission is possible ONLY through this constructor.
#IsScalarType
func IsScalarType(t FlagType) boolIsScalarType returns true for the four primitive types.
#IsListType
func IsListType(t FlagType) boolIsListType returns true for list compound types.
#IsDictType
func IsDictType(t FlagType) boolIsDictType returns true for dict compound types.
#IsCompoundType
func IsCompoundType(t FlagType) boolIsCompoundType returns true for any compound type (list or dict).
#ItemType
func ItemType(t FlagType) FlagTypeItemType returns the scalar element type for a compound type. For scalar types, returns the type itself.
#ListOf
func ListOf(itemType FlagType) FlagTypeListOf creates a list type from a scalar item type. Panics if the item type is not one of TypeStr, TypeInt, TypeFloat.
#DictOf
func DictOf(valueType FlagType) FlagTypeDictOf creates a dict type from a scalar value type. Panics if the value type is not one of TypeStr, TypeInt, TypeFloat.
#RelativeToRoot
func RelativeToRoot(envVar string, parts ...string) InfraRootPathRelativeToRoot returns a marker representing a path relative to a declared infrastructure root. envVar names the root (declared via WithInfraRoot); parts are joined onto the resolved root path. Accepted by flag Default(...) and WithConfigPathRelativeToRoot.
#WithEnvPrefix
func WithEnvPrefix(prefix string) AppOptionWithEnvPrefix sets the environment variable prefix for the app.
#WithConfig
func WithConfig() AppOptionWithConfig enables config file support.
#WithConfigPath
func WithConfigPath(path string) AppOptionWithConfigPath overrides the default config file path.
#WithConfigFormat
func WithConfigFormat(format string) AppOptionWithConfigFormat sets the config file format ("json" or "toml").
#WithNoDefaultConfigPath
func WithNoDefaultConfigPath() AppOptionWithNoDefaultConfigPath makes the app load NO config file unless --config is explicitly passed on the command line. Without this option (the default), the app loads from the XDG default path.
#WithConfigConflictMode
func WithConfigConflictMode(mode string) AppOptionWithConfigConflictMode sets the conflict resolution mode for config values. Valid values: "cli-wins" (default) and "error". In "error" mode, a flag set by both config AND cli (or config AND env) is a hard error. Implied sources are excluded from conflict checks.
#WithInfraRoot
func WithInfraRoot(envVar, defaultPath string) AppOptionWithInfraRoot declares an infrastructure location root: an env var that, when set, overrides defaultPath as the base directory for the tool's data. Multiple roots are allowed (keyed by env var name). Roots are resolved eagerly at construction and are immune to --hermetic (hermetic suppresses config and behavioral env, never location). A leading ~ in the value or default is expanded to the user's home directory.
#WithHandshakeEnv
func WithHandshakeEnv(envVar, help string) AppOptionWithHandshakeEnv declares a handshake env var: a cross-tool protocol signal set by the invoking process. It has no default and no resolution semantics beyond "read live at access time" via ctx.InfraValue.
#WithConnectionEnv
func WithConnectionEnv(envVar, help string) AppOptionWithConnectionEnv declares a connection env var: a behavioral "reach outside the process" signal such as a database or service connection URL. It is declared once at app level (name + help) and surfaced in --help and the schema dump alongside the other infrastructure env vars. Unlike roots and handshakes it is hermetic-SUPPRESSED: under --hermetic it resolves as absent. It has no default and is read lazily. Flags bind to it by reference via ConnectionURLFlag. A connection env must not collide with a declared root or handshake var, and duplicate declarations are a hard error.
#WithConfigPathRelativeToRoot
func WithConfigPathRelativeToRoot(envVar string, parts ...string) AppOptionWithConfigPathRelativeToRoot overrides the config file path with a location relative to a declared infrastructure root. The marker is resolved eagerly at construction into the absolute config path override.
#WithChecks
func WithChecks(path string) AppOptionWithChecks enables the check system with an explicit path to checks.toml.
#WithChecksEmbed
func WithChecksEmbed(data []byte) AppOptionWithChecksEmbed enables the check system with inline TOML data (e.g., from //go:embed).
#WithProcObserveAllowlist
func WithProcObserveAllowlist(prefixes [][]string) AppOptionWithProcObserveAllowlist declares app-level observe authorization: a list of argv PREFIXES, matched element-wise against the leading elements of an effect's argv by string equality. A ctx.Effects().Run whose argv matches any listed prefix is an observe -- it executes even in dry mode, returns a real value, and is never written to the would-do log.
#WithTestCoverage
func WithTestCoverage() AppOptionWithTestCoverage enables CLI test-coverage instrumentation. Every Test() and Call() invocation records the resolved command path to per-process shard files (.strictcli/coverage/
#Short
func Short(s string) FlagOptionShort sets the single-character short form for a flag.
#Default
func Default(v interface{}) FlagOptionDefault sets the default value for a flag.
#Env
func Env(varName string) FlagOptionEnv sets the environment variable name for a flag.
#Prefixed
func Prefixed(b bool) FlagOptionPrefixed controls whether env var prefix validation is applied.
#Choices
func Choices(vals ...interface{}) FlagOptionChoices sets the allowed values for a flag.
#Repeatable
func Repeatable() FlagOptionRepeatable marks a flag as accepting multiple occurrences.
#Unique
func Unique(b bool) FlagOptionUnique controls whether a repeatable flag rejects duplicate values.
#ConflictMode
func ConflictMode(mode string) FlagOptionConflictMode sets the per-flag config conflict mode, overriding the app-level default (WithConfigConflictMode). Must be "cli-wins" or "error". This applies only to flags; standalone ConfigFields have no CLI/env conflict surface, and a flag-colliding ConfigField inherits the flag's handling.
#ConnectionURLFlag
func ConnectionURLFlag(envVar string) FlagOptionConnectionURLFlag marks a flag as a connection-URL (URL-class) flag bound to the declared connection env named envVar (see WithConnectionEnv). The value resolves from the CLI token if present, else from the connection env (lazily, hermetic-suppressed), with no default. Binding to an env that was not declared via WithConnectionEnv is a registration-time hard error, as is marking a flag URL-class without a binding.
#EnvSeparator
func EnvSeparator(sep string) FlagOptionEnvSeparator sets the character used to split an env var value into multiple values for a repeatable flag (e.g., "," to split "a,b,c" into ["a","b","c"]).
#ValidateFn
func ValidateFn(fn func(interface{}) error) FlagOptionValidateFn sets a validation function for a flag.
#NegatableOpt
func NegatableOpt(b bool) FlagOptionNegatable controls whether a bool flag supports --no-X negation.
#ArgRequired
func ArgRequired(b bool) ArgOptionArgRequired sets whether an arg is required.
#ArgDefault
func ArgDefault(v interface{}) ArgOptionArgDefault sets the default value for an arg.
#Variadic
func Variadic() ArgOptionVariadic marks a positional argument as variadic (collects remaining values).
#ArgType
func ArgType(t FlagType) ArgOptionArgType sets the type for a positional argument.
#ArgChoices
func ArgChoices(vals ...interface{}) ArgOptionArgChoices sets the allowed values for a positional argument.
#WithArgs
func WithArgs(args ...Arg) CmdOptionWithArgs adds positional arguments to a command.
#WithFlags
func WithFlags(flags ...Flag) CmdOptionWithFlags adds flags to a command.
#WithFlagSets
func WithFlagSets(flagSets ...FlagSet) CmdOptionWithFlagSets adds flag sets (reusable flag bundles) to a command.
#WithMutex
func WithMutex(groups ...MutexGroup) CmdOptionWithMutex adds mutex groups to a command.
#WithDependencies
func WithDependencies(deps ...Dependency) CmdOptionWithDependencies adds dependency constraints to a command.
#WithPassthrough
func WithPassthrough(handler PassthroughHandler) CmdOptionWithPassthrough marks a command as passthrough (skips parsing, forwards raw args).
#WithHidden
func WithHidden() CmdOptionWithHidden marks a command as hidden (excluded from help but still routable).
#WithInteractive
func WithInteractive() CmdOptionWithInteractive marks a command as interactive (visible in help but excluded from tool export).
#WithEffect
func WithEffect(effect string) CmdOptionWithEffect declares a command's mandatory effect classification: either EffectReadOnly or EffectMutating. There is no default and nothing is inferred -- a command registered without it is a registration-time hard error, and so is a value that is neither constant.
A mutating command participates in dry mode and may call the mutating members of ctx.Effects(). A read_only command may not, and calling any mutating member is a hard error at call time. Classification does NOT decide whether a command prompts -- WithConsequential does (§8).
#WithConsequential
func WithConsequential() CmdOptionWithConsequential declares that a command's effects are worth interrupting someone for. It is the ONLY thing that makes the framework prompt (§8.1): a plain mutating command never does.
It is deliberately not mandatory. Classification answers "should a dry run record rather than execute?", which almost everything that touches anything answers yes to; consequentiality is a separate, much rarer judgement, and making it mandatory would push every registration to answer it reflexively.
Declaring it on a read_only command is a registration-time hard error: a command that changes nothing has nothing to confirm.
#WithDryRunUnsupported
func WithDryRunUnsupported(reason string) CmdOptionWithDryRunUnsupported declares that --dry-run is refused for this command, with a mandatory reason. It is the opt-out from the regime's baseline, where a mutating command's effects are recorded rather than executed under --dry-run.
Declare it when a preview would LIE: when the command's effects escape the effects handle, or when its later steps read state its earlier (recorded, therefore un-performed) steps would have written. A refusal that names the reason is honest; a preview that silently diverges from the real run is not.
The reason is mandatory and non-empty, and is shown both in the command's help and in the parse-time refusal. Declaring this on a read_only command is a registration-time hard error: a command that changes nothing has no effects a preview could misrepresent.
#WithGrants
func WithGrants(grants ...Grant) CmdOptionWithGrants declares per-effect-kind authorizations for a command. A grant is not permission to do something otherwise forbidden; it is a labelled reason that surfaces in the preview so a reviewer reading a dry run sees why a dangerous step is there.
#WithForwarding
func WithForwarding(reason string) CmdOptionWithForwarding declares that a handler deliberately accepts and forwards the app's global flag values. The reason is mandatory and non-empty, and is emitted in the schema so a consumer's audit gate can review every forwarding site. In Go the declaration is inert beyond the schema emission -- guard v2's enforcement is Python-only.
#WithConfigFields
func WithConfigFields(fields ...string) CmdOptionWithConfigFields binds config fields to a command. At startup, bound required config fields are validated to be present with correct types in the config file. Each field name must exist in app.configFields (validated at Run/Test time).
#WithTags
func WithTags(tags ...string) CmdOptionWithTags adds tags to a command.
#StringFlag
func StringFlag(name, help string, opts ...FlagOption) FlagStringFlag creates a string-typed flag.
#BoolFlag
func BoolFlag(name, help string, opts ...FlagOption) FlagBoolFlag creates a boolean-typed flag.
#IntFlag
func IntFlag(name, help string, opts ...FlagOption) FlagIntFlag creates an integer-typed flag.
#FloatFlag
func FloatFlag(name, help string, opts ...FlagOption) FlagFloatFlag creates a float-typed flag.
#ListFlag
func ListFlag(itemType FlagType, name, help string, opts ...FlagOption) FlagListFlag creates a list-typed flag. itemType must be TypeStr, TypeInt, or TypeFloat. List flags are automatically repeatable. The Unique option is supported. CLI usage: --flag val1 --flag val2 (each value coerced to itemType).
#DictFlag
func DictFlag(valueType FlagType, name, help string, opts ...FlagOption) FlagDictFlag creates a dict-typed flag. valueType must be TypeStr, TypeInt, or TypeFloat. Dict flags are automatically repeatable (multiple key=value pairs). CLI usage: --flag key=value --flag key2=value2 Also accepts JSON: --flag '{"key": "value"}'
#NewArg
func NewArg(name, help string, opts ...ArgOption) ArgNewArg creates a positional argument.
#NewApp
func NewApp(name, version, help string, opts ...AppOption) *AppNewApp creates a new CLI application.
#checkContextWithConn.ConnectionEnvValue
func (w checkContextWithConn) ConnectionEnvValue(envVar string) (string, bool)ConnectionEnvValue implements ConnectionEnvReader.
#checkContextWithConn.IsHermetic
func (w checkContextWithConn) IsHermetic() boolIsHermetic implements ConnectionEnvReader: reports whether the invocation ran under --hermetic. Mirrors the hermetic flag captured on the framework infra snapshot; false when no infra is present.
#reporterCore.Note
func (r *reporterCore) Note(text string)Note records an informational note. Non-empty text is required. Notes are allowed on EVERY outcome, including a pass -- they never cause the problems-present hard-errors that passed()/skipped() enforce. Notes are verdict-inert: they surface only under --verbose and in JSON output.
#reporterCore.Warn
func (r *reporterCore) Warn(text string)Warn mints a warn-severity problem. Non-empty text is required.
Reporter validation messages are worded identically to the Python implementation (method-agnostic phrasing, no "Warn:"/"warn:" prefix) so the two implementations are byte-for-byte in parity -- see conformance/ check_error_parity.py, which scans these panics.
#reporterCore.Passed
func (r *reporterCore) Passed(message string) CheckOutcomePassed finalizes a terminal PASS outcome. It hard-errors if any problems were accumulated (an impl that found problems cannot claim it passed -- use Found).
#reporterCore.Skipped
func (r *reporterCore) Skipped(reason string) CheckOutcomeSkipped finalizes a terminal SKIP outcome. It hard-errors if any problems were accumulated.
#reporterCore.Found
func (r *reporterCore) Found(message string) CheckOutcomeFound finalizes an outcome carrying the accumulated problems. It hard-errors when no problems were accumulated (nothing found means the check passed -- say so explicitly with Passed).
#ErrorReporter.Error
func (r *ErrorReporter) Error(text string)Error mints an error-severity problem. Non-empty text is required. This method exists only on ErrorReporter -- see the WarnReporter doc comment.
#App.RegisterCheckProvider
func (a *App) RegisterCheckProvider(provider func() []CheckSpec)RegisterCheckProvider registers a provider function that supplies check specs at materialization time. Registering a provider enables the check system (so a TOML-less app gains a working check command). Multiple providers may be registered; their specs are materialized in registration order. A registered provider is re-run whenever the registry is materialized fresh (first read or after a cwd change / ResetCheckProviderCache).
Reentrancy: a provider must not trigger check execution during materialization (e.g. by calling RunChecks or the check command). Doing so re-enters materialization while it is in progress -- behavior is undefined (unbounded recursion). A provider's job is to return specs, nothing else.
#App.ResetCheckProviderCache
func (a *App) ResetCheckProviderCache()ResetCheckProviderCache drops every provider-sourced definition and clears the materialization memo so the next registry read re-runs all providers. Intended for tests and long-lived singletons. It does NOT unregister the providers themselves.
#App.RunChecks
func (a *App) RunChecks(ctx CheckContext, opts RunChecksOptions) ([]CheckRunResult, []string, int, error)RunChecks executes checks programmatically and returns the executed results, the ordered names of checks left unexecuted by the purity partition, the exit code, and any error. The exit code follows the same rules as the check command: 0 for all pass (or warn with IgnoreWarnings), 1 for any failure/warn/cascade-skip. impureListed is empty unless opts.PureOnly is set; listed checks contribute nothing to the exit code (a consumer renders them as e.g. "would run:
#CheckRunResult.Status
func (r CheckRunResult) Status() stringStatus returns the derived label ("pass", "fail", "warn", "skip") used for display and JSON output.
#CheckRunResult.Gated
func (r CheckRunResult) Gated() boolGated reports whether the outcome carries an error-severity problem (derived FAIL). Cascade (skipping dependents) and the FAIL exit key on this predicate.
#CheckRunResult.Warned
func (r CheckRunResult) Warned() boolWarned reports whether the outcome carries only warn-severity problems (derived WARN). The --ignore-warnings predicate keys on this.
#App.ConfigField
func (a *App) ConfigField(name string, opts ...ConfigFieldOption)ConfigField declares a config field on the app. Panics on invalid configuration (programmer error).
#Context.DryRun
func (c *Context) DryRun() bool { return c.reserved.dryRun }DryRun reports whether the framework-owned --dry-run flag was passed.
#Context.ApproveConsequential
func (c *Context) ApproveConsequential() boolApproveConsequential reports whether the framework-owned --approve-consequential flag was passed.
#Context.Quiet
func (c *Context) Quiet() bool { return c.reserved.quiet }Quiet reports whether the framework-owned --quiet flag was passed.
#Context.Verbose
func (c *Context) Verbose() bool { return c.reserved.verbose }Verbose reports whether the framework-owned --verbose flag was passed.
#Context.Effects
func (c *Context) Effects() *EffectsEffects returns the effects handle for this run. Panics when the Context was constructed outside a command dispatch.
#Context.InfraValue
func (c *Context) InfraValue(envVar string) (string, bool)InfraValue returns the value of a declared infrastructure env var.
For a declared location root (WithInfraRoot), it returns the value resolved eagerly at construction (env var if set, else the declared default) and true. The resolved value is always available, so the boolean is always true for roots.
For a declared handshake var (WithHandshakeEnv), it reads the environment LIVE at call time (handshakes are set by the invoking process and carry no construction-time value), returning (value, isSet).
For a declared connection env (WithConnectionEnv), it reads the environment LIVE at call time and returns (value, isSet) -- EXCEPT under --hermetic, where it resolves as absent ("", false) so connection-dependent behavior skips visibly instead of connecting.
Panics if envVar is not a declared root, handshake, or connection var -- declare everything.
#Context.ConnectionEnvValue
func (c *Context) ConnectionEnvValue(envVar string) (string, bool)ConnectionEnvValue returns the value of a declared connection env (WithConnectionEnv), read LIVE at call time -- EXCEPT under --hermetic, where it resolves as absent ("", false). Panics if envVar is not a declared connection env. This is the check-side and handler-side accessor for the connection-URL kind; see also InfraValue, which resolves all three kinds.
#Context.Info
func (c *Context) Info(msg string)Info writes an informational message to stdout (hidden under --quiet).
#Context.Warn
func (c *Context) Warn(msg string)Warn writes a warning message to stderr (never suppressed).
#Context.Debug
func (c *Context) Debug(msg string)Debug writes a debug message to stdout (shown only under --verbose). --quiet DOMINATES --verbose: passing both hides debug output.
#Context.Error
func (c *Context) Error(msg string)Error writes an error message to stderr (never suppressed).
#Context.Source
func (c *Context) Source(name string) stringSource returns the provenance source label for a flag. Returns one of: "cli", "env", "config", "default", "implied", "infra". ("infra" indicates the value came from a RelativeToRoot default resolved through a declared infrastructure root.) Panics if the flag name is not found.
#Unsettled.String
func (u Unsettled) String() string { panic(u.truncate()) }String panics: stringifying a carrier is extraction, not forwarding.
#Unsettled.Bytes
func (u Unsettled) Bytes() []byte { panic(u.truncate()) }Bytes panics: extraction.
#Unsettled.Int
func (u Unsettled) Int() int64 { panic(u.truncate()) }Int panics: extraction.
#Unsettled.Bool
func (u Unsettled) Bool() bool { panic(u.truncate()) }Bool panics: extraction (and branching).
#Completed.ExitCode
func (c Completed) ExitCode() intExitCode returns the child's exit status. Panics when unsettled.
#Completed.Stdout
func (c Completed) Stdout() stringStdout returns the child's captured stdout. Panics when unsettled.
#Completed.Stderr
func (c Completed) Stderr() stringStderr returns the child's captured stderr. Panics when unsettled.
#Spawned.PID
func (s Spawned) PID() intPID returns the child's process id. Panics when unsettled.
#Spawned.Wait
func (s Spawned) Wait(opts ...EffectOption) (Completed, error)Wait waits for the child and returns its Completed result. It honours Check(bool) and nothing else: with the default true a nonzero exit is an error, mirroring run's opt-out. Calling Wait on an unsettled Spawned is extraction and truncates.
#Response.Status
func (r Response) Status() intStatus returns the HTTP status code. Panics when unsettled.
#Response.Body
func (r Response) Body() []byteBody returns the raw response body. Panics when unsettled.
#Response.Header
func (r Response) Header(name string) stringHeader returns a response header by (case-insensitive) name. Panics when unsettled.
#Effects.Run
func (e *Effects) Run(argv []interface{}, opts ...EffectOption) (Completed, error)Run runs a subprocess to completion (PROC_MUTATE), or performs an observe when the argv matches an app-level proc_observe_allowlist prefix.
#Effects.Spawn
func (e *Effects) Spawn(argv []interface{}, opts ...EffectOption) (Spawned, error)Spawn starts a subprocess without waiting (PROC_SPAWN).
Spawning is itself an effect: a dry run RECORDS the spawn instead of performing it, which is why no cross-process mode token exists.
#Effects.Write
func (e *Effects) Write(path interface{}, content interface{}, opts ...EffectOption) (Unsettled, error)Write writes bytes to a path (FILE_WRITE).
#Effects.Mkdir
func (e *Effects) Mkdir(path interface{}, opts ...EffectOption) (Unsettled, error)Mkdir creates a directory, parents included; an already-existing directory is not an error.
#Effects.Remove
func (e *Effects) Remove(path interface{}, opts ...EffectOption) (Unsettled, error)Remove removes a file, a symlink or a directory tree recursively; a missing path is not an error.
#Effects.Rename
func (e *Effects) Rename(src interface{}, dst interface{}, opts ...EffectOption) (Unsettled, error)Rename moves/renames a path (FILE_WRITE).
#Effects.Chmod
func (e *Effects) Chmod(path interface{}, mode int, opts ...EffectOption) (Unsettled, error)Chmod changes a path's mode (FILE_WRITE). The mode renders in the log as leading-zero octal.
#Effects.HTTP
func (e *Effects) HTTP(method string, url interface{}, opts ...EffectOption) (Response, error)HTTP performs a network request (NET_MUTATE).
#App.EffectLog
func (a *App) EffectLog() []map[string]interface{}EffectLog returns the structured effect records of the most recent dispatch. Test-only surface, beside Test() and the provenance accessors.
#InvokeError.Error
func (e *InvokeError) Error() stringError returns the error message describing the invocation failure.
#App.Call
func (a *App) Call(commandPath string, kwargs map[string]interface{}, opts ...CallOption) (interface{}, error)Call invokes a command programmatically and returns its result.
Unlike invoke(), this is the public API. It returns an InvokeError for parse/validation errors instead of os.Exit, making it safe for programmatic use.
commandPath uses dot-separated segments: "deploy", "dns.zone.create". kwargs keys use underscored parameter names (e.g., "dry_run", not "--dry-run").
For passthrough commands, the special key "_args" must contain a []string of raw arguments to forward to the handler.
Returns:
- - For handlers that return ExitData: the data value
- - For handlers that return Exit: the exit code (int)
- - For passthrough handlers: the exit code (int)
Returns an InvokeError if invocation fails (unknown command, missing required flags, mutex violations, dependency errors, etc.).
#App.ServeMCP
func (a *App) ServeMCP()ServeMCP starts a JSON-RPC 2.0 server on stdin/stdout implementing the Model Context Protocol. It reads one JSON object per line from stdin and writes one JSON object per line to stdout. The server handles initialize, tools/list, and tools/call requests.
#App.DumpSchemaDict
func (a *App) DumpSchemaDict() map[string]interface{}DumpSchemaDict returns the app's full schema as a map, excluding project_id.
This is the public, CWD-free accessor for the schema. Unlike the --dump-schema flag (which writes .strictcli/schema.json and derives project_id from go.mod in the current working directory), this method reads only the in-memory App and performs no filesystem or CWD access, and cannot fail. The returned map is equivalent to the written schema file with the project_id field removed.
#App.SetExitHook
func (a *App) SetExitHook(fn func())SetExitHook registers a function to run immediately before Run's terminal os.Exit, after the handler has returned and the would-do log has been written.
Test-only surface, beside Test() and EffectLog(). Go has no stdlib at-exit facility and Run ends in os.Exit, so a caller that needs to read a post-dispatch diagnostic -- EffectLog() above all -- has no other seam. It gives Go what Python's atexit and Node's process.on("exit") give their harnesses for free. It changes no behavior: the hook runs after every observable output the run produces, and its own errors are the caller's.
#App.RegisterErrorCheck
func (a *App) RegisterErrorCheck(name string, fn func(CheckContext, *ErrorReporter) CheckOutcome)RegisterErrorCheck registers an error-severity check implementation for a check declared with severity = "error" in checks.toml. The impl receives an *ErrorReporter (which can mint both error- and warn-severity problems) and must return a CheckOutcome obtained from that reporter.
Panics if checks are not enabled, the name is not declared, it is already registered, or the declared severity is not "error" (see registerCheckImpl).
#App.RegisterWarnCheck
func (a *App) RegisterWarnCheck(name string, fn func(CheckContext, *WarnReporter) CheckOutcome)RegisterWarnCheck registers a warn-severity check implementation for a check declared with severity = "warn" in checks.toml. The impl receives a *WarnReporter, which structurally lacks error-minting: a warn check cannot produce an error-severity problem, so it can never cascade.
Panics under the same conditions as RegisterErrorCheck, with the severity cross-check requiring the declared severity to be "warn".
#App.SetCheckContext
func (a *App) SetCheckContext(factory func() CheckContext)SetCheckContext sets the factory function that provides CheckContext to check implementations.
#App.TagContract
func (a *App) TagContract(tag, requiresFlag string)TagContract declares that any command tagged with the given tag must have a flag with the given name. Validated at Run/Test time.
#App.Command
func (a *App) Command(name, help string, handler func(ctx *Context, kwargs map[string]interface{}) Outcome, opts ...CmdOption)Command registers a top-level command with the given name, help text, and handler.
#App.Passthrough
func (a *App) Passthrough(name, help string, handler PassthroughHandler, opts ...CmdOption)Passthrough registers a passthrough command (raw args, no parsing). Accepts CmdOptions for validation purposes (e.g., to detect invalid passthrough+flags).
It routes through the same single validated registration path as every other command -- there is no direct-Command-construction bypass left -- so a passthrough is classified with WithEffect like everything else.
#App.GlobalFlag
func (a *App) GlobalFlag(f Flag)GlobalFlag registers a global flag on the app.
#App.Group
func (a *App) Group(name, help string, tags ...string) *GroupGroup creates and registers a command group.
#Group.Group
func (g *Group) Group(name, help string, tags ...string) *GroupGroup creates and registers a child subgroup.
#Group.Command
func (g *Group) Command(name, help string, handler func(ctx *Context, kwargs map[string]interface{}) Outcome, opts ...CmdOption)Command registers a command within a group.
#App.Deprecated
func (a *App) Deprecated(name, message string, opts ...CmdOption)Deprecated registers a deprecated command on the app. Invoking a deprecated command prints the message to stderr and exits 1.
#Group.Deprecated
func (g *Group) Deprecated(name, message string, opts ...CmdOption)Deprecated registers a deprecated subcommand on the group. Invoking a deprecated subcommand prints the message to stderr and exits 1.
#App.Commands
func (a *App) Commands() map[string]*CommandCommands returns the registered top-level commands.
#App.Groups
func (a *App) Groups() map[string]*GroupGroups returns the registered command groups.
#App.GlobalFlags
func (a *App) GlobalFlags() []FlagGlobalFlags returns the registered global flags.
#App.DeprecatedCommands
func (a *App) DeprecatedCommands() map[string]stringDeprecatedCommands returns the deprecated command map (name -> message).
#Group.DeprecatedCommands
func (g *Group) DeprecatedCommands() map[string]stringDeprecatedCommands returns the deprecated subcommand map (name -> message).
#App.Run
func (a *App) Run()Run executes the CLI, reading from os.Args.
#App.Test
func (a *App) Test(argv []string) ResultTest runs the CLI with the given argv, capturing output and exit code.
#App.JsonSchema
func (a *App) JsonSchema(commandPath string) map[string]interface{}JsonSchema produces a JSON Schema parameters object for a command's flags and positional args.
commandPath is a dot-separated path to the command (e.g. "deploy" or "config.show").
Returns a JSON Schema object with "type": "object", "properties", "required", and "additionalProperties": false.
Panics if the command path is invalid or resolves to a group.
#App.AsTools
func (a *App) AsTools() []ToolAsTools exports non-hidden, non-interactive leaf commands as Tool descriptors. Returns a list of Tool objects, one per eligible command plus a router tool. Each tool's Execute function wraps App.Call().