<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: David Pastor</title>
    <description>The latest articles on Forem by David Pastor (@davidcreador).</description>
    <link>https://forem.com/davidcreador</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F198158%2F84ba91f2-2e3e-4d9e-b457-97f1fc0a2294.jpeg</url>
      <title>Forem: David Pastor</title>
      <link>https://forem.com/davidcreador</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/davidcreador"/>
    <language>en</language>
    <item>
      <title>I was losing my mind switching branches with Claude Code, so I built this</title>
      <dc:creator>David Pastor</dc:creator>
      <pubDate>Wed, 20 Aug 2025 02:28:39 +0000</pubDate>
      <link>https://forem.com/davidcreador/i-was-losing-my-mind-switching-branches-with-claude-code-so-i-built-this-5e5f</link>
      <guid>https://forem.com/davidcreador/i-was-losing-my-mind-switching-branches-with-claude-code-so-i-built-this-5e5f</guid>
      <description>&lt;p&gt;Look, I'm just gonna say it - using Claude Code is amazing until you switch git branches. Then it's like your AI buddy just got amnesia.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem (aka my Tuesday afternoon meltdown)
&lt;/h2&gt;

&lt;p&gt;Picture this: You're deep in a feature branch, you've got your CLAUDE.md file dialed in with all the context about your payment integration. Claude knows about your Stripe webhooks, your database schema, that weird edge case with European VAT. Life is good.&lt;/p&gt;

&lt;p&gt;Then your PM pings you. Production bug. Critical. Drop everything.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash
git checkout main
git checkout &lt;span class="nt"&gt;-b&lt;/span&gt; hotfix/critical-bug-fix
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You open Claude Code and... it's still talking about Stripe webhooks. Because your CLAUDE.md is from the other branch. FML.&lt;/p&gt;

&lt;p&gt;So you do what we all do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout feature/payment-integration &lt;span class="nt"&gt;--&lt;/span&gt; CLAUDE.md
&lt;span class="c"&gt;# wait no, that's not right&lt;/span&gt;
git checkout main &lt;span class="nt"&gt;--&lt;/span&gt; CLAUDE.md
&lt;span class="c"&gt;# shit, now I've lost my payment context&lt;/span&gt;
&lt;span class="c"&gt;# let me just... manually copy... no wait...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;20 minutes later you're manually managing context files like it's 1999 and you're wondering why we can't have nice things.&lt;/p&gt;

&lt;h2&gt;
  
  
  The "Aha" Moment
&lt;/h2&gt;

&lt;p&gt;After the 50th time doing this dance, I had a thought that I'm sure you've had too: &lt;strong&gt;Why isn't this automatic?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Git hooks exist. Git knows when we switch branches. This should be a solved problem.&lt;/p&gt;

&lt;p&gt;So I spent a weekend building what should honestly just be built into every AI coding tool.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# One line install (yes, actually just one line)&lt;/span&gt;
curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/Davidcreador/claude-code-branch-memory-manager/main/install.sh | bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. Now when you switch branches, your CLAUDE.md switches too. Each branch maintains its own context. It just works.&lt;/p&gt;

&lt;p&gt;Here's what happens under the hood:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# When you switch to a branch&lt;/span&gt;
git checkout feature/new-feature

&lt;span class="c"&gt;# The tool automatically:&lt;/span&gt;
&lt;span class="c"&gt;# 1. Saves current CLAUDE.md to .claude/memories/old-branch.md&lt;/span&gt;
&lt;span class="c"&gt;# 2. Loads .claude/memories/new-feature.md (or creates it)&lt;/span&gt;
&lt;span class="c"&gt;# 3. Updates your CLAUDE.md&lt;/span&gt;

&lt;span class="c"&gt;# You literally don't do anything. It just happens.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Real-world workflow
&lt;/h2&gt;

&lt;p&gt;Here's my actual workflow now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Monday: Working on auth refactor&lt;/span&gt;
git checkout &lt;span class="nt"&gt;-b&lt;/span&gt; refactor/auth-system
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"# Auth Refactor
- Moving from JWT to sessions
- Need to migrate 50k users
- Remember: CEO really cares about SSO"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; CLAUDE.md

&lt;span class="c"&gt;# Tuesday: Urgent bug&lt;/span&gt;
git checkout &lt;span class="nt"&gt;-b&lt;/span&gt; fix/memory-leak
&lt;span class="c"&gt;# CLAUDE.md automatically switches&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"# Memory Leak Investigation
- Happens after 6 hours
- Only on EC2 instances
- Suspect: that sketchy Redis connection pool"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; CLAUDE.md

&lt;span class="c"&gt;# Wednesday: Back to auth&lt;/span&gt;
git checkout refactor/auth-system
&lt;span class="c"&gt;# Boom. Claude remembers everything about auth again.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No manual copying. No context loss. No accidentally committing the wrong CLAUDE.md to the wrong branch (yeah, we've all done it).&lt;/p&gt;

&lt;h2&gt;
  
  
  The Technical Bits (for the nerds)
&lt;/h2&gt;

&lt;p&gt;It's stupidly simple, which is why I'm kind of mad I didn't build it sooner:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Git post-checkout hook&lt;/strong&gt;: Triggers on branch switch&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Branch-specific storage&lt;/strong&gt;: &lt;code&gt;.claude/memories/{branch-name}.md&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automatic sync&lt;/strong&gt;: Save before switch, load after switch&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bash 3.2 compatible&lt;/strong&gt;: Works on that ancient macOS bash you refuse to upgrade&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The whole thing is ~500 lines of bash. No dependencies. No node_modules. No Docker. Just a git hook and some file operations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# What's actually in the git hook (simplified)&lt;/span&gt;
&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nv"&gt;OLD_BRANCH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;
&lt;span class="nv"&gt;NEW_BRANCH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$2&lt;/span&gt;

