I Built a CLI That Saves Your AI Coding Context When Rate Limits Hit
Developer Tools
14 min read

I Built a CLI That Saves Your AI Coding Context When Rate Limits Hit

How git hooks, token-aware compilation, and zero dependencies create an autonomous safety net for developers juggling multiple AI tools

February 20, 2026
Himanshu Shukla

Key Takeaway

Every time a rate limit kills your AI session, you lose 15 minutes re-explaining everything. I built a zero-dependency CLI that auto-saves your context via git hooks — so when limits hit, you just open a file and paste.

The 2 AM Disaster

Last Tuesday at 2 AM, I was deep in a coding session with Claude Code. I'd been working on a Firebase auth flow for about 3 hours — the kind of session where the AI finally gets your codebase, knows which files matter, remembers that you chose RS256 over HS256 for a reason, and understands the weird workaround you did in middleware/auth.ts.

Then Claude hit a rate limit.

Session over. Dead. I couldn't even run a command to save what I was working on.

I stared at the screen for a solid 10 seconds. Then I opened Cursor, and it asked me the most painful question a developer can hear after 3 hours of deep work:

"How can I help you today?"

I had to re-explain everything. From scratch. The project structure, the auth flow, the decision about RS256, the files I'd changed, the bugs I'd already fixed. It took me about 15 minutes to get Cursor up to speed. And honestly, it never quite got back to where Claude was.

That 15 minutes broke something in me. Not because it was a lot of time. But because I knew it would happen again. And again. And again.


This Happens to Everyone

I started paying attention after that night. And I noticed a pattern.

I work on 3-4 projects simultaneously. Analytics dashboard in one tab, a strategic platform in another, a client project somewhere else. Each one has sessions running in different AI tools — Claude Code for the heavy lifting, Cursor for quick edits, GitHub Copilot for autocomplete. If you're interested in how I manage complex projects with AI, I wrote about the AI revolution in project management separately.

Every single time I switched tools, I lost context. Every time a rate limit hit, I lost context. Every time I came back to a project after lunch, I lost context.

76%
Developers Use 2+ AI Coding Tools
Stack Overflow 2025 — most devs juggle multiple AI tools daily
15 min
Average Time Lost Per Context Switch
Re-explaining your project to a new AI session
11
AI Coding Tools Available Today
Claude, Cursor, Codex, Copilot, Windsurf, and more

The context loss tax is real. And nobody was solving it.

I Searched for Existing Tools

I'm not the "build everything from scratch" type. I always check what's out there first.

Ruler (~2,500 stars) does rule-syncing across AI tools really well. ai-rulez takes a similar approach. If you just need to keep your .cursorrules and CLAUDE.md in sync, those tools work.

But none of them save session context — what branch you're on, what you were working on, what decisions you made, what bugs you already fixed. And critically, none of them survive rate limits because they all require you to run a command to save.

What you needRuler / ai-rulezSaveContextai-context-bridge
Sync rules across toolsYes — this is their strengthNoYes
Save session contextNoYesYes
Survive rate limits (pre-saved)NoNoYes (git hooks)
Zero workflow changeManual syncManual saveAutomatic
DependenciesSomeSQLite + depsZero

The gap I was trying to fill wasn't "better Ruler." It was a different problem entirely:

The Core Problem

When a rate limit hits mid-session, you can't run any commands. Your context needs to already be saved.


The Insight That Changed Everything

The problem isn't "how do I save my context." The problem is "how do I make sure my context is already saved before I need it."

If you're using Claude Code and it hits a rate limit, you can't run save-my-context or whatever. The session is dead. You can't type anything. The horse has left the barn.

So the saving has to happen before the limit hits. Automatically. Without you doing anything.

And that's when it clicked: git hooks.

Every developer commits code. Every commit is a natural checkpoint. What if, every time you committed, your AI context auto-saved in the background? And what if it pre-generated resume prompts for every tool you might want to switch to?

Then when the rate limit hits — or when you just want to switch tools — you don't need to run anything. You just open a file. It's already there. This is the kind of autonomous tooling that defines the next era of developer workflows.


See It in Action

Here's what ctx init looks like in practice — one command, and your context auto-saves from that point on:

Terminal demo showing ctx init command setting up auto-saving context via git hooks
ctx init — sets up git hooks, creates resume prompts for 11 AI tools, registers in global dashboard

And here's the real payoff — when a rate limit hits, you switch tools in seconds, not minutes:

