codeshard manages Git worktrees as disposable AI coding sandboxes. It is designed to be run from an anchor clone and creates sibling worktree directories for isolated sessions.
- Python 3.12+
- macOS or Linux
uv run codeshard --helpuv run codeshard new ABC-123
uv run codeshard new ABC-123 --open-ide --ide-cmd 'code "{path}"'
uv run codeshard new ABC-123 --open-ai --ai-cmd 'wezterm start --cwd "{path}" -- codex'
uv run codeshard ls
uv run codeshard rm ABC-123
uv run codeshard rm ABC-123 --delete-branch
uv run codeshard config set ide_cmd 'code "{path}"'
uv run codeshard config set ai_cmd 'codex'
uv buildTip: if you want a shorter command, you can add alias cs="codeshard" to your shell profile.
- The anchor repo is discovered via
git rev-parse --show-toplevel(or--repo). - Worktrees live under a sibling directory:
<anchor_parent>/<anchor_name>-wt, unless overridden by--rootorWT_ROOT. codeshard newdefaults its base ref to the current branch of the anchor repo.
Config is stored in:
$XDG_CONFIG_HOME/codeshard/config.tomlifXDG_CONFIG_HOMEis set- otherwise
~/.config/codeshard/config.toml
Config keys:
ide_cmd: command template to open an IDE at{path}ai_cmd: command template to launch an AI tool (uses{path}if present, otherwise relies oncwd)ide_enabled_default: default for--open-ideai_enabled_default: default for--open-aiallow_shell: opt-in to execute IDE/AI commands through a shell (default false)
Environment variables override config:
CODESHARD_IDE_CMDCODESHARD_AI_CMD
IDE command examples (must include {path}):
- VS Code:
code "{path}" - Cursor:
cursor "{path}" - IntelliJ IDEA:
idea "{path}"
AI command examples (may include {path}; otherwise uses the worktree as cwd):
- Simple CLI in current terminal:
codex - WezTerm (new window):
wezterm start --cwd "{path}" -- codex - Kitty (new window):
kitty --directory "{path}" codex - macOS Terminal (new window):
open -a Terminal "{path}" - macOS iTerm (new window):
open -a iTerm "{path}"
Tip: If you want a new tab instead of a new window, use your terminal's CLI flags in ai_cmd (terminal-specific).
- Create a shard:
uv run codeshard new MY-TASK cdinto it- Run your AI tool (e.g.
codex) - Remove the shard when finished:
uv run codeshard rm MY-TASK