Sub topic 2
Scoping Work So a Task Fits One Session
Assume you can use a terminal, Git, and a coding agent. Also assume the agent has a fixed context window: the maximum amount of instructions, conversation, file content, and tool output it can consider at once.
Start With a Small Task Boundary
A session should have one observable outcome. “Improve authentication” is too broad. “Add validation for expired access tokens and update its tests” is easier to finish and verify.
Before starting, write:
- The goal and its success condition.
- The files or components likely involved.
- The tests you expect to run.
- Questions that can wait for another session.
Small boundaries reduce context growth and make handoffs clearer.
Keep Persistent Instructions Short
Persistent project instructions are rules the agent sees repeatedly. Keep them stable and focused on facts that apply to many tasks:
- How to run tests.
- Formatting and type-checking commands.
- Important architectural boundaries.
- Rules for handling secrets or generated files.
Do not store a temporary plan, a long history, or copied source code there. Put changing details in a progress file instead.
# AGENTS.md
- Run unit tests with `pytest -q`.
- Keep public APIs backward compatible.
- Do not edit generated files in `build/`.Read Targeted Code
Begin with symbols, references, and nearby tests. Read only the relevant line ranges instead of entire files.
grep -rn "def parse_config" src | head -n 20
sed -n '120,180p' src/config.pyThis approach gives the agent the working model without filling the session with unrelated implementation details.
Bound Tool Output
Commands can consume more context than source files. Stop after the first failure and keep only a summary from long logs.
pytest -x -q 2>&1 | tail -n 30Use capped searches, filtered logs, and focused test targets. If the full output matters, save it outside the conversation and provide the agent only the relevant section.
Compact Before the Context Crowds
When responses become repetitive, the agent forgets earlier decisions, or each new tool call produces less useful work, compact the session. Ask for a summary that preserves:
- The goal and current state.
- Decisions and their reasons.
- Files changed.
- Failing tests and unresolved questions.
- The next three actions.
Verify that the summary includes these items before continuing. For a large remaining task, write the summary to PROGRESS.md and start a fresh session.
Exercise
You need to change a parser, but the task also includes documentation, migration support, and performance testing. What should you do first?
Show answer
Scope the current session to one outcome, such as changing the parser with focused tests. Record the other work as separate follow-up tasks.