Usage
Usage
Command Groups
StackGen CLI commands are grouped by purpose, such as Infrastructure Lifecycle Management, appStack Management, and authentication.
Verified against StackGen CLI 0.81.0 (stackgen -h).
We've listed the grouping below:
ILM Commands
| Command | Description |
|---|---|
destroy | Teardown your infrastructure |
drift | Detect and manage infrastructure drift |
provision | Init and plan appStack IaC by default; add --apply to apply changes |
appStack Management Commands
| Command | Description |
|---|---|
appstack | Manage appStacks for complex codegen |
import | Import infrastructure to StackGen (Terraform state) |
Authentication Commands
| Command | Description |
|---|---|
login | Authenticate the CLI (configure is an alias) |
logout | Clear token and project from local config |
whoami | Show authenticated account and project |
AI Commands
| Command | Description |
|---|---|
ai | Guild Knowledge Hub upload, list, status, and delete |
Other Commands
| Command | Description |
|---|---|
policies | List, inspect, and upload organization policies |
preference | Get, set, and list preference keys (exists on CLI 0.81.0; not listed in root stackgen -h) |
project | Retrieve and manage projects within StackGen |
resource | Resource management commands |
run | Execute any tofu or terraform command |
state | Manage OpenTofu or Terraform state |
upload | Upload custom modules and security rules |
Additional Commands
| Command | Description |
|---|---|
completion | Generate the autocompletion script for the specified shell |
help | Help about any command |
mcp | Start the MCP stdio server for LLM integrations |
version | Prints the version of the stackgen cli |
stackgen generate still exists on CLI 0.81.0 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:
| CLI | Description |
|---|---|
| terraform-importer | Import existing Terraform configuration into StackGen |
| cloud2code | Generate 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
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).
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>
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
Use -v when you want Terraform or OpenTofu stdout, including Outputs, printed after apply. See appStack Outputs.