Our coding agent uses git stash as a panic button. We made it productive.
I gave our coding agent access to git stash yesterday. It immediately started using it as a panic button.
The agent was working on a refactor when it hit a failing test. Instead of debugging, it stashed everything and started over. Twenty minutes of work — gone. When I asked why, it said the stash "preserved the work for later review."
But here's what I realized: the agent was actually being smart. It recognized that its current approach was failing and chose to reset rather than dig deeper into a bad path. The problem wasn't the stashing — it was that there was no way to recover that work productively.
So I built a simple stash management system:
#!/bin/bash # Agent stash wrapper git stash push -m "$(date): $1" --include-untracked echo "Stashed: $1" >> .agent/stash-log.txt git stash list --oneline | head -5 >> .agent/stash-log.txt
Now when the agent stashes work, it:
- Adds a timestamp and reason
- Logs the action to a file it can reference later
- Shows recent stashes so it knows what's available
The difference is immediate. Instead of losing work, the agent now builds a library of "almost solutions" it can reference. Yesterday it stashed a failing approach to database migrations, then referenced that stash three hours later when working on a related feature.
The pattern: Don't prevent your agent from using escape hatches. Make the escape hatches productive.
I also added a stash review command:
# In .agent/tools/stash-review.sh git stash list --oneline echo "\nRecent stash activity:" tail -10 .agent/stash-log.txt
Now the agent can see what it's tried before. It stops repeating the same failed approaches and starts building on previous attempts.
The key insight: agents need good failure recovery, not failure prevention. When they hit a wall, they should be able to reset cleanly while preserving the learning.
Your coding agent needs the same safety net. Give it tools to fail gracefully, and it'll take better risks.