Terminal demo showing ctx switch command generating a ready-to-paste resume prompt for Cursor
ctx switch cursor — generates a ready-to-paste resume prompt. Open, paste, keep working.

Star on GitHub

ai-context-bridge is open source and free. If it saves you time, consider starring the repo — it helps other developers discover the tool.


So I Built It

I spent a weekend building ai-context-bridge (command: ctx). TypeScript, zero production dependencies, published on npm.

Terminal
1npm i -g ai-context-bridge
2cd my-project
3ctx init

That's the only command you need to run. Everything else is automatic.

What happens behind the scenes:

1
Creates context directory

Sets up .ctx/ (or external storage) with config, rules, and session directories

2
Installs git hooks

post-commit, post-checkout, post-merge — all fire silently in the background

3
Pre-generates resume prompts

Creates ready-to-paste prompts for all 11 supported AI tools

4
Registers in global dashboard

Tracks all your projects in ~/.ctx-global/ for multi-project management

From that point on, every time you commit, the hooks fire silently. They capture your current branch, recent commits, changed files, what you're working on — and generate a ready-to-paste resume prompt for all 11 tools.

When the rate limit hits, your prompts are already waiting:

.ctx/resume-prompts/
1claude.md ← paste into a new Claude session
2cursor.md ← paste into Cursor
3codex.md ← paste into Codex
4copilot.md ← paste into Copilot
5windsurf.md ← paste into Windsurf
6cline.md ← paste into Cline
7aider.md ← paste into Aider
8continue.md ← paste into Continue
9amazonq.md ← paste into Amazon Q
10zed.md ← paste into Zed
11antigravity.md ← paste into Antigravity

Open the file. Paste. Keep working. 10 seconds.

The Rate Limit Scenario — Solved

Before ctx: Rate limit hits → session dead → open Cursor → re-explain everything → 15 min wasted

With ctx: Rate limit hits → open .ctx/resume-prompts/cursor.md → paste → keep working in 10 seconds


The Engineering Challenges

Token-Aware Compilation

Each AI tool has wildly different size limits. This was the hardest engineering challenge:

