
Use AI to write a code spec by giving it evidence about the problem, then making it expose decisions and ambiguity before implementation. A useful spec defines the required behavior and constraints without pretending that every coding detail is already known.
Provide the user or system problem, current behavior, desired outcome, relevant repository paths, examples, constraints, and known stakeholders. Ask the AI to draft sections for goals, non-goals, user flows, functional requirements, data and interface changes, error behavior, security and privacy, observability, migration, rollout, rollback, and acceptance tests. Require it to label assumptions and unresolved questions. Have it trace each proposed change to an outcome and remove architecture that is not required. Then review the draft with the people who own affected systems.
Test the spec before coding. Can a developer distinguish required behavior from an example? Are authorization rules explicit? Do acceptance criteria cover invalid and partial states? Can the rollout be stopped or reversed? If two reasonable implementations would behave differently in an important way, the spec needs another decision.
Store the approved spec beside the work item and give the agent that version as its authority. Update it when decisions change rather than letting chat history become the contract. AI is good at organizing and challenging a spec; accountable humans still approve product, architecture, risk, and release choices.
