Skip to main content
4 min read

Usage

Usage

Command Groups​

StackGen CLI commands are grouped by purpose, such as Infrastructure Lifecycle Management, appStack Management, and authentication.

We've listed the grouping below:

ILM Commands​

CommandDescription
destroyTeardown your infrastructure
driftDetect and manage infrastructure drift
provisionInit and plan appStack IaC by default; add --apply to apply changes

appStack Management Commands​

CommandDescription
appstackManage appStacks for complex codegen
importImport infrastructure to StackGen (Terraform state)

Authentication Commands​

CommandDescription
loginAuthenticate the CLI (configure is an alias)
logoutClear token and project from local config
whoamiShow authenticated account and project

AI Commands​

CommandDescription
aiManage Aiden resources, workflows, sessions, and Knowledge Hubs

Other Commands​

CommandDescription
apiCall authenticated mothership HTTP APIs (paths, --service, --jq / --jsonpath)
policiesList, inspect, and upload organization policies
preferenceGet, set, and list preference keys (not listed in root stackgen -h)
projectRetrieve and manage projects within StackGen
resourceResource management commands
runExecute any tofu or terraform command
stateManage OpenTofu or Terraform state
uploadUpload custom modules and security rules

Additional Commands​

CommandDescription
completionGenerate the autocompletion script for the specified shell
helpHelp about any command
mcpStart the MCP stdio server for LLM integrations
versionPrints the version of the stackgen cli
note

stackgen generate still runs for project-level IaC generation, but it is not listed in root stackgen -h. Prefer stackgen appstack download-iac for a specific appStack. See generate.

Standalone CLIs​

These tools ship separately from the stackgen binary:

CLIDescription
terraform-importerImport existing Terraform configuration into StackGen
cloud2codeGenerate Terraform state files from cloud resources

Quick Commands​

Click to view

Help on Usage​

stackgen help

Enter the CLI Container​

docker run -it --rm -p 50525:50525 -v ~/.stackgen:/home/stackgen/.stackgen ghcr.io/stackgenhq/stackgen:latest
note

This will switch the terminal prompt to the StackGen CLI container where StackGen can be run.

Login or Configure Authentication​

stackgen login

You can also run stackgen configure (alias for stackgen login).

note

This will present you with a clickable link to copy and paste into your browser on your main machine to complete login.

Connect to a Repository​

export STACKGEN_GIT_AUTH_TOKEN={token with readonly access to desired repositories}

Create an appStack​

stackgen appstack create --appstack-name my-app --cloud-provider aws

Create from a template​

stackgen appstack list-templates
stackgen appstack create --template <template-uuid-or-name> --appstack-name my-app-from-template

List appStacks​

stackgen appstack list

Aliases: show, ls.

List template appStacks​

stackgen appstack list-templates

Download IaC for an appStack​

stackgen appstack download-iac --appstack <appStack-id-or-name> --destination <path/to/file.zip>
note

By default, the docker run command above creates a volume in /app/.stackgen in the container, so any files written there will be synced to ~/.stackgen on the host machine.

Provision (plan, or plan and apply)​

stackgen provision --appstack <appStack-id-or-name> -e <environment>
stackgen provision --appstack <appStack-id-or-name> -e <environment> --apply -v
stackgen provision --appstack <appStack-id-or-name> -e <environment> -S -F

Use -v when you want Terraform or OpenTofu stdout, including Outputs, printed after apply. See appStack Outputs.

Use -S / --security-scan to scan the plan against security policies. Add -F / --fail-on-violation to exit non-zero when violations are found (requires --security-scan).