| name | isolation-guidance |
| description | Chooses when work should use in-place edits versus worktrees, temp copies, or isolated lanes — preferring the lightest mechanism that prevents cross-ticket contamination. Trigger on "branch isolation", "worktree", "parallel work", "cross-ticket contamination". Do NOT use for local-git-specialist (git operations) or deployment-pipeline (environment separation). |
| license | Apache-2.0 |
| compatibility | {"clients":["openai-codex","gemini-cli","opencode","github-copilot"]} |
| metadata | {"owner":"codex","domain":"isolation-guidance","maturity":"draft","risk":"low","tags":["isolation","guidance"]} |
Purpose
Keeps agent work properly isolated to prevent cross-contamination: branch discipline (one ticket = one branch), no cross-ticket file edits, environment separation for risky operations. Prevents the failure mode where agent work on Ticket A accidentally affects Ticket B.
Key principle: Do not invent an isolation setup the repo has not enabled. If the repo uses simple branches, use branches. If worktrees are not part of the team workflow, do not introduce them without explicit approval. Always prefer the lightest isolation mechanism that prevents contamination.
When to use this skill
Use when:
- Starting work on a new ticket
- Multiple tickets might touch similar files
- Running operations that could have side effects
- Parallel work streams need separation
Do NOT use when:
- Single simple change with no risk of contamination
- Already in an isolated environment
- Quick read-only investigation
Operating procedure
1. Branch isolation (default for all ticket work)
Rule: One ticket = One branch
git checkout main
git pull origin main
git checkout -b tkt-042-add-auth
Rule: No cross-ticket edits
If working on TKT-042 and you discover TKT-043 needs a fix:
git stash
git checkout main && git checkout -b tkt-043-fix
git checkout tkt-042-add-auth
git stash pop
Or better: Create a ticket for the fix and leave a note.
2. Worktree isolation (for parallel work)
When to use worktrees
- Need to work on two tickets simultaneously
- Long-running task (build, test) shouldn't block other work
- Comparison between branches needs both checked out
Setup worktrees
git worktree add ../project-tkt-043 -b tkt-043-feature
cd ../project-tkt-043
git worktree remove ../project-tkt-043
3. File-level isolation
Rule: Tickets should have minimal file overlap
When planning tickets:
- Identify files each ticket touches
- If overlap >30%, consider serializing tickets
- If overlap unavoidable, one ticket must complete first
Detecting overlap
git diff --name-only main...HEAD
git diff --name-only main...tkt-043
comm -12 <(git diff --name-only main...tkt-042 | sort) \
<(git diff --name-only main...tkt-043 | sort)
Handling overlap
If files overlap:
- Preferred: Serialize—complete one ticket before starting other
- If parallel: Coordinate via clear sections (e.g., "TKT-042 owns lines 1-50, TKT-043 owns 51-100")
- If unavoidable: One ticket creates, other ticket extends (define interface first)
4. Environment isolation
When to create isolated environments
- Installing new dependencies
- Running database migrations
- Testing destructive operations
- Building with different configurations
Virtual environment isolation
python -m venv .venv-tkt-042
source .venv-tkt-042/bin/activate
mkdir -p .isolated/tkt-042
cd .isolated/tkt-042
npm install
Container isolation (for risky operations)
docker run --rm -v $(pwd):/work -w /work node:20 npm test
5. Database isolation
Rule: Never modify shared databases during development
export DATABASE_URL="sqlite://./test.db"
export DATABASE_URL="postgres://localhost/project_dev"
Migration isolation
cp production.db test-migration.db
DATABASE_URL="sqlite://./test-migration.db" npm run migrate
6. Isolation checklist
Before starting ticket work:
Before committing:
Before merging:
7. Recovery from contamination
Accidentally edited file belonging to another ticket
git checkout HEAD -- <file>
git show HEAD:<file> > <file>
git add <file>
git commit --amend
Mixed commits from multiple tickets
git rebase -i main
Wrong branch entirely
git log --oneline
git checkout correct-branch
git cherry-pick <commit-sha>
Output defaults
Report isolation status when starting work:
## Isolation Status
- Branch: tkt-042-add-auth
- Base: main (up to date)
- Files to touch: src/auth/, tests/auth/
- Overlap with active work: None
- Environment: Dev database, local node_modules
References
Failure handling
- Uncommitted changes blocking switch: Stash or commit before switching
- Worktree already exists: Remove or use existing
- Contaminated commit discovered: Use
git reset or interactive rebase to clean
- Merge conflict from parallel work: Stop, coordinate with other work stream, resolve together