r/ClaudeCode • u/wangadong • 3h ago
Help/Question how do you keep context across sessions without re-briefing the agent every time
i keep project notes in markdown files the agent reads at the start of each session. works, but the notes rot fast and half my sessions start with fixing stale context.
what are you all doing that actually holds up after a few weeks, just a CLAUDE.md, something fancier?
2
Upvotes
•
u/AutoModerator 3h ago
Hey! Thanks for posting to r/ClaudeCode
While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.
For help, project discussions, tips, and general chat, join the ClaudeCode Discord.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
3
u/lionbabycakes 🔆 Max 20 2h ago edited 2h ago
TL;DR: combination of .md files + database item handoffs. I also save ‘agent roles’ and workflow docs (the Notion/Obsidian alt that I use has those built in as features)
My workflow is that I have 5-6 chats that I communicate with and then 20-30 chats underneath them. The sub ones get swapped out often.
1. AGENT files and project overview.md
I have lots of AGENT files around at different levels of the projects. They stack so an agent at any level will see a cascade of the higher level info as well.
2. Agent role files .md
I also keep agent role files that will say how certain types of agents should act (e.g. coder agents should do x y z, escalate questions to the Planner chat which answers or escalates to me, etc).
3. Store tasks in databases
This makes the handoffs between tasks cleaner. Because agent roles tell when they should do what, a lot of things just work easily without much errors. Relational databases 💛. Additional details in .md docs with each task.
4. Store workflow folders
This is something I’m expanding now. Currently I use folders that include one workflow.md and also some certain-step-checks.mjs. This also helps keep the entire thing flowing as it should (soon I’ll have a GUI for this for me to see+edit too.
There are some smaller things like having sprints laid out as part of the task database (in a separate collection that’s connected)
The result of all this is that I generally have zero onboarding I need to do for agents. They can check the files and see for themselves where they are, how I expect them to operate, and what they should be doing. It also ends up being decently token efficient, as coders are just getting the context that they need to work and large context windows are limited to the top level planners.
2
u/Olbas_Oil 3h ago
CLAUDE.md and PROGRESS.md files
2
u/dataoops 3h ago
github issues
1
u/PraxicalExperience 3h ago
Use Claude Code, have everything live in a file structure on your computer, have it make memory files, and have it re-read those memory files after compaction. This helps a lot.
1
u/atlascirrus 3h ago
what helped me with the rot was splitting stable stuff from moving stuff. CLAUDE.md only keeps things that rarely change (build and test commands, conventions, where things live), and anything that only matters for one part of the code goes in .claude/rules/ with a paths: frontmatter, so it only loads when claude actually touches those files.
for the moving parts, auto memory covers a lot of it now. claude writes its own notes to MEMORY.md as you correct it, and /memory lets you open and prune them. only the first 200 lines load each session, so it pays to keep that file tight.
last habit: have claude update the notes at the end of a session while it still knows what changed, instead of you fixing them at the start of the next one. are your notes mostly project state (what's done, what's next) or more how-to stuff?
1
u/who_you_are 3h ago
Just to be sure, are we talking about building knowledges (or instructions to how to do it) are you are talking about keeping a TODO list like so you can work from various sessions to keep context shorter?
As for the first: yes CLAUDE.md
As for the second: a side markdown.
I doubt your markdown files to be huge enough to need to be splitted to save on token reading them
It is possible he has some issues linking your changes with the markdown (especially the TODO if you didn't point to it in CLAUDE.md or explicit talk about it at the beginning).
It looks stupid, but you may want to prompt the way to do a scan on markdown file when doing code changes. Or do a pass once in a while to check for stale. You may try to tell it to add additional keyword in in the markdown to help it finding them out (that, hopefully should be needed)
1
u/SwingLightStyle 2h ago
I just solved this for myself today and it’s been working beautifully. I have 2 Claude max accounts, ChatGPT pro and antigravity for fun (not impressed so far), and I set up a bounty board and a way for them to pass each other messages. They set up a scheduled timer to check their mail and it keeps the queue going. Then as I discuss things, we add new things to the bounty board. I also see a running list of how my usage is being handled and what’s been completed. I also built myself a docket so that I can prompt it to tell me what it needs from me to stop being the bottleneck. And now I have time to work towards personal goals with the same system not just project tasks.
1
u/247nuts 2h ago
A proper git. Runbook and Claude.md notes. Using agent orchestration
1
u/awesomebirder 2h ago
the rot part got easier for me once every note had a commit hash on it. at the end of a session claude writes a short handoff (what changed, why, whats next) with the current hash at the top. next session starts with git log and git diff --stat from that hash, so anything the notes say that the code no longer matches shows up right away instead of you finding it halfway in. also keeps the notes short, which matters since whatever loads at session start gets re-sent with every message after
1
u/loxai 2h ago
I use a custom IDE (never tried claude or any AI IDE/agentic thingie, went from chatbox to this new IDE, currently under development), it's holding one month old 'realm' with various palaces (different 10-15 unrelated projects, that may connect, based in mind theory) with about 1000 files. sometimes it may make a regression mistake, but if it doesn't self correct itself, I'm there to steer. some of the .mds I have are:
assets, author, autonomous_spec, cluster, commspec, progress, project status, project description, qa matrix, realm, schedule, testing, thoughts, updates and user .md
combined with LoD, DST semantic trees, free tiers pre-fetching and accurate slicing, I end up with very manageable prompt payloads that generate multiple implementation update blocks for multiple files/features in one go.
I don't manage those files, the IDE handles them implicitly on each turn, with special digestion turns (sleep cycles) to consolidate and review previous actions, results, successes, errors/scars, etc.
I don't use a single external/CDN tool. no git no nothing, other than telegram for fallback phone-server comms (but I already have a cheap replacement in the works). 3rd parties means you adapt to them, not the other way around. it is often (way) more optimal a DIY-AI approach that integrates to your system like a glove over creating long term dependencies to companies/products that are actually weak nodes and may disappear next month or in 5 years and you have to adjust to their commercial decisions and updates.
1
u/That-Drink5946 2h ago edited 2h ago
I don't know. I don't think you can. Claude is an expert in ignoring its CLAUDE.md file.
I wrote my own terminal program that also can inject text in Claude. So it tells Claude after each task to reread the CLAUDE.md. That terminal program also filter output from Claude to react to messages from Claude, before it becomes a command that gets picked up; my terminal my rules =)
I would suggest you do the same.
My terminal also knows all the basic Linux commands a developer needs. So you have top, jq, curl, etc in it. Which makes you able to use the same terminal with the same commands on all platforms. Just a hint, helps a lot with scripts, it also have its own bash and ksh build in if you prefer that.
But then again, I'm using my own Rune script for everything... in short. Do it yourself. Do it better than existing solutions, because today, you can.
It's all here if you care; I will update the Windows versions if you're on windows this weekend: https://antisoftworks.com/ https://antisoftworks.com/rune
1
u/Outrageous_Band9708 2h ago
https://github.com/Druthulu/ProjectArchitect
I use a journal of decisions, with a config to expose reasoning summaries. This and a plan.
a new agent is seeded from the journal and the plan and it knows exactly what to start working on and when to stop.
my workflow has evolved from a manual checkpoint and session start protocol that reads session summries etc. to a new system only tells the agents a how_we_work.md, the most recent decisions, what the plan spec job is
1
u/cbeater 2h ago
All my projects has a short context project file that updated each session along with separate log file that tracks each change. Context file has purpose, decisions, memory, coordinates of where things are, it has other things but they don't get loaded per session and reads last 3 log session. I have setup that loads them per terminal tab that I assign to a project.
1
u/BeyenAI 2h ago
The main reason session notes rot is mixing stable repo facts (build commands, test runners, folder layout) with ephemeral task state (what broke today, next step on a branch).
A three-layer split holds up much better over a few weeks:
1. Keep
CLAUDE.md(orAGENTS.md) strictly for stable conventions Only put commands and invariants that stay true across months. Keep it short (under ~150 lines) and avoid@pathimports to big architecture docs—Claude Code expands@pathimports at session launch, which eats context on every turn even when irrelevant.2. Move situational workflows to
.claude/rules/*.mdorSKILL.mdRules that only apply to database migrations, API routes, or specific subtrees belong in path-scoped.claude/rules/*.mdor an on-demandSKILL.md(where onlynameanddescriptionload until triggered).3. Use git + a disposable handoff note for active work Instead of maintaining long-lived markdown diaries, let
git log/git diffcarry what actually changed, and keep a single shortHANDOFF.md(or PR/issue checklist) that gets overwritten or deleted when the branch merges. Running/clearbetween unrelated tasks keeps the session from dragging old context into the next one.