---
name: devxkit-safe-stash
description: Preserve tracked and untracked work before devxkit agent slice start.
scope: global
devxkit_commands:
  - devxkit agent slice start
---

# devxkit safe stash

Legacy prepared-slice compatibility only. Ordinary work uses an isolated
worktree and preserves the human checkout; do not stash another task.

## When to use

- `devxkit agent slice start <issue>` fails with **Working tree is not clean**
- You have WIP (including **untracked** files) that must survive branch checkout
- Before starting any issue-backed slice on the configured base (default `main`)

## Preconditions

- You understand stash pop may cause conflicts if the same files changed on the new branch
- Prefer stash over discarding work; never use destructive clean without explicit user approval

## Commands

```bash
git status --short

git stash push -u -m "wip before devxkit slice <issue>"
devxkit agent slice start <issue>

# Or let devxkit stash automatically:
devxkit agent slice start <issue> --stash

git stash list --date=local | head
git stash pop
git status --short
```

Manual sequence if `--stash` is not used:

```bash
git stash push -u -m "wip before devxkit slice <issue>"
devxkit agent slice start <issue>
git stash pop
```

## Validation

- `git status --short` is empty (or only expected slice artifacts) **before** `slice start`
- After `stash pop`, review status; resolve conflicts before `devxkit agent validate`
- Stash entry visible in `git stash list` until popped

## Common failures

- **Untracked files block slice start** → always use `-u` / `--stash`
- **Stash pop conflicts** → resolve manually; do not force-merge or `git clean`
- **`--stash` but still dirty** → doctor message lists remaining paths; stash again or commit WIP elsewhere
- **Lost work fear** → verify stash with `git stash list` before continuing

## Stop conditions

- Do **not** run `git clean -fdx` or other destructive cleanup unless the user explicitly authorizes it
- Do **not** proceed with slice start while tree is dirty
- Stop and report if stash pop produces conflicts you cannot resolve safely

## Related skills

- `devxkit-agent-flow`
