惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Apple Machine Learning Research
Apple Machine Learning Research
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
G
Google Developers Blog
博客园 - 司徒正美
J
Java Code Geeks
aimingoo的专栏
aimingoo的专栏
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
T
The Blog of Author Tim Ferriss
D
Docker
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
腾讯CDC
V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
Check Point Blog
M
MIT News - Artificial intelligence
Jina AI
Jina AI
I
InfoQ
雷峰网
雷峰网
The Cloudflare Blog
美团技术团队
Engineering at Meta
Engineering at Meta

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Running Claude Code across multiple repos without losing ...
Sangmin Lee · 2026-05-23 · via DEV Community

Sangmin Lee

Originally published at claudeguide.io/claude-code-workflow-multi-repo

Running Claude Code across multiple repos without losing context

If you work on more than one codebase at a time — an API, a dashboard, a shared library — the honest problem with Claude Code is not the tool, it's you forgetting which conversation is which. This post documents the workflow that actually works on a Mac mini M4 with 32GB RAM after six weeks of daily use. For a full overview of what Claude Code can do, see the Claude Code Complete Guide.

TL;DR

  • One Claude Code session = one repository. Do not mix.
  • Use project-scoped CLAUDE.md at the root of each repo to pin context.
  • Put persistent cross-repo facts in ~/.claude/CLAUDE.md (user-global).
  • For cross-repo refactors, use a third "orchestrator" session that spawns Explore subagents into each repo.
  • Checkpoint before every context-heavy operation with /remember or /checkpoint.

Why the naive approach breaks

The first instinct is to open one Claude Code window and cd between projects. This fails for three concrete reasons:

  1. File cache collisions. Claude Code tracks which files you've opened. Switching directories mid-session causes stale path assumptions.
  2. System prompt dilution. Each repo's CLAUDE.md only gets loaded at startup. Switching afterwards means the guidance doesn't reattach.
  3. Conversation contamination. Decisions made for Repo A leak into Repo B's implementation when a single conversation carries both.

We measured the impact over a 2-week A/B split on a 3-repo project:

Workflow Avg tokens / task Rework rate Subjective frustration (1-5)
Single session, cd between repos 42,800 31% 4.1
One session per repo, user-global CLAUDE.md 18,600 8% 1.8

The one-session-per-repo workflow used 57% fewer tokens and reduced rework by 4x.

The setup, step by step

1. Write a tight CLAUDE.md in each repo

Keep it under 200 lines. It should answer: what is this repo, what stack, where does the code live, what tests exist, what's the deploy path. No aspirational content — only what's true today.

# CLAUDE.md — api-service
- Node 20, TypeScript 5.6, Fastify 5
- Routes: src/routes/*
- Tests: vitest run, one file per route under tests/
- Deploy: Fly.io via `fly deploy` (staging auto on main push)
- Secrets: .env.local (dev) / Fly secrets (prod)

Enter fullscreen mode Exit fullscreen mode

2. Put cross-repo facts in ~/.claude/CLAUDE.md

This is your shared preamble. Useful entries:

  • Your preferred commit message style
  • Tools you have globally (tsx, pnpm, bun)
  • Platform oddities (Mac mini M4, Apple Silicon specifics)
  • Recurring project names and what they mean

3. Open one session per repo

Use terminal tabs, iTerm split panes, or Warp workflows — one Claude Code process per repo. Expect 1-3 concurrent at any time. On a Mac mini M4 32GB, three sessions with full context hover around 6-8GB resident.

4. For cross-repo work, spawn an orchestrator

When you have a change that spans repos (say, "rename this API endpoint and update all callers across three frontends"), open a fourth session in a neutral directory and use the Agent tool to dispatch Explore subagents into each repo. Collect findings, then hand off to the per-repo sessions for implementation.

Frequently Asked Questions

Does Claude Code share memory across sessions?

No. Each session has its own conversation. The .remember/ folder in your project directory persists across sessions within that project, but two separate sessions do not see each other's live context.

How big should CLAUDE.md be?

Under 200 lines in the repo; under 100 lines globally. Anything longer will either get ignored or crowd out working memory.

Can I use Claude Desktop and Claude Code simultaneously?

Yes. They do not interfere. Claude Desktop is better for ideation and writing; Claude Code for anything touching the filesystem.

What about git worktrees?

Worktrees work well for the "spawn orchestrator" pattern. You can have one main checkout for active development and a worktree for an agent to explore safely without conflicting. See Worktree Isolation in Claude Code for a step-by-step setup guide.

How many concurrent sessions is too many?

On a Mac mini M4 with 32GB RAM, three full sessions hover at 6–8 GB resident. Four to five starts competing for memory with your other tools. In practice, keep concurrent sessions to three — one per active repo. Open a fourth only for short orchestrator tasks, then close it.

What we got wrong at first

Our first two weeks used a single session with symlinks instead of separate sessions. Token usage was 2.3x higher and we kept getting file path errors because Claude's cached path assumptions outlived our cd changes. Separate sessions eliminated both problems in a single afternoon of setup.

Source data

All measurements in this post come from logs on a Mac mini M4 32GB running macOS 15.4, April 4-18 2026. The repositories were an API (Fastify), a dashboard (Next.js 15), and a shared library (TypeScript). Raw log samples are available on request.


Part of the Claude Code workflow series on claudeguide.io. Disclosure: This site is part of the Biz AI self-investment project. The SaaS we build (claudecosts.app) is linked in our product index but not promoted in this post.


Take It Further

Claude Code Power Prompts 300 — 300 battle-tested prompts for Claude Code, organized by use case. Copy, paste, ship.

40 slash command templates. Token-optimized variants. JSONL file for direct import. Tested in production sessions.

→ Get Claude Code Power Prompts 300 — $29

30-day money-back guarantee. Instant download.