Module 03.2

Codex context and prompting

Give Codex the right task shape
before you expect the right output.

Most disappointing Codex results start earlier than the output. They start with a weak task frame. This lesson teaches the core prompt structure: goal, context, constraints, and done-when, plus when to ask for a plan instead of immediate edits.

Outcomes

What changes when you start prompting well

Task frame

You stop asking Codex to “help somehow” and start handing it a concrete unit of work.

Context packing

You include files, constraints, examples, and repo facts that actually alter the answer instead of dumping everything you know.

Escalation judgment

You know when to ask for a short plan first, when to ask for implementation directly, and when the task is still too vague.

Workflow

The five-part Codex task frame

01

Goal

What exactly should Codex produce or change, and why does it matter?

02

Context

Which files, examples, docs, or constraints give the task its real shape?

03

Constraints

What must not change, what style to follow, and what risks to avoid?

04

Done-when

What observable output, diff, test, or behavior proves the task is complete?

05

Mode

Should Codex plan first, implement directly, or explore before making changes?

Prompt templates

Prompt shapes you can reuse immediately

Feature request

Small implementation prompt

Goal: Add optimistic loading to the save button in SettingsPanel.

Context:
- Relevant files: src/components/SettingsPanel.tsx, src/hooks/useSettings.ts
- Existing pattern: follow the loading treatment used in ProfilePanel.

Constraints:
- Do not change API shapes.
- Keep styling consistent with the current design system.

Done when:
- The button shows a loading state during save.
- Existing tests still pass, and add tests if needed.
Ask for a plan

Use when the task has moving parts

Before making changes, inspect the relevant files and give me:
1. A short implementation plan.
2. Key risks or unknowns.
3. The verification steps you intend to run.

Then wait for confirmation before editing.

Practice

Deliberate drills for stronger prompts

Drill 1: rewrite weak asks

  • Write three vague prompts from your own work.
  • Rewrite each using goal, context, constraints, and done-when.
  • Compare which version produces a cleaner plan.

Drill 2: context pruning

  • Start with too much context.
  • Remove anything that does not change the task.
  • Notice how signal improves when the prompt gets sharper.

Drill 3: plan or execute?

  • Choose three tasks from your repo.
  • Decide which needs a plan first and which can go straight to implementation.
  • Explain your decision in one sentence each.
Common mistake

Giving context without a decision

Dumping files, logs, and tickets is not the same as telling Codex what job those materials should support.

Common mistake

Over-specifying the wrong layer

Do not micromanage implementation details before you are sure the task frame itself is correct.