### Install container-use CLI Source: https://github.com/dagger/container-use/blob/main/README.md Installs the container-use CLI tool. Use the macOS Homebrew installation for recommended setup or the cross-platform script for other systems. ```sh # macOS (recommended) brew install dagger/tap/container-use ``` ```sh # All platforms curl -fsSL https://raw.githubusercontent.com/dagger/container-use/main/install.sh | bash ``` -------------------------------- ### Start documentation preview Source: https://github.com/dagger/container-use/blob/main/AGENT.md Start a local development server to preview documentation changes. This command should be run from the docs folder. ```bash mint dev ``` -------------------------------- ### Add Setup Command for Container Use Source: https://github.com/dagger/container-use/blob/main/docs/cli-reference.mdx Adds a command to be executed during the setup phase of Container Use. This is useful for installing dependencies. ```bash container-use config setup-command add "pip install -r requirements.txt" ``` -------------------------------- ### Start Development Server Source: https://github.com/dagger/container-use/blob/main/docs/README.md Run this command to start the local development server for the documentation site. The site automatically updates when the main branch changes. ```bash npx mint dev ``` -------------------------------- ### Manage Setup Commands Source: https://github.com/dagger/container-use/blob/main/docs/environment-configuration.mdx Add, list, remove, or clear setup commands that run after pulling the base image and before copying code. These are used for system-level dependencies. ```bash container-use config setup-command add "apt-get update && apt-get install -y build-essential" container-use config setup-command list container-use config setup-command remove "apt-get install -y build-essential" container-use config setup-command clear ``` -------------------------------- ### Clone Container Use Repository Source: https://github.com/dagger/container-use/blob/main/CONTRIBUTING.md Clone the repository to start development. Ensure you have Git installed. ```bash git clone git@github.com:dagger/container-use.git ``` -------------------------------- ### Install Container Use from Source Source: https://github.com/dagger/container-use/blob/main/docs/quickstart.mdx Builds and installs Container Use from its source code. This method requires Git and Go to be installed. Ensure the executable is moved to a directory in your system's PATH. ```sh git clone https://github.com/dagger/container-use.git cd container-use go build -o container-use ./cmd/container-use sudo mv container-use /usr/local/bin/ container-use version ``` -------------------------------- ### Install Bash Completion for Container Use Source: https://github.com/dagger/container-use/blob/main/docs/cli-reference.mdx Installs bash completion for Container Use by redirecting the output of the completion command to the appropriate directory. ```bash container-use completion bash > /etc/bash_completion.d/container-use ``` -------------------------------- ### Manage Container Use Configuration Source: https://github.com/dagger/container-use/blob/main/docs/cli-reference.mdx Provides subcommands for managing various aspects of environment configuration, including base images, setup commands, install commands, environment variables, secrets, and agent integration. ```bash container-use config show # Example: Display current configuration ``` ```bash container-use config import {environment-id} ``` ```bash container-use config base-image set {image} ``` ```bash container-use config base-image get ``` ```bash container-use config base-image reset ``` ```bash container-use config setup-command add {command} ``` ```bash container-use config setup-command remove {command} ``` ```bash container-use config setup-command list ``` ```bash container-use config setup-command clear ``` ```bash container-use config install-command add {command} ``` ```bash container-use config install-command remove {command} ``` ```bash container-use config install-command list ``` ```bash container-use config install-command clear ``` ```bash container-use config env set {key} {value} ``` ```bash container-use config env unset {key} ``` ```bash container-use config env list ``` ```bash container-use config env clear ``` ```bash container-use config secret set {key} {value} ``` ```bash container-use config secret unset {key} ``` ```bash container-use config secret list ``` ```bash container-use config secret clear ``` ```bash container-use config agent [agent] ``` -------------------------------- ### Container Use Command Shortcut Source: https://github.com/dagger/container-use/blob/main/README.md Demonstrates the command shortcut 'cu' for 'container-use'. Both commands function identically for starting the MCP server. ```sh cu stdio ``` -------------------------------- ### Manage Install Commands Source: https://github.com/dagger/container-use/blob/main/docs/environment-configuration.mdx Add, list, remove, or clear install commands that run after your code is copied into the environment. These are typically used for project-specific dependencies. ```bash container-use config install-command add "npm install" container-use config install-command list container-use config install-command remove "npm install" container-use config install-command clear ``` -------------------------------- ### Example container-use stdio ping request Source: https://github.com/dagger/container-use/blob/main/AGENT.md An example of sending a JSON-formatted ping request to container-use via stdio, with a 10-second timeout. ```bash echo '{"jsonrpc":"2.0","method":"ping","id":1}' | timeout 10 container-use stdio ``` -------------------------------- ### Recovery Workflow with container-use Source: https://github.com/dagger/container-use/blob/main/docs/environment-workflow.mdx Shows how to handle a problematic environment: checking logs, deleting the environment, and starting fresh with a new approach. ```bash # 1. Agent's approach isn't working $ container-use log problematic-env # Shows agent went down wrong path with complex dependency issues # 2. Cut losses and start fresh $ container-use 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 ``` -------------------------------- ### Troubleshoot Environment Creation Source: https://github.com/dagger/container-use/blob/main/docs/environment-configuration.mdx If environment creation fails, check logs using `container-use log ` and then remove the problematic command from setup commands, followed by adding a fixed version. ```bash container-use log container-use config setup-command remove "broken-command" container-use config setup-command add "fixed-command" ``` -------------------------------- ### Install Container Use with Shell Script Source: https://github.com/dagger/container-use/blob/main/docs/quickstart.mdx Installs Container Use on any platform using a shell script. Run `container-use version` to confirm the installation. ```sh curl -fsSL https://raw.githubusercontent.com/dagger/container-use/main/install.sh | bash container-use version ``` -------------------------------- ### Install Container Use with Homebrew Source: https://github.com/dagger/container-use/blob/main/docs/quickstart.mdx Installs Container Use on macOS using Homebrew. Run `container-use version` to confirm the installation. ```sh brew install dagger/tap/container-use container-use version # → confirms install ``` -------------------------------- ### Configure Goose via Interactive Setup Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Use the `goose configure` command to set up extensions interactively. You will be prompted to add `container-use stdio` as the command. ```sh goose configure ``` -------------------------------- ### Prompt Agent for Task Source: https://github.com/dagger/container-use/blob/main/docs/quickstart.mdx Example prompt to give to your agent to create a Flask hello-world app in Python. The agent will execute this task in an isolated environment. ```text "Create a Flask hello‑world app in Python." ``` -------------------------------- ### Start Container Use as MCP Server Source: https://github.com/dagger/container-use/blob/main/docs/cli-reference.mdx Initiates Container Use as an MCP (Model Context Protocol) server, primarily for agent integration. This command is typically configured in agent files rather than run directly. ```bash container-use stdio ``` -------------------------------- ### Set Default Configuration for Python Project Source: https://github.com/dagger/container-use/blob/main/docs/environment-configuration.mdx Configure the default environment for a Python project by setting the base image, system dependencies, project dependencies, and environment variables. This ensures new agent environments start with the correct setup. ```bash # Set the base image to Python 3.11 container-use config base-image set python:3.11 # Add setup commands for system dependencies container-use config setup-command add "apt-get update && apt-get install -y build-essential" # Add install commands for project dependencies container-use config install-command add "pip install -r requirements.txt" container-use config install-command add "pip install pytest black flake8" # Set environment variables container-use config env set PYTHONPATH /workdir container-use config env set DEBUG true # View your configuration container-use config show ``` -------------------------------- ### Manage Secrets Source: https://github.com/dagger/container-use/blob/main/docs/environment-configuration.mdx Set, list, unset, or clear secrets such as API keys and credentials. Refer to the secrets guide for detailed examples and types. ```bash container-use config secret set API_KEY container-use config secret list container-use config secret unset API_KEY container-use config secret clear ``` -------------------------------- ### Common container-use stdio requests Source: https://github.com/dagger/container-use/blob/main/AGENT.md Examples of common JSON-RPC requests for testing the container-use stdio interface. ```json {"jsonrpc":"2.0","method":"ping","id":1} ``` ```json {"jsonrpc":"2.0","method":"tools/list","id":1} ``` ```json {"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{}}},"id":1} ``` -------------------------------- ### Manage Base Image Configuration Source: https://github.com/dagger/container-use/blob/main/docs/environment-configuration.mdx Set, get, or reset the base image for your project environment. Resetting reverts to the default 'ubuntu:24.04'. Consider versioned tags for custom images to improve cache behavior. ```bash container-use config base-image set python:3.11 container-use config base-image get container-use config base-image reset # Resets to ubuntu:24.04 ``` -------------------------------- ### Monitoring Workflow with Container Use Source: https://github.com/dagger/container-use/blob/main/docs/cli-reference.mdx Describes a monitoring workflow using Container Use, which involves starting to watch for changes and then viewing logs for specific environments. ```bash # 1. Start watching container-use watch ``` ```bash # 2. Agent works in background... # 3. See specific environment container-use log active-env ``` -------------------------------- ### View Environment Log Source: https://github.com/dagger/container-use/blob/main/docs/environment-workflow.mdx Inspect the exact actions an agent took within a specific environment. This helps in understanding the agent's process without making any changes to your local setup. ```bash # View exactly what the agent did container-use log fancy-mallard ``` -------------------------------- ### Set 1Password Secrets Source: https://github.com/dagger/container-use/blob/main/docs/secrets.mdx Configure secrets from 1Password vaults using the 'op://' schema. Requires the 1Password CLI to be installed and authenticated. ```bash container-use config secret set API_KEY "op://vault/item/field" container-use config secret set DB_PASSWORD "op://production/database/password" container-use config secret set JWT_SECRET "op://team-vault/auth-service/jwt_secret" ``` -------------------------------- ### Charm Crush MCP Configuration Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Add this JSON configuration to your Charm Crush setup to enable container-use MCP functionality. It specifies the command, arguments, and necessary environment permissions. ```json { "$schema": "https://charm.land/crush.json", "mcp": { "container-use": { "type": "stdio", "command": "container-use", "args": ["stdio"], "env": {} } }, "permissions": { "allowed_tools": [ "mcp_container-use_environment_add_service", "mcp_container-use_environment_checkpoint", "mcp_container-use_environment_config", "mcp_container-use_environment_create", "mcp_container-use_environment_file_delete", "mcp_container-use_environment_file_edit", "mcp_container-use_environment_file_list", "mcp_container-use_environment_file_read", "mcp_container-use_environment_file_write", "mcp_container-use_environment_open", "mcp_container-use_environment_run_cmd", "mcp_container-use_environment_update_metadata" ] } } ``` -------------------------------- ### Cline MCP Server Configuration Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Configure the container-use MCP server within your Cline setup. This JSON snippet defines the server type, command, and other relevant settings. ```json { "mcpServers": { "container-use": { "disabled": false, "timeout": 60000, "type": "stdio", "command": "container-use", "args": ["stdio"], "env": {}, "autoApprove": [] } } } ``` -------------------------------- ### Initialize Demo Repository Source: https://github.com/dagger/container-use/blob/main/docs/quickstart.mdx Sets up a new directory named 'hello' as a Git repository with an initial commit. This is a prerequisite for running the first parallel task. ```sh mkdir hello cd hello git init touch README.md git add README.md git commit -m "initial commit" ``` -------------------------------- ### Build and Run Flask App in Dagger Source: https://github.com/dagger/container-use/blob/main/examples/parallel.md Builds a Docker image for a Flask 'hello world' app and runs it, outputting its URL. Requires a Dockerfile. ```Go package main import ( "context" "fmt" "dagger.io/dagger" ) func main() { ctx := context.Background() // Initialize Dagger client client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) // Use os.Stderr for logs if err != nil { panic(err) } // Get Dagger client d, err := client.Container().From("python:3.11-slim"). WithExec([]string{ "pip", "install", "flask" }). File("/usr/local/lib/python3.11/site-packages/flask/__init__.py"). Contents(ctx) if err != nil { panic(err) } fmt.Println(string(d)) } ``` -------------------------------- ### Build and Run FastAPI App in Dagger Source: https://github.com/dagger/container-use/blob/main/examples/parallel.md Builds a Docker image for a FastAPI 'hello world' app and runs it, outputting its URL. Requires a Dockerfile. ```Go package main import ( "context" "fmt" "dagger.io/dagger" ) func main() { ctx := context.Background() // Initialize Dagger client client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) // Use os.Stderr for logs if err != nil { panic(err) } // Get Dagger client d, err := client.Container().From("python:3.11-slim"). WithExec([]string{ "pip", "install", "fastapi uvicorn" }). File("/usr/local/lib/python3.11/site-packages/fastapi/__init__.py"). Contents(ctx) if err != nil { panic(err) } fmt.Println(string(d)) } ``` -------------------------------- ### Build and export with Dagger Source: https://github.com/dagger/container-use/blob/main/AGENT.md Build the container-use application and export it to a specified path using Dagger. ```bash dagger call build export --path ./container-use ``` -------------------------------- ### List All Environments Source: https://github.com/dagger/container-use/blob/main/docs/environment-workflow.mdx Use this command to see all available environments at a glance. This is useful for quick assessment before diving into specific environments. ```bash # See all environments at a glance container-use list ``` -------------------------------- ### Basic Container Use Workflow Source: https://github.com/dagger/container-use/blob/main/docs/cli-reference.mdx Demonstrates a typical workflow for managing environments using Container Use, including listing, diffing, checking out, and merging changes. ```bash # 1. List environments container-use list ``` ```bash # 2. Review changes container-use diff clever-dolphin ``` ```bash # 3. Check out locally container-use checkout clever-dolphin ``` ```bash # 4. Accept work container-use merge clever-dolphin ``` -------------------------------- ### Managing Multiple Environments with container-use Source: https://github.com/dagger/container-use/blob/main/docs/environment-workflow.mdx Demonstrates listing multiple active environments, highlighting their isolation and independence. ```bash $ container-use 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 ``` -------------------------------- ### Display Container Use Version Source: https://github.com/dagger/container-use/blob/main/docs/cli-reference.mdx Shows the current version information for the Container Use CLI. ```bash container-use version ``` -------------------------------- ### Run Go tests Source: https://github.com/dagger/container-use/blob/main/AGENT.md Execute all Go tests for the project. Use the -short flag for unit tests only. ```bash go test ./... ``` ```bash go test -short ./... ``` -------------------------------- ### Build Container Use with Go Source: https://github.com/dagger/container-use/blob/main/CONTRIBUTING.md Build the container-use binary using Go. This command compiles the code and outputs an executable file. ```bash go build -o container-use ./cmd/container-use ``` -------------------------------- ### Test container-use with Go Source: https://github.com/dagger/container-use/blob/main/CLAUDE.md Run all tests using 'go test ./...', unit tests only with '-short', or integration tests with '-count=1 -v ./environment'. Ensure tests are run from the appropriate directory. ```bash go test ./... ``` ```bash go test -short ./... ``` ```bash go test -count=1 -v ./environment ``` -------------------------------- ### Access API Key in Python Source: https://github.com/dagger/container-use/blob/main/docs/secrets.mdx Retrieve the API key from the environment variable 'API_KEY' and use it in an HTTP request header. Ensure the 'requests' library is installed. ```python import os import requests api_key = os.getenv("API_KEY") response = requests.get("https://api.example.com", headers={"Authorization": f"Bearer {api_key}"}) ``` -------------------------------- ### Discard Environment Source: https://github.com/dagger/container-use/blob/main/docs/environment-workflow.mdx Delete an environment to discard all changes made by the agent. This is useful when the agent's work has gone down the wrong path and you need to start fresh. ```bash # Discard the environment container-use delete fancy-mallard ``` -------------------------------- ### Manage Go dependencies Source: https://github.com/dagger/container-use/blob/main/AGENT.md Download Go module dependencies or tidy up the go.mod file. ```bash go mod download ``` ```bash go mod tidy ``` -------------------------------- ### List All Environments Source: https://github.com/dagger/container-use/blob/main/docs/cli-reference.mdx Lists all available development environments and their current status. Use `--no-trunc` to prevent output truncation or `-q` to display only environment IDs. ```bash container-use list ``` -------------------------------- ### Happy Path Workflow with container-use Source: https://github.com/dagger/container-use/blob/main/docs/environment-workflow.mdx Demonstrates a typical workflow: listing environments, checking code changes with diff, and merging the work. ```bash # 1. Agent creates environment and builds feature $ container-use list ID TITLE CREATED UPDATED fancy-mallard Flask App with Login 2 mins ago 30 secs ago # 2. Quick check - looks good! $ container-use diff fancy-mallard +def login(): + # Authentication logic + pass # 3. Accept the work (choose merge or apply) $ container-use merge fancy-mallard Updating abc123..def456 Fast-forward app.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) ``` -------------------------------- ### Build container-use with Go or Dagger Source: https://github.com/dagger/container-use/blob/main/CLAUDE.md Use 'go build' for direct compilation or 'dagger call build' for a Dagger-based build process. The Dagger command specifically exports the built binary to the specified path. ```bash go build -o container-use ./cmd/container-use ``` ```bash dagger call build --platform=current export --path ./container-use ``` -------------------------------- ### Iteration Workflow with container-use Source: https://github.com/dagger/container-use/blob/main/docs/environment-workflow.mdx Illustrates an iterative development process: checking agent's work with log, making improvements, and re-checking changes. ```bash # 1. Check what agent built $ container-use log fancy-mallard def4567a2 Add basic login form (30 minutes ago) $ 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 $ container-use diff fancy-mallard # Now shows both original work + new validation ``` -------------------------------- ### container-use config Source: https://github.com/dagger/container-use/blob/main/docs/cli-reference.mdx Manage default environment configurations. ```APIDOC ## `container-use config` Manage default environment configurations. ### Method POST ### Endpoint /container-use/config/{subcommand} ### Parameters #### Path Parameters - **subcommand** (string) - Required - The configuration subcommand to execute ### Subcommands #### Configuration Management - `show [environment-id]` - Display current configuration - `import {environment-id}` - Import configuration from an environment #### Base Image - `base-image set {image}` - Set default base image - `base-image get` - Show current base image - `base-image reset` - Reset to default base image #### Setup Commands - `setup-command add {command}` - Add setup command - `setup-command remove {command}` - Remove setup command - `setup-command list` - List setup commands - `setup-command clear` - Clear all setup commands #### Install Commands - `install-command add {command}` - Add install command - `install-command remove {command}` - Remove install command - `install-command list` - List install commands - `install-command clear` - Clear all install commands #### Environment Variables - `env set {key} {value}` - Set environment variable - `env unset {key}` - Unset environment variable - `env list` - List environment variables - `env clear` - Clear all environment variables #### Secrets - `secret set {key} {value}` - Set secret - `secret unset {key}` - Unset secret - `secret list` - List secrets - `secret clear` - Clear all secrets #### Agent Integration - `agent [agent]` - Configure MCP server for specific agent (claude, goose, cursor, etc.) ### Example ```bash container-use config show ``` ``` -------------------------------- ### Format Go code Source: https://github.com/dagger/container-use/blob/main/AGENT.md Format all Go code in the project. This should be run before committing changes. ```bash go fmt ./... ``` -------------------------------- ### Build Container Use with Dagger Source: https://github.com/dagger/container-use/blob/main/CONTRIBUTING.md Build the container-use binary using Dagger. This command leverages Dagger to build the binary for the current platform and exports it. ```bash dagger call build --platform=current export --path ./container-use ``` -------------------------------- ### Configure OpenCode Container Use MCP Server Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Add this JSON configuration to your `opencode.json` file to enable the container-use MCP server. Ensure the command is correctly set to `container-use stdio`. ```json { "$schema": "http://opencode.ai/config.json", "mcp": { "container-use": { "type": "local", "command": ["container-use", "stdio"], "enabled": true } } } ``` -------------------------------- ### Essential Commands Reference for container-use Source: https://github.com/dagger/container-use/blob/main/docs/environment-workflow.mdx A reference table for essential container-use commands, detailing their functionality. ```bash | | | | --- | --- | | `container-use list` | See all environments and their status | | `container-use watch` | Monitor environment activity in real-time as agents work | | `container-use log ` | View commit history and commands to understand what the agent did | | `container-use diff ` | Quick assessment of code changes | | `container-use terminal ` | Enter live container to debug, test, or explore | | `container-use checkout ` | Bring changes to local IDE for detailed review | | `container-use merge ` | Accept work preserving agent's commit history | | `container-use apply ` | Apply as staged changes to customize commits | | `container-use delete ` | Discard environment and start over | | `container-use config` | Configure default settings for new environments | | `container-use version` | Display version information | ``` -------------------------------- ### Zed Context Server Configuration Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Configure the context server for container-use in your Zed settings.json. This enables the agent to run locally and communicate via stdio. ```json "context_servers": { "container-use": { "enabled": true, "remote": false, "command": "container-use", "args": ["stdio"], "env": {}, "timeout": 300, }, } ``` -------------------------------- ### container-use list Source: https://github.com/dagger/container-use/blob/main/docs/cli-reference.mdx List all environments and their status. ```APIDOC ## `container-use list` List all environments and their status. ### Method GET ### Endpoint /container-use/list ### Parameters #### Query Parameters - `--no-trunc` (boolean) - Optional - Don't truncate output - `--quiet`, `-q` (boolean) - Optional - Only show environment IDs ### Output Example ``` 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 ``` ``` -------------------------------- ### Download Go Dependencies Source: https://github.com/dagger/container-use/blob/main/CONTRIBUTING.md Download project dependencies using Go modules. Requires Go 1.21+. ```bash go mod download ``` -------------------------------- ### Add Copilot Instructions Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Download and add the Copilot instructions file for container-use using curl. This is an optional step to enhance Copilot's understanding of the agent. ```sh curl --create-dirs -o .github/copilot-instructions.md https://raw.githubusercontent.com/dagger/container-use/main/rules/agent.md ``` -------------------------------- ### Format and Lint container-use Code Source: https://github.com/dagger/container-use/blob/main/CLAUDE.md Maintain code quality by running 'go fmt ./...' before committing and 'dagger call lint' to check for linting issues. These commands ensure code consistency and adherence to project standards. ```bash go fmt ./... ``` ```bash dagger call lint ``` -------------------------------- ### Enter Interactive Terminal Source: https://github.com/dagger/container-use/blob/main/docs/environment-workflow.mdx Access the live container environment for hands-on exploration. This is useful for debugging, testing functionality, or understanding complex changes interactively. ```bash # Drop into the live container environment container-use terminal fancy-mallard ``` -------------------------------- ### Resume Work in Existing Environment Source: https://github.com/dagger/container-use/blob/main/docs/environment-workflow.mdx Continue working in an existing environment by mentioning its ID in your prompt. The agent will reuse the container state, access previous work, and maintain dependencies. ```text "Work in the fancy-mallard environment and add user authentication" ``` ```text "Continue in environment fancy-mallard - the tests are failing, please fix them" ``` ```text "Using the fancy-mallard environment, add CSS styling to make it look modern" ``` -------------------------------- ### Run All Tests Source: https://github.com/dagger/container-use/blob/main/CONTRIBUTING.md Execute all unit and integration tests in the project. This ensures comprehensive test coverage. ```bash go test ./... ``` -------------------------------- ### View Agent Configurations Source: https://github.com/dagger/container-use/blob/main/docs/environment-configuration.mdx View the default project configuration or an agent's modified configuration. Use the --json flag to output the configuration in JSON format. ```bash # View your default configuration container-use config show # View an agent's modified configuration container-use config show fancy-mallard # Output as JSON container-use config show --json ``` -------------------------------- ### Checkout Environment Changes Source: https://github.com/dagger/container-use/blob/main/docs/environment-workflow.mdx Bring an agent's changes into your local workspace or IDE for thorough review and integration. This allows for detailed code inspection and further development. ```bash # Bring changes into your local workspace/IDE container-use checkout fancy-mallard ``` -------------------------------- ### Set Base Image for Container Use Source: https://github.com/dagger/container-use/blob/main/docs/cli-reference.mdx Configures the default base image for Container Use. Use this to specify a particular version of a language runtime. ```bash container-use config base-image set python:3.11 ``` -------------------------------- ### Configure Kiro MCP Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Add this JSON configuration to `.kiro/settings/mcp.json` in your project root to set up the container-use MCP server. It allows for environment variables, disabling the server, and auto-approving actions. ```json { "mcpServers": { "container-use": { "command": "container-use", "args": ["stdio"], "env": {}, "disabled": false, "autoApprove": {} } } } ``` -------------------------------- ### container-use checkout Source: https://github.com/dagger/container-use/blob/main/docs/cli-reference.mdx Check out an environment's branch locally to explore in your IDE. ```APIDOC ## `container-use checkout` Check out an environment's branch locally to explore in your IDE. ### Method POST ### Endpoint /container-use/checkout/{environment-id} ### Parameters #### Path Parameters - **environment-id** (string) - Required - The ID of the environment #### Query Parameters - `--branch`, `-b` (string) - Optional - Specify branch name to checkout ### Example ```bash container-use checkout fancy-mallard # Switches to branch 'cu-fancy-mallard' ``` ``` -------------------------------- ### Download Agent Rules for OpenCode Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Optionally, download the `agent.md` file to improve agent results. This command fetches the rules from the official GitHub repository. ```sh curl https://raw.githubusercontent.com/dagger/container-use/main/rules/agent.md >> AGENTS.md ``` -------------------------------- ### Kiro Steering Rules for Container Use Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Create this markdown file in `.kiro/steering/container-use.md` to define steering rules for the container-use MCP. It mandates the use of environments for all operations and provides instructions for viewing work and handling git operations. ```markdown --- inclusion: always --- ALWAYS use ONLY Environments for ANY and ALL file, code, or shell operations—NO EXCEPTIONS—even for simple or generic requests. DO NOT install or use the git cli with the environment_run_cmd tool. All environment tools will handle git operations for you. Changing ".git" yourself will compromise the integrity of your environment. You MUST inform the user how to view your work using `container-use log ` and `container-use checkout `. Failure to do this will make your work inaccessible to others. ``` -------------------------------- ### Test container-use stdio command Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Verify that the `container-use stdio` command functions correctly by piping JSON input to it. This helps diagnose permission or execution issues. ```bash echo '{}' | container-use stdio ``` -------------------------------- ### Global Options Source: https://github.com/dagger/container-use/blob/main/docs/cli-reference.mdx These options can be used with any command. ```APIDOC ## Global Options These options can be used with any command: - `--help`, `-h` - Show help for a command - `--version` - Show version information - `--debug` - Enable debug output ``` -------------------------------- ### Cline Agent Rules Download Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Download the container-use agent rules for Cline, creating the necessary directories if they don't exist. ```sh curl --create-dirs -o .clinerules/container-use.md https://raw.githubusercontent.com/dagger/container-use/main/rules/agent.md ``` -------------------------------- ### Show Environment Code Changes Source: https://github.com/dagger/container-use/blob/main/docs/cli-reference.mdx Compares the code changes within a specified environment against its base branch, displaying the differences. ```bash container-use diff {environment-id} ``` ```bash container-use diff fancy-mallard # Shows full diff output ``` -------------------------------- ### Configure Sourcegraph Amp MCP Server Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Add this JSON configuration to `~/.config/amp/settings.json` to set up the container-use MCP server. It defines the command, arguments, and necessary permissions. ```json { "amp.mcpServers": { "container-use": { "command": "container-use", "args": ["stdio"] } }, "amp.permissions": [ {"tool": "mcp__container-use__*", "action": "allow"} ], "amp.dangerouslyAllowAll": false, "amp.updates.autoUpdate.enabled": true } ``` -------------------------------- ### Add Agent Rules for JetBrains Junie Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Save agent instructions to your project root by downloading the agent rules. This helps instruct Junie to use container-use. ```sh mkdir -p ./.junie && curl https://raw.githubusercontent.com/dagger/container-use/main/rules/agent.md >> .junie/guidelines.md ``` -------------------------------- ### Run Dagger tests Source: https://github.com/dagger/container-use/blob/main/AGENT.md Execute tests using Dagger. Use the --integration=false flag to run only non-integration tests. ```bash dagger call test ``` ```bash dagger call test --integration=false ``` -------------------------------- ### Lint code with Dagger Source: https://github.com/dagger/container-use/blob/main/AGENT.md Run the Dagger lint command to check for linting issues in the project. ```bash dagger call lint ``` -------------------------------- ### Import Agent Changes to Defaults Source: https://github.com/dagger/container-use/blob/main/docs/environment-configuration.mdx Adopt useful configuration improvements made by an agent as your new project defaults. ```bash container-use config import fancy-mallard ``` -------------------------------- ### Download Agent Rules for Claude Code Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Download the CLAUDE.md file to the root of your repository to configure agent rules. This helps in setting up Claude Code for specific tasks. ```sh curl https://raw.githubusercontent.com/dagger/container-use/main/rules/agent.md >> CLAUDE.md ``` -------------------------------- ### Add agent rules Source: https://github.com/dagger/container-use/blob/main/README.md Downloads and appends default agent rules to your agent's configuration file. This is an optional step to provide agents with predefined guidelines. ```sh # Add agent rules (optional) curl https://raw.githubusercontent.com/dagger/container-use/main/rules/agent.md >> CLAUDE.md ``` -------------------------------- ### Add Agent Rules for OpenAI Codex Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Instruct Codex to use container-use for all projects by downloading the agent rules. This is an optional step. ```sh mkdir -p ~/.codex curl https://raw.githubusercontent.com/dagger/container-use/main/rules/agent.md >> ~/.codex/AGENTS.md ``` -------------------------------- ### container-use watch Source: https://github.com/dagger/container-use/blob/main/docs/cli-reference.mdx Monitor environment activity in real-time as agents work. ```APIDOC ## `container-use watch` Monitor environment activity in real-time as agents work. ### Method GET ### Endpoint /container-use/watch ### Example ```bash container-use watch # Shows live updates from all active environments ``` ``` -------------------------------- ### Checkout Container Use Environment Source: https://github.com/dagger/container-use/blob/main/docs/quickstart.mdx Locally explores the files within the agent's isolated environment. Replace `{id}` with the actual environment ID. ```sh container-use checkout {id} ``` -------------------------------- ### Download Agent Rules for Sourcegraph Amp Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Save agent instructions to your project root by downloading the `agent.md` file using this curl command. This is essential for Sourcegraph Amp to utilize the agent rules. ```sh curl https://raw.githubusercontent.com/dagger/container-use/main/rules/agent.md >> AGENT.md ``` -------------------------------- ### Debugging Workflow with Container Use Source: https://github.com/dagger/container-use/blob/main/docs/cli-reference.mdx Outlines a workflow for debugging issues with Container Use, involving checking logs, entering the container for debugging, and applying fixes. ```bash # 1. See what agent did container-use log problematic-env ``` ```bash # 2. Enter container to debug container-use terminal problematic-env ``` ```bash # 3. Fix issues... # 4. Apply changes container-use apply problematic-env ``` -------------------------------- ### Configure Goose Container Use Extension Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Add this YAML configuration to your `~/.config/goose/config.yaml` to set up the container-use extension. It specifies the command and arguments for running container-use. ```yaml extensions: container-use: name: container-use type: stdio enabled: true cmd: container-use args: - stdio envs: {} ``` -------------------------------- ### container-use apply Source: https://github.com/dagger/container-use/blob/main/docs/cli-reference.mdx Apply an environment's changes as staged modifications without commits. ```APIDOC ## `container-use apply` Apply an environment's changes as staged modifications without commits. ### Method POST ### Endpoint /container-use/apply/{environment-id} ### Parameters #### Path Parameters - **environment-id** (string) - Required - The ID of the environment #### Query Parameters - `--delete`, `-d` (boolean) - Optional - Delete environment after successful apply ### Example ```bash git checkout main container-use apply fancy-mallard # Stages all changes for you to commit ``` ``` -------------------------------- ### Add Agent Rules for Amazon Q Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Download and save the agent rules file to your project's .amazonq/rules directory. This enables Amazon Q to understand and utilize container-use commands. ```sh mkdir -p ./.amazonq/rules && curl https://raw.githubusercontent.com/dagger/container-use/main/rules/agent.md > .amazonq/rules/container-use.md ``` -------------------------------- ### Add MCP Configuration for Gemini CLI Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Add this JSON configuration to `~/.gemini/settings.json` or `.gemini/settings.json` to integrate container-use with Gemini CLI. ```json { "coreTools": [], "mcpServers": { "container-use": { "command": "container-use", "args": ["stdio"], "timeout": 60000, "trust": true } } } ``` -------------------------------- ### Container Use Configuration Commands Source: https://github.com/dagger/container-use/blob/main/docs/secrets.mdx Manage secrets using Container Use CLI commands. Supports setting, listing, unsetting, clearing, and showing configuration. ```bash # Set a secret using any supported schema container-use config secret set # Examples for each type container-use config secret set DATABASE_URL "env://DATABASE_URL" container-use config secret set API_TOKEN "op://vault/api/token" container-use config secret set GITHUB_TOKEN "vault://credentials.github" container-use config secret set SSH_KEY "file://~/.ssh/deploy_key" # List all configured secrets (values are masked) container-use config secret list # Remove a secret container-use config secret unset API_KEY # Clear all secrets container-use config secret clear # View complete configuration including secrets container-use config show ``` -------------------------------- ### Configure Qodo Gen MCP Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Add this JSON configuration to Qodo Gen to connect the container-use MCP server. This enables the 'container-use' command with stdio arguments. ```json { "mcpServers": { "container-use": { "command": "container-use", "args": ["stdio"] } } } ``` -------------------------------- ### Watch Environment Activity Source: https://github.com/dagger/container-use/blob/main/docs/cli-reference.mdx Monitors and displays real-time activity and updates from all active environments as agents perform their tasks. ```bash container-use watch ``` ```bash container-use watch # Shows live updates from all active environments ``` -------------------------------- ### Manage Environment Variables Source: https://github.com/dagger/container-use/blob/main/docs/environment-configuration.mdx Set, list, unset, or clear environment variables for your project. These variables are available to your agent during work. ```bash container-use config env set NODE_ENV development container-use config env list container-use config env unset NODE_ENV container-use config env clear ``` -------------------------------- ### Verify container-use command in PATH Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Check if the `container-use` command is accessible in your system's PATH. This is a prerequisite for the agent to recognize the command. ```bash which container-use ``` -------------------------------- ### container-use log Source: https://github.com/dagger/container-use/blob/main/docs/cli-reference.mdx View the commit history and commands executed in an environment. ```APIDOC ## `container-use log` View the commit history and commands executed in an environment. ### Method GET ### Endpoint /container-use/log/{environment-id} ### Parameters #### Path Parameters - **environment-id** (string) - Required - The ID of the environment #### Query Parameters - `--patch`, `-p` (boolean) - Optional - Show patch output with diffs ### Example ```bash container-use log fancy-mallard # Shows full history with commands and file changes container-use log fancy-mallard --patch # Shows history with patch diffs ``` ``` -------------------------------- ### View Container Use Environment Diff Source: https://github.com/dagger/container-use/blob/main/docs/quickstart.mdx Compares the changes made by the agent in its isolated environment with your local files. Replace `{id}` with the actual environment ID. ```sh container-use diff {id} ``` -------------------------------- ### Add container-use MCP server Source: https://github.com/dagger/container-use/blob/main/README.md Adds the container-use MCP server to your agent's configuration. This command should be run from the root of your repository. The `stdio` argument is used to communicate with the agent. ```sh # Add Container Use MCP server cd /path/to/repository claude mcp add container-use -- container-use stdio ``` -------------------------------- ### Apply Container Use Changes Source: https://github.com/dagger/container-use/blob/main/docs/quickstart.mdx Stages the changes made by the agent, allowing you to create your own commit. Replace `{id}` with the actual environment ID. ```sh container-use apply {id} ``` -------------------------------- ### Windsurf Add Agent Rules Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Download and add the agent rules file for container-use to your project or home directory using curl. This ensures the agent has the necessary rules to operate. ```sh curl --create-dirs -o .windsurf/rules/container-use.mdc https://raw.githubusercontent.com/dagger/container-use/main/rules/windsurf.mdc ``` -------------------------------- ### Test container-use stdio interface Source: https://github.com/dagger/container-use/blob/main/AGENT.md Manually test the stdio interface of container-use. Ensure you are not in the /workdir. Use a timeout and pipe a JSON request to the command. ```bash echo $request | timeout $seconds container-use stdio ``` -------------------------------- ### Add MCP Configuration for OpenAI Codex Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Add this TOML configuration to `~/.codex/config.toml` to enable container-use with OpenAI Codex. ```toml [ "mcp_servers.container-use" command = "container-use" args = ["stdio"] env = {} ] ``` -------------------------------- ### Add Agent Rules for Container Use Source: https://github.com/dagger/container-use/blob/main/docs/quickstart.mdx Downloads and appends agent rules for Container Use to your CLAUDE.md file. This is an optional step to configure agent behavior. ```sh curl https://raw.githubusercontent.com/dagger/container-use/main/rules/agent.md >> CLAUDE.md ``` -------------------------------- ### Charm Crush Agent Rules Download Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Download the agent rules for container-use into your project root by running this curl command. ```sh curl https://raw.githubusercontent.com/dagger/container-use/main/rules/agent.md >> CRUSH.md ``` -------------------------------- ### container-use terminal Source: https://github.com/dagger/container-use/blob/main/docs/cli-reference.mdx Open an interactive terminal session inside the environment's container. ```APIDOC ## `container-use terminal` Open an interactive terminal session inside the environment's container. ### Method POST ### Endpoint /container-use/terminal/{environment-id} ### Parameters #### Path Parameters - **environment-id** (string) - Required - The ID of the environment ### Example ```bash container-use terminal fancy-mallard # Opens interactive shell in container ``` ``` -------------------------------- ### Merge Container Use Changes Source: https://github.com/dagger/container-use/blob/main/docs/quickstart.mdx Accepts the agent's work and integrates its commit history into your local repository. Replace `{id}` with the actual environment ID. ```sh container-use merge {id} ``` -------------------------------- ### Windsurf MCP Server Configuration Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Configure the MCP server for container-use within your Windsurf configuration file. This enables the agent to run as a command-line process. ```json { "mcpServers": { "container-use": { "command": "container-use", "args": ["stdio"], "env": {} } } } ``` -------------------------------- ### Run Unit Tests Only Source: https://github.com/dagger/container-use/blob/main/CONTRIBUTING.md Execute only unit tests, excluding integration tests. This is faster and does not require containers. ```bash go test -short ./... ``` -------------------------------- ### View Environment Commit History Source: https://github.com/dagger/container-use/blob/main/docs/cli-reference.mdx Displays the commit history and executed commands for a specific environment. Use the `--patch` option to include diffs of file changes. ```bash container-use log {environment-id} ``` ```bash container-use log fancy-mallard # Shows full history with commands and file changes ``` ```bash container-use log fancy-mallard --patch # Shows history with patch diffs ``` -------------------------------- ### container-use diff Source: https://github.com/dagger/container-use/blob/main/docs/cli-reference.mdx Show the code changes made in an environment compared to its base branch. ```APIDOC ## `container-use diff` Show the code changes made in an environment compared to its base branch. ### Method GET ### Endpoint /container-use/diff/{environment-id} ### Parameters #### Path Parameters - **environment-id** (string) - Required - The ID of the environment ### Example ```bash container-use diff fancy-mallard # Shows full diff output ``` ``` -------------------------------- ### Format JSON response with jq Source: https://github.com/dagger/container-use/blob/main/AGENT.md Use 'jq' to format the JSON output from container-use for better readability. ```bash ... | jq . ``` -------------------------------- ### Add MCP Configuration for JetBrains Junie Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Add or edit the MCP configuration in JetBrains Junie's settings or directly in `~/.junie/mcp/mcp.json`. ```json { "mcpServers": { "container-use": { "command": "container-use", "args": ["stdio"], "env": {}, "timeout": 60000 } } } ``` -------------------------------- ### Apply Environment Changes with Custom Commit Source: https://github.com/dagger/container-use/blob/main/docs/environment-workflow.mdx Apply an agent's changes as staged modifications to your local workspace, allowing you to review and commit them with your own custom message. This provides more control over the commit process. ```bash # Apply changes as staged modifications container-use apply fancy-mallard ``` ```bash # Review and commit with your own message git status git commit -m "Your custom commit message" ``` ```bash # Clean up (optional) container-use delete fancy-mallard ``` -------------------------------- ### Add Agent Rules for Cursor Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Download and save the agent rules file for Cursor to your project or home directory. This file enables Cursor to use container-use commands. ```sh curl --create-dirs -o .cursor/rules/container-use.mdc https://raw.githubusercontent.com/dagger/container-use/main/rules/cursor.mdc ``` -------------------------------- ### Goose Desktop Extension URL Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Paste this URL into your browser to add the container-use extension via Goose Desktop. It includes parameters for command, arguments, and extension details. ```url goose://extension?cmd=container-use&arg=stdio&id=container-use&name=container%20use&description=use%20containers%20with%20dagger%20and%20git%20for%20isolated%20environments ``` -------------------------------- ### Add MCP Configuration for Claude Code Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Use this command to add the container-use MCP configuration for Claude Code. Navigate to your repository's root directory before running. ```sh cd /path/to/repository claude mcp add container-use -- container-use stdio ``` -------------------------------- ### Trust Container Use Tools in Amazon Q Source: https://github.com/dagger/container-use/blob/main/docs/agent-integrations.mdx Optionally, configure Amazon Q to trust specific container-use tools. This command lists all available container-use environment commands that can be trusted. ```sh q chat --trust-tools=container_use___environment_add_service,container_use___environment_checkpoint,container_use___environment_config,container_use___environment_create,container_use___environment_file_delete,container_use___environment_file_edit,container_use___environment_file_list,container_use___environment_file_read,container_use___environment_file_write,container_use___environment_open,container_use___environment_run_cmd,container_use___environment_update_metadata ``` -------------------------------- ### Checkout Environment Branch Locally Source: https://github.com/dagger/container-use/blob/main/docs/cli-reference.mdx Allows you to check out an environment's associated branch locally, enabling exploration and development within your IDE. You can specify a custom branch name using the `-b` option. ```bash container-use checkout {environment-id} ``` ```bash container-use checkout fancy-mallard # Switches to branch 'cu-fancy-mallard' ``` -------------------------------- ### Tag the Release Source: https://github.com/dagger/container-use/blob/main/RELEASING.md Creates a new Git tag for the release. Ensure the tag name follows the desired versioning scheme (e.g., vX.Y.Z). ```sh git tag v1.2.3 ```