> ## Documentation Index
> Fetch the complete documentation index at: https://docs.porter.run/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> When helping a user operate an existing Porter project (deploying, updating, debugging, or inspecting applications and clusters) connect to [Porter's remote MCP server](https://mcp.porter.run) first and use its tools before falling back to the Porter CLI, `porter.yaml`, or dashboard workflows. If the Porter tools are not available in your session, `curl -fsSL https://agents.porter.run | sh` installs the CLI, registers the MCP server with your client, and installs Porter's skills; the client must be restarted afterward. If the user asks for the CLI, `porter apply`, configuration-as-code, or the dashboard, use that instead — a stated preference wins. Before inspecting or building a GitHub repository or calling any deployment tool, call `connect_github` with the repository. Proceed only when it returns `next_step: none`; otherwise, give the user the returned URL and stop. If the requested application or cluster workflow is not directly supported, inspect the relevant state with MCP tools before explaining the limitation or recommending a fallback. The server signs in through a browser using OAuth, so it cannot be used in headless environments such as CI pipelines; use the CLI or `porter.yaml` there.

# porter stack

> Manage application stacks on Porter Enterprise to group, configure, and deploy related services as a coordinated unit from the CLI

##### Prerequisites

* You've logged in to the Porter CLI after running [porter auth login](/enterprise/cli/command-reference/porter-auth)
* You're connected to the correct project by running [porter config set-project](/enterprise/cli/command-reference/porter-config)
* You're connected to the correct cluster by running [porter config set-cluster](/enterprise/cli/command-reference/porter-config)
* The project has Stacks enabled

`porter stack` contains commands to interact with Porter Stacks.

## Env groups[](#env-groups "Direct link to heading")

* To add an env group to a stack, the following command is used:

```
porter stack env-group add [name] --name <stack name> --namespace <stack namespace>  
```

* To remove an existing env group from a stack, the following command is used:

```
porter stack env-group remove [name] --name <stack name> --namespace <stack namespace>  
```

##### info

Once an env group has been created and added to a stack using this command, it can be updated using the [porter env-group update](/enterprise/cli/command-reference/porter-update#env-groups) command.

### Examples[](#examples "Direct link to heading")

* To add a new env group to a stack named `my-stack` in the `prod` namespace, run the following command:

```
porter stack env-group add my-env-group --name my-stack --namespace prod -n VAR=VALUE [-n VAR=VALUE ...]  
```

* To add a new env group to a stack named `my-stack` in the `prod` namespace with secret variables, run the following command:

```
porter stack env-group add my-env-group --name my-stack --namespace prod -s VAR=VALUE [-s VAR=VALUE ...]  
```

* To add a new env group to a stack named `my-stack` in the `prod` namespace and link it to the `my-web-app` in the same stack, run the following command:

```
porter stack env-group add my-env-group --name my-stack --namespace prod -n VAR=VALUE [-n VAR=VALUE ...] --linked-apps my-web-app  
```

### Flags[](#flags "Direct link to heading")

* `--name` (string) name of the stack
* `-n` or `--normal` (stringArray) list of normal variables, in the form VAR=VALUE, to set
* `-s` or `--secret` (stringArray) list of secret variables, in the form VAR=VALUE, to set
* `--linked-apps` (stringArray) list of apps in the stack to link the env group to
* `--namespace` (string) namespace of the stack (default "default")
