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

# Save and switch environments

> Save your mock environment, scenarios and evals as a named environment you can commit, switch to and reproduce later.

An environment is a saved, named snapshot of your setup: the mock environment, the scenarios and the evals, together with the input files they were built from. You can commit it to git, keep several side by side (for example one per component under test), and switch between them without regenerating anything.

## Manage environments in chat

There is no slash command for environments. Say what you want in chat:

| Say | What happens |
| - | - |
| "save this as env `billing-happy`" | Saves the current input files and backend IDs to `plurai_sim/envs/billing-happy/` and makes it the active environment. |
| "switch to env `billing-happy`" | Makes that environment active and redeploys its mock environment by ID. Nothing is regenerated. |
| "list envs" | Shows every environment, which one is active, whether its mock environment is deployed, whether its scenarios and evals still exist, and whether its inputs drifted. |

Listing is read-only. It does not deploy or generate anything.

## What an environment holds

Each environment is a directory under `plurai_sim/envs/`. The directory name is a local alias.

```text theme={null}
plurai_sim/
  envs/
    billing-happy/
      plurai.env.yaml          # manifest: backend IDs and input fingerprints
      plurai.config.yaml
      simulation_prd.md
      scenario_variables.yaml
      scenario_state_schema.yaml
      eval_intent.yaml
      policies_config.yaml
      simulate.py
      ...
    refunds-edge/
      plurai.env.yaml
      ...
  .active-env                  # the active alias (local, gitignored)
  .mock_service_url            # the live mock environment URL (local, gitignored)
```

The `plurai.env.yaml` manifest records the backend handles the environment was built against (`env_id`, `scenario_set_id`, `eval_set_id`, `corpus_id`) and a content fingerprint of each input file. The `env_id` is the canonical key; the alias is only a name in your repo. Do not edit the manifest by hand.

An environment also owns its knowledge corpus, its trace brief and its uploaded documents. Switching environments switches all three.

> [!NOTE]
>
> If you save an environment before you build the suite, it has no mock environment yet. You can save it, but you can't switch to it until `/simulation-generate-suite` creates its mock environment.

## Switching

When you switch, the plugin:

**1. Checks for drift**

It compares each input file with the fingerprint in the manifest. If a file changed since the environment was built, it warns you, for example: `plurai.config.yaml changed since this env was generated — its mock, scenarios, and evals may be stale.` It does not block the switch.

**2. Redeploys the mock environment**

The mock environment definition is stored on the Plurai backend under its `env_id`, so the plugin brings it back up at the same stable URL, `https://<your-backend>/mock/<env_id>/`. If the definition no longer exists, it tells you, and `/simulation-generate-suite` builds a replacement.

**3. Checks the scenarios and evals still exist**

It warns you if a scenario set or eval set the manifest references was deleted on the backend.

**4. Makes the environment active**

It writes the environment's handles locally and reports the active environment and its mock environment URL.

Every command then works in the active environment's directory. A repo with no `plurai_sim/envs/` directory works in `plurai_sim/` directly.

## What to commit

After you save an environment, commit its directory:

```bash theme={null}
git add plurai_sim/envs/billing-happy/
```

Commit the manifest, the input files and the backend-identity markers (`.scenario_set_id`, `.eval_set_id`, `.corpus_id`, `.knowledge_bases` and the like), so a clone knows which backend sets it uses. Machine-local handles (`.active-env`, `.mock_service_url`, `.env_id`) and every directory of extracted customer content stay out of git.

`/simulation-scan-agent` maintains one managed block in your repo root's `.gitignore` that does this for you:

```gitignore theme={null}
# BEGIN plurai-simulation rev 11 (managed — edits inside are overwritten by /simulation-scan-agent)
**/plurai_sim/**/artifacts/*
!**/plurai_sim/**/artifacts/data_profile.md
!**/plurai_sim/**/artifacts/scenarios.md
!**/plurai_sim/**/artifacts/evals.md
!**/plurai_sim/**/artifacts/suite.json
!**/plurai_sim/**/artifacts/agent_findings.md
!**/plurai_sim/**/artifacts/fixes.md
!**/plurai_sim/**/artifacts/pre_generation_findings.md
!**/plurai_sim/**/artifacts/scan_contract.json
!**/plurai_sim/**/artifacts/verification.json
**/plurai_sim/**/rag_corpus/
**/plurai_sim/**/traces/
**/plurai_sim/**/doc_examples/
**/plurai_sim/**/scenario_bundle/
**/plurai_sim/**/trace_scenario_bundle/
**/plurai_sim/**/grounded_scenario_bundle/
**/plurai_sim/**/runs/
**/plurai_sim/**/bridge/runtime/node_modules/
**/plurai_sim/**/.*
!**/plurai_sim/**/.scenario_set_id
!**/plurai_sim/**/.eval_set_id
!**/plurai_sim/**/.corpus_id
!**/plurai_sim/**/.corpus_ids
!**/plurai_sim/**/.corpus_scope
!**/plurai_sim/**/.knowledge_bases
!**/plurai_sim/**/.doc_examples_set_id
!**/plurai_sim/**/.scenario_bundle_id
!**/plurai_sim/**/.document_fields
!**/plurai_sim/**/.workspace_id
!**/plurai_sim/**/.ledger_version
# END plurai-simulation
```

The patterns cover both a single `plurai_sim/` directory and the `plurai_sim/envs/<name>/` layout. Don't edit inside the block: the next scan overwrites it. If the block is missing or out of date, run `/simulation-scan-agent` again.

Also add `.plurai/` to your `.gitignore`. It holds local runtime state, including the upload audit log.

> [!WARNING]
>
> An environment keeps one anonymization posture. Once it has uploaded data with `anonymize: true` or `anonymize: false`, switching to the other posture is refused. Start a new environment instead. See [Data and privacy](https://docs.plurai.ai/security/data-and-privacy.md).

## Next steps

> [card] [Shape your simulation](https://docs.plurai.ai/guides/iterate.md)
>
> Change the mock environment, scenarios or evals, then save the result.

> [card] [Run unattended](https://docs.plurai.ai/guides/ci.md)
>
> Run a saved environment where nobody can answer questions.

> [card] [Configuration](https://docs.plurai.ai/reference/config.md)
>
> Every key in `plurai.config.yaml`.

> [card] [Build the suite](https://docs.plurai.ai/guides/build-the-suite.md)
>
> Create the mock environment an environment needs.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.