Sub topic 12
Keep the Plan as a File for Later Sessions
This chapter assumes you have used a coding agent on a repository and followed the earlier chapters: you can write a planning request, review a plan, and approve it. You should also be comfortable with git commits and diffs. Here you will learn how to turn an approved plan into a file that outlives the chat.
Why a chat plan is not enough
A plan that exists only in the conversation has three weaknesses.
- Sessions end. If you close the terminal or start a new chat, the agent starts with no memory of the plan. You would have to paste it back or ask the agent to rebuild it, and the rebuilt plan may differ.
- Context fills up. In a long session, early messages can be dropped or summarized. The details you approved, such as "use the shared Redis client", may be the first to go.
- Other people cannot see it. A reviewer reading your pull request sees the diff but not the reasoning. A teammate who picks up the work has nothing to go on.
A plan file fixes all three. It is the written record of what you and the agent agreed to do. Any session can read it, and so can any person.
Where the file lives
Pick one location and use it consistently. Common choices:
| Location | Good for | Trade-off |
|---|---|---|
| `docs/plans/` in the repository | Plans reviewed with the code and kept as history | Adds files to the repository |
| `.plans/` and ignored by git | Personal scratch plans | Not shared, lost if you clean the folder |
| A pull request description | Short plans tied to one change | Hard for an agent to read in a later session |
For work that spans several sessions or several people, docs/plans/ is the usual choice. Name files by the task, not by date alone. login-rate-limit.md is easier to find than plan-3.md.
If your team does not want plan files in the main branch, commit the plan on the feature branch and remove it in the final commit. Either way, the file should be under version control while the work is in progress. That way you can see how the plan changed.
Ask the agent to save it, and loosen the no-edits rule once
There is a trap here. Your planning request said "Do not edit any files." If you now say "save the plan", a careful agent may refuse, or it may write the file and also start changing code. Be precise about the one exception.
The plan is approved with the Redis and config changes included.
Save it to docs/plans/login-rate-limit.md. This is the only file you may
create or edit right now. Do not change any source code or tests.
Use these sections: Goal, Constraints, Decisions, Steps (as a checklist),
Assumptions, Verification, and Progress log. Set Status to "approved".Two things are worth noting in this request. First, it names the single permitted file, which keeps the approval gate intact. Second, it records the decisions you made during review. A plan file that only contains the agent's first draft loses the corrections you worked for.
What goes in the file
The file is a working document, not a transcript. Keep what a reader needs to continue the work, and leave out the discussion that produced it.
# Plan: rate limit /login
Status: approved
Branch: feature/login-rate-limit
## Goal
Reject more than 5 failed login attempts per IP address in 10 minutes.
## Constraints
- No new dependencies.
- Keep the existing error response format.
## Decisions
- Use the shared Redis client, not an in-memory counter (several processes run).
- Limit values live in the existing config file, not in code.
## Steps
- [ ] 1. Add limit values to the config file.
- [ ] 2. Add `auth/limiter.py` using the Redis client.
- [ ] 3. Call the limiter from `auth/routes.py` before checking credentials.
- [ ] 4. Add tests in `tests/test_login_limit.py`.
## Assumptions
- The client IP is available from the request object.
- The Redis client is already initialized at app start.
## Verification
- Run `tests/test_login_limit.py` and the existing auth tests.
## Progress log
- (empty)Each section has a job:
- Status tells a new session whether it may edit code. The values
draft,approved,in progress,done, andsupersededcover most cases. - Decisions explains why the plan looks the way it does. Without it, a later session may "improve" the plan back to the in-memory counter you rejected.
- Steps as a checklist gives both you and the agent a place to record progress.
- Progress log holds short dated notes about surprises, such as "step 3 needed a change to the middleware order".
The lifecycle of a plan file
The file moves through states, and the Status line should always match reality.
The transition from InProgress back to Draft matters most. If the agent discovers mid-work that an assumption was false, the correct move is to stop, update the plan, and get approval again. Quietly working around the problem leaves the file describing something that is no longer true.
Resuming in a new session
Starting a new session is where the file pays off. Point the agent at it and restate the rules.
Read docs/plans/login-rate-limit.md. Check the git log and the current diff
to see which steps are actually done, and tell me if the checklist and the
code disagree.
Do not edit anything yet. Report the next unchecked step and wait for me.The instruction to compare the checklist with the code is not optional. A checklist can say step 2 is done when the commit was never made, or the reverse. The agent should report the mismatch before it relies on either one.
After each step passes review, have the agent update the file:
Step 2 is accepted. Tick it off in the plan file and add a one-line entry
to the Progress log. Change nothing else.To see how much work remains without opening the file, a quick check works:
grep -c '^- \[ \]' docs/plans/login-rate-limit.mdThis prints the number of unchecked steps.
Edge cases and failure modes
- Stale plan. The code changes after the plan was approved, for example another branch merges a refactor. Before resuming, ask the agent to check each named file and function still exists. If not, set the status to
draftand revise. - The agent edits the plan on its own. An agent that "helpfully" adds steps or rewrites assumptions has bypassed review. Commit the plan after approval, and look at
git diffon the plan file the same way you look at code. - Plan and diff drift apart. The final diff touches a file that the plan never listed. Either the plan was incomplete, in which case update it with a note, or the change is unwanted and should be reverted.
- Secrets and internal details. Plans copy hostnames, account IDs, and sometimes example credentials from the conversation. Review the file before committing it, especially in a public repository.
- Many plans, one repository. Old plans clutter the folder and can mislead an agent that reads the whole directory. Mark finished plans
doneorsuperseded, and tell the agent which single file is current. - Overly long files. A plan over a few hundred lines is hard to review and costly to load into every session. Split large work into a parent plan and one file per phase.
Check your understanding
Exercise
You return the next day and open a new session. The plan file shows steps 1 and 2 ticked, but git log shows only one commit for this task, and auth/limiter.py does not exist. What should you ask the agent to do, and what should you not let it do?
Show answer
Ask the agent to read the plan, compare the checklist with the git log and current diff, and report the mismatch without editing anything. Then decide together which is correct: either step 2 was ticked by mistake (untick it and redo the step) or the work exists somewhere else, such as an uncommitted change or another branch. Do not let the agent assume the checklist is right and start step 3, because step 3 depends on the missing limiter module. After the mismatch is resolved, update the file and the progress log so they match the code.