r/ClaudeCode • • 14h 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?

0 Upvotes

28 comments sorted by

•

u/AutoModerator 14h 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.

2

u/Olbas_Oil 13h ago

CLAUDE.md and PROGRESS.md files

2

u/dataoops 14h ago

github issues

1

u/PraxicalExperience 14h 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 14h 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 14h 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 13h 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 13h ago

A proper git. Runbook and Claude.md notes. Using agent orchestration

1

u/awesomebirder 13h 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 13h 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 13h ago edited 13h 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 13h 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 12h 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 12h 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 (or AGENTS.md) strictly for stable conventions Only put commands and invariants that stay true across months. Keep it short (under ~150 lines) and avoid @path imports to big architecture docs—Claude Code expands @path imports at session launch, which eats context on every turn even when irrelevant.

2. Move situational workflows to .claude/rules/*.md or SKILL.md Rules that only apply to database migrations, API routes, or specific subtrees belong in path-scoped .claude/rules/*.md or an on-demand SKILL.md (where only name and description load until triggered).

3. Use git + a disposable handoff note for active work Instead of maintaining long-lived markdown diaries, let git log / git diff carry what actually changed, and keep a single short HANDOFF.md (or PR/issue checklist) that gets overwritten or deleted when the branch merges. Running /clear between unrelated tasks keeps the session from dragging old context into the next one.

1

u/ClemensLode Senior Developer 8h ago

each change should be very small

1

u/AgentYurt 8h ago

What finally made this stick for me was keeping one short handoff note per project and rewriting it instead of appending to it: the decisions we made and why, the options we tried that didn't work, and the single next step. At the start of a session I have the agent read just that note, then ask it to restate the plan in its own words before it touches anything — if it can't, the note is stale and I fix it first. The rewriting part matters more than the format; an ever-growing log rots just like the notes you're describing.

How often are you finding the notes go stale — is it after a few days, or mainly when you switch between projects?

1

u/CandidSystem6155 7h ago

What held up for us was a handoff file per working folder, kept separate from long term memory. A SessionStart hook injects it into the next session, and another hook writes it automatically when a session has been idle for about 55 minutes, so it never depends on remembering to save. For the rot, anything that came from outside or from one person's claim is marked unverified in the note until we check it, and memory is one small file per note plus a one line index, so fixing a stale fact means editing one file.

1

u/torvalds75 6h ago

The rot usually comes from one file trying to hold two different things: facts about the code (which go stale the moment the code changes) and the why behind decisions (which almost never changes). I'd split them:

  • Don't write down what the code already says. Where things live, what a function does, current structure: let the agent read the code. Notes that describe the code are the ones that rot.
  • Keep only what the code can't tell it: "tried A, dropped it because B, next is C". That stays true even after a refactor.
  • Tie that record to a unit of work, not to one big file. One note per task that opens when the work starts and closes when it's done, so nothing stale lingers in what gets loaded at session start. The new session reads the task it's on, not the whole history.

The commit hash trick mentioned above is a good complement: the code tells you what changed, the task record tells you why.

I went the GitHub Issues route someone mentioned for exactly this, and ended up building a plugin around it, trailhead (I build it): each decision is a ticket, the discussion, plan and verification live on the issue, and any new session (Claude Code or Codex) picks up from the ticket instead of a re-brief. https://github.com/ToRvaLDz/trailhead

1

u/Obvious-Actuator-672 6h ago

What stopped the rot for me was giving one agent the job of keeping the current state doc tidy, so fresh sessions start from something that's actually true. I run it all in Worktable (a tool I built, open source)

1

u/japbujan 5h ago

The rot for us came from writing notes as a summary at the end of a session. They described what we did, so they went stale as soon as the code moved. What has held up for a few months: write a short record at the moment something is decided (what, why, what we rejected), give it a status, and when it changes, mark the old one replaced instead of editing it. A session loads only the current ones. Progress and todo notes go somewhere disposable; only the decisions are kept.

1

u/onitsoga 2h ago

the rot is the real problem, not the notes. keep the file for docs but let tasks live where agents claim them, so the next session reads what the last one finished. i'm building KanbanMCP for that. do you prune it or rewrite it?

1

u/LabAccomplished299 1h ago

It’s crazy easy yet people have no clue how to do it which is insane to me

1

u/Ok-Form1598 5m ago

the notes that rot are the ones describing the code. keep why you decided things and let it read the code for the rest

1

u/RodrixLabs 1m ago

A plain CLAUDE.md still holds up after a few weeks, as long as you stop it from becoming a dumping ground. If it keeps growing every time the model does something dumb, it's worth a split instead of another line:

  1. Keep the always-loaded file small. The Claude Code docs suggest under ~200 lines per CLAUDE.md, since longer files eat context and reduce adherence. What belongs there: how to build, how to test, the few rules that apply to every task.
  2. Move area-specific stuff into path-scoped rules. A file in .claude/rules/ with paths: frontmatter (e.g. "src/api/**/*.ts") only loads when Claude reads or edits matching files, so your API conventions stop costing context while it works on the frontend.
  3. Don't count on @imports to save space. They help organize, but imported files load together with the CLAUDE.md that imports them, so the context cost is the same.
  4. After a model upgrade, try deleting the lines that only existed to patch an older model's quirks, then re-run a couple of normal tasks. A lot of that scar tissue isn't needed anymore, and two rules that contradict each other can get picked arbitrarily.

3

u/[deleted] 13h ago edited 13h ago

[removed] — view removed comment

1

u/1s2_2s2_2p2 10h ago

May I ask a follow up question? When you suggest no 3 store task in databases. Do you mean a history of tasks previously performed? Or a literal spreadsheet of what agent should code what line of code level of specificity?

I have .md files describing agent roles but am wondering if I also need something more.