ToolConfig FormatSize Limit
Claude CodeCLAUDE.md~100K chars
Cursor.mdc files with YAML frontmatter~2.5K/file
CodexAGENTS.md32 KiB
Windsurf.windsurf/rules/*.md6K/file, 12K total
Copilot.github/copilot-instructions.mdNo limit
Cline.clinerules/*.mdNo limit

When you have project rules + session context + recent commits + changed files, and you need to fit it all into Windsurf's 12K limit... what do you cut?

I built a priority-based compiler:

  • Session context is never truncated — that's the whole point
  • Rules are added in priority order until the tool's budget is exhausted
  • Windsurf gets aggressive compression
  • Claude gets everything because it has a ~100K char budget

Autonomous Auto-Save via Git Hooks

The auto-save system triggers on natural developer workflows:

Git EventWhat HappensYou Do Nothing
git commitAuto-saves context, refreshes all resume promptsYes
git checkoutUpdates branch context, refreshes promptsYes
git mergeUpdates context with merge stateYes
ctx watchBackground watcher refreshes every 30s + on file changesYes

The Public Repo Problem

Here's something I didn't anticipate until it bit me.

I was building ctx in a public GitHub repo. I ran ctx init in my own project. It created .ctx/ inside the repo — with sessions containing details about my private blog drafts, launch strategy, and feature plans. Then I pushed.

Oops.

I accidentally pushed private session data to a public repository. Had to rewrite git history to clean it up.

The irony of a context-saving tool accidentally leaking context was not lost on me.

So I built external storage mode:

Terminal
1# Private repos — .ctx/ inside the project
2ctx init
3
4# Public repos — zero files in the project directory
5ctx init --external

The --external flag stores ALL ctx data — config, rules, sessions, resume prompts — at ~/.ctx-global/projects/<project-name>/ instead of .ctx/ inside the project. Zero files created in the project directory.

Git hooks still work because they live in .git/hooks/, which git itself never pushes.

External Mode Benefits

  • Zero files in the project directory — nothing to accidentally push
  • All commands work identically (path resolution is automatic)
  • Git hooks still auto-save on every commit
  • Backwards-compatible — internal mode unchanged

Trade-offs

  • Rules can't be shared with teammates via git (they're not in the repo)
  • Need to re-init if you move the project directory

Multi-Project Was an Afterthought That Became Essential

I work on 3-4 projects simultaneously. After building the core tool, I added a global registry at ~/.ctx-global/ that tracks all your ctx-initialized projects.

ctx projects list
1Projects (3)
2dtc-dashboard [feature/charts] (live)
3 ~/dtc-dashboard (git) — Adding Recharts analytics
4 Last active: 5m ago
5
6strategic-platform [main] (live)
7 ~/strategic-platform (git) — Firebase auth flow
8 Last active: 2h ago
9
10open-source-lib [main] (live)
11 ~/open-source-lib (external) — Building v2 API
12 Last active: 1d ago
13
143 project(s) with live context ready.

This turned out to be way more useful than I expected. Before, I'd context-switch between projects and forget where I left off. Now I run ctx projects list and immediately see what I was doing in each one. It's like a dashboard for your brain.


The Vibe Coding Paradox

I should be honest about something. I'm not the kind of developer who dreams in assembly or has opinions about Rust lifetimes. I'm a project manager by profession. I think in systems, workflows, and business problems. I've built AI agents and shipped real products over the past year — all through vibe coding.

And yet I built a TypeScript CLI tool with 11 adapters, a priority-based token compiler, a git hooks system, and a global project registry. Published on npm. 115 tests passing.

How?

AI. I built this entire thing with Claude Code. Not "AI assisted" in the polished LinkedIn sense — I mean I described what I wanted in plain English, Claude wrote the code, I tested it, we iterated. I've written about why the right strategy matters more than the tool itself — and this project proved it.

Here's the funny part. The whole time I was building ctx with Claude Code, I kept hitting the exact problem the tool is designed to solve. Rate limits would hit mid-session. I'd switch to a new session. Context gone.

I started using ctx on itself during development. Running ctx init in the repo, committing regularly, and when Claude's session died, I'd open .ctx/resume-prompts/claude.md and paste it into a new session. It actually worked. The new session picked up exactly where the old one left off.

Terminal demo showing rate limit recovery — opening a pre-generated resume prompt and pasting into a new AI session
Rate limit hits → open resume prompt → paste into new session → keep working. 10 seconds.

A project manager who thinks in systems, not syntax, building a developer tool with AI to solve a problem caused by AI. The tool kept saving itself during its own creation. That's either poetic or absurd — probably both.

Me3 AM, using ctx to rebuild ctx

What I Learned

Key Takeaways

  • 1The best developer tools solve invisible problems. Context loss isn't dramatic — nobody tweets about it. But it happens dozens of times a day to millions of developers.
  • 2Zero dependencies is a feature. The whole thing runs on Node.js built-ins. Startup is instant. Install is 62 KB. No native compilation. No build issues. Just works.
  • 3Autonomous beats manual every time. The first version required manual saves. Making it automatic via git hooks was the difference between 'nice idea' and 'actually useful.'
  • 4External storage matters for open source. One accidental push of session data to a public repo taught me that the --external flag isn't optional — it's essential.

Try It

Terminal
1# Install
2npm i -g ai-context-bridge
3
4# Private repos
5cd your-project
6ctx init
7
8# Public/open-source repos (zero files in project)
9ctx init --external
10
11# That's it. Work normally. Commit normally.
12# Your context is always saved.

Zero Dependencies. 11 Tools. Autonomous. Open Source.

Install size: 62 KB | Tests: 115 passing | License: MIT

GitHub: github.com/himanshuskukla/ai-context-bridge | npm: ai-context-bridge

I'd genuinely love to hear what you think. If you're one of those developers who uses Claude and Cursor side by side (I know there are a lot of us), I think this will save you a surprising amount of time and frustration.

And if you hit a rate limit right now... well, at least next time you'll be ready.


Frequently Asked Questions

When Claude hits a rate limit, your session dies and you can't run any commands. Without ctx, you'd have to open a new AI tool and spend 10-15 minutes re-explaining your entire project context. With ctx installed, your context is already saved (it auto-saves on every git commit via hooks). Just open .ctx/resume-prompts/cursor.md (or whichever tool you want), paste it in, and keep working — about 10 seconds total.

Want to Level Up Your AI Coding Workflow?

I help teams and individuals design productive workflows with AI coding tools. From context engineering to multi-tool strategies — let's talk about how to make AI actually work for you.

AI Coding ToolsDeveloper ProductivityOpen SourceContext EngineeringCLI ToolsVibe CodingRate LimitsClaude CodeCursorAI Tool Switching

Subscribe to my newsletter

Get the latest articles, insights, and updates delivered straight to your inbox.

No spam, unsubscribe at any time.