Skip to content

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.

CACD looks for configuration in this order:

  1. .cacd.json in the project root
  2. .cacd/config.json in the project root

Use whichever fits your preference. The first one found is used.

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

Runs before a worktree is deleted. Use it to:

  • Clean up resources
  • Save state
  • Log activity

Scripts have access to:

VariableDescription
CACD_ROOT_PATHGit repository root
CACD_WORKTREE_PATHPath to the worktree
CACD_WORKTREE_NAMEName of the worktree
CACD_BRANCHBranch name

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