Sub topic 3
Project Instruction Files for Stable Conventions
Assume you know Git, automated tests, and how to use an AI coding agent. This chapter focuses on the rules that shape an agent's work after the feature specification is written.
Project instruction files
A project instruction file gives an agent stable rules that should apply across tasks. Common names include AGENTS.md, CONTRIBUTING.md, and repository-specific instruction files.
Useful instructions include:
- Where specifications and source code live.
- Which commands run tests, formatters, and linters.
- Naming and architecture conventions.
- Security constraints, such as never committing secrets.
- The expected workflow for updating tasks and tests.
Keep these rules durable and concise. Put feature-specific behavior in the feature specification instead. An instruction file might say, “Run pytest before reporting completion,” while the specification says what the password-reset feature must do.
Review gates and spec drift
Use review gates at three points:
- Review the requirements and acceptance criteria before implementation.
- Review the design and task breakdown before the agent changes code.
- Review the implementation and test results against the specification.
A review should check behavior, scope, security, and maintainability. Do not approve work only because the tests pass. Tests can omit an acceptance criterion or encode an incorrect interpretation.
Spec drift occurs when code and documentation describe different behavior. Update the specification when the intended behavior changes. Update the code and tests when the specification remains correct. Record the decision in the change history so later agents do not restore outdated behavior.
Right-sizing and common pitfalls
A small change may need only a short requirement, one acceptance criterion, and a test. A cross-service or security-sensitive change needs design decisions, failure cases, migration notes, and review gates.
Avoid these anti-patterns:
- Vague requirements such as “make login better.”
- Huge tasks that hide several untestable decisions.
- Tests that check implementation details instead of behavior.
- Instruction files that duplicate every feature specification.
- Letting an agent silently resolve contradictory requirements.
- Treating generated code as proof that the design is correct.
Supporting tools
Use Git for reviewable history, Markdown for specifications, issue trackers for tasks, and the project test runner for executable verification. Linters, formatters, type checkers, and continuous integration add repeatable checks. The tools should reinforce the workflow rather than replace human judgment.
Exercise
What belongs in an instruction file rather than a feature specification?
Show answer
A stable project rule, such as where tests live or which verification command to run, belongs in the instruction file. Feature behavior belongs in the specification.