Sub topic 10
Keeping plans and progress in files outside the chat
A conversation with a coding agent is temporary. Compaction rewrites it, a crash ends it, and a new session starts with none of it. Files in your repository persist through all of these. This chapter covers how to keep the plan, the decisions, and the progress in files so that the work can survive a context reset.
This chapter assumes you have read the earlier chapters on compaction and task scoping. You should be comfortable with git and with editing Markdown files in a terminal.
Why the chat is a poor place to store state
The chat history is the agent's working memory. It has three weaknesses as a record of the work:
- It is lossy. Compaction replaces many turns with a summary. A decision that was made in passing, such as "we will not touch the public API", can be dropped without anyone noticing.
- It is local to one session. A fresh session, a different machine, or a teammate sees none of it.
- It is expensive. Every message stays in the window and counts against the token budget on each turn, whether or not it is still relevant.
A file has the opposite properties. It is exact, because the text is what you wrote and not a paraphrase. It is shared, because any session can read it. It costs tokens only when someone reads it, and you control how much it holds.
The practical rule is this: anything you would be upset to lose in a reset belongs in a file.
What to put in files
Not everything needs to be saved. Three kinds of information are worth writing down.
| Kind | Example | Where it goes |
|---|---|---|
| Plan | The ordered steps of a migration | A plan section in the notes file |
| Decisions and reasons | "Use `tomllib`, because it is in the standard library" | A decisions section |
| Progress | Which steps are done, which tests still fail | A done and next section |
Do not save raw command output, full file contents, or exploratory dead ends. The code is already in the repository, and git history records what changed. Notes should point to these things and not copy them.
A progress file
A single short Markdown file at the repository root is enough for most tasks. The name is a convention you choose. PROGRESS.md is used here.
# PROGRESS.md
## Goal
Migrate the settings loader from INI to TOML without changing the public API.
## Decisions
- Keep `load_settings()` signature unchanged.
- Use the standard library `tomllib` for parsing (read-only).
## Done
- [x] Added TOML parser path in `config.py`
- [x] Updated unit tests for the loader
## Next
- [ ] Update the docs page for configuration
- [ ] Run the full test suite and fix failures
## Open questions
- Should INI files still be accepted with a deprecation warning?Each section has a job:
- Goal is one or two sentences. It lets a new session check whether a proposed action serves the task.
- Decisions hold the reasons as well as the choices. Without the reason, a later session may reverse a decision that was made for a good cause.
- Done shows what not to redo. Checkboxes make this quick to scan.
- Next is the part a fresh session acts on first. Keep it short and ordered.
- Open questions mark what the agent should ask you about and not guess.
Plan files versus progress files
A plan and a progress record change at different speeds. A plan is written once, then revised occasionally. Progress changes after every step. Mixing them makes every update rewrite a long document.
For larger tasks, use two files:
PLAN.mdholds the approach, the ordered steps, and the constraints. You review and approve it.PROGRESS.mdholds the current state, as in the example above, and refers to plan steps by number.
For a task that fits in one session, one file is enough. Splitting early adds upkeep without benefit.
The note-taking loop
A file helps only if it stays current. Build the updates into the work as a loop:
- Ask the agent to write the plan to the file, and read it yourself before approving.
- Work on one step.
- When the step is verified, for example when its tests pass, update the file before starting the next step.
- Commit the code and the notes together, or at least at the same checkpoints.
Updating after verification, not before, matters. A note that says "done" for work that does not pass its tests is worse than no note, because the next session trusts it.
You can state the rule once in your persistent instructions, for example: "After each completed step, update PROGRESS.md before starting the next one." This works well with the short, stable instructions described in an earlier chapter.
Writing notes that survive a cold read
Assume the reader has no memory of the session. That reader may be a fresh agent session, a teammate, or you next week. Three habits make notes readable in that situation.
Use concrete references. Write "config.py, function load_settings" and not "the loader". Write "test_config.py::test_missing_key fails with a KeyError" and not "one test is broken".
Record the reason with the decision. "Keep the signature unchanged because three other packages import it" prevents a later session from simplifying it.
Mark the state of each claim. Notes drift from reality. Distinguish what was verified from what was assumed:
## Status
- Verified: `pytest tests/test_config.py` passes (run after the TOML change).
- Assumed: the docs build does not depend on the INI sample file. Not yet checked.This tells the next session which claims to trust and which to check first.
Keeping the file small
A progress file that grows without limit becomes a second context problem. If the agent reads a 2,000-line notes file at the start of every session, you have moved the cost and not removed it.
Some ways to keep it short:
- Move finished work out of Done. After a milestone, replace ten checked items with one line such as "Loader migrated; see commit
a1b2c3d", or delete them. Git history keeps the detail. - Cap the Next list at about three to five items. Plan further ahead in
PLAN.md. - Resolve open questions and delete them, moving the answer into Decisions.
- Link to other files for detail. Write "API shape is described in
docs/api.md" instead of copying it.
A reasonable target is a file the agent can read in well under a page of output, a few dozen lines.
Reading the notes back
A new session does not know the file exists unless something tells it. There are two ways to handle this:
- Name the file in your first message: "Read PROGRESS.md and continue with the first unchecked item."
- Mention the convention in your persistent instructions, so each session knows to look.
Then check the agent's understanding before it edits. Ask it to state the goal and the next step in its own words. If the answer differs from the file, the file is unclear, and it is cheaper to fix the file now than to undo wrong edits later.
Failure modes
Notes in files fail in predictable ways.
- Stale notes. The code moved on and the file did not. The next session then acts on false information. Prevent this by updating at each verified step and by committing notes with the code.
- Conflicting sources. The notes say one thing, and the persistent instructions or the code say another. When you notice a conflict, fix the file. Do not rely on the agent to pick the right source.
- Over-detailed notes. Long pasted logs and code blocks consume the context you were trying to protect. Keep references, not copies.
- Notes committed by accident. A progress file can contain internal details. Decide whether it belongs in the repository, a gitignored location, or a branch. Never put secrets in it.
- Agent edits you did not review. An agent can rewrite a plan to match what it did and not what was agreed. Review changes to
PLAN.mdwithgit diff, as you would any code.
A short checklist
Before ending a session or running a compaction, check these items:
- The goal is stated in the file in one or two sentences.
- Every decision made in this session is written down with its reason.
- Done matches what is verified, and Next lists the first concrete step.
- Unresolved failures are named with the test or command that shows them.
- The file is committed, or you know where it is saved.
Exercise
Your agent session has run for two hours, and the context is almost full. You plan to compact it and then continue. A teammate suggests relying on the compaction summary alone, without a progress file. Give two reasons the file is still worth writing, and say what you would put in its Decisions section.
Show answer
Reasons: (1) A summary is a paraphrase, so a decision made in passing can be dropped without notice, while a file keeps the exact text. (2) The file survives a crash, a new session, or a handoff to another person, and the compaction summary does not. Decisions section: each choice with its reason, for example "Keep load_settings() signature unchanged, because other packages import it" and "Use tomllib, because it is in the standard library and parsing is read-only". Reasons matter because a later session may reverse a choice if it cannot see why it was made.
Exercise
A progress file has grown to 300 lines, and each new session spends a large part of its context reading it. Name three ways to shrink it without losing information that matters.
Show answer
Any three of: replace finished items in Done with a single line that refers to a commit; cap the Next list at three to five items and move later steps to PLAN.md; delete resolved open questions and record the answers under Decisions; replace pasted content with links to the files or docs that contain it; remove exploratory dead ends and raw output, since git history and the code already hold what matters.