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
| 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 |
generate | Generate IaC files and export to a directory |
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 |
Other Commands
| Command | Description |
|---|---|
policies | List, inspect, and upload organization policies |
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 |
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 APPCD_GIT_AUTH_TOKEN={token with readonly access to desired repositories}
Exporting a valid token allows stackgen appStack create to display your available repositories and branches for easier selection.
Create an appStack
stackgen appstack create
Create appStack Version
stackgen appstack create-version <name of appStack>
See create-version for flags and examples.
List appStacks
stackgen appstack show
Download or Generate IaC Files 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.