Sub topic 3
Putting It Together in One Request
Assume you can read basic code, use an editor or terminal, and have used an AI coding assistant. A strong request combines only the context needed to solve one task.
Putting It Together in One Request
Include four parts:
- File context: name the file and provide the relevant contents or path.
- Selection context: identify the function, lines, or behavior that matters.
- Error context: include the exact error and complete stack trace when available.
- Task statement: describe the requested change and its constraints.
For example:
Context: stats.py, selection: the average function on lines 1-2.
Error: ZeroDivisionError: division by zero when average([]) is called.
Task: Change average so an empty list returns None. Keep the function
signature and do not change other code.This request gives the assistant a location, a focused selection, evidence of failure, and a clear target.
Standing Instructions and Project Conventions
Provide stable rules once when the tool supports standing instructions. Examples include the Python version, test command, naming rules, and type-hinting preferences. Do not repeat a large instruction block in every request. Apply standing instructions only when they still match the project.
Keeping Context Current and Uncluttered
Context has limits. Extra files can hide the important details and increase the chance of an irrelevant answer. Start with the smallest useful selection. Add related files only when imports, interfaces, tests, or configuration affect the task.
Remove old error messages and earlier solutions after the problem changes. Label copied material clearly so the assistant can distinguish current code from historical context.
Keeping Secrets and Personal Data Out
Remove passwords, API keys, access tokens, private customer data, and unnecessary personal details before sharing context. Replace them with placeholders such as API_KEY or USER_ID. Preserve the structure of the data when that structure matters for diagnosis.
Verifying Answers and Refining Context
Treat the first answer as a proposal. Run the relevant tests, inspect the diff, and check edge cases. If the answer is vague, add the missing file or exact error. If it is wrong, state the observed result and provide the smallest new context needed to explain it.
Exercise
What should you add when an assistant suggests a fix that fails a test?
Show answer
Give the exact failing test output, identify the changed code, and state the expected and actual behavior.