Claude Skills Guide

Claude Code for Git Stash Advanced Workflow

Git stash is one of those commands that seems simple at first but becomes indispensable when you need to context-switch between features, hotfixes, or experiments without committing half-finished work. When you pair git stash with Claude Code, you unlock powerful automation patterns that can transform how you manage working directories across complex projects. This guide walks through advanced stash workflows that use Claude’s ability to understand context, execute commands, and help you make intelligent decisions about your code.

Understanding Git Stash Fundamentals

Before diving into advanced workflows, let’s establish the core stash operations that form the foundation for everything else. The basic workflow involves saving uncommitted changes, switching contexts, and then restoring those changes when you’re ready. But Claude Code can enhance each step of this workflow by providing context-aware suggestions and automating repetitive tasks.

The essential stash commands you should know are:

When working with Claude, you can ask it to perform these operations conversationally. For example, saying “Stash my current changes before I check out the main branch” will prompt Claude to analyze your working directory, identify uncommitted changes, and execute the appropriate stash command with a descriptive message.

Intelligent Stash Management with Claude

One of the most powerful aspects of using Claude for stash operations is its ability to understand your project context. Claude can analyze what files have changed, suggest appropriate stash names, and help you organize multiple stashes in a meaningful way.

Named Stashes for Better Organization

Instead of relying on auto-generated stash references like “stash@{0}”, you can create named stashes that describe their contents:

git stash save "feature: user authentication work"
git stash save "bugfix: login redirect issue"
git stash save "experiment: new API integration"

Claude can help you create meaningful stash names by analyzing your changes. When you ask Claude to stash your work, it will often suggest a descriptive name based on the files modified, recent commit messages, or the feature you’re working on.

Listing and Selecting Stashes

When you have multiple stashes, finding the right one can become challenging. Here’s a useful pattern for viewing stash details:

git stash list --pretty=format:"%gd: %s (%ci)"

This shows each stash with its reference, description, and creation date. Claude can help you parse this output and recommend which stash to apply based on what you’re trying to accomplish.

Advanced Stash Workflows

The Context Switch Pattern

The most common advanced use case for stash is the context switch—temporarily setting aside current work to address something else. Here’s a refined workflow:

  1. Before switching contexts, ask Claude: “ stash my current changes before I work on the hotfix”
  2. Claude analyzes your changes, creates a named stash, and confirms the operation
  3. Switch to your new task (checkout branch, pull updates, etc.)
  4. When ready to return, ask Claude: “restore my previous work from the stash”

This pattern becomes especially valuable when you’re working on multiple features simultaneously or need to quickly respond to production issues.

Selective Stashing with Patch Mode

Sometimes you don’t want to stash everything—only certain files or even specific hunks within files. The patch mode allows you to interactively select which changes to stash:

git stash push --patch --message "partial: authentication module"

When you use this command, git presents each hunk of changes and asks whether you want to stash it. Claude can guide you through this process, explaining what each hunk contains and helping you make informed decisions about what to stash versus what to commit or discard.

Stashing Untracked Files

By default, git stash only tracks changes to tracked files. If you’ve added new files that haven’t been committed yet, you need to include them explicitly:

git stash --include-untracked

Or with a shorter form:

git stash -u

This becomes crucial when you’re starting new features that involve adding files before you’re ready to commit. Claude can remind you to include untracked files when stashing, preventing the common frustration of “where did my new files go?”

Automating Stash Workflows with Claude

Beyond interactive use, you can create Claude skills that automate common stash patterns. Here’s an example skill for a frequent workflow:

---
name: "Context Switch"
description: "Stash current work and prepare for new task"
---

This skill helps you switch contexts by stashing your current work.

When invoked, first check for uncommitted changes using `git status`.
If there are uncommitted changes:
1. Show me what files have changed
2. Create a stash with an appropriate name based on the changes
3. Confirm the stash was created successfully

If there are no uncommitted changes, simply confirm that the working directory is clean.

