Project Configuration
You can add a .cacd.json file to your project root to configure project-specific behavior. This is useful for setup scripts that should run when working with worktrees in that project.
File Location
Section titled “File Location”CACD looks for configuration in this order:
.cacd.jsonin the project root.cacd/config.jsonin the project root
Use whichever fits your preference. The first one found is used.
Configuration Options
Section titled “Configuration Options”Scripts
Section titled “Scripts”Define shell commands that run automatically:
{ "scripts": { "setup": "npm install && cp .env.example .env", "teardown": "echo 'Cleaning up...'" }}Runs after a new worktree is created in this project. Use it to:
- Install dependencies
- Set up environment files
- Run initialization scripts
teardown
Section titled “teardown”Runs before a worktree is deleted. Use it to:
- Clean up resources
- Save state
- Log activity
Environment Variables
Section titled “Environment Variables”Scripts have access to:
| Variable | Description |
|---|---|
CACD_ROOT_PATH | Git repository root |
CACD_WORKTREE_PATH | Path to the worktree |
CACD_WORKTREE_NAME | Name of the worktree |
CACD_BRANCH | Branch name |
Example
Section titled “Example”A typical .cacd.json for a Node.js project:
{ "scripts": { "setup": "cd \"$CACD_WORKTREE_PATH\" && npm install" }}For a project with multiple package managers:
{ "scripts": { "setup": "cd \"$CACD_WORKTREE_PATH\" && npm install && pip install -r requirements.txt" }}- Scripts run asynchronously and don’t block CACD
- Failures are logged but don’t prevent operations
- This file is optional - CACD works fine without it
- Project config is separate from global CACD settings