Sub topic 12
Keep the plan as a file for later sessions
This chapter assumes you can run a planning conversation with a coding agent, approve a plan, and review a diff. It covers saving the approved plan as a file so that later sessions can use it.
Why a chat plan is not enough
A plan that exists only in the chat has three weaknesses. A new session starts with no memory of it. A long conversation can push the plan out of the agent's context, so the agent works from a partial or stale version. A teammate who picks up the work cannot see what you agreed to.
A plan saved in the repository avoids all three. You can point any session at the file, track its changes in version control, and tick off steps as they finish.
Save the plan after approval
Save the plan once you have approved it, not before. If you save a draft, the file and the conversation drift apart as you revise. Saving the approved version gives you a single source of truth.
Ask the agent to write the file, and name the path yourself:
Approved. Save the final plan to docs/plans/login-rate-limit.md, exactly as approved.
Add a checkbox in front of each implementation step.
Do not change any other file.The last line matters. Writing the plan file is an edit, so the no-edits rule needs a narrow exception. Name the one file the agent may create.
Keep plans in a consistent location, such as docs/plans/. A predictable path makes them easy to find and easy to reference in later requests.
What the saved file should contain
Use the same parts as the plan in the chat: files, ordered steps, risks and assumptions, and verification. Add a status line and checkboxes so progress is visible:
# Plan: rate limit /login
Status: in progress (step 1 done)
## Steps
- [x] 1. Add `auth/limiter.py` with a function that records a failure and reports whether the limit is exceeded.
- [ ] 2. Call the limiter from `auth/routes.py` and return the existing error format when exceeded.
- [ ] 3. Add tests for under the limit, at the limit, and after the window expires.
## Assumptions
- Several server processes run, so counters use the shared Redis client.
- Limit values live in the existing config file.
## Verification
- Run the new tests and the existing auth tests.Notice that the assumptions reflect the corrections you made during review. The file should describe the plan you approved, not the first draft.
Resume in a new session
In a fresh session, the agent knows nothing about earlier work. Point it at the file and say where to continue:
Read docs/plans/login-rate-limit.md. Steps 1 is done and committed.
Implement step 2 only, then stop and show me the diff and test results.
Tick the checkbox for step 2 once I confirm.The agent can also check the repository state against the file. If the checkbox says a step is done but the code disagrees, you want to find that out before building on it.
flowchart TD
A[Approve plan in chat] --> B[Agent saves plan file]
B --> C[Commit the file]
C --> D[New session reads the file]
D --> E[Implement one step]
E --> F[Review diff and tests]
F --> G[Tick the checkbox]
G --> DKeep the file honest
A plan file helps only while it matches reality. Follow these habits:
- Update the file when the plan changes. If a step turns out to be wrong, revise the step in the file and note why.
- Tick a box only after you have reviewed the result, not when the agent claims it is done.
- Commit the plan with the code it describes, or on the same branch, so the history shows both.
- Delete or archive the file when the work is complete. Old plans mislead later sessions.
<br>
Exercise
You approved a plan in chat, and tomorrow you will continue in a new session. Write the two prompts you need: one to save the plan, and one to resume at step 3. State one constraint each prompt should include.
Show answer
Save prompt: "Save the approved plan to docs/plans/<name>.md exactly as approved, with a checkbox per step. Do not change any other file." The constraint is limiting edits to that one file. Resume prompt: "Read docs/plans/<name>.md. Steps 1 and 2 are done. Implement step 3 only, then stop and show me the diff and test results." The constraint is implementing a single step and stopping for review.