This type of skill standardizes the context-switching process across your team and ensures consistent stash naming conventions.

Integrating Stash with Claude Skills

Claude Skills can enhance your stash workflow. The supermemory skill preserves context about what you were working on when you stash and step away:

<!-- In your project notes -->
## Claude Code Session Context
- Working on: authentication module
- Stashed changes: 3 files modified
- Stash message: "WIP: OAuth2 implementation"
- Next step: Resume and complete token refresh logic

When using the tdd skill, stashing requires extra care. Always ensure test files are saved before stashing, and run the test suite after popping to restore context:

git add tests/
git stash push -m "WIP: tdd - user auth tests"
# After popping back:
claude -p "Run the test suite to verify current state"

Practical Workflow Examples

Emergency Hotfix Scenario

You’re mid-session with Claude Code implementing a new feature, and a production bug report comes in:

# 1. Quickly stash current work
git stash push -m "WIP: new feature - brief description"
# 2. Switch to main/production branch
git checkout main
# 3. Create hotfix branch
git checkout -b hotfix/production-bug
# 4. Work with Claude Code on the fix
claude -p "Fix the login timeout issue described in ticket #123"
# 5. Deploy and merge
git checkout main && git merge hotfix/production-bug
# 6. Return to your feature work
git checkout feature/my-new-feature
git stash pop

Stash for Experimentation

When you want to try a different approach suggested by Claude Code but aren’t sure it will work:

# Stash current approach
git stash push -m "Experiment: original approach"
# Try the new approach with Claude
# If it works, drop the old stash: git stash drop
# If it doesn't work, recover the original: git stash pop

Common Stash Issues and Solutions

Stash Conflicts After Long Absences

If you return to find stash conflicts after an extended break, let Claude Code help resolve them:

git stash show -p stash@{0} | head -100
claude -p "Help me resolve this git stash conflict. The changes involve [describe what you were working on]"

Losing Stash References

Stashes can become orphaned if branches are deleted. Convert important stashes to commits for safekeeping:

git stash show -p stash@{0} | git commit -m "Stashed work: feature implementation" -F -

Stash Recovery and Cleanup

Even with careful management, stashes can accumulate or become stale. Here’s how to stay organized:

Viewing Stash Contents

Before applying a stash, always review its contents:

git stash show -p stash@{0}

The -p flag shows the actual diff. Claude can help you interpret these changes and decide whether to apply, pop, or drop the stash.

Cleaning Up Old Stashes

Stashes that are no longer needed should be removed to keep your repository clean:

# Remove a specific stash
git stash drop stash@{2}

# Remove all stashes (use with caution!)
git stash clear

A good practice is to periodically review your stash list and remove items that are no longer relevant. You might say to Claude: “clean up stashes older than a week” and let it help you identify and remove outdated entries.

Best Practices for Stash Workflows

Following these practices will help you maintain a clean, manageable stash history:

Name your stashes descriptively — A stash named “WIP” provides no context. Instead, use names that describe what the stash contains and why it was created.

Stash early, stash often — There’s no penalty for creating stashes, and having more granular snapshots makes it easier to recover specific changes.

Prefer branches for long-term work — If you’re going to set aside work for more than a day or two, consider creating a feature branch instead. Stashes are best for short-term context switches.

Keep stash list manageable — If you find yourself with more than five or ten stashes, it’s a sign you might need better branch management or more frequent commits.

Document important stashes — For stashes that contain significant work, consider adding a comment or keeping a reference in your project management tool.

Conclusion

Git stash is an essential tool in any developer’s toolkit, and Claude Code amplifies its power by adding intelligent context awareness, automation, and decision support. By mastering these advanced workflows, you can handle complex context switching with confidence, maintain a clean working directory, and never lose track of unfinished work. Start incorporating these patterns into your daily workflow, and you’ll find yourself switching between tasks more fluidly than ever before.

Built by theluckystrike — More at zovo.one