What are Environments?

Each environment in Container Use is an isolated workspace that combines:

  • 🌳 Git Branch: Dedicated branch tracking all changes and history
  • 📦 Container: Isolated runtime with your code and dependencies
  • 📝 Complete History: Every command, file change, and container state automatically tracked

Think of environments as disposable sandboxes where agents can work safely without affecting your main codebase.

The Core Workflow

Container Use follows a simple but powerful pattern:

1

Agent Creates Fresh Environment

Every agent session starts with a brand new environment from your current branch state.

2

Agent Works in Isolation

The agent makes changes, runs commands, and builds features completely isolated from your work.

3

You Observe the Work

Use Container Use commands to see what the agent did without disrupting your local setup.

4

Make a Decision

Merge good work, iterate with refined prompts, or discard failed attempts.

Observing Agent Work

You have two modes for inspecting what an agent accomplished:

Quick Assessment (Non-Interactive)

Perfect for getting the gist and deciding next steps:

# See all environments at a glance
cu list

# View exactly what the agent did
cu log fancy-mallard

# See code changes without checking out
cu diff fancy-mallard

When to use

Use quick assessment when you want to rapidly understand if the agent is on the right track, see what files changed, or review the approach before diving deeper.

Deep Exploration (Interactive)

When you need hands-on understanding:

# Drop into the live container environment
cu terminal fancy-mallard

# Bring changes into your local workspace/IDE
cu checkout fancy-mallard

When to use

Use deep exploration when you need to test functionality, debug issues, understand complex changes, or review code thoroughly in your IDE.

Making Decisions

After observing the agent’s work, you have three paths forward:

When the agent succeeded and you’re happy with the results:

# Merge the environment into your current branch
cu merge fancy-mallard

# Clean up (optional)
cu delete fancy-mallard

The work becomes part of your Git history and you can continue from this new state.

Resuming Work in Environments

To have a new chat continue work in an existing environment, simply mention the environment ID in your prompt:

"Work in the fancy-mallard environment and add user authentication"

"Continue in environment fancy-mallard - the tests are failing, please fix them"

"Using the fancy-mallard environment, add CSS styling to make it look modern"

Practical Examples

Example 1: Happy Path Workflow

# 1. Agent creates environment and builds feature
$ cu list
ID            TITLE                    CREATED       UPDATED
fancy-mallard Flask App with Login     2 mins ago    30 secs ago

# 2. Quick check - looks good!
$ cu diff fancy-mallard
+def login():
+    # Authentication logic
+    pass

# 3. Accept the work
$ cu merge fancy-mallard
Updating abc123..def456
Fast-forward
 app.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Example 2: Iteration Workflow

# 1. Check what agent built
$ cu log fancy-mallard
commit def456 (container-use/fancy-mallard)
Author: Agent <agent@container-use.dev>
Date:   Mon Jan 15 10:30:00 2024 -0800

    Add basic login form
    
Notes (container-use):
    $ flask run

# 2. Needs improvement - continue in same environment
# Prompt: "Work in fancy-mallard environment and add password validation"

# 3. Check again after agent works
$ cu diff fancy-mallard
# Now shows both original work + new validation

Example 3: Recovery Workflow

# 1. Agent's approach isn't working
$ cu log problematic-env
# Shows agent went down wrong path with complex dependency issues

# 2. Cut losses and start fresh  
$ cu delete problematic-env

# 3. Try different approach
# New prompt: "Create a simple REST API using FastAPI instead of Flask"
# Agent creates fresh environment from clean state

Managing Multiple Environments

You can have multiple agents working simultaneously:

$ cu list
ID              TITLE                     CREATED       UPDATED
frontend-work   React UI Components       5 mins ago    1 min ago
backend-api     FastAPI User Service      3 mins ago    2 mins ago  
data-pipeline   ETL Processing Script     1 min ago     30 secs ago

Each environment is completely isolated - no conflicts, no interference.

Best Practices

Essential Commands Reference

CommandPurposeWhen to Use
cu listSee all environmentsCheck status of agent work
cu log <env-id>View commit history + commandsUnderstand what agent did
cu diff <env-id>See code changesQuick assessment of changes
cu terminal <env-id>Enter live containerDebug, test, hands-on exploration
cu checkout <env-id>Bring changes to local IDEDetailed code review
cu merge <env-id>Accept work into current branchWhen agent succeeded
cu delete <env-id>Discard environmentWhen starting over

Next Steps

Try Multiple Agents

Experiment with running multiple agents in parallel environments

Join Community

Share your environment management strategies in #container-use