| layout |
default |
| title |
Agent OpenSpec and TDD |
| permalink |
/contributing/agent-rules/openspec-and-tdd/ |
| description |
OpenSpec selection, change validation, and strict TDD order for behavior changes. |
| keywords |
agents |
openspec |
tdd |
change-validation |
evidence |
|
| audience |
|
| expertise_level |
|
| doc_owner |
specfact-cli-modules |
| tracks |
AGENTS.md |
openspec/config.yaml |
openspec/CHANGE_ORDER.md |
docs/agent-rules/** |
|
| last_reviewed |
2026-10-05 |
| exempt |
false |
| exempt_reason |
|
| id |
agent-rules-openspec-and-tdd |
| always_load |
false |
| applies_when |
implementation |
openspec-change-selection |
|
| priority |
40 |
| blocking |
true |
| user_interaction_required |
true |
| stop_conditions |
no valid OpenSpec change |
change stale or superseded |
failing-before evidence missing |
|
| depends_on |
agent-rules-index |
agent-rules-non-negotiable-checklist |
|
- Before modifying application code, verify that an active OpenSpec change explicitly covers the requested modification.
- Skip only when the user explicitly says
skip openspec or implement without openspec change.
- The existence of any open change is not sufficient; the change must cover the requested scope.
- If no change exists, clarify whether the work needs a new change, a modified existing change, or a delta.
This modules repository does not require a sibling internal wiki checkout. When a modules change is explicitly paired with work in specfact-cli, use the paired public change, issue, and spec artifacts there as read-only context before changing shared workflow semantics.
- Apply
15-intent-and-scope.md before converting a user request into requirements. Record confirmed use cases, trust assumptions, non-goals, alternatives, the selected design, and a bounded first end-to-end milestone in the proposal/design.
- Identify agent recommendations and unresolved assumptions separately from user-confirmed or externally mandatory requirements. Structural OpenSpec validation and generic plan approval do not establish customer need.
- When new evidence materially changes scope, acceptance, or expected effort, challenge the decision before refining the change or implementing the expansion. Preserve existing gates pending that decision.
- Never implement from a change id alone.
- Revalidate the selected change against current repository reality, dependency state, and possible superseding work.
- Use
openspec validate <change-id> --strict to capture dependency and interface impact before implementation and before finalization.
- Update or add spec deltas first.
- Add or modify tests mapped to spec scenarios.
- Run tests and capture a failing result before production edits.
- Only then modify production code.
- Re-run tests and quality gates until passing.
Record the failing-before and passing-after runs in openspec/changes/<change-id>/TDD_EVIDENCE.md. Behavior work is blocked until failing-first evidence exists.
- When a change is implemented and merged, finalize it only with the OpenSpec CLI:
openspec archive <change-id>.
- The CLI merges delta specs into
openspec/specs/ and moves the change into openspec/changes/archive/.
- Do not manually move or rename
openspec/changes/<change-id>/.