Skip to main content

Overview

Superset allows you to automate workspace initialization and cleanup through configuration files. The .superset/config.json file in your repository root defines scripts that run when workspaces are created or deleted.
Configuration is per-repository. Each project can have its own setup and teardown logic.

.superset/config.json Format

The configuration file uses a simple JSON structure:
Scripts are executed in order. If a script fails, subsequent scripts still run.

Setup Scripts

Setup scripts run automatically when a workspace is created, before any presets execute.

When Setup Scripts Run

  1. User creates a workspace (⌘N or ⌘⇧N)
  2. Superset creates git worktree
  3. Setup scripts execute ← You are here
  4. Terminal session starts
  5. Presets execute (if configured)

Example Setup Script

Here’s a typical setup script that prepares a workspace:
Make your setup scripts executable: chmod +x .superset/setup.sh

Common Setup Tasks

Copy .env Files

Git ignores .env, so copy it from the main repo.

Install Dependencies

Each worktree needs its own node_modules.

Database Migrations

Ensure database schema is up to date.

Build Assets

Pre-build assets if needed.

Teardown Scripts

Teardown scripts run when a workspace is deleted, before the git worktree is removed.

When Teardown Scripts Run

  1. User deletes workspace
  2. Superset closes terminal sessions
  3. Teardown scripts execute ← You are here
  4. Git worktree is removed
  5. Workspace metadata cleaned up

Example Teardown Script

Common Teardown Tasks

Stop Services

Kill long-running processes.

Clean Temp Files

Remove temporary data.

Archive Data

Save important files before deletion.

Cleanup Docker

Stop and remove containers.

Environment Variables in Scripts

Scripts run with special environment variables provided by Superset:

Using Environment Variables

Don’t rely on $PWD or relative paths. Use $SUPERSET_ROOT_PATH to reference the main repository.

Real Configuration Examples

Example 1: Node.js Project

Setup script:
Teardown script:

Example 2: Python Project with Database

setup-venv.sh:
setup-db.sh:
cleanup.sh:

Example 3: Docker Compose Project

docker-setup.sh:
docker-teardown.sh:

Example 4: Monorepo with Selective Install

monorepo-setup.sh:

Example 5: Multi-Stage Setup

This approach breaks setup into logical stages, making it easier to debug issues.

Script Best Practices

Use set -euo pipefail

Start scripts with:
Exits on error, unset variables, and pipe failures.

Provide Feedback

Let users know what’s happening.

Handle Failures Gracefully

Don’t break setup for non-critical failures.

Make Scripts Idempotent

Safe to run multiple times without side effects.

Error Handling

Handle errors gracefully to prevent setup failures:

Performance Optimization

Debugging Scripts

If setup or teardown scripts fail:

1. Check Script Output

Superset shows script output in the workspace creation dialog. Look for error messages.

2. Run Scripts Manually

Test scripts in a terminal:

3. Add Debug Output

4. Check Permissions

Configuration Validation

Superset validates .superset/config.json when loading a project:
  • ✅ Valid JSON syntax
  • setup and teardown are arrays of strings
  • ✅ Script paths are relative (not absolute)
  • ⚠️ Warning if script files don’t exist
  • ⚠️ Warning if scripts aren’t executable
Common mistake: Using absolute paths in config.json. Always use relative paths:✅ Good: "./.superset/setup.sh"❌ Bad: "/Users/you/project/.superset/setup.sh"

Relationship with Presets

Setup scripts run before presets:
When to use setup scripts vs presets:
Setup scripts configure the workspace. Presets launch tools in the workspace.

Security Considerations

Setup and teardown scripts run with your user permissions. Be careful with:
  • Scripts from untrusted sources
  • Commands that modify files outside the workspace
  • Scripts that access sensitive data

Safe Practices

  1. Review scripts before running: Check .superset/ contents in new projects
  2. Limit scope: Only modify files within the workspace
  3. Avoid sudo: Setup scripts shouldn’t require elevated permissions
  4. Validate inputs: Don’t trust environment variables blindly

Advanced Use Cases

Conditional Logic Based on Branch

Port Allocation

Caching Dependencies

Next Steps

Presets

Configure workspace presets that run after setup

Workspaces

Learn more about workspace creation

Quickstart

Create your first workspace with setup scripts

Worktrees

Understand git worktree mechanics