Skip to main content
Scopes let you focus on specific parts of a large repository, making wit faster and less noisy.

Overview

In a monorepo, you often only care about one package or service. Scopes limit all wit operations to the paths you specify.
# Set scope to frontend package
wit scope set packages/frontend/

# Now all commands are scoped
wit status   # Only shows frontend files
wit add .    # Only stages frontend files
wit log      # Only shows frontend commits

Commands

View Current Scope

wit scope
Output:
Current scope: packages/frontend/
Or if no scope:
Current scope: (entire repository)

Set Scope

wit scope set <path>
Examples:
# Scope to a directory
wit scope set packages/frontend/

# Scope to multiple paths (comma-separated)
wit scope set packages/frontend/,packages/shared/

# Scope to a pattern
wit scope set "src/**/*.ts"

Use Preset

wit scope use <preset>
Presets are predefined scopes in your config:
wit scope use frontend
wit scope use backend
wit scope use docs

Clear Scope

wit scope clear
Returns to operating on the entire repository.

Configuration

Define presets in .wit/config:
[scope "frontend"]
    paths = packages/frontend/
    
[scope "backend"]
    paths = packages/backend/,packages/api/
    
[scope "docs"]
    paths = docs/,*.md

Effect on Commands

When a scope is set, these commands are affected:
CommandEffect
statusOnly shows scoped files
add .Only stages scoped files
logOnly shows commits affecting scoped paths
diffOnly shows changes in scoped files
commitCommits all staged files (scope affects staging)
blameWorks on any file (not affected)

Example Monorepo Structure

my-monorepo/
├── packages/
│   ├── frontend/
│   │   ├── src/
│   │   └── package.json
│   ├── backend/
│   │   ├── src/
│   │   └── package.json
│   └── shared/
│       └── src/
├── docs/
├── scripts/
└── package.json

Working on Frontend

# Set scope
wit scope set packages/frontend/

# Work normally - only frontend files
wit status
wit add src/components/Button.tsx
wit commit -m "Update Button component"

# Clear when done
wit scope clear

Using Presets

# Quick scope switching
wit scope use frontend
# ... work on frontend ...

wit scope use backend
# ... work on backend ...

wit scope clear
# ... work on everything ...

Use Cases

Focus During Development

# Focus on what you're working on
wit scope set packages/auth/

# Less noise in status
wit status
# Only shows auth package files

Scoped Commits

# Ensure you only commit frontend changes
wit scope set packages/frontend/
wit add .
wit commit -m "Frontend: Update styles"

Scoped History

# What changed in the API recently?
wit scope set packages/api/
wit log --oneline -n 20

CI/CD Pipelines

# Only run tests if package changed
wit scope set packages/auth/
if [ "$(wit status --porcelain)" ]; then
    npm run test:auth
fi

Tips

Set scope in your terminal profile for focused work:
alias fe='wit scope use frontend'
alias be='wit scope use backend'
alias all='wit scope clear'
Use scopes with other commands:
wit scope set packages/frontend/
wit stats  # Stats for frontend only
wit cleanup  # Branches affecting frontend

Limitations

  • Scopes are session-based (not persisted)
  • Some commands ignore scopes (e.g., branch, switch)
  • Scopes don’t affect file system operations