&lt;span class="c"&gt;# Save current context&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="s2"&gt;"CLAUDE.md"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; .claude/memories
    &lt;span class="nb"&gt;cp &lt;/span&gt;CLAUDE.md &lt;span class="s2"&gt;".claude/memories/&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;OLD_BRANCH&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.md"&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="c"&gt;# Load new context&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="s2"&gt;".claude/memories/&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;NEW_BRANCH&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.md"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;cp&lt;/span&gt; &lt;span class="s2"&gt;".claude/memories/&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;NEW_BRANCH&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;.md"&lt;/span&gt; CLAUDE.md
&lt;span class="k"&gt;else
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"# &lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;NEW_BRANCH&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; context"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; CLAUDE.md
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What I didn't expect
&lt;/h2&gt;

&lt;p&gt;The thing that surprised me most? It made me write better context files.&lt;/p&gt;

&lt;p&gt;Before, I'd write these massive CLAUDE.md files trying to cover everything because switching was such a pain. Now each branch has focused context. My feature/payment branch knows about payments. My fix/auth-bug branch knows about auth. Claude gives better suggestions because the context isn't polluted with irrelevant stuff.&lt;/p&gt;

&lt;p&gt;Also, code reviews got easier. The CLAUDE.md in each PR now actually describes what that branch does. It's documentation that writes itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  The "yeah but what about..." section
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;"What if I don't want it to switch?"&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;branch-memory disable  &lt;span class="c"&gt;# Turn it off&lt;/span&gt;
branch-memory &lt;span class="nb"&gt;enable&lt;/span&gt;   &lt;span class="c"&gt;# Turn it back on&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;"What if I want to share context between branches?"&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;branch-memory copy main feature/new-branch  &lt;span class="c"&gt;# Copy context from main&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;"What if I fuck something up?"&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;branch-memory restore  &lt;span class="c"&gt;# Restore from automatic backup&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;"Does it work with worktrees/submodules/whatever?"&lt;/strong&gt;&lt;br&gt;
Yes. If git can track it, this can handle it.&lt;/p&gt;
&lt;h2&gt;
  
  
  Try it, seriously
&lt;/h2&gt;

&lt;p&gt;Look, I built this because I needed it. Not for stars on GitHub (though stars are nice 👀), not for my resume, but because switching branches with Claude Code was driving me insane.&lt;/p&gt;

&lt;p&gt;If you're using Claude Code (or Cursor, or any AI tool with context files) and you work on multiple branches, just try it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install (30 seconds)&lt;/span&gt;
curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/Davidcreador/claude-code-branch-memory-manager/main/install.sh | bash

&lt;span class="c"&gt;# That's it. You're done.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If it doesn't save you time in the first day, uninstall it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/Davidcreador/claude-code-branch-memory-manager/main/uninstall.sh | bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But I'm betting you'll wonder how you lived without it.&lt;/p&gt;

&lt;h2&gt;
  
  
  P.S.
&lt;/h2&gt;

&lt;p&gt;If you find bugs, open an issue. If you have ideas, send a PR. If it saved your sanity, maybe star the repo so other devs can find it.&lt;/p&gt;

&lt;p&gt;And if someone from Anthropic is reading this - please just build this into Claude Code. Until then, we've got git hooks.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;GitHub&lt;/strong&gt;: &lt;a href="https://github.com/Davidcreador/claude-code-branch-memory-manager" rel="noopener noreferrer"&gt;claude-code-branch-memory-manager&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Install&lt;/strong&gt;: &lt;code&gt;curl -fsSL https://raw.githubusercontent.com/Davidcreador/claude-code-branch-memory-manager/main/install.sh | bash&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My rage-driven development philosophy&lt;/strong&gt;: If you have to do something stupid more than 3 times, automate it.&lt;/p&gt;

</description>
      <category>git</category>
      <category>ai</category>
      <category>productivity</category>
      <category>bash</category>
    </item>
    <item>
      <title>Fish Shell + Deno | Command Line</title>
      <dc:creator>David Pastor</dc:creator>
      <pubDate>Thu, 14 May 2020 17:35:15 +0000</pubDate>
      <link>https://forem.com/davidcreador/fish-shell-deno-command-line-28nk</link>
      <guid>https://forem.com/davidcreador/fish-shell-deno-command-line-28nk</guid>
      <description>&lt;h3&gt;
  
  
  TLDR; This is a short tutorial on how to set up and use Deno with the Fish shell. NOTE: I am using a Macbook, I am not sure how to fix it on other OS.
&lt;/h3&gt;

&lt;p&gt;Today, I wanted to try Deno for the first time, but I also use Fish as my main shell for the Command Line and I got this error after executing &lt;code&gt;deno&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;fish: Unknown command: deno&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The way I solved it was to go into the fish config files:&lt;br&gt;
&lt;code&gt;~/.config/fish/config.fish&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and add the following lines:&lt;br&gt;
&lt;code&gt;set -x DENO_INSTALL /Users/YOUR_USER/.deno&lt;/code&gt;&lt;br&gt;
&lt;code&gt;set -x PATH $DENO_INSTALL/bin:$PATH&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;then just &lt;code&gt;source ~/.config/fish/config.fish&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After that you will be able to execute Deno in the command line using Fish Shell. Any errors after that, might be related to Deno’s shell or missing flags when running it.&lt;/p&gt;

&lt;p&gt;Thanks for reading this short how-to post and feel free to share it.&lt;/p&gt;

</description>
      <category>deno</category>
      <category>fish</category>
      <category>commandline</category>
      <category>software</category>
    </item>
  </channel>
</rss>
